How to display the current user name?

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


Please Help Members By Posting Answers For Below Questions

what are Multiple Transports?

1349


How to run executables created in Kylix?

1428


How to make the TDateTimePicker display blank?

1474


How to Set Up a C++ Builder or Delphi Form to View InterBase Data?

1410


'Invalid BLOb handle' error . what does this indicates?

1426


How to Debug an In-Proc COM Server?

1411


How to get the version information for a file?

1506


How to Create a custom TInplaceEdit for TDBGrid ?

2157


Explain about Multi-Threaded ISAPI DLLs ?

1959


How to retrieve an InterBase Blob in Delphi using SavetoFile?

1528


How to use the Find Error entry under the search heading of the menu bar?

1454


How to capture the URL and title of the current webpage being viewed?

1696


How to use a true DWORD value passed to Delphi application?

1506


How to Disable ALT-F4 to prevent form closing

4160


How to Set the MaxPage property of the PrintDialog component?

1611