Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do get a user login name from Windows
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00501724
Message ID:
00501935
Views:
27
>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,

If the Windows Script Host is available
oNet = CREATEOBJECT("WScript.Network")
? oNet.UserName
George

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

Click here to load this message in the networking platform