本文介绍了SHGetKnownFolderItem - Wow64的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!
我编译32位可执行文件,并在64位计算机上运行(Windows 10)
I compile 32 bit executable, and run it on a 64-bit machine (Windows 10)
I调用函数 SHGetKnownFolderItem来获取FOLDERID_AppUpdates的已知文件夹,但是,我得到E_INVALIDARG
I call the function SHGetKnownFolderItem to get the known folder of FOLDERID_AppUpdates, However, I get E_INVALIDARG
在x64中它可以正常工作。我有限制以32位编译它。
In x64 it works fine. I have limitation to compile it in 32-bit.
我之所以选择该选项是因为它是最快的。
I chose that option because it was the fastest.
代码:
void ViewInstalledUpdates()
{
using namespace std;
HRESULT hr = CoInitialize(NULL);
int count = 0;
if (SUCCEEDED(hr))
{
CComPtr<IShellItem> pUpdates;
CComPtr<IEnumShellItems> pShellEnum;
hr = SHGetKnownFolderItem(FOLDERID_AppUpdates, static_cast<KNOWN_FOLDER_FLAG>(0), nullptr, IID_PPV_ARGS(&pUpdates));
hr = pUpdates->BindToHandler(nullptr, BHID_EnumItems, IID_PPV_ARGS(&pShellEnum));
if (pShellEnum)
{
do {
CComPtr<IShellItem> pItem;
CComHeapPtr<WCHAR> szName;
hr = pShellEnum->Next(1, &pItem, nullptr);
if (pItem)
{
HRESULT hres = pItem->GetDisplayName(SIGDN_NORMALDISPLAY, &szName);
std::wcout << static_cast<LPWSTR>(szName) << endl;
count++;
}
} while (hr == S_OK);
}
}
CoUninitialize();
std::wcout << L"Found " << count << " updates" << endl;
return;
}
我有什么办法让它有效吗?
Is there something I can do to make it works?
提前谢谢你,
Tom
推荐答案
这篇关于SHGetKnownFolderItem - Wow64的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!