Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
User Name
Message
De
30/08/2001 17:28:49
 
 
À
30/08/2001 17:16:02
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00551037
Message ID:
00551132
Vues:
31
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform