Board index » delphi » How to Get network login ID?

How to Get network login ID?

How can I read the network login ID of the user?
Thanks for any hints.
--
Huang

 

Re:How to Get network login ID?


well, try to figure out some network functions too. So far found the
folowing two :
Login Username and Computername.
You can get the username by reading the userid of the current program,
which usually is the current username. The function for that is
"GetUserName", and for computername "GetComputerName" (ofcourse). some
example functions :

Function UserName:string;
Var buffer:array[0..20] of char;     {just 0..15 should be enough, but just
for sure...}
    size:Dword;
Begin
  fillchar(buffer,0,sizeof(buffer));    {just for sure}
  size:=sizeof(buffer);                 {save buffersize}
  GetUserName(buffer,size);             {fill buffer, bytes read saved in
size}
  UserName:=copy(strpas(buffer),1,size);{convert to pascal style}
End;

Function ComputerName:string;
Var buffer:array[0..20] of char;     {just 0..15 should be enough, but just
for sure...}
    size:Dword;
Begin
  fillchar(buffer,0,sizeof(buffer));        {just for sure}
  size:=sizeof(buffer);                     {save buffersize}
  GetComputerName(buffer,size);             {fill buffer, bytes read saved
in size}
  ComputerName:=copy(strpas(buffer),1,size);{convert to pascal style}
End;

You can just copy those functions in a new created application, and for
example make a button which just puts the username in the caption, so
Caption:=Username;
Quite simple this way (I thought...)

If you find out any more, please mail it to me. Thanx for that in
advance...

Chris van Mourik, ABC.van.Mou...@indaut.fnt.hvu.nl

Huang Su <hqs...@mbox2.singnet.com.sg> wrote in article
<3476FE37.7C95B...@mbox2.singnet.com.sg>...

Quote
> How can I read the network login ID of the user?
> Thanks for any hints.
> --
> Huang

Other Threads