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
LVL 1
khaledcAsked:
Who is Participating?
 
stevesuConnect With a Mentor Commented:
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.

Glad this helped, Khaledc.
0
 
khaledcAuthor Commented:
Edited text of question
0
 
NorbertCommented:
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
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
khaledcAuthor Commented:
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.
0
 
NorbertCommented:
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 ...

0
 
khaledcAuthor Commented:
Forgive my ignorancy, but where do I add the above codes.
0
 
khaledcAuthor Commented:
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....
0
 
stevesuCommented:
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.
0
 
khaledcAuthor Commented:
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.
0
 
NorbertCommented:
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
0
 
khaledcAuthor Commented:
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.

 
0
 
NorbertCommented:
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 ?

0
 
stevesuCommented:
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.
0
 
khaledcAuthor Commented:
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.

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.

All Courses

From novice to tech pro — start learning today.