The MASM Forum

Microsoft 64 bit MASM => Examples => Topic started by: hutch-- on October 09, 2019, 01:28:27 PM

Title: Private clipboard using a memory mapped file.
Post by: hutch-- on October 09, 2019, 01:28:27 PM
The example has been put into a rich edit skeleton to show how it works. Instead of the normal cut, copy and paste using the system clipboard, it uses a pre allocated memory mapped file to provide the cut, copy and paste which has no connection to the system clipboard. This frees up the system clipboard and also makes data passed between instances unavailable to other apps.

The example is the bare bones of what you can do with a private clipboard that uses a memory mapped file, in conjunction with either SendMessage or PostMessage using the HWND_BROADCAST handle, you can interactively control data transfer between independent application or multiple instances of a single app.

To run this test piece, start up 2 or more instances then type text into one of the editors, then do normal cut, copy and paste between any of the running instances.

The code to do this is in fact very simple, to make it easier to find in the clutter of a rich edit skeleton, I have marked the specific code used like this.

    ; |||||||||||||||||||||||||||

      PM_COMMAND dq ?           ; private message variables
      hMMF  dq ?                ; memory mapped file handle
      pMMF  dq ?                ; pointer to mapped memory

    ; |||||||||||||||||||||||||||

Just scan for the ; ||||||||||||||| and you will find each section of code used.