HOWTO: Download a Text File Using IE Component Download

ID: Q185373


The information in this article applies to:
  • Microsoft Internet Explorer (Programming) versions 5.0, 3.0, 3.01, 3.02, 4.0, 4.01


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 <OBJECT> 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:
  1. 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.


  2. 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.


  3. Sign the CAB file using the code signing tools provided in either the ActiveX SDK or the Internet Client SDK.


  4. Insert an <OBJECT> 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:
  1. 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.


  2. 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.


  3. Sign the CAB file using the code signing tools provided in either the ActiveX SDK or the Internet Client SDK.


  4. 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.


  5. Create an <OBJECT> tag reference in HTML similar to the one in the following sample:
    
       <HTML>
       <HEAD>
       <TITLE>Text file download sample</title>
       </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> 


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.


REFERENCES

For more information, please see the MSDN Web Workshop:

http://msdn.microsoft.com/workshop/default.asp


For more information about signing a Visual Basic Internet Application, please see the following article in the Microsoft Knowledge Base:
Q169609 HOWTO: Digitally Sign Your Visual Basic 5.0 Internet Application

Additional query words:

Keywords : kbIE300 kbIE301 kbIE400 kbIE401 kbIE302 kbIE500 kbDSupport
Version : WINDOWS:3.0,3.01,3.02,4.0,4.01,5.0
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: July 22, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.