Board index » cppbuilder » Register ActiveX

Register ActiveX


2006-11-15 03:15:38 AM
cppbuilder72
Hi,
How can I register an ActiveX without regsvr32.exe but with C++ source ?
Thanks
 
 

Re:Register ActiveX

"Laurent ESTIVAL" < XXXX@XXXXX.COM >wrote in message
Quote
How can I register an ActiveX without regsvr32.exe but with C++ source ?
You would have to dynamically load the DLL/OCX via the LoadLibrary()
function, and then use the GetProcAddress() function to get a pointer to the
library's exported DllRegisterServer() function.
Why wouldn't you want to use regsvr32, though? That is what you should be
using. It is just as easy to launch regsvr32 in code as it is to register
the library manually. Besides, regsvr32 does exactly the same thing that I
mentioned above, so there is no need to do it manually in your own code.
Gambit
 

Re:Register ActiveX

Hello Laurent,
Is the ActiveX a local or inproc server? If it's the former, you can run the
server with the /regserver option. However, in the case of an inproc server,
you'll need some tool that loads the library and invokes the appropriate
entry point (DllRegisterServer / DllUnregisterServer). REGSVR32.EXE is one
such tool but you can also use Borland's tregsvr.exe or others. Optionally,
you can write a utility that uses ::LoadLibrary and ::GetProcAddress on the
server to retrieve the entrypoint and invokes it.
Cheers,
Bruneau.
 

{smallsort}

Re:Register ActiveX

Quote
How can I register an ActiveX without regsvr32.exe but with C++ source ?
If you have a .TLB file for you server, you can do the following:
void __fastcall RegisterTypeLibrary(const AnsiString& cTLBName)
{
TComInterface<ITypeLib>pTypeLib;
OLECHECK(LoadTypeLibEx(WideString(cTLBName), REGKIND_REGISTER,
&pTypeLib));
}
Mark