此代码在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);
答案 0 :(得分: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);