Ok, I've got my hands dirty and I'm back with a few questions...
First, thanks James for your Plugin tutorial and whoever wrote MachRemote.
I've developed an application in C# (VS2005) and have been tasked with making it automate Mach3.
What I've done is created a DLL which exports many of the functions of the Mach3.exe Object Model. I used James' Plugin Tutorial as a reference to get started. I then imported these functions into C# and wrapped them with a C# class (which handles connection, exceptions, etc).
This isn't a plugin. I'm not doing anything with dialogs. I'm just setting DRO's, pushing buttons, etc.
So far it is working well except for when I shutdown my app and restart it. After the first time I run, future runs of my app fail to connect to Mach3. If I shutdown Mach3 and restart it, everything is fine (until I shutdown my app and restart it).
I've added some debug code and discovered subsequent runs are failing with a result code (HRESULT) of 1 from GetActiveObject(clsid,NULL,&lpUnk) (see Mach3ObjectModelStartup() in Plugin Tutorial; page 73/92 in V01).
So I started by looking at the shutdown code where I detach from Mach3. In the plugin tutorial, it appears to only be calling "CoUninitialize();" (see Mach3ObjectModelShutdown(VOID); page 74/92 in V01).
However, in MachRemote, I find this code in CMachRemoteDlg::OnBnClickedDisconnect():
scripter.DetachDispatch(); //detach the scripter object
//mach4.ShutDown(); //then shutdown MAch3's interface..
With only the CoUninitialize() call in Plugin Tutorial, Mach 3 would complain on exit with an Art Code of 9991. After I added the scripter.DetachDispatch(), this complaint went away (mostly at least). If I add the "mach4.ShutDown()", this creates an additional error.
Any insights on what I'm missing?
Why doesn't the Plugin Tutorial call scripter.DetachDispatch()? (oversight? am I missing something?)
Why is mach4.ShutDown() commented out in MachRemote?
Any insights appreciated,
Dave