2016-11-10 46 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; 
} 
相關問題