you have to use the win32 api to retrieve that info. Do you have any experience with the Windows API? If not I can recommend a book called Visual Basic 5.0 programmers guide to the Win32 API. You would need to set up a module with the getusername function. And call the function from your form with a button click event or other event of your choice. You can run the apiload.exe in your \devstudio\vb\winapi\ directory. This way you can view the necessaries of the getusername api. Need anymore clues post away...<br>
<br>
pos<br>
Try this declaration in the declarations sections of a module<br>
<br>
Declare Function WNetGetUser Lib "advapi32.dll" Alias "GetUserNameA" (ByVal szUser$, lpnBufferSize%) As Long<br>
<br>
and call it like this:<br>
<br>
dim uname as string, len as integer<br>
call GetUserNameA(uname,len)<br>
<br>
uname should be set to the user name<br>
<br>
Mike<br>
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long<br>
Function ClipNull(InString As String) As String<br>
<br>
Dim intpos As Integer<br>
<br>
If Len(InString) Then<br>
intpos = InStr(InString, vbNullChar)<br>
If intpos > 0 Then<br>
ClipNull = Left(InString, intpos - 1)<br>
Else<br>
ClipNull = InString<br>
End If<br>
End If<br>
<br>
End Function<br>
Function GetUser() As String<br>
<br>
Dim lpUserID As String<br>
Dim nBuffer As Long<br>
Dim Ret As Long<br>
lpUserID = String(25, 0)<br>
nBuffer = 25<br>
Ret = GetUserName(lpUserID, nBuffer)<br>
<br>
If Ret Then<br>
GetUser$ = lpUserID$<br>
End If<br>
<br>
End Function<br>
'Call like this<br>
dim strUser as string<br>
strUser = ClipNull(GetUser())
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.