此代码在 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);