Jose's Blog

July 25, 2016

Desktop Duplication API in Delphi

Filed under: Uncategorized — jp2712 @ 8:57 am


One way some remote access applications speed up the screen capture on remote computers is by installing a Display Mirror Driver. Mirror Drivers exist since Windows 2000. However, for Windows 8 and above, Mirror Drivers will not install any more. Still, Microsoft decided to offer an alternative solution.
Such solution is called the Desktop Duplication API and is part of DirectX 11, more precisely the DXGI 1.2 update. Actually, the DirectX 11 API can fallback to versions 10 or 9, if the system does not support DirectX 11, but DXGI does not. Moreover, there will be no DXGI 1.2 for Windows 7 and Vista – you do need Windows 8 or later.

To get acquainted with the Desktop Duplication API, I went through the sample supplied by Microsoft. The fact is that I was not able to find much more samples elsewhere.
The sample supplied by Microsoft works on a single desktop, but that is just fine for its purpose.

DirectX is COM based, this means that you will have to master C or C++ to deal properly with it, right? Not exactly, Delphi is well tailored to deal with COM interfaces as well. I would say, that with Delphi, COM might even be easier, because it manages reference counting.

The Samples

I have produced 2 samples:
1) The first one mimics the Microsoft sample. I called it the Console Sample, although no console is actually there. It creates a window with the Windows API, launches one or more threads for the desktop duplication, then enters in an endless message loop to update the created window with the grabbed frames.

2) The second one is done more according to the Delphi way of doing things. Here a VCL Form is created and the grabbed frames update a TPanel component inside the Form. I choose a TPanel because it is TWinControl descendant, so has an HWND.



1) DirectX header files are from Reference 3, below. Great work (a lot of it, indeed!)
2) Pixel Shaders and Vertex Shaders are not directly compiled by the samples. Instead I inserted the precompiled results inside the PixelShader and VertexShader units.


  1. Desktop Duplication API
  2. DXGI desktop duplication sample
  3. DelphiDX12 Headers


SourceCode and Binaries



October 11, 2011

Mixing .Net and Assembly Language in a standalone 64-bit exe

Filed under: ASM 64-Bit, Assembly Language, Developments, Software — Tags: , , , — jp2712 @ 1:16 pm

Building a standalone 64-bit .Net .exe file that is statically linked with an Assembly Language compiled object file is something I would say “is not possible” a few months ago. Actually, it is possible, because .Net has all sorts of tricks to create the illusion that it is what it is not not. Let’s read my page about “Mixing .Net and Assembly Language in a standalone 64-bit exe” and see how this can be done and in 64-bit (of course can be done in 32-bit as well)

September 29, 2011

More about Assembly Language and Delphi (64-bit and 32-bit)

Filed under: Delphi Programming, Developments, Software — jp2712 @ 9:13 pm

Things are like this. We stay a long time without posting then comes a fever and we post two times in a row. It happen yesterday and today we are here again to write about a related subject, How to use Assembly Language with Delphi 64-bit (and 32-bit as well)

64-bit Basm with Delphi XE2

After a long time without posting in this blog, I decided it was about time.

I was trying the new Delphi XE2, to see if there was anything really useful and worthwhile on it. To my surprise, Delphi XE2 is the product to change the route to dead that Delphi was following.

I and thousands of others always thought that was not worthwhile to upgrade from Delphi 5 or Delphi 7, unless we prefer bloated, slower and more buggy programs.

Well, things appear to be changing. Delphi XE2 is excellent value, particularly if you were waiting for the long promised 64-bit compiler.

Not that Delphi XE2 is bug free, not that its documentation is good (it is terribly bad), not that it has a good price (it is extremely expensive, namely for Europeans. Embarcadero, Microsoft and many other American companies suck for the price differentiation – and I am not talking about VAT).

Anyway, because Delphi XE2 brings somethig new, I rolled up my sleeves and wrote an article about BASM for 32-bit and 64-bit Delphi. Read it!

December 13, 2010

New articles, but not yet here :(

Filed under: Developments, Software — Tags: , — jp2712 @ 11:59 am

Since long I have not posted here but I had posted a couple of articles in my website, one about MPIR and MPFR and another is a great free software to get information about your monitor. May be I will post them here as well but for now please check at

May 3, 2010

Simulate Ctrl-Alt-Del

Filed under: Developments, Software — Tags: , , , , , — jp2712 @ 9:26 pm

As promised, I am posting today an amazing jewel. Follow the link or click the page called simulate ctrl-alt-del on the side bar.
If you are the sort of developer that believe that .Net programming is all you need, don’t bother reading it. I am starting to like .Net but am still convinced that the real fun lies in doing things in the old fashioned way. This is the way Microsoft itself does the things while at the same time pushes everybody to do things in a different way.

If you like, or dislike the Ctrl-Alt-Del article, please cast your vote. It will help me decide if I should continue posting here this sort of jewels.

April 30, 2010


Filed under: Developments, Software — Tags: , , — jp2712 @ 6:58 am

I will be using this blog to sport some rare developer’s code.
Because rare is something unfrequent, please don’t expect the blog to be updated frequently!
However, I have a number of undergoing hot developments which I plan to post here in the upcoming months (or years), I can’t establish a schedule because many other important projects take much of my time.
To celebrate the Grand Opening I have an extremely valuable jewel, which I will post here in the first week of May.
No more hints at this time!

Blog at