Microsoft KB Archive/247315

= How To Create a CAB File That Installs a COM DLL Using the Visual J++ 6.0 IDE =

Article ID: 247315

Article Last Modified on 6/14/2006

-

APPLIES TO


 * Microsoft Visual J++ 6.0 Standard Edition

-



This article was previously published under Q247315



SUMMARY
This article describes an alternative to creating and signing .cab files through the command line.



Step-by-Step Instructions
NOTE: Although these steps use a DLL that is created in Visual J++ 6.0 to illustrate how to distribute DLLs in .cab files, the DLL could just as easily have been created in another tool.  Create a new dynamic-link library (DLL) file that will be installed using a .cab file as follows:  In Visual J++ 6.0, create a new COM DLL project.  Add the following method to the newly created class: public String test(int count){ String retval=""; for(int i=0;i Because you will need to access this DLL from script, you must make it safe for scripting. To do this, follow the instructions in the following Microsoft Knowledge Base article:

252661 PRB: WFC-Based ActiveX Control Is Not Safe for Scripting

  Package the newly created DLL into a .cab file as follows:  In the Project Explorer, right-click Solution, and then click Add Project.</li> To add a new project to the current solution, click Visual Studio, click Distribution Units, and then click CAB project.</li> In the Project Explorer, right-click the new CAB project, and then click Add Project Outputs.</li> Select the original project, and then click OK.</li> Build the Project.</li></ol> </li> By default, the COM project in step 1 generates a DLL, and the CAB project in step 2 places that DLL into a signed .cab file with of all the proper permissions and versioning information.</li>  Create a new HTML file that begins the installation process when it is accessed.

Create the HTML file in the same directory as the generated .cab file. The following sample assumes that your .cab file is named Cabinet1.cab. Replace the sample ClassID with the ClassID that is listed in the "@com.register" tag within the first block comment in Class1.java: <HTML>

<script language=javascript for=window event=onload>

<BODY> <OBJECT classid=clsid:99999999-9999-9999-9999-999999999999 id=testDLL VIEWASTEXT codeBase="Cabinet1.CAB#version=1,1,1,1"> </OBJECT> You should see a dialog box with the text: "Hello! Hello! Hello! ". </BODY> </HTML> </li></ol>

NOTE: If you include two or more DLLs in the .cab file, only the first DLL downloads and installs as expected. This is a known issue. To work around this problem, manually edit the .osd file (within the generated .cab file), and combine the two NATIVE XML blocks into one large NATIVE block.

<div class="references_section">