当用户安装系统时,就会出现几个向导界面,这几个向导界面是怎么样实现的呢?具体又是做些什么样的功能呢?它的实现代码如下:
#001 VOID
#002 InstallWizard(VOID)
#003 {
#004 PROPSHEETHEADER psh;
#005 HPROPSHEETPAGE ahpsp[8];
#006 PROPSHEETPAGE psp = {0};
#007 UINT nPages = 0;
#008
#009 /* Clear setup data */
#010 ZeroMemory(&SetupData,sizeof(SETUPDATA));
#011
处理无人值守安装的文件。
#012 ProcessUnattendSetup();
#013
#014
创建欢迎向导页。
#015 /* Create the Welcome page */
#016 psp.dwSize = sizeof(PROPSHEETPAGE);
#017 psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER;
#018 psp.hInstance = hDllInstance;
#019 psp.lParam = (LPARAM)&SetupData;
#020 psp.pfnDlgProc = WelcomeDlgProc;
#021 psp.pszTemplate = MAKEINTRESOURCE(IDD_WELCOMEPAGE);
#022 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
#023
创建版权说明向导页。
#024 /* Create the Acknowledgements page */
#025 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
#026 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_ACKTITLE);
#027 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_ACKSUBTITLE);
#028 psp.pszTemplate = MAKEINTRESOURCE(IDD_ACKPAGE);
#029 psp.pfnDlgProc = AckPageDlgProc;
#030 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
#031
创建个人电脑的名称。
#032 /* Create the Owner page */
#033 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
#034 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_OWNERTITLE);
#035 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_OWNERSUBTITLE);
#036 psp.pszTemplate = MAKEINTRESOURCE(IDD_OWNERPAGE);
#037 psp.pfnDlgProc = OwnerPageDlgProc;
#038 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
#039
创建电脑的名称。
#040 /* Create the Computer page */
#041 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
#042 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_COMPUTERTITLE);
#043 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_COMPUTERSUBTITLE);
#044 psp.pfnDlgProc = ComputerPageDlgProc;
#045 psp.pszTemplate = MAKEINTRESOURCE(IDD_COMPUTERPAGE);
#046 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
#047
#048
创建选择不同国家或地区的语言。
#049 /* Create the Locale page */
#050 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
#051 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_LOCALETITLE);
#052 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_LOCALESUBTITLE);
#053 psp.pfnDlgProc = LocalePageDlgProc;
#054 psp.pszTemplate = MAKEINTRESOURCE(IDD_LOCALEPAGE);
#055 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
#056
#057
创建选择不同的时区。
#058 /* Create the DateTime page */
#059 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
#060 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_DATETIMETITLE);
#061 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_DATETIMESUBTITLE);
#062 psp.pfnDlgProc = DateTimePageDlgProc;
#063 psp.pszTemplate = MAKEINTRESOURCE(IDD_DATETIMEPAGE);
#064 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
#065
#066
创建注册安装组件的向导页。
#067 /* Create the Process page */
#068 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
#069 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_PROCESSTITLE);
#070 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_PROCESSSUBTITLE);
#071 psp.pfnDlgProc = ProcessPageDlgProc;
#072 psp.pszTemplate = MAKEINTRESOURCE(IDD_PROCESSPAGE);
#073 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
#074
#075
创建完成提示向导页。
#076 /* Create the Finish page */
#077 psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER;
#078 psp.pfnDlgProc = FinishDlgProc;
#079 psp.pszTemplate = MAKEINTRESOURCE(IDD_FINISHPAGE);
#080 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
#081
创建向导对话框。
#082 /* Create the property sheet */
#083 psh.dwSize = sizeof(PROPSHEETHEADER);
#084 psh.dwFlags = PSH_WIZARD97 | PSH_WATERMARK | PSH_HEADER;
#085 psh.hInstance = hDllInstance;
#086 psh.hwndParent = NULL;
#087 psh.nPages = nPages;
#088 psh.nStartPage = 0;
#089 psh.PHPage = ahpsp;
#090 psh.pszbmWatermark = MAKEINTRESOURCE(IDB_WATERMARK);
#091 psh.pszbmHeader = MAKEINTRESOURCE(IDB_HEADER);
#092
创建标题字体。
#093 /* Create title font */
#094 SetupData.hTitleFont = CreateTitleFont();
#095
#096 /* Display the wizard */
#097 PropertySheet(&psh);
#098
#099 DeleteObject(SetupData.hTitleFont);
#100 }
安装完成后,就会显示下面的窗口,就会重新启动。