SHLoadIndirectString的返回值是一个errorcode

Return value of SHLoadIndirectString is an errorcode

本文关键字:一个 errorcode 返回值 SHLoadIndirectString      更新时间:2023-10-16

嗨,我一直试图从各自应用程序的AppManifest.xml中获得地铁应用程序的名称。我知道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"总是一个负值(如果我改变输入字符串分别到app)。请指点我的错误。谢谢。

答对了。

#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;
}