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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can you extract the NT username or Computer name 2

Status
Not open for further replies.

wculver

MIS
May 1, 2000
2
0
0
US
Hello All<br><br>I'm new to this group and would like to thank everyone for all the great information that's been posted.<br><br>I have a question, I need a way to identify who is logged on and what computer the user is at.&nbsp;&nbsp;Is there a way to grab the NT logon name and the Computer name?&nbsp;&nbsp;I know the computer name is stored in the WIN registry, but I can't figure out how to get any FoxPro hooks to it.<br><br>Any and all thoughts, ideas or suggestions are greatly appreciated.<br><br>Thanks
 
On both my Win95 and NT Workstation box,<br><FONT FACE=monospace>SYS(0)</font><br>returns my machine name followed by &quot;#&quot; followed by my user name, as in:<br><br>machineID # username<br> <p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br>
 
To obtain a user's network login name in FoxPro for Windows 2.6, I use the FOXTOOLS.FLL library to call the Windows API function WNetGetUser.<br><br>First, you need to load the library with SET LIBRARY TO...<br><br>Then use code like the following:<br><br>* Register the function and store the registration handle<br>*<br>*&nbsp;&nbsp;&nbsp;@C@I = Pass a character and an integer to the function<br>*&nbsp;&nbsp;&nbsp;&quot;I&quot;&nbsp;&nbsp;= Return an integer value<br>*<br>m.FuncHandle=RegFn(&quot;WNetGetUser&quot;, &quot;@C@I&quot;, &quot;I&quot;)<br>*<br>m.BufferSize=255<br>m.UserLogNam=SPACE(m.BufferSize)<br>IF CallFn(m.FuncHandle, @m.UserLogNam, @m.BufferSize)=0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&& No errors<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m.UserLogNam=UPPER(STRTRAN(ALLTRIM(m.UserLogNam),CHR(0),&quot;&quot;));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&& Remove the NULL from the end of the user name and convert to upper case<br>ENDIF<br><br>Hope this is helpful,<br><br>Andy Blay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top