Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, How do I get the username that

Status
Not open for further replies.

mmfried

Programmer
Sep 17, 2003
33
IL
Hi,
How do I get the username that's currently logged in (I want to run a script in VB which will be able to deal with all users and I need the username 4 it).
thanks,
Moshe
 
Something like:



Public Declare Function WNetGetUser Lib "mpr" Alias "WNetGetUserA" _
(ByVal x As String, ByVal UserName As String, IBufSz As Long) As Long




Dim BufSz As Long, result As Long, Buffer As String
Dim NullPos As Integer
BufSz = 256
Buffer = String$(BufSz, 0)
result = WNetGetUser("", Buffer, BufSz)
If result = 0 Then
NullPos = InStr(Buffer, Chr(0))
GmsGetUser = Left(Buffer, NullPos - 1)
End If
 
Sorry this was cut & pasted from a function called GmsGetUser - i.e. GmsGetUser contains result.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top