Nie ma co się za bardzo rozpisywać. Kod pozwalający pobrać nazwę użytkownika komputera. Jako ciekawostkę warto zwrócić uwagę na deklarację dla systemów 32 bitowych i 64 bitowych. Niestety zapomniałem źródło kodu.
' Deklaracje dla 64bit i 32bit pobieranie nazwy użytkownika windows
#If VBA7 Then
Declare PtrSafe Function Get_User_Name Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, _
nSize As Long) As LongPtr
#Else
Declare Function Get_User_Name Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long
#End If
Sub UserName()
' Uruchom to makto
MsgBox GetUserName
End Sub
Function GetUserName() As String
' This is used by GetUserName() to find the current user's
' name from the API
Dim lpBuff As String * 25
Get_User_Name lpBuff, 25
GetUserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
End Function
Hm,
MsgBox Environ(„username”)
Dzięki 😉