MICS
asked on
Register OCX within VB
Ok SO i need to register an OCX in Visual basic. The fine is called "MYOCX.ocx" its located in the System Folder of the computer. my problem is that the system folder can change. For example in Win2000 C:\Winnt\System32, and in WinXP C:\windows\system32.
any ideas how i can do it.
any ideas how i can do it.
use environ("windir") & "\system32"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
use environ("windir") & "\system32"
Use the following API:
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal parDirectory As String, ByVal parSize As Long) As Long
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal parDirectory As String, ByVal parSize As Long) As Long
ASKER
opps...
That didn't answer it fully.
that gives me the system folder path.
but How do i register it?
That didn't answer it fully.
that gives me the system folder path.
but How do i register it?
Once you have the system directory, use the shell command to call regsvr32.exe using the command line switches /s {for being silent and the user doesnt know} /i {to install and pass command line to the dll} and the dll name.
so an example would be - the backslash is not required if you have already picked it up-
RetVal = Shell(WinSysDir & "\" & "regsvr32 /s /i " & "myocx.dll", vbHide)
so an example would be - the backslash is not required if you have already picked it up-
RetVal = Shell(WinSysDir & "\" & "regsvr32 /s /i " & "myocx.dll", vbHide)