Link to home
Start Free TrialLog in
Avatar of stev75

asked on

loading an ActiveX without registering

I like to use an already accepted solution by jkr. This describes how to load ActiveX without registering.

(Related Solution:
Loading ActiveX without registry)

Normally, when using COM, you would declare an interface in idl and let the compiler create the REFIID to the interface pointer.

Now things look different at my configuration:

I have a project, which I want to modify, to use ActiveX without registering. This project (mfc) has activeX controls as dialog controls in the resources.
The dialog resource is viewable in visualstudio, when you register the control by regsvr32. Otherwise not.
So I removed the ocx dialog controls. Now want to put them in again at runtime. I don't know how to find out the necessary RIID

So in the solution mentioned, I need to find out what to pass for these parameters:  

  REFIID riid,         //Reference to the identifier of the interface ? I have no COM interface, but a header file

  LPVOID * ppv         //that should be a ptrptr to my dialog (OCX) control (?)

Thanks jkr, and all other experts, for some more info on this topic!!
Avatar of jkr
Flag of Germany image

So, you basically want to access the resource in the DLL and no COM object? In that case, 'LoadLibrary()'/'LoadResource()' should work...
Avatar of stev75


ah, i guess i have to call LoadLibrary("my.ocx") and then Create the control using CWnd::CreateControl() ?
btw, does CWnd::CreateControl() have an influence on Wind OS users rights ? The point of it all is, that every user, also non-administrators, should use the software that uses the activeX functions.
Err, 'CreateControl()' requires a registered object, so that is not the way to go. But, what about temporarily registering your module? See e.g. ("INFO: How Regsvr32.exe Registers and Unregisters COM DLLs")
Avatar of stev75


ok, if there's no other way, i need to do it. But I'm still looking for a workaround for regsvr32 or DllRegisterServer().
CreateControl() function may be needed for OCX controls, but what about using createwindow() and "connect" to the library handle ?
The error that CreateControl returns is 126 ERROR_MOD_NOT_FOUND. On the other hand i have a library handle returned by loadlibrary("my.ocx").
Is it worth trying to set it as the "missing module" from CreateControl ? What do you think ?
An ActiveX control requires a complex framework to communicate with the app that hosts it, so I think that you would be better off going the route to register it. A library handle is something completely different, it basically represents the base load address of that DLL in your process' memory - nothing else.
Avatar of stev75


ah, OK! Then can you leave a comment on this solution>
 Loading ActiveX without registry
 Now it sounds to me that it isn't working either. How does your previous comment  go along with the posted solution ?
Sorry that i don't see the difference. Can you explain ?
Avatar of stev75

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial