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 |
what are the different String Trim functions?
How to Get the actual size of a TComboBox?
How to Get a list of the available drives on a system?
How to obtain IDAPI32.LIB and IDAPI.H ?
Are there any tools to help me migrate my applications to Delphi?
How to Connect via ODBC using Delphi or C++ Builder ?
what is Client launching ?
How to Hide the application from the Windows Taskbar?
Can we write multi-user database applications in regular Delphi?
Can ALTER TABLE statment on Paradox tables removes passwords ?
What are the different ways of defining array sizes?
How does Delphi's exception handling work?