Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 黑屏试图捕捉谷歌Chrome窗口,每个应用程序都使用硬件加速_C++_Windows_Webrtc_Screen Capture_Window Handles - Fatal编程技术网

C++ 黑屏试图捕捉谷歌Chrome窗口,每个应用程序都使用硬件加速

C++ 黑屏试图捕捉谷歌Chrome窗口,每个应用程序都使用硬件加速,c++,windows,webrtc,screen-capture,window-handles,C++,Windows,Webrtc,Screen Capture,Window Handles,我正在使用Webrtc本机模块捕获单个窗口: webrtc::DesktopCaptureOptions co = webrtc::DesktopCaptureOptions::CreateDefault(); desktop_capturer = webrtc::DesktopCapturer::CreateWindowCapturer(co); desktop_capturer->GetSourceList(&deskto

我正在使用Webrtc本机模块捕获单个窗口:

    webrtc::DesktopCaptureOptions co = webrtc::DesktopCaptureOptions::CreateDefault();
            desktop_capturer = webrtc::DesktopCapturer::CreateWindowCapturer(co);
            desktop_capturer->GetSourceList(&desktop_screens);
            desktop_capturer->SelectSource(desktop_screens[selectedIndex].id);
            desktop_capturer->Start(this);
它工作得很好,但是对于像“谷歌浏览器”这样的一些应用程序,我会看到黑屏,搜索后我发现任何使用“硬件加速”的应用程序都会出现这种情况,如果我在“谷歌浏览器设置”中禁用了硬件加速我可以捕获它的窗口而不会出现黑屏,但我不能对每个使用“硬件加速”的应用程序都这样做

我试图实现另一个窗口捕获器,我得到了同样的问题“每个应用程序的黑色图像使用硬件加速”:


Google Chrome在Windows上使用Direct-X进行渲染,可以使用Direct-X钩子捕获。Google Chrome在Windows上使用Direct-X进行渲染,可以使用Direct-X钩子捕获。
  void CaptureFrame(int i, System::String ^ title){
RECT rc;
std::string stdTitle = convertToStdString(title);
std::wstring tit = s2ws(stdTitle);
LPCWSTR t = tit.c_str();
HWND hwnd = FindWindow(0, t);

if (hwnd == NULL)
{
    return;
}
GetClientRect(hwnd, &rc);

HDC hdcScreen = GetDC(NULL);
HDC hdc = CreateCompatibleDC(hdcScreen);
HBITMAP hbmp = CreateCompatibleBitmap(hdcScreen,
    rc.right - rc.left, rc.bottom - rc.top);
SelectObject(hdc, hbmp);

PrintWindow(hwnd, hdc, PW_CLIENTONLY);


OpenClipboard(NULL);
EmptyClipboard();
SetClipboardData(CF_BITMAP, hbmp);
CloseClipboard();
std::string ind = std::to_string(i);

std::wstring stemp = s2ws(stdTitle + ind + ".jpeg");
LPCWSTR result = stemp.c_str();
CImage image;
image.Attach(hbmp);
image.Save(result, Gdiplus::ImageFormatBMP);


DeleteDC(hdc);
DeleteObject(hbmp);
ReleaseDC(NULL, hdcScreen);}