AllAPI Network - The KPD-Team

 
Allapi Network
 API-Guide
 ApiViewer

 API List

 
API Resources
 Tips & Tricks
 VB Tutorials
 Error Lookup
 
Misc Stuff
 VB examples
 VB Tools
 VB Links
 Top Downloads
 
This Site
 Search Engine
 Contact Form
 

Donate to AllAPI.net

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.

Declarations

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

Declare Function RegComCtl32 Lib "ComCtl32.OCX" _
Alias "DllRegisterServer" () As Long

Declare Function UnRegComCtl32 Lib "ComCtl32.OCX" _
Alias "DllUnregisterServer" () As Long

Const ERROR_SUCCESS = &H0

Code

To register the Microsoft Common Controls, use this code:

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

If UnRegComCtl32 = ERROR_SUCCESS Then
    MsgBox "UnRegistration Successful"
Else
    MsgBox "UnRegistration Unsuccessful"
End If      

Note: Each DLL function call may take up to 5 seconds.

 

 


Copyright © 1998-2007, The Mentalis.org Team - Privacy statement
Did you find a bug on this page? Tell us!
This site is located at http://allapi.mentalis.org/