Solved

Get User Name

Posted on 2004-04-21
7
143 Views
Last Modified: 2010-04-05
How can I get current  UserName? Windows UserName?
0
Comment
Question by:nthiyab
  • 3
7 Comments
 
LVL 17

Accepted Solution

by:
geobul earned 50 total points
ID: 10877157
function GetLocalName: string;
var
  i: cardinal;
  sUser: array[0..255] of Char;
begin
  try
    i := 255;
    GetUserName(sUser, i);
    result := sUser;
  except
    result := '';
  end;
end;

Regards, Geo
0
 
LVL 17

Expert Comment

by:geobul
ID: 10877172
Or:

function GetLocalUser: string;
var
  i : cardinal;
begin
  try
    i:=255;
    SetLength(result,i);
    GetUserName(PChar(result),i);
    SetLength(result,(i-1));
  except
    result := '';
  end;
end;
0
 

Expert Comment

by:amjedmsa
ID: 10877174
here is the computer names as well


function Cn String;
var
  Size DWord;
begin
  Size = MAX_PATH;
  SetLength(Result, Size);
  if not GetComputerName(PChar(Result), Size) then Size = 0;
  SetLength(Result, Size);
end;
0
 
LVL 17

Expert Comment

by:geobul
ID: 13194123
I'm pretty sure I've answered the question.

Regards, Geo
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now