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.
MICSAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

EDDYKTCommented:
use environ("windir") & "\system32"
0
Tommy KinardCommented:
Refer to GetWindowsSysDir in the setup program that comes with VB. It is located in the C:\Program Files\Microsoft Visual Studio\VB98\Wizards\PDWizard\ directory. This is VB 6. The code will retrieve the system directory for versions of windows.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EDDYKTCommented:
use environ("windir") & "\system32"
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

kokolokoCommented:
Use the following API:

Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal parDirectory As String, ByVal parSize As Long) As Long
0
MICSAuthor Commented:
opps...

That didn't answer it fully.

that gives me the system folder path.

but How do i register it?
0
Tommy KinardCommented:
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)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.