Récupérer le login NT d'un Utilisater à la place de son IP
JT
-
29 août 2001 à 16:03
ovincent
Messages postés13Date d'inscriptionmercredi 9 janvier 2002StatutMembreDernière intervention19 décembre 2002
-
17 janv. 2002 à 14:50
Comment peux-t'on récupérer le login (Windows NT) d'un utilisateur?
A voir également:
Récupérer le login NT d'un Utilisater à la place de son IP
Public Declare Function WNetGetUser Lib "mpr" _
Alias "WNetGetUserA" _
(ByVal lpName As String, _
ByVal lpUserName As String, _
lpnLength As Long) _
As Long
Private Const NoError = 0
Public Function fGetLoginName() As String
' Buffer size for the return string.
Const lpnLength As Integer = 255
' Get return buffer space.
Dim Status As Integer
' For getting user information.
Dim lpName, lpUserName As String
' Assign the buffer size constant to lpUserName.
lpUserName = Space$(lpnLength + 1)
' Get the log-on name of the person using product.
Status = WNetGetUser(lpName, lpUserName, lpnLength)
' See whether error occurred.
If Status = NoError Then
' This line removes the null character. Strings in C are null-
' terminated. Strings in Visual Basic are not null-terminated.
' The null character must be removed from the C strings to be used
' cleanly in Visual Basic.
lpUserName = Left$(lpUserName, InStr(lpUserName, Chr(0)) - 1)
Else
' An error occurred.
MsgBox "Unable to get the name."
End
End If