Microsoft KB Archive/185373

= How To Download a Text File Using Internet Explorer Component Download =

Article ID: 185373

Article Last Modified on 5/11/2006

-

APPLIES TO


 * Microsoft Internet Explorer 3.0
 * Microsoft Internet Explorer 3.01
 * Microsoft Internet Explorer 3.02
 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q185373



SUMMARY
A text file can be downloaded in connection with an ActiveX control or by itself using the Microsoft Internet Explorer component download facility.



MORE INFORMATION
Downloading a text file using the component download facility requires a unique Class ID (GUID) that can be a Class ID associated with a dummy ActiveX control or a dummy GUID generated specifically for the purpose of downloading a text file by itself.

Downloading a text file in association with a dummy ActiveX control (a control whose only purpose is to provide a versioning mechanism for downloading a text file) follows the same principles as downloading a Readme.txt file along with any functional ActiveX control.

When using a dummy ActiveX control, the control would:
 * Have no user interface and the  tag width and height attributes set to zero.
 * Export no methods or properties and accept no initialization parameters.
 * Be built according to requirements for successful Internet component download.

Note that an ATL-based ActiveX control requires less download overhead than either a Visual Basic (VB) or an MFC-based ActiveX control.

To create the files necessary for downloading a text file with an ActiveX control are listed in the following steps:   Add entries to the .inf file generated by the VB Setup Wizard or created by hand for ATL and MFC ActiveX controls, or incorporated into the .inf using a third party download setup utility.

In the [Add.Code] section of the .inf file, include the following at the bottom of the list of entries: [Add.Code] ... (other files) Myfile.txt=Myfile.txt NOTE: Myfile.txt is the name of the text file you want to download.

Add the following section to the end of the .inf file: [Myfile.txt] file=thiscab FileVersion= DestDir=10 RegisterServer=no The DestDir=10 entry causes the text file to be downloaded to the main Windows directory (Windows 95 and Windows NT). This is necessary so that the file is visible in the file explorer window. Otherwise, if DestDir= is used (no value after the "="), and Internet Explorer 4.0 or later is installed, the text file will not be visible to users in the Downloaded Program Files directory except when viewed in a DOS command window.  Incorporate the .inf file into a cabinet (.cab) file using Makecab.exe (available in the VB/SetupKit/KitFil32 directory), Cabarc.exe (available in the Cabinet (CAB) SDK), or a third party download setup utility. Sign the CAB file using the code signing tools provided in either the ActiveX SDK or the Internet Client SDK. Insert an  tag for the ActiveX control into an HTML page in the normal manner. The file Myfile.txt would then be downloaded each time a new version of the ActiveX control was downloaded.

In the alternate scenario, a text file without an associated ActiveX Control, the text file is downloaded each time the page is refreshed since there is no version information to control the download process.

To create the files necessary for downloading a text file each time page is refreshed:   Create an .inf file (Mytext.inf) similar to the following: ; INF file for text file download

[Add.Code] Mytext.txt=Mytext.txt

[Mytext.txt] file=thiscab FileVersion= DestDir=10 RegisterServer=no Myfile.txt is the name of the text file you want to download. </li>  Place the text file and .inf file in a CAB file using Cabarc.exe (available in the Cabinet (CAB) SDK) as follows: cabarc n mytext.cab mytext.inf mytext.txt Use the appropriate names that you chose for your .inf and text files, choosing a relevant name for the .cab file. </li> Sign the CAB file using the code signing tools provided in either the ActiveX SDK or the Internet Client SDK.</li> Use the Guidgen.exe file to generate a dummy GUID for use in the HTML file <OBJECT> tag. Guidgen.exe is available with Visual Studio 97 in the \DevStudio\VC\Bin folder, or as source code that can be compiled and run.</li>  Create an <OBJECT> tag reference in HTML similar to the one in the following sample: <HTML> <HEAD> <TITLE>Text file download sample </HEAD> <BODY BGCOLOR="#FFFFFF"> Before text cab object--> <OBJECT ID="MyText" width=0 height=0 CLASSID="CLSID:7DA8B621-FA5A-11d0-B4D7-00AA00B92AB3" CODEBASE="mytext.cab"> </OBJECT> <--after text cab object </BODY> </HTML> </li></ol>

Note that the CLSID in the sample above is shown for discussion purposes only. Your CLSID for the <OBJECT> tag would be defined in step 4. DO NOT use the GUID above in production code to avoid conflict with a similar dummy GUID used by another developer.

Each time an HTML page like the one shown above is accessed, the text file in Mytext.cab will be downloaded into the Windows directory.

<div class="references_section">