Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to capture the username
Message
From
29/06/2000 11:11:16
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00385462
Message ID:
00386472
Views:
21
You are right Ed:

I changed the code to extract machinename and username from
SYS(0). Thank you and have a nice day.

* * *

>This returns the same value as:
>
>ALLTRIM(SUBST(SYS(0),AT('#',SYS(0))+1))
>
>To get the userid associated with a given share, you need to use a different API call, WNetGetUser().

* * *

>>Thank you for your reply. Like you said, I found a code snippet that does what I wanted - right here - at UT. Long live UT brotherhood and God bless the programmer who posted this snippet.
>>
>>Thanks again. I have included the code snippet in case you are interested.
>>
>>//
>>
>>func whoami()
>>
>>Local lcusername, lres
>>
>>declare integer GetUserName in advapi32 String@, Integer@
>>
>>m.lcusername = replicate(chr(0),255)
>>m.lres = getusername(@lcusername,255)
>>
>>return iif(empty(m.lres),space(0),left(m.lcusername,at(chr(0),m.lcusername)-1))
>>
>>//
>>
>
>
>>>>How do I capture the logged in (current) username say from NT from within a VFP applicatiion?
>>>>
>>>
>>>You can extract it from SYS(0) - everything to the left of the "#" is the NetBIOS machine name, and everything to the right is the Windows user name. There are also several API calls you can use that are discussed in the FAQ here on UT (advisable if you need the username relative to the login used to access a shared resource rather than the Windows user name) and the Wscript.Network has a UserName property as well.
Real office automation starts with hiring a programmer!
Previous
Reply
Map
View

Click here to load this message in the networking platform