Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Log In Coding? 7

Status
Not open for further replies.

FattyKat

Programmer
Feb 21, 2002
32
IN
I want to capture the login_name supplied by the user at the windows log_in screen and use the same as the user_name/Log_in_name in my application. So that all the user will have to do then is type in his password. Any ideas?
[Poke]
 
Here's what I use:-

Code:
LOCAL StringSize, ResultNumber
evUser = SPACE(32)
StringSize = LEN(evUser)
DECLARE Integer GetUserName IN Win32API String@, Integer@
ResultNumber = GetUserName(@evUser, @StringSize)
evUser = STRTRAN(UPPER(TRIM(evUser)), CHR(0), [])

Stewart
 
HI FattyKat,

myLoginUser = GETENV("USERNAME")

:) ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Stewart,Ramani,
Kindly explain whats happening in ur stuff.Seems too complex for my small head, (but not the brains!)
[poke]
 
If I type what Ramani suggested:
Code:
myLoginUser = GETENV("USERNAME")

I get the variable myLoginUser with "Administrator" in it with is the name I log into the server.
 
Which is the environment variable USERNAME. Any of the environment variables, PATH, WINDIR, etc,. that you can see by going to a command prompt and typing SET <enter>, can be accessed with the GETENV() function. StewartUK 's method uses the actual MS Win API calls to access the login name used by Windows. DECLARE is necessary to tell VFP you are going to use a Windows API call instead of an internal VFP function, and INTEGER and STRING are the types of variables you are going to use for the API call. These will vary of course for each API function used.

Dave S.
 
You probably want to go the more complex route and use the Win32 functions; the environment variable is defined in WinNT, Win2000 and WinXP, but not in Win95, Win98, Win98SE. I'm not sure about WinME. But the Win32 function should work everywhere.
 
Try Sys(0)
ucNetName=substr(sys(0),at(&quot;#&quot;,sys(0))+1)
ucMachine=substr(sys(0),1,at(&quot;#&quot;,sys(0))-1)
David W. Grewe
Dave@internationalbid.com
 
Hi,
I have tried all the options given here, but only one of them works(dgrewe's), though it has several LOC's, and as u know, many at times we wanna reduce the LOC as musc as possible.
The getnev()thing just looks at me on activation.This suh a sweet short code i would like to use.

Stewart's option gives an error message that it cant identify entry point &quot;getusername&quot; in the DLL.
Anything left out?

Am using VFP 6.0 with a peer to peer network.

[Poke]
 
DLL function names are case-sensitive and getusername <> GetUserName. Jon Hawkins
 
Hey Ramani-

according to myLoginUser = GETENV(&quot;USERNAME&quot;)
I am assuming that this will only work for Winnt and Win2000....
I was having a similar problem, and used this statement on a Win98 machine and win2000

Nothing appeared for win98
Got a user login when tried on Win2000....

Lemme know
angie
 
Hi all,
I feel, David W. Grewe's suggestion of using SYS(0)

ucNetName = substr(sys(0),at(&quot;#&quot;,sys(0))+1)
ucMachine = substr(sys(0),1,at(&quot;#&quot;,sys(0))-1)

is the easiest. My suggestion seem doesnt work in some OS.
I think David deservs a vote for this and I give him the vote. WinApi usage is another method. :)

ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Wow,
A Star and Kind Words From Ramani.
I Thank You. David W. Grewe
Dave@internationalbid.com
 
Hey those two line of code are worthy of a Tips-n-Tricks FAQ too. I have my 10 rating itching to click. -Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top