Click here to Skip to main content
15,920,508 members
Home / Discussions / COM
   

COM

 
GeneralRe: Threading issue Pin
kkfromus12-Sep-03 14:40
kkfromus12-Sep-03 14:40 
GeneralThread Id of client app Pin
In-At1-Sep-03 18:30
In-At1-Sep-03 18:30 
GeneralRe: Thread Id of client app Pin
igor19603-Sep-03 10:33
igor19603-Sep-03 10:33 
Generalwhy CoCreateInstance( ... IID_IShellLink, ..) failed Pin
nofeel1-Sep-03 16:41
nofeel1-Sep-03 16:41 
GeneralRe: why CoCreateInstance( ... IID_IShellLink, ..) failed Pin
PengFeidu7-Sep-03 20:08
PengFeidu7-Sep-03 20:08 
GeneralRe: why CoCreateInstance( ... IID_IShellLink, ..) failed Pin
Lim Bio Liong18-Sep-03 8:06
Lim Bio Liong18-Sep-03 8:06 
GeneralRe: why CoCreateInstance( ... IID_IShellLink, ..) failed Pin
Lim Bio Liong19-Sep-03 0:53
Lim Bio Liong19-Sep-03 0:53 
GeneralKeeping COM server active Pin
Gilrock1-Sep-03 14:00
Gilrock1-Sep-03 14:00 
I have an .exe application that communicates to a device through a serial port. The application is in VC++ and is dialog-based to provide a GUI for interfacing to the device. I also needed a COM interface to allow access to the device to be scripted. I wanted to allow multiple scripts to access the device and allow the GUI dialog to be opened or closed at any time while the scripts are running. The problem, unless I'm way off track, is that I need there to be only one instance of the server so that it can route all traffic through the same serial port.

After I initially created the application containing an automation class, the problem was that running a .vbs script would create one instance of the server and running the .exe created a second instance of the server.
Then I found that if I moved the COleTemplateServer::RegisterAll() call in front of the "if (RunEmbedded() || RunAutomated())" line that running a .vbs script would attach to the already running instance of the server, but not the other way around. If I run a script first and then execute the .exe a second instance of the server is started and it cannot talk to the serial port because the first instance has control.

Next I used the SingleInstanceApp class I found on this website and with it I was able to detect that I already had an instance of the server running when launching the .exe and it sends a registered message to the first instance and then terminates. The first instance receives the message and launches the GUI dialog if it is not already active. So with this change I now am guaranteed to only have one instance of the server running at a time but it left me with one problem.

Once I launch the dialog I cannot close it because it terminates the server and basically pulls the rug out from under any script clients that are using the server. I tried intercepting the WM_QUIT message using ProcessMessageFilter and that does work if I run a script first, launch the .exe, and then close the .exe. But if I start the .exe first and then start running any scripts, the server is terminated when I close the dialog.

I know this was a long message but I've been banging my head against the wall to try to solve this and any help would be greatly appreciated.

Gil Jones

GeneralRe: Keeping COM server active Pin
igor19603-Sep-03 10:43
igor19603-Sep-03 10:43 
GeneralRe: Keeping COM server active Pin
Gilrock3-Sep-03 11:20
Gilrock3-Sep-03 11:20 
GeneralRe: Keeping COM server active Pin
igor19603-Sep-03 11:36
igor19603-Sep-03 11:36 
GeneralRe: Keeping COM server active Pin
Gilrock3-Sep-03 11:50
Gilrock3-Sep-03 11:50 
GeneralRe: Keeping COM server active Pin
igor19603-Sep-03 12:01
igor19603-Sep-03 12:01 
GeneralRe: Keeping COM server active Pin
Gilrock3-Sep-03 12:13
Gilrock3-Sep-03 12:13 
GeneralRe: Keeping COM server active Pin
Gilrock3-Sep-03 13:02
Gilrock3-Sep-03 13:02 
GeneralRe: Keeping COM server active Pin
Gilrock4-Sep-03 6:20
Gilrock4-Sep-03 6:20 
GeneralRe: Keeping COM server active Pin
igor19604-Sep-03 6:50
igor19604-Sep-03 6:50 
GeneralReturn Interface Pointer Pin
Daniel Strigl1-Sep-03 4:50
Daniel Strigl1-Sep-03 4:50 
GeneralRe: Return Interface Pointer Pin
valikac1-Sep-03 6:01
valikac1-Sep-03 6:01 
GeneralRe: Return Interface Pointer Pin
Daniel Strigl1-Sep-03 20:03
Daniel Strigl1-Sep-03 20:03 
GeneralRe: Return Interface Pointer Pin
Stefan Pedersen1-Sep-03 10:20
Stefan Pedersen1-Sep-03 10:20 
GeneralRe: Return Interface Pointer Pin
Daniel Strigl1-Sep-03 20:04
Daniel Strigl1-Sep-03 20:04 
GeneralRe: Return Interface Pointer Pin
Lim Bio Liong18-Sep-03 19:28
Lim Bio Liong18-Sep-03 19:28 
GeneralRe: Return Interface Pointer Pin
Lim Bio Liong18-Sep-03 19:34
Lim Bio Liong18-Sep-03 19:34 
GeneralRe: Return Interface Pointer Pin
Daniel Strigl11-Oct-03 2:27
Daniel Strigl11-Oct-03 2:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.