Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
User Name
Message
From
30/08/2001 17:28:49
 
 
To
30/08/2001 17:16:02
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00551037
Message ID:
00551132
Views:
32
>Thanks, Igor!
>
>I got an error message: function is not defined.
>Should I add some library files like advapi32.dll?
>
>Natasha

The following works for me on VB6:
'General Declarations on module:
Public gsUserID As String
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
   (ByVal lpBuffer As String, nSize As Long) As Long

Public Sub Main()
   gsUserID = GetUserID
End Sub

Public Function GetUserID() As String
   Dim gunReturn As Long
   Dim lpBuffer As String * 255
   Dim nSize As Long
   nSize = 255
   gunReturn = GetUserName(lpBuffer, nSize)
   Dim UserName As String
   UserName = Mid(lpBuffer, 1, nSize - 1)
   GetUserID = UserName
End Function
Note that Sub Main() has been largely simplified to show only the calling syntax.
HTH
Previous
Reply
Map
View

Click here to load this message in the networking platform