Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do get a user login name from Windows
Message
From
30/04/2001 17:55:38
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00501724
Message ID:
00501814
Views:
29
Hi Stuart.

>I need to be able to find the user name a person has used to login onto Windows 2000 Server from within a FoxPro application.

Here's what I use:
local lcName, ;
    lnSize, ;
    lcUser, ;
    lnStatus

* Initialize the variables we need and declare the Windows function.

lcName = chr(0)
lnSize = 64
lcUser = replicate(lcName, lnSize)
declare integer WNetGetUser in Win32API ;
    string @cName, string @cUser, integer @nBufferSize

* Call the function and return the result.

lnStatus = WNetGetUser(@lcName, @lcUser, @lnSize)
lcUser   = iif(lnStatus = 0, upper(left(lcUser, at(chr(0), lcUser) - 1)), '')
return lcUser
Doug
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform