2016-11-10 40 views
-1

您好我一直在尝试从各自应用程序的AppManifest.xml中获取metro应用程序的名称。知道SHLoadIndirectString可以用于此目的。在手动检查其功能时,我无法获得结果资源。代码片段如下所示。SHLoadIndirectString的返回值是一个错误代码

#include <iostream> 
using namespace std; 
#include <Shlwapi.h> 
int main(){ 
    LPWSTR output = L""; 
    LPWSTR input = L"@{Microsoft.BingMaps_2.1.3230.2048_x64__8wekyb3d8bbwe?ms-resource://Microsoft.BingMaps/resources/AppDisplayName}"; 
    int result = SHLoadIndirectString(input, output, sizeof(output), NULL); 
    cout<<output; 
    return 0; 
} 

返回值“result”始终为负值(如果我正在更改输入字符串各自的应用程序)。请指导我解决我的错误。谢谢。

回答

0

得到了正确的答案。

#include <iostream> 

using namespace std; 
#include <Shlwapi.h> 
int main() 
{ 
    PWSTR output = (PWSTR) malloc(sizeof(WCHAR)*256); 


    PCWSTR input = L"@{C:\\Program Files\\WindowsApps\\Microsoft.BingMaps_2.1.3230.2048_x64__8wekyb3d8bbwe\\resources.pri?ms-resource://Microsoft.BingMaps/Resources/AppShortDisplayName}"; 
    int result = SHLoadIndirectString(input, output, 256, NULL); 

    cout<<output; 
    return 0; 
} 
相关问题