Hi
How to register a component in vb? To find out if my machine has some component or not?
Printable View
Hi
How to register a component in vb? To find out if my machine has some component or not?
WIth the Help of Revser32.exe
Write Following Command in
Start Menu -->Run
e.g. Regsver32 C:TestMyOcx.Ocx
How to: Register a Component for COM Interop
The Register for COM interop project property specifies whether your managed application will expose a COM object (a COM-callable wrapper) that allows a COM object to interact with your managed application.
The Register for COM interop property is set on the Compile page of the Visual Basic Project Designer or the Build page of the C# Project Designer. This property is not available for Windows Application or Console Application projects.
To register a component for COM interop
1. With a project selected in Solution Explorer, on the Project menu, click Properties.
2. Click the Compile tab in Visual Basic. Click the Build tab in C#.
3. Select the Register for COM interop check box.
This code sample shows how to Register and Unregister ActiveX Components directly through VB Code - useful if you write your own Setup/Installation routines for projects.
Code:public Function RegisterComponent(byval FileName$, _
byval RegFunction as REGISTER_FUNCTIONS) as STATUS
'************************************************************
'Author: Vasudevan S
'Helena, MT
'Function: RegisterComponent
'Purpose: Registers/Unregisters any ActiveX DLL/EXE/OCX
'component
'Entry Points in ActiveX DLL/EXE/OCX are DllRegisterServer
'and DllUnRegisterServer
'input: FileName: Any valid file with complete path
'RegFunction: Enumerated Type(DllRegisterServer,
'DllUnregisterServer)
'Returns: Returns the status of the call in a enumerated type
'Comments: The utility REGSVR32.EXE need not be used to
'register/unregister ActiveXcomponents.
'This code can be embedded inside any application
' that needs to register/unregister any ActiveX
'component from within the code base
'SAMPLE FORM is INCLUDED
'WORKS IN VB5.0/6.0
'HOW to CALL:
'-----------
'Dim mEnum as STATUS
'
'to REGISTER A COMPONENT USE
'mEnum = RegisterComponent("C:\windows\system\filename.dll",
'DllRegisterServer) 'to Register
'
'If mEnum = [File Could Not Be Loaded Into Memory Space] then
' MsgBox "Your Message Here", vbExclamation
'ElseIf mEnum = [Not A Valid ActiveX Component] then
' MsgBox "Your Message Here", vbExclamation
'ElseIf mEnum = [ActiveX Component Registration Failed] then
' MsgBox "Your Message Here", vbExclamation
'ElseIf mEnum = [ActiveX Component Registered Successfully] _
'then
' MsgBox "Your Message Here", vbExclamation
'End If
'
'to UNREGISTER A COMPONENT USE
'mEnum = RegisterComponent("C:\windows\system\filename.dll", _
'DllUnRegisterServer) 'to UnRegister
'
'If mEnum = [File Could Not Be Loaded Into Memory Space] then
' MsgBox "Your Message Here", vbExclamation
'ElseIf mEnum = [Not A Valid ActiveX Component] then
' MsgBox "Your Message Here", vbExclamation
'ElseIf mEnum = [ActiveX Component Registration Failed] then
' MsgBox "Your Message Here", vbExclamation
'ElseIf mEnum = [ActiveX Component UnRegistered Successfully] _
'then
' MsgBox "Your Message Here", vbExclamation
'End If
'************************************************************