News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Inter Application Communication Example

Started by hutch--, July 24, 2022, 01:48:55 PM

Previous topic - Next topic

hutch--

The example is two almost identical apps which use a registered message to communicate between the two apps in both directions.

It creates a private message using the following code.

    PM_COMMAND = RegisterWindowMessage("My_Private_Message")

From a normal WM_COMMAND message it sends the following,

            PostMessage %HWND_BROADCAST,PM_COMMAND,1,0
            SetWindowText hStat, "Message Sent"

And at the receiving end it uses,

      Case PM_COMMAND
        Select Case as LONG wParam
          Case 2
            SetWindowText hStat, "Message from test 2"

        End Select

The example is in an API based dialog but the same code should work in a DDT wrapper dlalog.

The technique establishes "signalling" between two apps, to pass data of any quantity you would create a memory mapped file, write data to it and read it from the other end.

hutch--

This is a version that uses the same signalling technique with PostMessage and the %HWND_BROADCAST handle but uses a memory mapped file as shared memory between the two test apps. The logic is to write data to the memory mapped file then post a message to signal that the data is available. The message processing at the other end uses the signal to load the data from the memory mapped file memory and displays it.

Differing from normal API methods, the data is basic string data that is encoded in the same manner as a basic dynamic string at the sender end and decodes the data at the receiving end back into a basic string. This means that you can routinely pass basic string data from one app to another via a memory mapped file. The matching pair of functions are in both test pieces as are the functions for creating the memory mapped file.

It is an unusual capacity in that you can use executable files for external tasks without the need for dedicated DLLs and while DLLs are very useful, having other options is also very useful.