-
#include <iostream>
-
#include <windows.h>
-
BOOL EnableShutDwonProv()
-
{
-
HANDLE hToken = NULL;
-
TOKEN_PRIVILEGES tkp = {};
-
BOOL bRet = FALSE;
-
do
-
{
-
// Get a token for this process.
-
if (!OpenProcessToken(GetCurrentProcess(),
-
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
-
break;
-
if (!LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
-
&tkp.Privileges[0].Luid))
-
break;
-
tkp.PrivilegeCount = 1; // one privilege to set
-
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
-
// Get the shutdown privilege for this process.
-
if (AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
黑科技之无限关机
最新推荐文章于 2024-03-14 21:57:19 发布