|
From: <all...@ho...> - 2005-07-24 05:11:51
|
I want to use NtShutdownSystem to shutdown the system. I use mingw4.1.1 and
Dev-C++4.9.9.2, when i compile, i reived erros:
[Linker error] undefined reference to `NtShutdownSystem@4'
ld returned 1 exit status
here is my code(i'm sorry for the urgly code, i picked up from google, and
i'm a newbie, either mingw, or programming):
#include <stdio.h>
#include <stdlib.h>
#include "windows.h"
#include "ntdll.h"
int main(int argc, char *argv[])
{
HANDLE hToken;
if (OpenProcessToken(GetCurrentProcess(),
TOKEN_QUERY|TOKEN_ADJUST_PRIVILEGES, &hToken))
{
TOKEN_PRIVILEGES tkp;
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, 0);
CloseHandle(hToken);
}
SHUTDOWN_ACTION myAction;
myAction = ShutdownPowerOff;
NtShutdownSystem(myAction);
}
who can show me the full successful code?
_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn
|