我在设备管理器中禁用了图形卡,然后运行了程序。返回的“ hr”为S_OK。
...
D2D1_RENDER_TARGET_PROPERTIES props =
D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_HARDWARE,
D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED));
props.dpiX = (float)_dpi_x;
props.dpiY = (float)_dpi_y;
HRESULT hr = _pD2DFactory->CreateHwndRenderTarget(props, D2D1::HwndRenderTargetProperties(_hWnd, D2D1::SizeU((UINT32)(_width * _dpi_x / 96.0f), (UINT32)(_height * _dpi_y / 96.0f))), &_pRenderTarget);
ATLASSERT(SUCCEEDED(hr));
...