Hi!
Here is C++ example code, wish it can help you
BOOL GetShutdownPrivileg()
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
// SE_SHUTDOWN_NAME must be enabled
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
&hToken))
return FALSE;
//Get a LUID for SE_SHUTDOWN_NAME privilege
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
// PrivilegeCount enables more than one privilege to be set at a time.
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
// Some privileges are initially disable, so each process must adjust
// the privilege by calling AdjustTokenPrivilege
return AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, 0);
}