Link to home
Start Free TrialLog in
Avatar of khaledc
khaledc

asked on

Exporting an Active X Control

I developed an ActiveX Control using VC++ version 5, called MyactiveX.OCX (for example) . I used this control in a Visual Basic application. Everything was working OK until I decided to install my VB application on another computer. I used the Application Setup Wizard in VB to make distribution disks, everything went OK. Then, I tried to install this software on another comupter and the following message was given by the Install Shield:
 ( An error occur while registering the file 'C:\Windows\Sysytem\MyactiveX.OCX')
I appreciate any feedback on this problem.
Thankyou in advance
Avatar of khaledc
khaledc

ASKER

Edited text of question
probably you ocx needs a dll that is not installed on the other machine
you can try dumpbin (shipped with VC) to have a look which dll's your ocx needs
you have to run it in a Dos box
example:
[path\]dumpbin /imports [sourcepath\]Myactivex.ocx >MyactiveXImports.txt
now you gets a list of all dlls that your ocx imports directly
take the list go to the other machine and look if some dll is missing
i
Avatar of khaledc

ASKER

All DLL needed for the OCX are already installed. In my opinion, I need (somehow) to register in the windows registry (coming from the fact that the message comes up once the Install Field is updating the registry. I am afraid that did not answer the question.
did you check that all DLL's are installed or do you belive that only ?
for example you use VC++ 5 are you also using MFC ?
if so are you using MFC DLL version or static link ?
if you use DLL version are the right MFC DLL's installed ?
install shield trys to register your OCX and fails.
BTW
Registering an OCX is very simple:
an OCX is only a DLL
here some code that registers an ocx
text outputs are snipped
so only she basics are here
void CNregsDlg::RegisterLib(LPCTSTR LibName)
{
      HINSTANCE hInst;
      FARPROC proc;
      hInst=LoadLibrary(LibName);
      if(hInst==NULL)
      {
                        //Error Library not found
                       return;

      }
      proc=GetProcAddress(hInst, "DllRegisterServer");
      if(proc==NULL)
      {
                      //error procedure not found
                     return;
      }

      proc();// now the ocx is registered
      return;
}

thats the only thing that happens when registering an ocx
therefore check DLL'S needed from OCX and DLL'S needed from DLL'S from OCX ...

Avatar of khaledc

ASKER

Forgive my ignorancy, but where do I add the above codes.
Avatar of khaledc

ASKER

I forgot to add that I am using VC++5, MFC in a shared DLL.
Also, the Install Shield message is as followed:
*** ERROR: LoadLibrary() Failed while registering file 'C:\Windows\System\MyActiveX.OCX'
*** DURING THIS ACTION: DllSelfRegister: "C:\Windows\System\MyActiveX.OCX"
*** ERROR: An error occured while registering the file 'C:\Windows\System\MyActiveX.OCX'.
and so on....
A registration program will attempt to do a LoadLibrary() of the ActiveX/DLL and call DLLRegister() on it. If LoadLibrary() fails and GetLastError() returns 1157, this means that a DLL needed by the control cannot be found. Use DUMPBIN as described above and keep in mind that the dependant dll's must already be installed when your ocx attempts registration. DLL's will only be found if they are in the current directory, in the windows system directory, or in a directory in your path. One of these dlls could also be trying to load another dll and cannot find it. The following files should be distributed with your ocx along with any other dll's you link to:

mfc42.dll
msvcrt.dll
olepro32.dll

Hope this help.
Avatar of khaledc

ASKER

stevesu,
I tried what you have suggested, it did not make any difference (I did include the three files in the App. Wizard).
One more comment I may add is: if I install VC++5, then I compile MyActiveX.OCX on the same machine, everything would work properly. Therefore, I think that I need to register this OCX somehow. I have no experience whatsoever with registering OCX.
if it installs and register perfectly after installing VC++ 5.0 there must be a missing DLL that is installed by VC that is the reason why it works with VC 5.0 installed not something magic register code.
A shot in the dark because you use VC 5.0:
VC 5.0 uses a newer version of MFC42.DLL.
Registering an OCX is nothing more than I described above.
Perhaps you should wrote your own register program using the skeleton above. Then you you can check better what errors occures
Avatar of khaledc

ASKER

Dear whoever get this one first,
I followed your advise in Using Dumpbin.exe.
I know which DLL files are needed for MyActiveX, One of them is mfc42D.DLL.
I got rid of the message that displays error in registering MyActiveX. However, same error message appears for the file mfc42D.DLL.
I used Dumpbin.exe to find what DLL files are needed with mfc42D.DLL, they are:
MSVCRTD.DLL
KERNEL32.DLL
GDI32.DLL
USER32.DLL

I included all these files in my project Setup Wizard, but unlike MyActiveX.OCX doing this did not solve the problem.

Then, I used regsvr32.exe to manually register the program, it returns that GetLastError returns 0x000485 = 1157.

I am really puzzled here, help please.

 
an other thing each OCX needs are the OLE libraries - not sure which all OLE32.DLL OLEAUT.DLL OLEPRO.DLL ? this DLL's are also updated by VC5.0. Did you check the versions of these DLL'S ?

The reason you need mfc42d.dll and the others is because your doing a dubug build on your ocx. Try doing a release build and all you should need are the files I mentioned and any other dll's you might be using i.e if your using dao you'll need those dlls. You keep getting an 1157 message and that means your missing a dll. Keep searching.
Avatar of khaledc

ASKER

stevesu,
You were right, I compiled a release version of the program and installation is working OK
Send your comment as an Answer in order for me to credit you.

ASKER CERTIFIED SOLUTION
Avatar of stevesu
stevesu

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