How to display the current user name?



How to display the current user name?..

Answer / 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

More Delphi Interview Questions

'General SQL Error : Connection does not exist' in threaded application . what does this indicates?

1 Answers  


How to display seconds, minutes, tracks of an AVI ?

1 Answers  


How to detect if the current user is logged in administrator?

1 Answers  


How to get the coding for : Well-ordered numbers

0 Answers  


How to Create a palette with more than one entry ?

1 Answers   Wipro,


How to Use an instance of TPrinter ?

1 Answers   Delta,


How to Print a WEB page with the HTML control?

1 Answers  


How to Prevent changing pages in a page control?

1 Answers  


How to get the version information for a file?

1 Answers  


How to Get a handle on your files ?

1 Answers  


Define PRIMARYLANGID(), SUBLANGID(), and MAKELANGID() macros?

1 Answers  


How to Modify application server SQL from the client?

1 Answers  


Categories