本文整理汇总了C++中CComPtr::AcquireNextFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ CComPtr::AcquireNextFrame方法的具体用法?C++ CComPtr::AcquireNextFrame怎么用?C++ CComPtr::AcquireNextFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComPtr
的用法示例。
在下文中一共展示了CComPtr::AcquireNextFrame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wWinMain
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
CoInitializeEx(NULL, COINIT_MULTITHREADED);
aslog::openlog();
aslog::setlevel(aslog::level::debug);
curl_global_init(CURL_GLOBAL_ALL);
load_settings();
HRESULT hr = CoCreateInstance(CLSID_WICImagingFactory,
NULL,
CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&g_pImagingFactory)
);
hr = find_output();
CComPtr<IDXGIOutputDuplication> pDup;
std::mt19937 rand(std::chrono::high_resolution_clock::now().time_since_epoch().count());
while (true) {
Sleep((rand() % 30 + 1) * 60000 + (rand() % 30 + 1) * 1000);
DXGI_OUTDUPL_FRAME_INFO frameInfo;
CComPtr<IDXGIResource> pResource;
if (!pDup) {
hr = g_pOutput->DuplicateOutput(g_pDevice, &pDup);
// First image captured is always black
hr = pDup->AcquireNextFrame(1000, &frameInfo, &pResource);
pDup->ReleaseFrame();
pResource.Release();
}
hr = pDup->AcquireNextFrame(1000, &frameInfo, &pResource);
if (hr == DXGI_ERROR_ACCESS_LOST) {
pDup.Release();
continue;
} else if (FAILED(hr)) {
aslog::error(L"Unable to capture frame: 0x%.8x", hr);
Sleep(1000);
continue;
} else {
aslog::info(L"Captured frame successfully");
DWORD sz;
UINT8 *data, *jpeg_data;
UINT width, height;
get_screen_data(pResource, &data, &width, &height);
pResource.Release();
pDup->ReleaseFrame();
encode_jpeg(data, width, height, &jpeg_data, &sz);
delete[] data;
send_email(jpeg_data, sz);
delete[] jpeg_data;
}
}
aslog::closelog();
return 0;
}