我试图用C++制作Windows Update卸载程序,但是每当我尝试调用wusa时,它都会在灾难性故障0x80000ffff上退出。我在命令提示符中调用了相同的命令,它运行良好。我该如何解决?
这是我用来调用wusa的函数:
system("wusa /uninstall /kb:2511455");
最佳答案
我已经弄清楚了如何解决此问题,以后我会将解决方案发布给有相同问题的任何人。 system()命令正在%windir%\SysWoW64\中运行32位可执行文件,而不是 native 64位版本。要解决此问题,我必须使用以下内容:
PVOID OldValue = NULL;
if( Wow64DisableWow64FsRedirection(&OldValue) )
{
// Anything in this block uses the system native files and not the WoW64 ones
// put native WoW64 code here
system("wusa /uninstall /kb:2511455");
//system("wusa /?"); // use this for testing
// Immediately re-enable redirection. Note that any resources
// associated with OldValue are cleaned up by this call.
if ( FALSE == Wow64RevertWow64FsRedirection(OldValue) )
{
// Failure to re-enable redirection should be considered
// a criticial failure and execution aborted.
return 0;
}
}
关于c++ - 从system()VC++调用时,WUSA发生灾难性故障0x8000ffff,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30587930/