crazyman
asked on
Register OCX
Does anyone know how to register an OCX in code and not just shelling regserv32.exe with the file.
I would like to know if there is any api to do this.
Thanks.
I would like to know if there is any api to do this.
Thanks.
If you are doing this for an EXE your setup program will automatically register your controls and libraries.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Since every ActiveX ocx/dll file has to provide a 'DllRegisterServer' and 'DllUnregisterServer' function, you can (un)register them as shown below (example is for Common Controls OCX, change the 'Lib' part of the declarations to your ocx filename, and give the functions a better name if you like). Keep in mind that this is the same thing as what regsvr32 does, so this takes about the same time as using regsvr32, which can be rather slow.
'------------------------- ----------
Private Declare Function RegComCtl32 Lib "ComCtl32.OCX" _
Alias "DllRegisterServer" () As Long
Private Declare Function UnRegComCtl32
Lib "ComCtl32.OCX" _
Alias "DllUnregisterServer" () As Long
Const ERROR_SUCCESS = &H0
Private Sub Form_Load()
'Register
If RegComCtl32 = ERROR_SUCCESS Then
MsgBox "Registration Successful"
Else
MsgBox "Registration Unsuccessful"
End If
'Unregister
If UnRegComCtl32 = ERROR_SUCCESS Then
MsgBox "UnRegistration Successful"
Else
MsgBox "UnRegistration Unsuccessful"
End If
End Sub
'------------------------- ----------
Cheers,
Jeremy
'-------------------------
Private Declare Function RegComCtl32 Lib "ComCtl32.OCX" _
Alias "DllRegisterServer" () As Long
Private Declare Function UnRegComCtl32
Lib "ComCtl32.OCX" _
Alias "DllUnregisterServer" () As Long
Const ERROR_SUCCESS = &H0
Private Sub Form_Load()
'Register
If RegComCtl32 = ERROR_SUCCESS Then
MsgBox "Registration Successful"
Else
MsgBox "Registration Unsuccessful"
End If
'Unregister
If UnRegComCtl32 = ERROR_SUCCESS Then
MsgBox "UnRegistration Successful"
Else
MsgBox "UnRegistration Unsuccessful"
End If
End Sub
'-------------------------
Cheers,
Jeremy
D*mn, beaten by the clock again :-(