Implementation of screen capture via DirectX using IDXGIOutputDuplication in C# without any dependencies.
Emphasis on perfomance, but unfortunately due to a language limitation is completely covered by boxing structures into interfaces.
Both samples can be found in Program.cs
But for illustrative purposes:
usingvarcapturer=newScreenCapturer();Frameframe;while(true)if(capturer.CaptureFrame(&frame))
…or with the choice of device and screen:
GraphicDevicedevice;GraphicDevice.EnumDevice(&device,index:0);Screenscreen;Screen.EnumScreen(&screen,&device,index:0);Duplicatorduplicator;Duplicator.Create(&device,&screen,&duplicator);Frameframe;while(true)if(duplicator.CaptureFrame(&frame))
…