I have some code to get the current screens contents which works smoothly on at least one computer (code simplified, only the relevant parts are shown and error handling is removed):
hr = D3D11CreateDevice(nullptr,gDriverTypes[DriverTypeIndex],nullptr,0,gFeatureLevels,
NumFeatureLevels,D3D11_SDK_VERSION,&lDevice,&lFeatureLevel,
&lImmediateContext);
ComPtr<IDXGIDevice> lDxgiDevice;
hr = lDevice.As(&lDxgiDevice);
// Get DXGI adapter
ComPtr<IDXGIAdapter> lDxgiAdapter;
hr = lDxgiDevice->GetParent(__uuidof(IDXGIAdapter), &lDxgiAdapter);
lDxgiDevice.Reset();
// Get output
ComPtr<IDXGIOutput> lDxgiOutput;
hr = lDxgiAdapter->EnumOutputs(output, &lDxgiOutput);
lDxgiAdapter.Reset();
hr = lDxgiOutput->GetDesc(&lOutputDesc);
// QI for Output 1
ComPtr<IDXGIOutput1> lDxgiOutput1;
hr = lDxgiOutput.As(&lDxgiOutput1);
lDxgiOutput.Reset();
// Create desktop duplication
hr = lDxgiOutput1->DuplicateOutput(lDevice.Get(), &lDeskDupl);
On an other computer that last call to DuplicateOutput() fails, here "hr" returns E_UNEXPECTED.
DxDiag of this second, not working computer shows DirectX12, right as the first, working one.
Any idea how to get additional information about the reason for this error or any idea what could be wrong?
Thanks!