?
Solved

How to shut down a VB COM server called from VC++ client

Posted on 2004-11-15
3
Medium Priority
?
240 Views
Last Modified: 2010-04-01
What is the proper way to shut down a VB server (and associated forms) from a VC++ client?  

We are writing a VC++ application that is started and monitors/commands hardware, collects/stores data and does some number-crunching.  We are also writing a VB HMI (an ActiveX EXE) that is created (when the user desires a UI) from the VC++ client using the CoCreateInstance command above.  So our VC++ engine is a COM client and our VB HMI is a COM Server.  They communicate through events and properties we've set up on the VB/HMI/Server side, and an event sink on the VC++/Engine/Client side.

In brief:

VB 6.0=GUI=out-of-process COM Server / ActiveX EXE (instantiated by engine)
VC++=engine=standard MFC project and COM client (instantiates the GUI when needed)

Basically we are using the standard interface class module that is created when you use the new app wizard and select "ActiveX EXE", and that creates/loads a few GUI forms that accept user input.  When the interface class terminates (per request by the engine), I have code that closes all those GUI forms and sets the pointers to nothing.

Unfortunately the GUI EXE remains in the process list after this is done.  I can't seem to find the right sequence to kill my GUI dead.

So, what is the proper way to shut down a VB server (and associated forms) from a VC++ client?  Is there something special we have to do from the VC++/client side?  We are relatively new at COM.

(High point value because it is a specific/deep question, and I have a feeling we're going to require a little education plus some code snippets.  Thanks in advance.)
0
Comment
Question by:riceman0
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 750 total points
ID: 12594021
>>I have code that closes all those GUI forms and sets the pointers to nothing.
>>Unfortunately the GUI EXE remains in the process list after this is done

Why don't you call 'ExitProcess()' or (it's VB equivalent) in the server at this point?
0
 
LVL 4

Assisted Solution

by:Glom
Glom earned 750 total points
ID: 12604356
Hi,

Have you tried to send it a windows message to tell your VB App to shutdown ?

Like
PostMessage(yourVBWindowHandle, WM_QUIT, 0L, 0L);
0
 
LVL 4

Expert Comment

by:Glom
ID: 12604406
Tip : You can use FindWindow(..) to retreive your Window Handle
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question