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

📄 vcg24.htm

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

        External

           Files:

        Comments:  This template script performs a basic installation to a

                   Windows 95 or Windows NT platform.  The installation

                   includes components: Application Program Files, Sample and

                   Template Files, Online Help Files, and Multimedia Tutorial

                   Files.  With minor modifications, this template can be

                   adapted to create new, customized installations.

   Modifications:  (Precede each entry with "+" sign. Include name and date.)

                   +                             Date:

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

        // Size of components

#define SIZE_REQ_SAMPLES        1400000

#define SIZE_REQ_TEMPLATES        10000

#define SIZE_REQ_PROGRAM         200000

#define APP_NAME                "Sample App"

#define PROGRAM_GROUP_NAME      "Sample App Group"

#define APPBASE_PATH            "Company\\SampleApp\\"

#define COMPANY_NAME            "SampleCompany"

#define PRODUCT_NAME            "SampleApp"

#define PRODUCT_VERSION         "3.0"

#define PRODUCT_KEY             "designer.exe"

#define UNINSTALL_KEY           "SampleAppV3"

#define APPBASE_DIR95           "Program Files"

#define BASE_REGISTRYNT \

    "Software\\Microsoft\\Windows NT\\CurrentVersion\\App Paths\\"

#define BASE_REGISTRY95 \

    "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\"

#define SYS_BOOTMACHINE         3

#define STR_COMPLETE95 \

    "by selecting the program icon in the Programs menu.\n\n"

#define STR_COMPLETENT \

    "by selecting the program icon in the program group.\n\n"

declare

        // --- Global variable definition ---

        STRING  svGrp, szMsg, szFileSet, szTitle, szAppPath, szAppSharedDir;

        STRING  szProgram, szTemp, svUninstLogFile, szRegKey;

        STRING  svMainDirectory[ _MAX_STRING ];

        BOOL    bSpaceOk, bReshowSetupType;

        NUMBER  nResult, nStatusId, nType;

        BOOL    bIncludeProgram, bIncludeSamples, bIncludeHelp, bIncludeTut;

        BOOL    bWinNT;

        // --- Function definition ---

        prototype SetupScreen();

        prototype CheckRequirements();

        prototype CheckSpaceRequirements( number, number, number, string );

        prototype CreateRegDBEntries();

program

StartHere:

        Disable( BACKGROUND );

        // Setup installation screen

        SetupScreen();

        // Set installation info that is required for other functions.

  InstallationInfo( COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, PRODUCT_KEY );

        // Create a Welcome dialog.

WelcomeDlg:

        Disable( BACKBUTTON );

        Welcome( "Welcome", 0 );

        Enable( BACKBUTTON );

        // --- System test for proper configuration ---

        CheckRequirements();

        // --- Ask user for the path to place installed application ---

GetTargetDirectory:

        svMainDirectory = TARGETDISK ^ APPBASE_DIR95 ^ APPBASE_PATH;

        if ( AskDestPath( "Choose Destination Location", szMsg,

                          svMainDirectory, 0 ) = BACK ) then

           goto WelcomeDlg;

        endif;

        szAppSharedDir = svMainDirectory ^ "System";

DetermineUserSelection:

        nType = SetupType( "Setup Type", "", svMainDirectory, TYPICAL, 0 );

        if ( nType = BACK ) then goto GetTargetDirectory; endif;

        bReshowSetupType = FALSE;

        switch (nType)

        case TYPICAL:

             bIncludeSamples  = TRUE;

             bIncludeProgram  = TRUE;

             bIncludeHelp = TRUE;

        case COMPACT:

             bIncludeProgram  = TRUE;

        case CUSTOM:

             SetDialogTitle( DLG_ASK_OPTIONS, "Select Components" );

             bIncludeSamples  = TRUE;

             bIncludeProgram  = TRUE;

             bIncludeHelp = TRUE;

             szMsg = "Select the components that you wish to install.\n"+

                 "If the check box is unchecked, that component will not be "+

                 "installed. Click Next to continue with the installation.";

             nResult = AskOptions( NONEXCLUSIVE, szMsg,

                               "Application Program Files", bIncludeProgram,

                               "Sample and Template Files", bIncludeSamples,

                                   "On-Line Help Files", bIncludeHelp,

                                   "Multimedia Tutorial", bIncludeTut );

             if ( nResult = BACK ) then goto DetermineUserSelection; endif;

             // Handle exiting of setup

             if (nResult = CANCEL) then

                if (AskYesNo( "Are you sure you would like to exit setup?", NO)

                   = YES) then

                   abort;

                else

                   bReshowSetupType = TRUE;

                endif;

             endif;

        endswitch;

        if (bReshowSetupType = TRUE) goto DetermineUserSelection;

        // Check space requirements

        bSpaceOk = CheckSpaceRequirements( bIncludeSamples,

                                           bIncludeProgram,

                                           bIncludeHelp,

                                           svMainDirectory );

        if (bSpaceOk = FALSE) goto DetermineUserSelection;

                                     // Ask user to try again

FolderSelection:

        if ( bWinNT ) then

           svGrp = PROGRAM_GROUP_NAME;

           // Allow user to modify folder name

           if ( SelectFolder( "Folder Selection", svGrp, svGrp ) = BACK ) then

              goto DetermineUserSelection;

           endif;

        endif;

