Discussion Locked

Username in Win95 Visual Basic App

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

How can I obtain the username of a Windows 95 user who has logged into our NT 4 domain from a Visual Basic application?

Similarly, how can I query NT group membership from a Visual Basic application on Windows 95 client?

1 reply

by binarysleeper

You need to make an API call.

Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Dim lngRetVal As Long
Dim strUserName As String
Dim UserName As String
strUserName = Space$(255)
lngRetVal = GetUserName(strUserName, Len(strUserName))
UserName = Left(Trim(strUserName), Len(Trim(strUserName)) - 1)

There, that should do it. Enumuerating groups is a little trickier. Search the web for network API calls, and you'll find a load of stuff. There was also a sight called VBAdminCode that had lots of goodies on it.

This discussion is closed to new replies.