Answer Posted / clive
use win32 function getUserName
function MyUserFunction : String;
var
pcUserName : pChar; // temporary storage
dwMaxChars : DWORD; // length parameter
Const
MAXCHARS = 255; // max length
begin
dwMaxChars := MAXCHARS;
pcUserName := strAlloc( MAXCHARS + 1 );
try
If not getUserName( pcUserName, dwMaxChars ) Then
result := ''
else
result := String( pcUserName );
finally
strDispose( pcUserName );
end;
end;
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
How to Set a form's maxwidth in code?
How to do Sorting on Calculated fields ?
How to Use Control Characters With Delphi?
What if I do not have a CD-ROM drive?
How to Send a message to all controls on a form 16-JUL-98?
How to capture an image from a video source?
How to Move the application server to another machine?
What is the procedure to access the database from delphi?
How to Finddistance between two points?
How can one prevent a TForm from being moved or resized?
How to avoid "Random" Exceptions being raised when using TJPEGImage or the JPEG unit?
How to install programatically a printer?
How do abstract classes differ from interfaces?
What is the diff between IT Company & other companies?.
How to Convert a TColor value to a HTML Color string ?