function EnableDebugPriv: Boolean; //提升进程权限为DEBUG权限 var hToken: THandle; tp: TTokenPrivileges; rl: Cardinal; begin Result := false; OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,hToken); if LookupPrivilegeValue(nil, 'SeDebugPrivilege', tp.Privileges[0].Luid) then begin tp.PrivilegeCount:=1; tp.Privileges[0].Attributes:= SE_PRIVILEGE_ENABLED; Result := AdjustTokenPrivileges(hToken, false, tp, SizeOf(tp), nil, rl); end; end;