⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vcg24.htm

📁 Visual C++与数据库的连接经典实例
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<HTML>

<HEAD>

<TITLE>vcg24.htm </TITLE>

<LINK REL="ToC" HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/index.htm">

<LINK REL="Index" HREF="htindex.htm" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/htindex.htm">

<LINK REL="Next" HREF="vcgp7.htm" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/vcgp7.htm">

<LINK REL="Previous" HREF="vcg23.htm" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/vcg23.htm"></HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">

<A NAME="I0"></A><P ALIGN=CENTER>

<A HREF="vcg23.htm" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/vcg23.htm" TARGET="_self"><IMG SRC="blanprev.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/blanprev.gif" WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT="Previous Page"></A>

<A HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/index.htm" TARGET="_self"><IMG SRC="blantoc.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/blantoc.gif" WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT="TOC"></A>

<A HREF="vcgp7.htm" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/vcgp7.htm" TARGET="_self"><IMG SRC="blannext.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/blannext.gif" WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT="Next Page"></A>


<HR ALIGN=CENTER>

<P>

<UL>

<UL>

<UL>

<LI>

<A HREF="#E68E123" >Using Microsoft Setup, the Microsoft Installation Program</A>

<UL>

<LI>

<A HREF="#E69E292" >Configuring Microsoft Setup</A></UL>

<LI>

<A HREF="#E68E124" >Using the Sax Setup Wizard</A>

<LI>

<A HREF="#E68E125" >Using the InstallSHIELD SDK Version</A>

<LI>

<A HREF="#E68E126" >Using InstallSHIELD Professional</A>

<LI>

<A HREF="#E68E127" >Modifying the CONFIG.SYS and AUTOEXEC.BAT Files</A>

<LI>

<A HREF="#E68E128" >The CD-ROM AutoPlay Facility</A>

<UL>

<LI>

<A HREF="#E69E293" >Using the AUTORUN.INF Files</A>

<LI>

<A HREF="#E69E294" >Suggestions for Creating AutoPlay CDs</A></UL>

<LI>

<A HREF="#E68E129" >Demos and Shows</A>

<UL>

<LI>

<A HREF="#E69E295" >Using DemoSHIELD</A>

<LI>

<A HREF="#E69E296" >Working Demos</A></UL>

<LI>

<A HREF="#E68E130" >Summary</A></UL></UL></UL>

<HR ALIGN=CENTER>

<A NAME="E66E59"></A>

<H1 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>- 24 -</B>

<BR><B>Creating Distribution Disks for Visual C++ Applications</B></FONT></CENTER></H1>

<BR>

<P>Some Visual C++ database applications might call for a one-time-only installation by you, the developer. If that's the case, you can copy the applications' .EXE, .HLP, and .VBX files, together with any database and ancillary files that might be required, onto a set of disks that you will copy to the appropriate directories of the client's computer. If your Visual C++ database front end will be used by a large number of people, or if you want to impress your clients with a sophisticated setup application similar to those used to install mainstream Windows applications, you need to create &quot;official&quot; distribution disks.

<BR>

<P>This chapter is intended primarily for developers who are creating applications that will be used with Windows 95 and later versions of Windows. The techniques shown here are very useful for versions of Windows earlier than Windows 95; however, it's unlikely that readers of this book will be creating many applications for earlier versions of Windows. In the future, expect Windows NT to offer facilities that are comparable to those offered by Windows 95.

<BR>

<P>Most of the setup tools are part of the WIN32SDK. The AutoPlay facility is entirely part of Windows, and the developer's portion of AutoPlay consists of a five-page Word for Windows document. The InstallSHIELD Professional toolkit expands on the InstallSHIELD SDK product included with Visual C++ 4 and that is part of the WIN32SDK. It's available from InstallShield Corporation. (InstallShield Corporation used to be called Stirling Technologies, Inc. They changed their name to reflect their most successful product.)

<BR>

<P>The WIN32SDK, which is part of the MSDN Level II product, includes Microsoft Setup, the &quot;standard&quot; setup program that has been used extensively by Microsoft and other application vendors. One problem with Microsoft Setup is that it requires the setup program to be created as an application (you edit C source code and then build your own SETUP.EXE program). With InstallSHIELD SDK, you need to modify only a single script file&#151;a much simpler process.

<BR>

<P>The Sax Setup Wizard product from Sax Software is entirely Windows-based. It uses no scripting at all, because all user input is accomplished through wizard dialog boxes.

<BR>

<P>All three installation generator programs described in this chapter create professional installations that will help assure the user that your product is professional and of high quality&#151;an important factor in today's competitive software market.

<BR>

<BR>

<A NAME="E68E123"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Using Microsoft Setup, the Microsoft Installation Program</B></FONT></CENTER></H3>

<BR>

