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

getting the user name that logged on a maching

Status
Not open for further replies.

johndelphi

IS-IT--Management
Jul 1, 2003
10
ZA
how would you get that?
 
Here's a function I find which I shall add to the FAQ area:
Code:
  function  GetWindowsUserName : string;
  const
    cnMaxLen=254;
  var
    sUserName     : string;
    dwUserNameLen : DWord;
  begin
    dwUserNameLen:=cnMaxLen-1;
    SetLength(sUserName, cnMaxLen);
    GetUserName(Pchar(sUserName), dwUserNameLen);
    SetLength(sUserName, dwUserNameLen);
    result:=sUserName;
    if dwUserNameLen=cnMaxLen-1 then
      result:='';
  end;

Clive [infinity]
Ex nihilo, nihil fit (Out of nothing, nothing comes)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top