📄 27
字号:
- endif;- endif;- if (bUpdateModules) then- UpdateModules();- endif;- exit;- endif; - // install drops through- - DoCleanInstall:- - // Defaults- - // Create a Welcome dialog.- WelcomeDlg:- Disable( BACKBUTTON );- Welcome( "", 0 );- Enable( BACKBUTTON );- - // Test target system for proper configuration.- CheckRequirements();- - ModuleDir: - if (AskDestPath("Network Time Protocol Server program file location",- "Choose the directory for storage of the NTP support files",- svModuleDir,0) = BACK) then- goto WelcomeDlg;- endif;- - ThatsItDoIt: - - InstallNTPFiles(svModuleDir,0); // uncompress & place files in directories- - GetConfigurationType:- Disable(BACKBUTTON);- TARGETDIR = svModuleDir; // point back to ntp directory- - SetStatusWindow( 85, "Creating Configuration Files..." );- DoConfigType(); // do the configuration for user-spec'd type- Enable(BACKBUTTON);- - RegistryInit:- - SetStatusWindow( 90, "Creating NTP Service..." );- - CreateService:- // was svModuleDir^"\\xntpd.exe"- nReturnValue2 = CallDLLFx(szDllNTPInst,"CreateNTPService",nValue,WINSYSDIR^"\\xntpd.exe");- if (nReturnValue2 != 0) then- ReportError(nReturnValue2,szMessage);- szMessage = "Unable to install NTP - NT Service entry in Service Control Manager.\n" + szMessage;- MessageBox(szMessage,SEVERE);- exit;- endif;- - - SetStatusWindow( 95, "Adding Additional Registry Keys..." );- - nReturnValue2 = CallDLLFx(szDllNTPInst,"addKeysToRegistry",nValue,dummy);- if (nReturnValue2 != 0) then- szMessage = "Unable to add the Depend on service key in the NT registry\n";- MessageBox(szMessage,SEVERE);- exit;- endif;- - - SetStatusWindow( 98, "Starting the Service..." );- - StartService:- nReturnValue2 = CallDLLFx(szDllNTPInst,"StartNTPService",nValue,dummy);- if (nReturnValue2 != 0) then- ReportError(nReturnValue2,szMessage);- szMessage = "Unable to start the NTP - NT Service.\n" + szMessage;- MessageBox(szMessage,SEVERE);- exit;- endif;- - // Announce setup complete and offer to read README file.e- FinalInstallProcess:- SetStatusWindow( 100, "Installation complete." );- Delay( 2 );- - if (AskYesNo("Setup is complete. The NTP service is running.\n"+- "Do you want to look at the documentation for NTP?\n",- YES) = YES) then- LaunchAppAndWait("WRITE.EXE",TARGETDIR ^ "ntpog.wri",1);- endif;- exit;- - - /*---------------------------------------------------------------------------*\- *- * Function: InstallNTPFiles()- *- * Purpose: Uncompress the IShield package, and put files in the directory- * passed as an argument.- *- * This function used both for new installations, and for the - * "update modules" function.- *- \*---------------------------------------------------------------------------*/- function InstallNTPFiles(svInstDir,updateonly)- NUMBER nResult;- STRING szBitmapPath;- begin- // szBitmapPath = SUPPORTDIR^"ishield.bmp";- // PlaceBitmap(szBitmapPath,1,10,10,UPPER_RIGHT);- - // Insure that directories have sufficient permissions- // ReleaseModuleDirSecurity(svInstDir);- - szFileSet = "NetworkTimeProtocolServer";- FileSetBeginDefine(szFileSet);- - TARGETDIR = WINSYSDIR;- SetStatusWindow( -1, "Copying modules..." );- // MessageBox("decompressing data.z: sourcedir = " + SRCDIR + " target dir = " +- // TARGETDIR,INFORMATION);- // change this to comp update date eventually- - if (updateonly != 0) // update case- then- // uncomment if adding a Control Panel Applet to package- //nResult = CompressGet("data.z","*.cpl",COMP_UPDATE_DATE);- //if (nResult < 0) then- // NumToStr( szTemp, nResult );- // MessageBox("File Decompression1 failed! ecode = " + szTemp, SEVERE);- // exit;- // endif;- - nResult = CompressGet("data.z","*.exe",COMP_UPDATE_DATE);- if (nResult < 0) then- NumToStr( szTemp, nResult );- MessageBox("File Decompression2 failed! ecode = " + szTemp, SEVERE);- exit;- endif;- - else // not update install all- nResult = CompressGet("data.z","*.exe",COMP_UPDATE_DATE);- if (nResult < 0) then- NumToStr( szTemp, nResult );- MessageBox("File Decompression2 failed! ecode = " + szTemp, SEVERE);- exit;- endif;- - TARGETDIR = svInstDir; // set destination directory- - nResult = CompressGet("data.z","readme.nt",COMP_UPDATE_DATE);- if (nResult < 0) then- NumToStr( szTemp, nResult );- MessageBox("File Decompression3 failed! ecode = " + szTemp, SEVERE);- exit;- endif;- - nResult = CompressGet("data.z","ntpog.wri",COMP_UPDATE_DATE);- if (nResult < 0) then- NumToStr( szTemp, nResult );- MessageBox("File Decompression4 failed! ecode = " + szTemp, SEVERE);- exit;- endif;- - endif; // Decompress File end- - FileSetEndDefine(szFileSet);- - // Set up progress indicator and information gauge.- Disable( DIALOGCACHE );- Enable( STATUSDLG );- - StatusUpdate( ON, 80 );- - // Perform the file set.- SetStatusWindow( 0, "Copying program files..." );- 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 );- exit;- 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 +- "\n Related File: "+ ERRORFILENAME,SEVERE);- exit;- endswitch;- - RegisterEventlogMessages(svInstDir); // put EventLog reg entries in- end;- - - /*---------------------------------------------------------------------------*\- *- * Function: RegisterEventlogMessages- *- * Purpose: Put an entry under the Eventlog registry information, so that- * it understands where to find messages that come from NTP.- *- * History: PIW Created 12/14/95- *- \*---------------------------------------------------------------------------*/- #define EVENTLOG_ENTRY "\\SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application\\NTP"- #define SERVICE_ENTRY "\\SYSTEM\\CurrentControlSet\\Services\\NetworkTimeProtocol"- - function RegisterEventlogMessages(svTemp)- NUMBER nvSize;- begin- RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);- RegDBSetKeyValueEx(EVENTLOG_ENTRY,"EventMessageFile",- REGDB_STRING,svTemp^"xntpd.exe",nvSize);- RegDBSetKeyValueEx(EVENTLOG_ENTRY,"TypeSupported",REGDB_NUMBER,"7",nvSize);- end;- - - /*---------------------------------------------------------------------------*\- *- * Function: DoConfigType- *- * Purpose: Find out what type of installation the user is planning,- * and then create and/or show the configuration files to them.- *- \*---------------------------------------------------------------------------*/- function DoConfigType()- BOOL bSingleSourceNTP,bSecondarySourceNTP, bNoSourceNTP;- begin- bSingleSourceNTP = FALSE;- bSecondarySourceNTP = TRUE;- bNoSourceNTP = FALSE;- szMessage = "For creation of configuration files, please select the setup\n" +- "you want for NTP. Do you want to set up a:\n";- AskOptions(EXCLUSIVE, szMessage,- "&Single Time Source", bSingleSourceNTP,- "&Two Time Sources", bSecondarySourceNTP,- "&Specify No Time Sources", bNoSourceNTP);- - Enable(BACKBUTTON);- if (bSingleSourceNTP) then- szMessage = "Please enter the IP address of the Time Source.\n";- AskText(szMessage, svNTPAddress, svNTPAddress);- CreateConfigFiles(ONETIMESOURCE); // create ntp.conf- endif;- - if (bSecondarySourceNTP) then- szMessage = "Please enter the IP address of the First Time Source from\n" +- "which you will RECEIVE synchronization\n";- AskText(szMessage, svNTPAddress, svNTPAddress);- szMessage = "Please enter the IP address of the Second Time Source from\n" +- "which you will RECEIVE synchronization\n";- AskText(szMessage, svNTPAddress2, svNTPAddress2);- CreateConfigFiles(TWOTIMESOURCES); // create ntp.conf- endif;- - if (bNoSourceNTP) then- CreateConfigFiles(NOTIMEYET); // create ntp.conf and ntp.drift- endif; - - if (AskYesNo("Do you want to see the NTP configuration file which has\n" + - "been created for this host?\n", YES) = YES) then- // Let them see/edit the files, if they want to:- LaunchAppAndWait("NOTEPAD.EXE", WINDIR ^ "ntp.conf",1);- endif;- end;- - - /*---------------------------------------------------------------------------*\- *- * Function: CreateConfigFiles- *- * Purpose: Now that we know the domain name, host name, and IP Address,- * create the configuration files for this NTP to be of type - * specified by parameter:- * ONETIMESOURCE- * TWOTIMESOURCES- * NOTIMEYET- * - *- * Need to have filled in: - * svNTPAddress- * svNTPAddress2- *- \*---------------------------------------------------------------------------*/- function CreateConfigFiles(nType)- NUMBER nvFileHandle;- STRING svInAddrArpa;- STRING saveddir;- STRING svIP;- begin- - CreateFile(nvFileHandle,WINDIR,"ntp.conf");- WriteLine(nvFileHandle,"#");- WriteLine(nvFileHandle,"# File: ntp.conf");- WriteLine(nvFileHandle,"# Purpose: give the NTP Service its startup parameters and");- WriteLine(nvFileHandle,"# list of startup files.");- WriteLine(nvFileHandle,"# ");- WriteLine(nvFileHandle,"# ");- - WriteLine(nvFileHandle,"#");- WriteLine(nvFileHandle,"# Miscellaneous stuff");- WriteLine(nvFileHandle,"#");- WriteLine(nvFileHandle,"driftfile %windir%\\ntp.drift # path for drift file");- WriteLine(nvFileHandle,"# statsdir c:\\var\\ntp\\stats\\ # directory for statistics files");- WriteLine(nvFileHandle,"# filegen peerstats file peerstats type day enable");- WriteLine(nvFileHandle,"# filegen loopstats file loopstats type day enable");- WriteLine(nvFileHandle,"# filegen clockstats file clockstats type day enable");- - if (nType != NOTIMEYET) then - WriteLine(nvFileHandle,"# Need to set up time sources...");- WriteLine(nvFileHandle,"# server ip-address");- WriteLine(nvFileHandle,"# ");- WriteLine(nvFileHandle,"# ");- endif; - - - if (nType = TWOTIMESOURCES) then - WriteLine(nvFileHandle,"# ");- WriteLine(nvFileHandle,"server " + svNTPAddress);- WriteLine(nvFileHandle,"server " + svNTPAddress2);- WriteLine(nvFileHandle,"# ");- WriteLine(nvFileHandle,"# ");- endif;- - if (nType = ONETIMESOURCE) then- WriteLine(nvFileHandle," ");- WriteLine(nvFileHandle,"server " + svNTPAddress);- WriteLine(nvFileHandle," ");- WriteLine(nvFileHandle," ");- endif;- - CloseFile(nvFileHandle);- - CreateFile(nvFileHandle,WINDIR,"ntp.drift");- WriteLine(nvFileHandle,"0 0");- CloseFile(nvFileHandle);- - end; - - - /*---------------------------------------------------------------------------*\- *- * Function: SetupScreen- *- * Purpose: This function will set up the screen look. This includes- * colors, fonts, text to be displayed, etc.- *- \*---------------------------------------------------------------------------*/- function SetupScreen()- INT nDx, nDy;- begin- Enable( DEFWINDOWMODE );- Enable( INDVFILESTATUS );- - //----------------------------------------------------------- // If you want to downsize the Blue-fade background:- //- // GetExtents(nDx,nDy);- //- //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -