Microsoft KB Archive/247315

From BetaArchive Wiki
Knowledge Base


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.

MORE INFORMATION

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.

  1. Create a new dynamic-link library (DLL) file that will be installed using a .cab file as follows:
    1. In Visual J++ 6.0, create a new COM DLL project.
    2. Add the following method to the newly created class:

      public String test(int count){
         String retval="";
         for(int i=0;i<count;i++){
            retval+="Hello! ";
         }
      
         return retval;
      }
                              
    3. 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

  2. Package the newly created DLL into a .cab file as follows:
    1. In the Project Explorer, right-click Solution, and then click Add Project.
    2. To add a new project to the current solution, click Visual Studio, click Distribution Units, and then click CAB project.
    3. In the Project Explorer, right-click the new CAB project, and then click Add Project Outputs.
    4. Select the original project, and then click OK.
    5. Build the Project.
  3. 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.
  4. 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>
       <!--
          alert(testDLL.test(3));
       //-->
       </script> 
    
    <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>
                        

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.

REFERENCES

For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:

Keywords: kbcab kbcode kbdownload kbhowto kbjava kbsecurity KB247315