>From a previous post by Jacques Paris,  I created a program to return the
current user name logged into Windows.
I am running Windows 2k with Mapinfo 7.0.   When I test the function the
slength returned is of the correct length, but the username
value is blank.  Help appreciated as always!  Source code included below.

Thanks,
Jay Russell



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

Sub FindUser

Dim username As String ' receives name of the user


Dim slength As Integer ' length of the string


Dim retval As Integer ' return value


' Create room in the buffer to receive the returned string.


username = Space$(255) ' room for 255 characters


slength = 255 ' initialize the size of the string


' Get the user's name and display it.


retval = GetUserName(username, slength) ' slength is now the length of the
returned string


username = Left$(username, slength - 1) ' extract the returned info from
the buffer


' (We subtracted one because we don't want the null character in the
trimmed string.)


Print "The name of the current user is "+ username


End Sub 'FindUser


---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 12607

Reply via email to