How to get the “Application Name” from hWnd for Windows 10 Store Apps (e.g. Edge)

前端 未结 5 1716
清歌不尽
清歌不尽 2020-12-31 13:28

I\'m trying to get an understandable \"Process Name\" for Windows 10 apps. Currently, all of them use ApplicationFrameHost, so I thought I could use either the

5条回答
  •  时光取名叫无心
    2020-12-31 13:38

    You can use GetPackageId() and then PackageFullNameFromId().

    E.g.:

    HANDLE hProcess = OpenProcess(
        PROCESS_QUERY_LIMITED_INFORMATION,
        false,
        pe32.th32ProcessID);
    
    UINT32 bufferLength = 0;
    
    LONG result = GetPackageId(hProcess, &bufferLength, nullptr);
    
    BYTE* buffer = (PBYTE) malloc(bufferLength);
    result = GetPackageId(hProcess, &bufferLength, buffer);
    
    PACKAGE_ID* packageId = reinterpret_cast(buffer);
    wprintf(L"Name: %s\n", packageId->name);
    

提交回复
热议问题