0

此代码在 Vista/Win7 上成功运行,但在 win xp 上失败(返回 ERROR_INVALID_PARAMETER)。互联网上没有关于这个问题的文档。有人知道错误在哪里吗?谢谢。

QList<std::pair<int, int> > versions;
versions << std::pair<int, int>(5, 0);
versions << std::pair<int, int>(5, 1);
versions << std::pair<int, int>(5, 2);
versions << std::pair<int, int>(6, 0);
versions << std::pair<int, int>(6, 1);

QList<int> architectures;
architectures << PROCESSOR_ARCHITECTURE_INTEL << PROCESSOR_ARCHITECTURE_AMD64;

for (int i = 0; i < versions.count(); i++)
{
    int major = versions[i].first;
    int minor = versions[i].second;

    for (int j = 0; j < architectures.count(); j++)
    {
        int arch = architectures[j];

        SP_INF_SIGNER_INFO_V2 signerInfo;
        signerInfo.cbSize = sizeof(SP_INF_SIGNER_INFO_V2);

        SP_ALTPLATFORM_INFO_V2 altPlatInfo;
        altPlatInfo.cbSize = sizeof(SP_ALTPLATFORM_INFO_V2);
        altPlatInfo.Platform = VER_PLATFORM_WIN32_NT;
        altPlatInfo.MajorVersion = major;
        altPlatInfo.MinorVersion = minor;
        altPlatInfo.Flags = SP_ALTPLATFORM_FLAGS_VERSION_RANGE;
        altPlatInfo.FirstValidatedMajorVersion = major;
        altPlatInfo.FirstValidatedMinorVersion = minor;
        altPlatInfo.ProcessorArchitecture = arch;
        SP_INF_SIGNER_INFO_V2 signerInfo;
        signerInfo.cbSize = sizeof(SP_INF_SIGNER_INFO_V2);

        bool result = SetupVerifyInfFile((wchar_t*)package.infFilePath.utf16(), 0, &signerInfo);
4

1 回答 1

0

我也无法让 UNICODE 版本的 SetupVerifyInfFile 在 XP 上工作。非 Unicode 版本工作正常。如果 package.infFilePath 仅包含 ASCII,您可以使用以下解决方法:

SP_INF_SIGNER_INFO_V2_A signerInfo;
signerInfo.cbSize = sizeof(SP_INF_SIGNER_INFO_V2_A);
bool result = SetupVerifyInfFileA(package.infFilePath.toUtf8(), 0, &signerInfo);
于 2012-05-23T16:48:05.807 回答