VBGood网站全文搜索 Google

首页 - 经验之谈 - 如何注册和反注册ActiveX控件
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:12459, 日期:2001-04-11
How to register and un-register ActiveX Controls

This tip describes how ActiveX controls can be registered and unregistered directly from Visual Basic. Every ActiveX control contains two functions that can be called that will instruct the OCX to either register or un-register itself with the system. These functions are DLLRegisterServer and DLLUnregisterServer. The following tip demonstrates how to register and un-register the Microsoft Common Controls OCX, ComCtl32.OCX.


Copy the following code into the declarations section of your projects.

Declare Function RegComCtl32 Lib "ComCtl32.OCX" _
Alias "DllRegisterServer" () As LongDeclare Function UnRegComCtl32 Lib "ComCtl32.OCX" _
Alias "DllUnregisterServer" () As LongConst ERROR_SUCCESS = &H0Code

To register the Microsoft Common Controls, use this code:

If RegComCtl32 = ERROR_SUCCESS Then
    MsgBox "Registration Successful"
    MsgBox "Registration Unsuccessful"
End If

If UnRegComCtl32 = ERROR_SUCCESS Then
    MsgBox "UnRegistration Successful"
    MsgBox "UnRegistration Unsuccessful"
End IfNote: Each DLL function call may take up to 5 seconds.