...determine if my program/Service is running under the System account?
|
Autor:
Michael Fritzsche |
[ Print tip
] | | |
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;
|