Microsoft KB Archive/247315: Difference between revisions
m (Text replacement - "<" to "<") |
m (Text replacement - ">" to ">") |
||
Line 87: | Line 87: | ||
<br /> | <br /> | ||
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:</p> | 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:</p> | ||
<pre class="codesample"><HTML | <pre class="codesample"><HTML> | ||
<script language=javascript for=window event=onload | <script language=javascript for=window event=onload> | ||
<!-- | <!-- | ||
alert(testDLL.test(3)); | alert(testDLL.test(3)); | ||
//-- | //--> | ||
</script | </script> | ||
<BODY | <BODY> | ||
<OBJECT classid=clsid:99999999-9999-9999-9999-999999999999 id=testDLL VIEWASTEXT | <OBJECT classid=clsid:99999999-9999-9999-9999-999999999999 id=testDLL VIEWASTEXT | ||
codeBase="Cabinet1.CAB#version=1,1,1,1" | codeBase="Cabinet1.CAB#version=1,1,1,1"> | ||
</OBJECT | </OBJECT> | ||
You should see a dialog box with the text: "Hello! Hello! Hello! ". | You should see a dialog box with the text: "Hello! Hello! Hello! ". | ||
</BODY | </BODY> | ||
</HTML | </HTML> | ||
</pre></li></ol> | </pre></li></ol> | ||
Revision as of 09:44, 21 July 2020
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.
- 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<count;i++){ retval+="Hello! "; } return retval; }
- 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.
- To add a new project to the current solution, click Visual Studio, click Distribution Units, and then click CAB project.
- In the Project Explorer, right-click the new CAB project, and then click Add Project Outputs.
- Select the original project, and then click OK.
- Build the Project.
- 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.
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