На этот вопрос постарается ответить Олег Кулабухов:
function GetCurrentUserName: string; var Len: Cardinal; { This will have to be Integer, not cardinal, in Delphi 3. } begin Len := 255; { arbitrary length to allocate for username string, plus one for null terminator } SetLength(Result, Len - 1); { set the length } if GetUserName(PChar(Result), Len) then { get the username } SetLength(Result, Len - 1) { set the exact length if it succeeded } else begin RaiseLastWin32Error; { raise exception if it failed } end; end; |
[001929]