从特定程序捕获音频

时间:2018-09-15 19:11:31

标签: c++ winapi audio

我有一个带有一些音频输出的窗口的HWND。如何像Windows调音台那样捕捉震级?

这是如何获取所有窗口的HWND的代码:

BOOL CALLBACK FindWindowBySubstr(HWND hWnd, LPARAM substring)
{
    const DWORD TITLE_SIZE = 1024;
    TCHAR windowTitle[TITLE_SIZE];

    std::string sTitle = CWinAPI::GetTheWindowText(hWnd);
    unsigned int nTitleLength = CWinAPI::GetWindowTextlength(hWnd);
    RECT rect = CWinAPI::GetWindowRectangle(hWnd);

    if(nTitleLength > 0)
    {
        vecAllWindows.push_back(CWinAPI::SWindow(hWnd, sTitle, nTitleLength, rect));
    }
    return true; // Need to continue enumerating windows 
}

void CWinAPI::ListAllWindows(bool bShowWindowsWithoutTitle)
{
    vecAllWindows.clear();
    const TCHAR substring[] = TEXT("A");
    EnumWindows(FindWindowBySubstr, (LPARAM)substring);
}

从该列表中,我可以选择要查找的窗口。

下图是Microsoft Windows音频混音器:

enter image description here

对不起,这是德语,但我希望每个人都能理解... 我想做的是捕获特定窗口HWND的当前音频(幅度)的实际值。

有可能吗? Windows API也可能吗? 如果是这样:哪个命令可以帮助我?

编辑:

此代码为我提供了processID(也许这更有用)

DWORD CWinAPI::GetProcessIDFromHWND(HWND hWnd)
{
    return GetWindowThreadProcessId(hWnd, NULL);
}

0 个答案:

没有答案