|
-
Oct 23rd, 2002, 04:51 PM
#1
Thread Starter
Addicted Member
Anyone know why this doesn't work
Does anyone know why this doesn't work?
Public Class Class1
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, ByVal NSize As Long) As Long
Public Function SysGetUserName() As String
Dim UserName As String
Dim BufSize As Long
Dim RetCode As Long
Dim NullCharPos As Long
UserName = Space(80)
BufSize = Len(UserName)
RetCode = GetUserName(UserName, BufSize)
NullCharPos = InStr(UserName, Chr(0))
If NullCharPos > 0 Then
UserName = Left(UserName, NullCharPos - 1)
Else
UserName = ""
End If
MsgBox(UserName)
End Function
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|