Solved

Exporting an Active X Control

Posted on 1998-06-17
14
212 Views
Last Modified: 2013-11-25
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
0
Comment
Question by:khaledc
  • 7
  • 4
  • 3
14 Comments
 
LVL 1

Author Comment

by:khaledc
ID: 1166112
Edited text of question
0
 
LVL 3

Expert Comment

by:Norbert
ID: 1166113
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
 
LVL 1

Author Comment

by:khaledc
ID: 1166114
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 3

Expert Comment

by:Norbert
ID: 1166115
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
 
LVL 1

Author Comment

by:khaledc
ID: 1166116
Forgive my ignorancy, but where do I add the above codes.
0
 
LVL 1

Author Comment

by:khaledc
ID: 1166117
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
 

Expert Comment

by:stevesu
ID: 1166118
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
 
LVL 1

Author Comment

by:khaledc
ID: 1166119
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
 
LVL 3

Expert Comment

by:Norbert
ID: 1166120
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
 
LVL 1

Author Comment

by:khaledc
ID: 1166121
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
 
LVL 3

Expert Comment

by:Norbert
ID: 1166122
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
 

Expert Comment

by:stevesu
ID: 1166123
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
 
LVL 1

Author Comment

by:khaledc
ID: 1166124
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
 

Accepted Solution

by:
stevesu earned 100 total points
ID: 1166125
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

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question