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 set the Wallpaper on Windows98/2000 when ActiveDesktop is turned on?

0 Answers  


How to use the Lookup method to return values from multiple columns ?

0 Answers  


I just bought Delphi. Where are the language and library reference manuals?

0 Answers  


How to tell if a form has been created (or any object)?

0 Answers  


Why won't the virtual key codes work in program?

0 Answers  






How to Hide the application from the Windows Taskbar?

0 Answers  


what are the Current MSACCESS driver limitations ?

0 Answers  


What does memory leak show in delphi?

0 Answers  


How to create Interbase stored procedures that return parameters with TIBQuery?

0 Answers  


How to Access a grid's column or row by name ?

0 Answers  


what are the different Dataset event handlers?

0 Answers  


How to Change the owner of a component at runtime ?

0 Answers  


Categories