Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WHO AM I in Novell
Message
From
07/11/1998 02:07:56
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00155101
Message ID:
00155464
Views:
24
Ed Rauh wrote:

>This will retrieve the login name for the local machine. If you wanted to see how the user was logged in to access a particular device, such as a mapped network drive Z:, you would use 'Z:'+CHR(0) in place of the first argument, ie
>
>IF WNetGetUser('Z:'+CHR(0), @cBuffer, @nBufSize)


Thanks, Ed.

Here is my function based on your code:

***********************************************************************
* FUNCTION UserName.prg
***********************************************************************
* Purpose.....: Get the user name for this machine.
* Parameters..: none
* Returns.....: char -- user name
* Notes.......:
* Examples....: ? UserName()
* Calls.......: WNetGetUser in WIN32API
* Refers to...:
* Sets........:
* Created.....: 1998.11.07
* History.....:
**********************************************************************

local lcBuffer, lnBufSize

declare ;
integer WNetGetUser in WIN32API ;
string lpDeviceName, ;
string lpUserNameBuffer, ;
integer @BufferLength

lcBuffer = repl(chr(0),256)

lnBufSize = 256

if WNetGetUser(0, @lcBuffer, @lnBufSize ) = 0
return alltrim(strtran(left(lcBuffer, lnBufSize - 1),chr(0),""))
else
return "USERNAME--ERROR"
endif

endfunc


Peter Robinson ** Rodes Design ** Virginia
Previous
Reply
Map
View

Click here to load this message in the networking platform