Why Access Denied while using ExitWindowEx(EWX_REBOOT)
mathe 2001-10-01 10:20:57 I am using Windows2000 Service Pack2.
And I am using one of Administrators Account to run my program.
It is very strange that ExitWindowEx(EWX_REBOOT,0) will return FALSE.
So I try to use InitiateSystemShutdown(NULL,NULL,5,FALSE,TRUE) & it return FALSE too. The GetLastError() tells that "Access Denied".
Another problem is that when I run MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING,
the function return TRUE. But after I restart the computer, the file was not moved&replaced. And I could not find new items in register
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations
as MSDN says.
Who can help me?
Following is my code:
CopyFile(UNINSTALL_PATH,TEMP_PATH,FALSE);
if(!MoveFileEx(TEMP_PATH,DESTINE_PATH,MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING))
{//No Error reported here.
int Error=GetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,Error,0,text,1024,NULL);
MessageBox(NULL,text,"MoveFileEx",MB_OK);
}
if(!InitiateSystemShutdown(NULL,NULL,5,FALSE,TRUE)){
int Error=GetLastError();//Access Denied reported.
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,Error,0,text,1024,NULL);
MessageBox(NULL,text,"InitiateSystemShutdown",MB_OK);
}