• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6147
  • Last Modified:

Cannot register OCX using Regsvr32

In a command prompt I am running this line:  

C:\Windows\System32> regsvr32 C:\Windows\System32\ImageViewer2.OCX

I get the following error:

RegSvr32
The Module "C:\Windows\System32\ImageViewer2.OCX" failed to load.
Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files.  
The Specified module could not be found.  

This is a new 64 bit, Win7 laptop.  The OCX file has been transferred from a 64 bit Win 7 system it succesfully installed on.  I am logged in as Administrator and running cmd as Administrator.  I have a VFP app that relies on this OCX to run.
0
woodwyn
Asked:
woodwyn
2 Solutions
 
CSI-Windows_comCommented:
You are probably attempting to register it with the 64-bit version.

You need to execute: c:\windows\syswow64\regsvr32 C:\Windows\System32\ImageViewer2.OCX

Another way to do it, which may be relevant to scripting, is to elevate 32-bit CMD.exe which is in c:\windows\sysWOW64\cmd.exe and THEN use your previous command line.

Since the CMD.EXE is 32-bit, what appears to be "C:\windows\system32" is actually being redirected to "C:\windows\syswow64"
0
 
CaptainCyrilFounder, Software Engineer, Data ScientistCommented:
The user trying to register does not have enough access privileges.

Let me tell you an example. I have a software that exports charts to PowerPoint. If the software is launched via QuickLaunch or StartMenu, the software won't be able to communicate with PowerPoint. It is only able to communicate with it when launched via CREATEOBJECT from the software itself. This is because of User Access Control by Vista and 7.

You should launch the Command Prompt as admin and try that.
0
 
pcelbaCommented:
And if it is no 32/64 problem then the most probable reason is some missing DLL which is necessary for the OCX control.

Try Dependency Walker software.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Olaf DoschkeSoftware DeveloperCommented:
As it's a 64bit system the first error is to put a 32 bit OCX into the system32 folder, this has to go into SysWoW64.

But if the OCX is 64bit, it goes ito system32, and then you have no chance to use it from FoxPro.

Bye, Olaf.


Edit:

It's easily mistaken: system32 is named that way for "downward compatibility" for new 64bit software, which indeed was a bad idea. New software doesn't need downward compatibility, old software does.

SysWoW64 is short for Subsystem Windows 32bit on Windows 64bit, naming it SysW32onW64 would have been better, perhaps.

http://en.wikipedia.org/wiki/WoW64

The downward compatibility for 32 bit software is, that 32bit processes accessing system32 are redirected to SysWow64, but if you manually put an OCX into system32 that is not redirected, of course.

Besides that UAC is another hurdle to register something manually. Even if you invoke the correct regsvr32 as admin, the regsvr process does not run with elevated rights and that makes it write registry entries into virtualised registry and report success, though it has not created the registry entries really needed. Running a cmd window as admin and executing regsvr32 from there, as CaptainCyril suggested, helps to overcome this.
0
 
woodwynAuthor Commented:
Does this make sense:  I could register the OCX in the SysWOW64 folder using the SysWOW64\regsvr32, but when done the VFP app would still not run correctly.   I was able to register the OCX in SysWOW64 using System32\regsver, but still no luck with the app.  Next I successfully registered the OCX in the System32 folder using SysWOW64\regsvr32, but still the app wouldn't run.  Lastly, I successfully registered the OCX in the System32 folder using System32\regsvr32 and the app worked!  

I can't guarentee I am reporting the steps taken with 100% accuracy, but I think I am.
0
 
CSI-Windows_comCommented:
The answer depends on whether your command prompt was 32 or 64 bit.

FYI - System32 redirection is based on the bitness of the module (EXE /DLL), not the location of the module.
0
 
Olaf DoschkeSoftware DeveloperCommented:
From your report you registered the OCX in any location with any regsvr32 version. I said, you will never get a fail reported, as writing to the registry also is done anyway, sometimes with redirection.

What CIS-Windows_com says also makes sense, as for the 32bit version of the command window the same redirection towords SysWow64 is done.

So you could eg remove or rename the OCX file from SysWow64 and see, if it's not used by foxpro, I would be surprised.

Bye, Olaf.
0
 
CSI-Windows_comCommented:
I see that I didn't address this statement

"Next I successfully registered the OCX in the System32 folder using SysWOW64\regsvr32, but still the app wouldn't run."

That is because when you use sysWOW64\regsvr32.exe COM registration correctly goes to the 32-bit location in HKLM\Software\Wow6432Node\Classes\CLSID\<COMGUID>\InProcServer32\(default) which will be "C:\windows\system32\ImageViewer32.ocx"

The 32-bit EXE then also correctly reads "C:\windows\system32\ImageViewer32.ocx" from that same registry key.

But when the 32-bit EXE asks Windows to load the OCX from that location, system32 folder redirection picks up the reference and translates it to be "C:\windows\SysWOW64\ImageViewer32.ocx".

Since the file is not actually located there, the load fails.

If you put procmon on it you can verify the above.

Also, as an aside, if you use the "Start" "Run" box (it's no longer a separate "Run" box) to do the command "regsrv32.exe C:\windows\system32\ImageViewer32.ocx" you are automatically attempting to use the 64-bit version of regsrv32.exe because you are running from 64-bit Explorer.exe which picks up regsrv32.exe from the windows path in the actual C:\windows\system32 folder.
0
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.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now