Detection of OCX File
-
Hi all, I have a problem. I have written a program that uses a commercial activeX component. I need to distribute this program on other machines and in order to do that I need to also distribute the commercial .ocx file and register it. This is no problem. What I want to do is for my program to send a popup error message if the ocx file is not installed/registered with windows. Currently it just crashes. X| thanks ---
-
Hi all, I have a problem. I have written a program that uses a commercial activeX component. I need to distribute this program on other machines and in order to do that I need to also distribute the commercial .ocx file and register it. This is no problem. What I want to do is for my program to send a popup error message if the ocx file is not installed/registered with windows. Currently it just crashes. X| thanks ---
-
bryce wrote: why not do a cocreateinstance and catch any errors/exceptions Ok How do I do that???? ---
You can create an object of your control using COM techniques:
HRESULT hr = CoCreateInstance( CLSID_YourControlID, NULL, CLSCTX_INPROC_SERVER, IID_IYourControlInterface, (void**)&pInterfaceName); if (FAILED(hr)) { MessageBox( NULL, ”Failed to create instance of “ “Your Control”, ”Error!”, MB_ICONERROR); }
For that you need to know the basics of COM. MSDN is a good source of learning so read about the basics of COM. All the best!! ;) @!$h@ -
It crashes at
TRY { CModelessMain::Create(...) } CATCH_ALL { ... } END_CATCH_ALL
Never tried CoCreateInstance - will give it a go ---Create()
method returns aBOOL
, If you have specified appropriate parameters, the method does not crash. So better check for your parameters. In case the control is not registered,Create
returns aFALSE
. In this case, give user the message that control is not registered or installed. @!$h@