Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting the user name?
Message
De
21/10/1998 01:47:01
Penmetsa Sridhar
Visualsoft Technologies Limited
Hyderabad, Inde
 
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00141215
Message ID:
00148774
Vues:
26
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform