RE/
How can I get the currently logged in username from windows 2000/xp?
-------------------------------------
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
(ByVal lpBuffer As String, nSize As Long) As Long
Public Function userIdWindowsGet() As String
debugStackPush mModuleName & ": userIdWindowsGet"
On Error GoTo userIdWindowsGet_err
' PURPOSE: To retrieve the Windows UserID of the person currently logged on to
this PC
' RETURNS: UseID or empty string
Dim myBuffer As String * 255
Dim myUserName As String
GetUserName myBuffer, Len(myBuffer) 'Get the
user name
myUserName = Left(Trim(myBuffer), InStr(myBuffer, Chr(0)) - 1) 'Trim excess
characters
If Len(myUserName) > 0 Then
userIdWindowsGet = myUserName
Else
bugAlert True, "Unable to get Windows UserID"
End If
userIdWindowsGet_xit:
debugStackPop
On Error Resume Next
Exit Function
userIdWindowsGet_err:
bugAlert True, ""
Resume userIdWindowsGet_xit
End Function
-------------------------------------
--
PeteCresswell