• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 401
  • Last Modified:

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.
0
kkandasa
Asked:
kkandasa
  • 4
  • 3
1 Solution
 
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now