Deactivating ActiveX exe

Hello,

I have coded a console app with MFC
support that activates a vbasic
activeX exe and calls a method on it.
I don't know how to deactivate it,
the program crashes when I do.

Provided below is sample code on
how I activate and call a method on
the object. This works fine.

-------------------
//create object & get dispatch pointer
hrReturnCode = CoCreateInstance (pClsid, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch,(void FAR* FAR*)&gpHandleInfo.lpDispatch );

//get dispatch id for method
hrReturnCode = gpHandleInfo.lpDispatch->GetIDsOfNames
(IID_NULL,
&szStartLine, 1, LOCALE_SYSTEM_DEFAULT, &dispid);

//invoke method
hrReturnCode = gpHandleInfo.lpDispatch->Invoke (dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
--------------

After I invoke the Active X exe, I can
see it in the NT Task Manager.

How do I then deactivate the object I
created ? Deleting the IDispatch pointer seems to crash the program.

If I deactivate the object, the
ActiveX exe should also not appear
in the task manager.

Any sample code would be of great help.


Thanks.
kkandasaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chensuCommented:
//create object & get dispatch pointer
hrReturnCode = CoCreateInstance (pClsid, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch,(void FAR* FAR*)&gpHandleInfo.lpDispatch );

if (SUCCEEDED(hrReturnCode))
{
//get dispatch id for method
hrReturnCode = gpHandleInfo.lpDispatch->GetIDsOfNames
(IID_NULL,
&szStartLine, 1, LOCALE_SYSTEM_DEFAULT, &dispid);

//invoke method
hrReturnCode = gpHandleInfo.lpDispatch->Invoke (dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);

// Release the interface
gpHandleInfo.lpDispatch->Release();
}
0
kkandasaAuthor Commented:
I tried this. But the ActiveX exe is
still running under the WinNT task
manager.
What should I do to stop it from running ?
0
chensuCommented:
It is up to the server (EXE) how to close itself. If the server provides a quit method, you can call it. Otherwise, it will remain open.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

kkandasaAuthor Commented:
How would a vb ActiveX app close itself
via a method. Would the invoke method
execute gracefully ?
0
chensuCommented:
The server (EXE) can implement such a method just like other methods. You may look into some server samples.
0
kkandasaAuthor Commented:
I will look into this. Please reply
so I can award you the points.

Thanks.
0
chensuCommented:
Thank you.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.