Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get user name from the operating system
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00717731
Message ID:
00717743
Views:
22
>Wow--I'd been looking for a while and right after I posted this msg I think I found it--SYS(0). If anyone knows of another better one please let me know.
>
>JR
>
>>I have a client who's on W2K server. They want to create an audit trail in a program I wrote for them, which records user name. However, they don't want to have to have a log-in screen in the program I made (the network log-in is sufficient).
>>
>>How can I interrogate W2K to get the user name in VFP6?
>>
>>JR

There's also the Windows Script Host's WScript.Network object
oNet = CREATEOBJECT("WScript.Network")
? oNet.UserName
or the API
FUNCTION UserName

  DECLARE INTEGER WNetGetUser IN Win32API;
    STRING @lpszLocalName, STRING @lpszUserName,; 
    INTEGER @lpcchBuffer
  LOCAL lcresult, lnpt, lnargs
  * Call to the API
  lcresult = SPACE(200)
  = WNetGetUser(0, @lcresult, LEN(lcresult)) 
  lnpt = AT(CHR(0), lcresult)
  IF lnpt > 1
    lcresult = LEFT(lcresult, lnpt - 1)
  ELSE
    lcresult = ""
  ENDIF
  RETURN lcresult
ENDFUNC
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform