C++ _popen 'UWFmgr' 不被识别为内部或外部命令、可操作程序或批处理文件

问题描述 投票:0回答:1

我正在使用 _popen 方法在 Windows 10 Enterprise 上执行 uwfmgr,但我的程序显示“UWFmgr”未被识别为内部或外部命令、可操作程序或批处理文件,尽管 UWF 功能已安装并且 uwfmgr 在 C: 中可用\Windows\System32.

bool Utils::DoesUwfExist()
{
    char psBuffer[128];
    FILE *pPipe;

    printf("Search UWF...");

    if ((pPipe = _popen("UWFmgr volume get-config C:", "rt")) == NULL)
    {
        return false;
    }
    else
    {
        bool ok = false;
        char* okstr = "Protected Volume Configuration";

        while (!feof(pPipe))
        {
            if (fgets(psBuffer, 128, pPipe) != NULL)
            {
                if (ok == false && _mbsnbcmp((const unsigned char*)psBuffer, (const unsigned char*)okstr, 25) == 0)
                    ok = true;
            }

            _pclose(pPipe);

            return ok;
        }
    }
    return false;
}

我检查了环境变量,C:\Windows\System32 设置在 Path 变量中。

但是,我可以从命令提示符执行 uwfmgr,如下所示: command prompt

还有其他我错过的事情吗?谢谢。

c++ popen
1个回答
0
投票

该应用程序是32位应用程序,在Windows 64位上运行。因此,默认情况下,它将重定向到 C:\Windows\SysWOW64。但是,UWF 仅在 C:\Windows\System32 中提供 64 位版本。为了解决这个问题,我们必须在执行UWF之前调用Wow64DisableWow64FsRedirection函数,并在UWF执行之后调用Wow64RevertWow64FsRedirection函数。

© www.soinside.com 2019 - 2024. All rights reserved.