FileTransferSetup:

        // Set the deinstallation information

        DeinstallStart( svMainDirectory, svUninstLogFile, UNINSTALL_KEY, 0 );

        RegDBSetItem( REGDB_UNINSTALL_NAME, APP_NAME );

        // Set APPPATH for the main application

        szAppPath = svMainDirectory ^ "PROGRAM" + ";" + szAppSharedDir;

        RegDBSetItem( REGDB_APPPATH, szAppPath );

        szProgram = svMainDirectory ^ "PROGRAM\\designer.exe";

        RegDBSetItem( REGDB_APPPATH_DEFAULT, szProgram );

        // Set APPINFO for auxiliary application

        if (bWinNT) then

           szRegKey = BASE_REGISTRYNT ^ "demo.exe";

        else

           szRegKey = BASE_REGISTRY95 ^ "demo.exe";

        endif;

        RegDBSetDefaultRoot( REGKEY_LOCAL_MACHINE );

        RegDBSetKeyValueEx( szRegKey, "Path", REGDB_STRING,  szAppPath, -1 );

        szProgram = svMainDirectory ^ "PROGRAM\\demo.exe";

        RegDBSetKeyValueEx( szRegKey, "", REGDB_STRING,  szProgram, -1 );

        // --- Define the file to be copied to the user's machine ---

        szFileSet = "General";

        TARGETDIR = svMainDirectory;

        FileSetBeginDefine( szFileSet );

          SetStatusWindow( -1, "Copying program files..." );

          // Always copy readme and related

          CompressGet( "data.z", "*.*", COMP_NORMAL );

          if (bIncludeProgram) then

             TARGETDIR = svMainDirectory ^ "PROGRAM";

             CompressGet( "data.z", "program\\*.*", INCLUDE_SUBDIR );

             CompressGet( "data.z", "shared\\*.*", COMP_NORMAL );

             TARGETDIR = szAppSharedDir;

             CompressGet( "data.z", "shared\\*.*", SHAREDFILE | COMP_NORMAL );

          endif;

          if (bIncludeSamples) then

             TARGETDIR = svMainDirectory ^ "SAMPLES";

             CompressGet( "data.z", "samples\\*.*", INCLUDE_SUBDIR );

          endif;

          if (bIncludeHelp) then

             TARGETDIR = svMainDirectory ^ "TEMPLATE";

             CompressGet( "data.z", "template\\*.*", INCLUDE_SUBDIR );

          endif;

        FileSetEndDefine( szFileSet );

DoFileTransfer:

        // --- Set up status bar/file info and perform file transfer ---

        Enable( EXIT );

        Enable( STATUS );

        Enable( FEEDBACK_FULL );

        StatusUpdate( ON, 90 );

        // --- Copy all files on all disks ---

        nResult = FileSetPerformEz( szFileSet, 0 );

        switch (nResult)

        case FS_DONE: // --- Successful completion ---

        case FS_CREATEDIR: // --- Create Directory Error ---

           MessageBox( "Unable to create a directory under " + TARGETDIR + "."+

              "Please check write access to this directory.", SEVERE );

             abort;

        default: // --- Group all other errors under default label ---

             NumToStr( szTemp, nResult );

             MessageBox( "General file transfer error."+

                          "Please check your target location and try again."+

                          "\n\n Error Number:"+szTemp, SEVERE );

             abort;

        endswitch;

SetRegistryEntries:

//        RegDBSetAppInfo( "Template", REGDB_STRING, "good.tpl", -1 );

//        RegDBSetAppInfo( "TemplatePath", REGDB_STRING,

//            svMainDirectory ^ "TEMPLATE", -1 );

        Disable( FEEDBACK_FULL );

        CreateRegDBEntries( );

        // --- Create program groups and icons ---

CreateFolderIcons:

        SetStatusWindow( 95, "Creating Folder and Icons...." );

        if ( bWinNT ) then

           CreateProgramFolder( svGrp );

           ShowProgramFolder( svGrp, 0 );

           LongPathToShortPath( svMainDirectory );

           Delay(1);

        endif;

        TARGETDIR = svMainDirectory;

        if (bIncludeProgram) then

           szProgram = TARGETDIR ^ "PROGRAM\\DESIGNER.EXE";

           if ( bWinNT ) then

              AddFolderIcon( svGrp, APP_NAME, szProgram,

                             TARGETDIR ^ "PROGRAM",

                             "", 0, "", REPLACE );

           else

              LongPathToQuote( szProgram, TRUE );

              AddFolderIcon( "", APP_NAME, szProgram,

                             TARGETDIR ^ "PROGRAM",

                             "", 0, "", REPLACE );

           endif;

           Delay( 1 );

        endif;

        if ( bWinNT ) then

           if (bIncludeSamples) then

              szProgram = TARGETDIR ^ "PROGRAM\\DEMO.EXE ";

              AddFolderIcon( svGrp, "Example1",

                             szProgram + TARGETDIR ^ "PROGRAM\\MULTI.DBD",

                             TARGETDIR ^ "PROGRAM",

                             "", 0, "", REPLACE );

              Delay( 1 );

           endif;

           if (bIncludeSamples) then

⌨️ 快捷键说明

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