从system()VC ++调用WUSA灾难性故障0x8000ffff

时间:2015-06-02 05:22:15

标签: c++ windows visual-c++ windows-update

我试图用C ++制作Windows Update卸载程序,但每当我尝试调用wusa时,它就会在灾难性的失败0x80000ffff上退出。我在命令提示符中调用相同的命令,它完美地工作。我该如何解决这个问题?

这是我用来调用wusa的函数:

system("wusa /uninstall /kb:2511455");

1 个答案:

答案 0 :(得分:1)

我已经想出如何解决这个问题,并且我将在未来发布具有相同问题的任何人发布我的解决方案。 system()命令在%windir%\ SysWoW64 \中运行32位可执行文件,而不是本机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;
        }
}