I posted this request earlier and was directed to some code that would not
work. I am using win2000 Professional. I want to find out who is logged in
to the computer and take that ID look it up in a table and put the persons
name into a combo box on the form. I think I can handle the combo box part
but can not get the User Login ID.
I have triedthe following but always come with no one loged in and of course
I am logged into my computer.
Option Compare Database
Declare Function wu_GetUserName Lib "advapi32" Alias "GetUserNam eA" _
(ByVal lpBuffer As String, nSize As Long) As Long
Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Private Declare Function SHGetPathFromID List Lib "shell32.dl l" Alias _
"SHGetPathFromI DListA" (ByVal pidl As Long, _
ByVal pszPath As String) As Long
Private Declare Function SHBrowseForFold er Lib "shell32.dl l" Alias _
"SHBrowseForFol derA" (lpBrowseInfo As BROWSEINFO) _
As Long
Private Const BIF_RETURNONLYF SDIRS = &H1
Function NetworkUserName () As String
Dim lngStringLength As Long
Dim sString As String
lngStringLength = Len(sString)
sString = String$(iString Length, 0)
If wu_GetUserName( sString, lngStringLength ) Then
networkname = Left$(sString, lngStringLength )
Else
networkname = "Unknown"
End If
End Function
I step through the code at the If above and always go to the else stmt and
ge "Unknown" as the answer
Any Ideas of what is wrong.
work. I am using win2000 Professional. I want to find out who is logged in
to the computer and take that ID look it up in a table and put the persons
name into a combo box on the form. I think I can handle the combo box part
but can not get the User Login ID.
I have triedthe following but always come with no one loged in and of course
I am logged into my computer.
Option Compare Database
Declare Function wu_GetUserName Lib "advapi32" Alias "GetUserNam eA" _
(ByVal lpBuffer As String, nSize As Long) As Long
Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Private Declare Function SHGetPathFromID List Lib "shell32.dl l" Alias _
"SHGetPathFromI DListA" (ByVal pidl As Long, _
ByVal pszPath As String) As Long
Private Declare Function SHBrowseForFold er Lib "shell32.dl l" Alias _
"SHBrowseForFol derA" (lpBrowseInfo As BROWSEINFO) _
As Long
Private Const BIF_RETURNONLYF SDIRS = &H1
Function NetworkUserName () As String
Dim lngStringLength As Long
Dim sString As String
lngStringLength = Len(sString)
sString = String$(iString Length, 0)
If wu_GetUserName( sString, lngStringLength ) Then
networkname = Left$(sString, lngStringLength )
Else
networkname = "Unknown"
End If
End Function
I step through the code at the If above and always go to the else stmt and
ge "Unknown" as the answer
Any Ideas of what is wrong.
Comment