<P>The Microsoft Setup program (which is also referred to as MS Setup or MSSETUP) is based on the design of the wizards included with Access 1.0, which predated the release of Visual C++. The Microsoft Setup program resembles the SetupWizard of the Access 1.1 Distribution Kit (ADK), but the C version uses a different approach to create the distribution files and execute the setup application. The primary differences between the methods used by Visual C++ and the ADK wizards to create the distribution disks are explained in the following sections.

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE><B>NOTE</B>

<BR>

<BR>Microsoft no longer supports the Microsoft Setup program. It's still included with Visual C++, but it hasn't changed for some time, and Microsoft won't update it in the future. Unless you're already using Microsoft Setup, you shouldn't consider it for new projects.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<BR>

<A NAME="E69E292"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Configuring Microsoft Setup</B></FONT></CENTER></H4>

<BR>

<P>When you use Microsoft Setup, you don't get the same effects as with the other, newer setup programs such as Sax Setup Wizard and InstallSHIELD. For example, the Microsoft Setup program doesn't support the uninstall process automatically. If you use Microsoft Setup, you must write your uninstall code completely on your own, something that both InstallSHIELD and Sax Setup Wizard do for you.

<BR>

<P>Using Microsoft Setup is a multistep process. Follow these steps to create your own setup application:

<BR>

<OL>

<LI>Create your SETUP.EXE program using the sample code provided in the WIN32SDK CD's \WIN32SDK\MSTOOLS\MSSETUP\SAMPLE folder as a starting point. You can customize this sample program from Microsoft for your own purposes.

<BR>

<BR>In your version of Setup, you can specify the background bitmap, title, and billboards (messages that tell the user to register the product, and so on).

<BR>

<BR>

<LI>Lay out the files on the distribution media (usually disks, but now more commonly CD-ROMs). To lay out your application, use the DSKLAYT program, shown in Figure 24.1.

<BR>

<BR><B><A HREF="24vcg01.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/24vcg01.gif">Figure 24.1. The DSKLAYT program in action.</A></B>

<BR>

<BR>

<LI>Create the SETUP.INF file and distribution disks. Your setup program uses the SETUP.INF file to control the application installation. The SETUP.INF file contains at least three sections, as shown in Listing 24.1. The DSKLAYT2.EXE program takes the layout file created by DSKLAYT.EXE, as well as the files included with your application, and creates the SETUP.INF file for you. The DSKLAYT2.EXE program also creates distribution media images, each in their own directory.

<BR>

<BR>

</OL>

<P>

<FONT COLOR="#000080"><B>Listing 24.1. A sample SETUP.INF file.</B></FONT>

<BR>

<PRE>

<FONT COLOR="#000080">[Source Media Descriptions]

    &quot;1&quot;, &quot;Disk 1&quot;, &quot;&quot;, &quot;&quot;

[Minimum Files]

      1, setupapi.c,,,COPY,1992-01-30,,,,,,,,,,52174,,999,,,

[Extra Files]

      1, sample.inf,,,!COPY,1992-01-30,,,,,,,,,,10,,999,,,

[Default File Settings]

&quot;STF_BACKUP&quot;     = &quot;&quot;

&quot;STF_COPY&quot;       = &quot;YES&quot;

&quot;STF_DECOMPRESS&quot; = &quot;YES&quot;

&quot;STF_OVERWRITE&quot;  = &quot;ALWAYS&quot;

&quot;STF_READONLY&quot;   = &quot;YES&quot;

&quot;STF_ROOT&quot;       = &quot;&quot;

&quot;STF_SETTIME&quot;    = &quot;YES&quot;

&quot;STF_TIME&quot;       = &quot;1&quot;

&quot;STF_VITAL&quot;      = &quot;YES&quot;</FONT></PRE>

<P>Figure 24.2 shows the process of developing your application's distribution disks. Note that the DSKLAYT2.EXE program is a DOS-based application that runs in a DOS window under Windows 95 and Windows NT. This application won't run under Windows 3.x or native-mode DOS because it's an NT console mode application.

<BR>

<P><B><A HREF="24vcg02.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/24vcg02.gif">Figure 24.2. The Microsoft Setup process.</A></B>

<BR>

<BR>

<A NAME="E68E124"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Using the Sax Setup Wizard</B></FONT></CENTER></H3>

<BR>

<P>Sax Software markets an application installation system called the Sax Setup Wizard. This product was initially developed for Windows 3.x; it now fully supports Windows 95. The Sax Setup Wizard is a powerful yet easy-to-use setup generator, excellent for many types of projects.

<BR>

<P>Using Sax Setup Wizard is much simpler than using the Microsoft Setup program. Sax Setup Wizard is a totally Windows-based installation program that offers extensive user feedback to assist in creating installation disks. Sax Setup Wizard can create not only disk-based installations but also installations for CD-ROM-based products. This is very helpful, because the AutoRun facility (described later) can call the Sax Setup Wizard-created setup program if needed.

<BR>

<P>Sax Setup Wizard is a single program that requires no additional scripts or other manual input from the user. This differs from Microsoft Setup and InstallSHIELD, both of which are multistep processes that require some form of script from the user.

<BR>

