Solved

Get User Name

Posted on 2004-04-21
7
147 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

808 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