首页  编辑  

判断是否在系统账户下运行程序(Win2K,XP)

Tags: /超级猛料/OS.操作系统/Process.进程/   Date Created:

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;