I'm building a mixer app and need to get the user-friendly names for each audio session.
I tried:
IAudioSessionControl::GetDisplayName()
method, but it returned empty string for each session.Calling
QueryFullProcessImageName()
andGetModuleFileNameEx()
, but they only outputC:\Users\
since I have Cyrillic letters in the path. But even if they did output the full path, I assume it would end with something like...\brave.exe
(correct me if I'm wrong), which is not a user-friendly name likeBrave Browser
in Windows' built-in mixer.I also tried getting all process names and PIDs like this, and later match them to session process IDs, which successfully gave me names like
chrome.exe
orsteam.exe
, but they are still, again, not quite what I want:std::vector<std::pair<DWORD, wchar_t*>> processes; HANDLE handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); PROCESSENTRY32 entry; entry.dwSize = sizeof(PROCESSENTRY32); Process32First(handle, &entry); do { processes.emplace_back(entry.th32ProcessID, entry.szExeFile); } while (Process32Next(handle, &entry)); CloseHandle(handle);
What I want is to retrieve names like in the built-in mixer app, ie Steam
, Chrome Browser
, Zoom Meetings
, etc.
Is there a way to achieve this? Or does Microsoft use some kind of black magic here?
CodePudding user response:
Calling
QueryFullProcessImageName()
andGetModuleFileNameEx()
, but they only outputC:\Users\
since I have Cyrillic letters in the path.
Then you are simply not displaying the path correctly. The presence of Cyrillic characters is not a problem.
I also tried getting all process names and PIDs like this, and later match them to session process IDs, which successfully gave me names like
chrome.exe
orsteam.exe
, but they are still, again, not quite what I want
That code doesn't work properly. You are storing pointers in your std::vector
that point to a single wchar_t[]
buffer which is modified on each loop iteration. You should instead store std::wstring
instead of wchar_t*
so each path is copied.
What I want is to retrieve names like in the built-in mixer app, ie
Steam
,Chrome Browser
,Zoom Meetings
, etc.
Once you have the path to the EXE, you can use GetFileVersionInfo()
and VerQueryValue()
to retrieve the app's human-readable FileDescription
. See Retrieve File Description for an Application using VerQueryValue.