int SetPrivilege(bool en)
{
HANDLE hToken;
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
{
TOKEN_PRIVILEGES tp;
tp.PrivilegeCount=1;
LookupPrivilegeValue (0,SE_DEBUG_NAME,&tp.Privileges[0].Luid);
tp.Privileges[0].Attributes = en ? SE_PRIVILEGE_ENABLED : 0;
AdjustTokenPrivileges (hToken, false, &tp, sizeof(tp), NULL, NULL);
}
CloseHandle(hToken);
return 0;
}