<P>Figure 24.3 shows Sax Setup Wizard's main window before a project has been opened.

<BR>

<P><B><A HREF="24vcg03.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/24vcg03.gif">Figure 24.3. Sax Setup Wizard's main window.</A></B>

<BR>

<P>After a project has been opened, the values defined by the programmer are displayed in Sax Setup Wizard's main window, as shown in Figure 24.4.

<BR>

<P><B><A HREF="24vcg04.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/24vcg04.gif">Figure 24.4. Sax Setup Wizard's main window with a project opened.</A></B>

<BR>

<P>The main thing the user sees when installing applications is the installation program's background. All installation programs let you set the background when the setup program is being developed, and Sax Setup Wizard is no different. With Sax Setup Wizard, you can configure the shading (the trend for a gradient color in installation programs has almost become the standard). Also, your application's title can be text. You specify this in the General tab of the Project Options dialog box, shown in Figure 24.5.

<BR>

<P><B><A HREF="24vcg05.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/24vcg05.gif">Figure 24.5. Sax Setup Wizard's Project Options dialog with the Background tab open.</A></B>

<BR>

<P>Building a distribution disk set is a simple process with Sax Setup Wizard. You can specify the destination (most of the time you will build to a directory on a hard disk) and the disk size (you can choose from all of the common sizes, including CD-ROM distribution media, which offers a virtually unlimited size), or e-mail distribution.

<BR>

<P>After you have configured the distribution of your application and generated the disk images, you can copy these images to disks and distribute your application. If I were writing a review, I'd certainly rate the Sax Setup Wizard as the easiest setup generator currently on the market.

<BR>

<BR>

<A NAME="E68E125"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Using the InstallSHIELD SDK Version</B></FONT></CENTER></H3>

<BR>

<P>The documentation from InstallShield Corporation refers to the InstallSHIELD SDK version as InstallSHIELD SE. This chapter uses the same designation. InstallSHIELD SE is a basic application installation system that is very compatible with Windows 95. Applications that are installed using InstallSHIELD SE can be easily removed later using the Add/Remove Programs option under the Windows 95 Control Panel applet.

<BR>

<P>The InstallSHIELD SE program works like this:

<BR>

<OL>

<LI>Either write or modify an existing script file to be used with your application.

<BR>

<BR>

<LI>Process the script file using the InstallSHIELD SE &quot;compiler&quot; to create the installation script that the InstallSHIELD SE Setup program will use for input.

<BR>

<BR>

<LI>Process all temporary resource files (such as bitmaps, DLLs, and dialog boxes) using the ICOMP.EXE program to create the _SETUP.LIB file that the Setup program uses.

<BR>

<BR>

<LI>Use the ICOMP.EXE program to process your application's file(s) and create a single (compressed) output (.Z) file that is used by Setup.

<BR>

<BR>

<LI>For larger applications that will require more than one disk, use the SPLIT.EXE program to split the .Z file that you created in step 4. If your entire application with the InstallSHIELD SE files will fit on a single disk, you don't need to use SPLIT.EXE.

<BR>

<BR>

</OL>

<P>Figure 24.6 shows the process of creating a distribution disk set for a Windows 95 application.

<BR>

<P><B><A HREF="24vcg06.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/24vcg06.gif">Figure 24.6. The InstallSHIELD SE process.</A></B>

<BR>

<P>Take a look at each of the files you must create in order to use InstallSHIELD SE. This example uses the files from InstallShield Corporation's sample program because they represent an excellent starting point and can be easily modified to work with different applications.

<BR>

<P>The first file you need is the rules file. This file, which is a standard text file created using any editor you want (such as Notepad), is shown in Listing 24.2. The rules file is processed using the InstallSHIELD SE Compile program. The Compile program converts the rules file into an .INS file, which must be named SETUP.INS and be placed on the first disk of your product's distribution disk set, where the InstallShield SE program will look for it.

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE><B>NOTE</B>

<BR>

<BR>The files shown in the listings for InstallSHIELD SE are all found in the InstallSHIELD SE directory of the WIN32SDK. They are not found on this book's CD-ROM.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<P>

<FONT COLOR="#000080"><B>Listing 24.2. SETUP.RUL: The rules file.</B></FONT>

<BR>

<PRE>

<FONT COLOR="#000080">/*----------------------------------------------------------------------------\

    IIIIIIII SSSSSSSS

       II    SS                     InstallSHIELD SDK Edition (R)

       II    SSSSSSSS            1995, Stirling Technologies, Inc.

       II          SS                   All Rights Reserved.

    IIIIIIII SSSSSSSS

    This source code is intended as a supplement to Stirling Technologies,

    Inc., product documentation.  Refer to your Stirling Technologies, Inc.,

    product documentation for more detailed information.

\-----------------------------------------------------------------------------/

/*----------------------------------------------------------------------------\

        Filename:  SETUP.RUL

     Description:  InstallSHIELD SDK Edition Template One template script.

          Author:  Stirling Technologies, Inc.   Date: 2-4-95

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -