Changeset 260 for Common/UCommon.pas


Ignore:
Timestamp:
Aug 9, 2011, 10:02:32 AM (13 years ago)
Author:
george
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/UCommon.pas

    r252 r260  
    277277
    278278function LoggedOnUserNameEx(Format: TUserNameFormat): string;
    279 var
    280   UserName: array[0..250] of Char;
     279const
     280  MaxLength = 1000;
     281var
     282  UserName: array[0..MaxLength] of Char;
    281283  VersionInfo: TOSVersionInfo;
    282284  Size: DWORD;
     
    284286  VersionInfo := GetVersionInfo;
    285287  if VersionInfo.dwPlatformId = VER_PLATFORM_WIN32_NT then begin
    286     Size := 250;
     288    Size := MaxLength;
    287289    GetUserNameEx(Integer(Format), @UserName, @Size);
    288     Result := UTF8Encode(UserName);
     290    //ShowMessage(SysErrorMessage(GetLastError));
     291    if GetLastError = 0 then Result := UTF8Encode(UserName)
     292      else Result := GetUserName;
    289293  end else Result := GetUserName;
    290294end;
Note: See TracChangeset for help on using the changeset viewer.