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

How to print an HTML document from inside of your application?

1407


'External Exception C0000008' or 'Access Violation' . what does this error mean?

3152


How to use the InterBase API security functions to add, modify and delete users?

1379


How to Pass a function to a procedure or vice versa?

1603


How to run executables created in Kylix?

1411


How to Create a PolyPolygon using a point array?

2074


How to Align maximized forms?

1453


How to Link an animated cursor to a resource file?

1480


How to determine the week number of a given day in the year?

1459


How to create an About Box in Delphi or C++ Builder?

2295


How to Convert from Long to Short file names and paths ?

1519


How to Register a file extension and context menu operations?

1373


What is the equivalent in BCB to a Pdox TCursor?

1647


How to Avoid an Application Error when using EM_POSFROMCHAR ?

1596


What are the reasons involved in using the interface?

564