Ads Top

Registering a component using VB program

Components are registered and unregistered by calling the procedures DllRegisterServer and DllUnregisterServer exported by the component. This is what regsvr32 does, and you can do the same. If you know the name of the DLL (or OCX) when the program is compiled you can do this with a Declare statement.

Private Declare Function DllRegisterServer Lib "MyControl.dll" () As Long
Result = DllRegisterServer

The return value is zero for success.

There is no easy way of specifying the name or path of the control at run time. To solve this problem you can download a DLL (not ActiveX) written in C which makes the call for you. The download contains a sample VB project, the DLL and the source code of the DLL.

Download sample code here (mirror1) or here (mirror2)

No comments:

Powered by Blogger.