<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Comments for How to display the current user name.</title>
<link rel="alternate" type="text/plain" href="http://dn.codegear.com/article/26731" title="How to display the current user name." />
<link rel="self" type="application/atom+xml" href="http://dn.codegear.com/article/26731/feed" title="Comments for How to display the current user name." />
<id>http://dn.codegear.com/article/26731</id>
<updated>2008-11-19T05:03:48-08:00</updated>
<entry>
<title>re: How to display the current user name.</title>
<author>
<name>Arthur van Dijk</name>
<uri>http://threads.codegear.com/threads/threads.exe/userall?commentid=39920</uri>
</author>
<id>http://threads.codegear.com/threads/threads.exe/view?commentid=39920</id>
<updated>2007-02-27T09:34:49-08:00</updated>
<published>2007-02-27T09:34:49-08:00</published>
<summary>re: How to display the current user name.</summary>
<content>Happend here too... I solved the problem like this:added the following line in the Procedure declarations section:function CurrentUserName: String;then added the function like this:function TForm1.CurrentUserName:String;var  u: array[0..127] of Char;  sz:DWord;begin  sz:=SizeOf(u);  GetUserName(u,sz);  Result:=u;end;Now you can call it anytime using Form1.CurrentUserName and it acts as a String.</content>
</entry>
<entry>
<title>How to display the current user name.</title>
<author>
<name>Ben Hull</name>
<uri>http://threads.codegear.com/threads/threads.exe/userall?commentid=27931</uri>
</author>
<id>http://threads.codegear.com/threads/threads.exe/view?commentid=27931</id>
<updated>2001-02-12T06:45:00-08:00</updated>
<published>2001-02-12T06:45:00-08:00</published>
<summary>How to display the current user name.</summary>
<content>I have found that there is a high failure rate on GetUserName (50%) if you do not call it like this:procedure TfrmMain.FormCreate(Sender: TObject);var UserName : PChar; c : Cardinal;begin//Get User Name Windows API call c := 0; GetUserName(nil, c); UserName := StrAlloc(c); if GetUserName(UserName, c) then  UserRec.Login := Uppercase(StrPas(UserName)); StrDispose(UserName);//NT GetUserName Windows API call//Other stuff goes here end;</content>
</entry>
</feed>
