In essence I suppose this is nothing but a really stripped down version of the classic MSDN "Coffee Monitor" tutorial application that came with VB6 and is described in detail in the manual.
Demo
The basic idea here is to show how you can have multiple programs (or multiple instances of the same program, as in this demo) sharing objects. In this exampe we're sharing a single Scripting.Dictionary object.
Of course a real application would want to add locking and concurrency control to avoid data integrity errors and client exceptions. You'd also probably want to persist the data, loading the Dictionary on startup and writing its contents back to disk on shutdown.
But by keeping this example thin perhaps it can help illustrate the bare bones fundamentals involved.
Attachment
The attachment contains two projects: SharedObjects (ActiveX EXE) and Client (Standard EXE). I've also included WSH scripts to register and unregister Sharedobjects which can be used by drag and drop of the EXE into the script in Explorer. These scripts should work on Win2K and XP as well as Vista and later.
To compile and run the demo you must first open the SharedObjects project and Make the EXE. Then drag and drop this EXE onto AxExeReg.vbs
Next open the Client project, and go into the References dialog and select your own new SharedObjects library ("A Sample Shared Objects Server"). Then you should be able to make this too.
Then run 1, 2, 3, etc. copies of Client.exe for testing.
Screenshots
Here are some screenshots showing two instances of Client side-by-side. On load they set the title bar to contain their App.ThreadId so you can see that they're different.
First I added some Items (I'm just using String values as Dictionary items here) on the left.
Then I click List on the right to show that the second copy can see the same data.
Last I typed in another Key and Item value on the left and am ready to add it.
Hopefully this is useful and will get people started, but there is more detail in the VB6 documentation.


Reply With Quote