Link to home
Start Free TrialLog in
Avatar of MICS
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.
Avatar of EDDYKT
EDDYKT
Flag of Canada image

use environ("windir") & "\system32"
ASKER CERTIFIED SOLUTION
Avatar of Tommy Kinard
Tommy Kinard
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
use environ("windir") & "\system32"
Avatar of kokoloko
kokoloko

Use the following API:

Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal parDirectory As String, ByVal parSize As Long) As Long
Avatar of MICS

ASKER

opps...

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)