Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
'Pour obtenir le nom de l'ordinateur
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
'Pour obtenir le nom de l'utilisateur
Public Function Get_UserName() As String
'Retourne le nom de l'utilisateur
Dim StrUser As String
Dim LTemp As Long
StrUser = String$(255, vbNullChar)
LTemp = GetUserName(StrUser, Len(StrUser))
LTemp = InStr(StrUser, Chr$(0)) - 1
Get_UserName = Mid(StrUser, 1, LTemp)
End Function
Public Function Get_ComputerName() As String
'Retourne le nom de l'utilisateur
Dim StrComputer As String
Dim LTemp As Long
StrComputer = String$(255, vbNullChar)
LTemp = GetComputerName(StrComputer, Len(StrComputer))
LTemp = InStr(StrComputer, Chr$(0)) - 1
Get_ComputerName = Mid(StrComputer, 1, LTemp)
End Function
---------------
Des bons sites pour Delphi? http://forum.hardware.fr/forum2.php3?post=16838&cat=10 -- informaticien -- http://www.z0rglub.com/phpwebgallery/ -- Delphi :love: