DelphiFAQ Home Search:

Get the login name of the current user

 

comments7 comments. Current rating: 5 stars (1 votes). Leave comments and/ or rate it.

You need to use the GetUserName() API call, and pass NIL as the first parameter.

See the following example:

// Returns the network ID for the current system user. Returns
// null string ('') on error.
function GetNetUser : Ansistring;
var
  dwI : DWord;
begin 
  dwI := MAX_PATH; 
  SetLength (Result, dwI + 1); 
  if WNetGetUser (Nil, PChar (Result), dwI) = NO_ERROR then 
    SetLength (Result, StrLen (PChar (Result))) 
  else 
    SetLength (Result, 0)
end;

Comments:

2006-11-24, 18:27:57
anonymous from China  
Get System netusername?


Keywords: junk
2008-06-24, 02:25:26
Amir,Cohen from Israel  
To the guy from Iran,

I would gladly have write down the answer for you but unfortunately I cannot do it since you guys are involed in global terrorism activities against humanity and breach human rights. Therefore should not have any help whatsoever.


We shall prevail !!!
2008-06-24, 05:22:18
Peter from Germany  
Amir,
most of persians are not on the side of this regime, all my friends there are not! There was a guy asking for help and not a political system.
2008-07-01, 12:43:45
anonymous from Iran  
Hey Israeli babe, you think you are important? You terrorists days are counted, wait to see how you'll be eradicated, then you'll not be able to post comments...

About your stupid Peter, we don't care about sold and two-faced iranians... You can die far from Iran, do not come back to Iran, it will be bad for you....
2008-09-18, 07:43:18
christy  
rating
you guys are just rasists and nazi regarding to each other. All that because you have no personal brains, your brains live by TV only.
2012-09-09, 07:22:59
anonymous  
wow from delphi to world politics
2013-05-18, 14:46:13   (updated: 2013-05-18, 14:49:06)
Amir  
LOL I wrote this note as a joke some years ago :)
I am not even an Israeli by the way I'm from the UK, just worked there.
The guy from Iran you are so full of hate, shame on you, I fill sorry for you guys.
Peace.

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: