tsunami

log in
history

VB6 cross-process communication

Luke Breuer
2008-03-24 17:35 UTC

Intro
Update 2: It would appear that we've been reduced to DDE or Windows messages, via SetWindowLong + WndProc + SendMessage. I can fully list the Win32 APIs that would be required for subclassing.

Update: DDE is apparently a good bet (MSDN).

Windows allows one to use the following registry keys to implement a URI protocol handlers. For our VB6 application, ES2, the following key and values exist:
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ES2(default)      REG_SZ    URL:ES2 Protocol
                                       \URL Protocol   REG_SZ

The problem with this scheme is that each time a URI is clicked, it launches a new instance of ES2.exe. This is unfortunate; when two URIs are similar enough (if they indicate the same database & credentials as an existing instance), the second one launched should really launch in the already-running ES2.exe. Therefore, there needs to be a way for ES2 to query itself. Theoretically, it can be compiled as an ActiveX EXE and be queried by itself using OLE. If this is easy, I want a code sample where, upon launch, the EXE enumerates all other instances of itself, invokes a method on them passing the command line arguments, and receives a boolean back: the command line arguments were processed successfully and work can cease, or any other instances should be queried. If no instances respond with true, then the new instance should start up normally.

If an ActiveX exe would work, I want a simple VB6 project that demonstrates the above. Otherwise, I would like alternative approaches. One such alternative would be to create a special, lightweight Win32 window which could be subclassed in order to receive SendMessage messages. If this can be done very cleanly, it is definitely an option. However, subclassing any existing VB6 forms is most likely undesirable, as doing so tends to make applications unstable.

RegisterActiveObject or something like it might also be an option. (discussion forum post)
Named Pipes