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!

Accessing Win API files

Status
Not open for further replies.

xk120

Technical User
Jul 24, 2000
17
0
0
US
I am running an application on our network server. When someone logs
onto the application I want to store his/her login initials in a file so I know
who is currently using my application. The problem is I don't know how to
get to the Window API that stores the initials.
 
Hi!

Instead of storing initials, better use account name of the user currently logged on in Windows. GetUserName() function gives you this on the local computer.

Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
I went to help in VFP6.0 and getusername() is not avaliable. How do I use it?
 
You cannot find it in VFP help because this is Windows API function, as you requested ;-)
Following is sample of how to call it:

LOCAL lcUserID, lnBuffSize
m.lnBuffSize = 255
m.lcUserID = SPACE(m.lnBuffSize)
DECLARE INTEGER GetUserName IN WinAPI32 STRING @lpBuffer, integer @nSize

m.llSuccess = GetUserName(@lcUserID, @lnBuffSize) > 0
* m.llSuccess contains .T. if function worked ok.



Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Try SYS(0) it returns user login name and machine name

David W. Grewe
Dave@internationalbid.com
ICQ VFP ActiveList #46145644
 
Made me dig deep for this routine, Had to go all the way back to my FoxPlus Library to dust this one off, There maybe a more eliquent way of doing it now but this still works. After you get the user name by API or Sys(0) here is a routine that returns initials.
[tt]
*/***************************************************************************
*/Program : function INITIALS
*/System :
*/Purpose : Returns The First Letter Of Every Word In A String
*/Syntax : =Initials(Str)
*/Returns : String
*/Parameter : String - Str - The String to be used
*/Defaults : None
*/Requires : None
*/Changes : Nothing
*/Internal Calls : None
*/External Calls : None
*/Calls :
*/Version : 1.0
*/Dated : 12/04/1987
*/Written By: David W. Grewe
*/***************************************************************************
*& String Function
*/***************************************************************************
*/ Record Of Change
*/
*/***************************************************************************
parameter pcString
private lnSpot , lnLen
*
* If the String has a Comma in it, Move Front part to the back
*
if at(",",pcString) > 0
pcString = substr(pcString , at("," , pcString) + 1) + " " + substr(pcString , 1 , at("," , pcString)-1)
endif
*
* Change anything not a letter to a space
*
pcString = alltrim(upper(pcString))
lnLen = len(pcString)
for lnSpot = 2 to lnLen
if isalpha(substr(pcString , lnSpot , 1)) = .f.
pcString = stuff(pcString , lnSpot , 1 , " ")
endif
endfor
*
pcString = alltrim(pcString)
lcInitials = ""
*
* get first letter after a space
*
lcInitials = substr(pcString , 1 , 1)
do while at(" " , pcString) > 0
pcString = alltrim(substr(pcString , at(" " , pcString) + 1))
lcInitials = lcInitials + substr(pcString , 1 , 1)
enddo
release lnSpot , lnLen
return lcInitials
[/tt]


David W. Grewe
Dave@internationalbid.com
ICQ VFP ActiveList #46145644
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top