Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WHO AM I in Novell
Message
De
07/11/1998 02:07:56
 
 
À
05/11/1998 23:08:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00155101
Message ID:
00155464
Vues:
23
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform