System Delphi

Title: How to determine if my program/Service is running under the System account
function OnSystemAccount(): Boolean;
const
cnMaxNameLen = 254;
var
sName: string;
dwNameLen: DWORD;
begin
dwNameLen := cnMaxNameLen - 1;
SetLength(sName, cnMaxNameLen);
GetUserName(PChar(sName), dwNameLen);
SetLength(sName, dwNameLen);
if UpperCase(Trim(sName)) = 'SYSTEM' then Result := True
else
Result := False;
end;