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

How to Access new interfaces in a RemoteDataModule?

0 Answers  


How to Get bin names from your printer?

0 Answers  


How to Converta RGB color to a CMYK color?

0 Answers  


How to get the default Windows folders ?

0 Answers  


How to prevent the user from moving or sizing my form?

0 Answers  






How to use return instead of tab or mouse to move off a control ?

0 Answers  


How to Generate a Windows Console Application?

0 Answers   Satyam,


How to Avoid an Application Error when using EM_POSFROMCHAR ?

0 Answers  


How do we get access to a database from Delphi?

0 Answers  


How to set the desktop icon color in code, or make the text behind them transparent?

0 Answers  


How to Determine minor version number?

0 Answers   Infosys,


How to Move a form by clicking in its client area ?

0 Answers  


Categories