General information
Category:
Coding, syntax & commands
U can also get the User Name using this API
Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
-----
Dim s As String
Dim cnt As Long
Dim dl As Long
cnt = 199
s = String$(200, 0)
dl = GetUserName(s, cnt)
If dl <> 0 Then
usernm = ConvertString(s, cnt)
Else
usernm = ""
End If
-------
Function ConvertString(tmpVal As String, KeyValSize As Long) As String
If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then
' Win95 Adds Null Terminated String...
ConvertString = Left(tmpVal, KeyValSize - 1)
' Null Found, Extract From String
Else
' WinNT Does NOT Null Terminate String...
ConvertString = Left(tmpVal, KeyValSize)
' Null Not Found, Extract String Only
End If
End Function
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only