1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793
|
/*---------------------------------------------------------------------------*\
* File Name: SETUP.RUL
*
* Description: XNTP - NT Install,
* Reworked by Greg Schueman for XNTP.
*
* BIND version by Larry Kahn... using ideas from Paul Wren's (PIW) version.
*
\* ----------------------------------------------------------------------------*/
// Next 4 lines defined by mksetup.bat script
// declare
// #define APP_NAME2 "XNTPPACKAGE XNTPVERSION Freeware"
// #define PRODUCT_VERSION "XNTPVERSIONRel"
// #define DEINSTALL_KEY "NTPXNTPVERSION"
// Constant declarations.
#define SPACE_REQUIRED 1300000 // Disk space in bytes.
#define APP_NAME "NetworkTimeProtocol"
#define APPBASE_PATH "\\var\\ntp\\"
#define UNINSTALL_NAME "NTP"
#define PRODUCT_KEY "xntpd.exe"
#define NTP_PORT 123
#define ONETIMESOURCE 1
#define TWOTIMESOURCES 2
#define NOTIMEYET 3
// Global variable declarations
STRING svDir, szMsg, szFileSet,szTitle, szMessage, svUninstLogFile;
STRING szProgram, szParam, szTemp, szTemp2, szAppPath;
STRING svFileName;
STRING svTempStr;
STRING svModuleDir;
STRING svAnswer;
STRING dummy;
BOOL bRemoveNTP, bUpdateModules;
STRING svNTPAddress; // the IP address of "1st" time source
STRING svNTPAddress2; // the IP address of "2nd" time source
STRING szDllNTPInst;
NUMBER nReturnValue;
INT nReturnValue2;
INT nValue;
//--------Custom Dialog in Ishield-------------------------
BOOL bDone;
LIST lNames, lAddrs;
//------- NTPInst.DLL defines------------------------
#define k_PrivilegeErr 1
#define k_CreateKeyErr 2
#define k_RestoreKeyErr 3
#define k_ErrUnableToOpenWriteOwner 4
#define k_ErrUnableToSetOwner 5
#define k_ErrUnableToOpenDAC 6
#define k_ErrUnableToWriteDACL 7
#define k_OpenKeyError 8
#define k_ModifySetAccountFail 10
#define k_SCMErr 11
#define k_SCMpoErr 12
#define k_DeleteServiceFail 13
#define k_DeleteKeyFail 14
#define k_DeleteValueFail 15
#define k_DirSecurityErr 16
#define k_DirSetDACLErr 17
#define k_DirSetSecurityErr 18
#define k_SCMpoStopErr 19
#define k_SaveKeyErr 20
#define k_ServiceUnknownErr 50
#define k_ServiceDependency 51
#define k_ServiceDependencyFail 52
#define k_ServiceLogonFail 53
#define k_BadPath 101
#define k_AccessDenied 102
#define k_ServiceExists 103
#define k_createservicefailed 104
#define k_removeservicefailed 105
#define k_ServicenoExists 106
//--------Function declarations----------------------------
prototype SetupScreen ();
prototype CheckRequirements ();
prototype RemoveNTP ();
prototype UpdateModules ();
prototype ReportError (INT, BYREF STRING);
prototype DoConfigType ();
prototype CreateConfigFiles (INT);
prototype InstallNTPFiles (STRING, INT);
prototype RegisterEventlogMessages (STRING);
prototype CheckForService ();
prototype GetImagePath (BYREF STRING);
prototype LaunchAppAndWait (STRING,STRING, INT);
prototype ReverseOctet (BYREF STRING, STRING);
prototype FixDirectory (BYREF STRING, STRING);
//--------------------------------------------------------------------------
program
StartHere:
Disable( BACKGROUND );
dummy = " ";
// Set default registry tree
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
// Set up the installation screen.
SetupScreen();
Enable( DIALOGCACHE );
TARGETDIR = SUPPORTDIR;
szDllNTPInst = SUPPORTDIR ^ "NTPDLL.DLL"; // NTP-specific helper library
svDir = WINSYSDISK + "\\";
// Module locations, XNTP - NT location
svModuleDir = WINDISK^"\\win32app\\ntp";
OfferReadmeFile:
if (AskYesNo("Would you like to see the readme file before proceeding? \n",NO ) = YES) then
LaunchAppAndWait("NOTEPAD",SUPPORTDIR ^ "README.NT",1);
endif;
CheckForService1:
// Look for service
if (CheckForService() != 0) then // Not clean install
Disable(BACKBUTTON);
bUpdateModules = TRUE;
szMessage = "Setup has determined that the NTP - NT service is\n" +
"already present. Do you want to:\n";
AskOptions(EXCLUSIVE, szMessage,
"&Remove NTP service", bRemoveNTP,
"&Update NTP to this version", bUpdateModules);
Enable(BACKBUTTON);
if (bRemoveNTP) then
if (AskYesNo("Are you certain you wish to remove the NTP service\n" +
"and registry entries? \n",NO ) = YES) then
RemoveNTP();
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);
//
//
// PlaceWindow(BACKGROUND,nDx/2,0,UPPER_LEFT);
// SizeWindow(BACKGROUND,nDx/2,nDy/2);
//
// However will also have to move all the dialogs/bitmaps
// around to make this work correctly...
//----------------------------------------------------------
SetTitle( APP_NAME2 + " Setup", 24, WHITE );
// SetColor( BACKGROUND, BK_BLUE ); // Dark blue.
// SetColor( STATUSBAR, BLUE ); // Bright blue.
SetTitle( "Setup", 0, BACKGROUNDCAPTION ); // Caption bar text.
Enable( BACKGROUND );
Delay( 1 );
// Show the bitmap.
// PlaceBitmap( SUPPORTDIR ^ "NTPNT.BMP",1,10,10,UPPER_RIGHT);
end;
/*---------------------------------------------------------------------------*\
* Function: CheckRequirements
* Purpose: This function will make sure we are on NT, not Win95.
\*---------------------------------------------------------------------------*/
function CheckRequirements()
number nvVersion;
STRING szResult, svVersion;
begin
// Determine the target system's operating system.
GetSystemInfo( OS, nvVersion, svVersion );
if (nvVersion = IS_WINDOWSNT) then
MessageBox("This product can only run on Windows NT", SEVERE);
exit;
endif;
end;
//+---------------------------------------------------------------------------
// Member: ReportError()
//----------------------------------------------------------------------------
function ReportError(n_Err, sz_Message)
begin
switch(n_Err)
case k_PrivilegeErr: sz_Message = "Privilege Error";
case k_CreateKeyErr: sz_Message = "Create Key Failed";
case k_RestoreKeyErr: sz_Message = "Restore Default Key Failed";
case k_ErrUnableToOpenWriteOwner: sz_Message = "Unable to Open and Write Owner Information";
case k_ErrUnableToSetOwner: sz_Message = "Unable to Set Owner Information";
case k_ErrUnableToOpenDAC: sz_Message = "Unable to Open Access Control List";
case k_ErrUnableToWriteDACL: sz_Message = "Unable to Write Access Control List";
case k_OpenKeyError: sz_Message = "Unable to Open Registry Key Entry";
case k_ModifySetAccountFail: sz_Message = "Unable to Setup Account Parameters";
case k_SCMErr: sz_Message = "Unable to Open Service Control Manager Database";
case k_SCMpoErr: sz_Message = "Unable to Open NTP - NT service entries in the Service Control Manager";
case k_DeleteServiceFail: sz_Message = "Unable to delete NTP - NT service";
case k_DeleteKeyFail: sz_Message = "Unable to delete registry key information";
case k_DeleteValueFail: sz_Message = "Unable to delete registry value information";
case k_DirSecurityErr: sz_Message = "Unable to retreive Security information on directory";
case k_DirSetDACLErr: sz_Message = "Unable to add security information on directory";
case k_DirSetSecurityErr: sz_Message = "Unable to set directory security information";
case k_SCMpoStopErr: sz_Message = "Unable to stop the NTP - NT service";
case k_SaveKeyErr: sz_Message = "Unable to save registry key.";
case k_ServiceUnknownErr: sz_Message = "The service control manager could not start the NTP - NT service - please check the event log";
case k_ServiceDependency: sz_Message = "The NTP - NT service depends on several other services which are not installed.";
case k_ServiceDependencyFail: sz_Message = "The NTP - NT service depends on other services which failed to start.";
case k_ServiceLogonFail: sz_Message = "The service manager was unable to login the NTP - NT service - Please check the password and logon as service privilege";
case k_BadPath: sz_Message = "Bad Path Specified.";
case k_AccessDenied: sz_Message = "Access Denied.";
case k_ServiceExists: sz_Message = "NTP - NT service already exists so cannot be re-installed";
case k_createservicefailed: sz_Message = "Creation of the NTP - NT service failed.";
case k_removeservicefailed: sz_Message = "Unable to remove the NTP - NT service.";
case k_ServicenoExists: sz_Message = "NTP - NT service is not installed so cannot be removed.";
default: sz_Message = "Unknown Error";
endswitch;
end;
//+---------------------------------------------------------------------------
//
// Member: RemoveNTP()
//
// Synopsis: Remove the NTP service entry and registry entries
//
//----------------------------------------------------------------------------
function RemoveNTP()
NUMBER n_Result;
begin
dummy = APP_NAME;
SetStatusWindow( 0, "Stopping and removing NTP service..." );
// Remove the NTP service entry & Registry but first stop the service
nReturnValue2 = CallDLLFx(szDllNTPInst,"StopNTPService",nValue,dummy);
if (nReturnValue2 != 0) then
ReportError(nReturnValue2,szMessage);
NumToStr( szTemp, nReturnValue2 );
szMessage = "Unable to Stop the NTP - NT Service. \n" + szTemp + "\nAre you sure it is installed?\n" + szMessage;
MessageBox(szMessage,SEVERE);
exit;
endif;
Delay( 3 ); // delay for xntpd.exe file to free up so delete works
// have to get the currently install directory from the dll by pulling it off of the imagepath param
//if (GetImagePath(svModuleDir) != 0) then
// szMessage = "Unable to retrieve the path to Remove NTP Files \n" + svModuleDir +
// "\nAre you sure it is installed?\n";
// MessageBox(szMessage,SEVERE);
// exit;
//endif;
n_Result = CallDLLFx(szDllNTPInst,"RemoveNTPService",nValue,dummy);
if (n_Result != 0) then
MessageBox("Unable to remove NTP - NT service from the registry.",SEVERE);
exit;
else
if (AskYesNo("Service Removed\n Do you want to delete all the NTP Executables and config files also?\n",
NO) = YES) then
TARGETDIR = WINSYSDIR; // pick off the files we put in the
DeleteFile("ntpdate.exe");
DeleteFile("ntpq.exe");
DeleteFile("ntptrace.exe");
DeleteFile("xntpdc.exe");
DeleteFile("xntpd.exe");
DeleteFile("instsrv.exe");
TARGETDIR = svModuleDir;
DeleteFile("ntpog.wri");
DeleteFile("readme.nt");
DeleteDir(svModuleDir, ONLYDIR);
TARGETDIR = WINDIR;
DeleteFile("ntp.conf");
DeleteFile("ntp.drift");
MessageBox("NTP - NT service and registry entries are removed.\n" +
"All Executable/Config files have been deleted.",INFORMATION);
else
MessageBox("NTP - NT service and registry entries are removed.\n" +
"All Executable/Config files are retained.",INFORMATION);
endif;
endif;
end;
//+---------------------------------------------------------------------------
//
// Member: UpdateModules()
//
//----------------------------------------------------------------------------
function UpdateModules()
STRING szFileSet;
STRING szMessage;
NUMBER nvSize, nvType;
begin
SetStatusWindow( 0, "Updating NTP installation..." );
nReturnValue2 = CallDLLFx(szDllNTPInst,"StopNTPService",nValue,dummy);
if (nReturnValue2 != 0) then
ReportError(nReturnValue2,szMessage);
NumToStr( szTemp, nReturnValue2 );
szMessage = "Unable to Stop the NTP - NT Service. \n" + szTemp + "\nAre you sure it is running?\n" + szMessage;
MessageBox(szMessage,SEVERE);
exit;
endif;
Delay( 3 ); // delay for xntpd.exe file to free up so copy works
// have to get the currently install directory from the dll by pulling it off of the imagepath param
if (GetImagePath(svModuleDir) != 0) then
szMessage = "Unable to retrieve the path to Update NTP Files \n" + svModuleDir +
"\nAre you sure it is installed?\n";
MessageBox(szMessage,SEVERE);
exit;
endif;
InstallNTPFiles(svModuleDir,1);
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;
SetStatusWindow( 100, "Update completed." );
Delay( 2 );
MessageBox("Your Network Time Protocol Server modules have been updated and\n" +
"the service restarted. You should check the event log\n" +
"to make sure everything came back up properly.",INFORMATION);
end;
/*---------------------------------------------------------------------------*\
*
* Function: GetImagePAth
*
* Purpose: Get the given value, under the given key, from the registry.
* l. kahn
\*---------------------------------------------------------------------------*/
function GetImagePath(svValue)
NUMBER nvSize;
NUMBER nvType;
begin
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
if (RegDBGetKeyValueEx(SERVICE_ENTRY,
"ImagePath",nvType,svValue,nvSize) < 0) then
return -1;
endif;
StrSub(svValue,svValue,0,nvSize - 10); // trim to REAL length
return 0;
end;
function CheckForService()
STRING temp;
NUMBER nvSize;
NUMBER nvType;
begin
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
if (RegDBGetKeyValueEx(SERVICE_ENTRY,
"ImagePath",nvType,temp,nvSize) < 0) then
return 0;
endif;
return -1;
end;
/*---------------------------------------------------------------------------*\
*
* Function: LaunchAppAndWait
*
* Purpose: replace predefined function in more expensive InstallShield
* with C function.
* l. kahn
\*---------------------------------------------------------------------------*/
function LaunchAppAndWait(svApp, svData, waitval)
STRING tstring;
begin
nValue = waitval;
tstring = svApp+" "+svData;
nReturnValue2 = CallDLLFx(szDllNTPInst,"LaunchApp",nValue,tstring);
return 0;
end;
/*---------------------------------------------------------------------------*\
*
* Function: FixDirectory
*
* Purpose: put the double slashes in the directory
* l. kahn
\*---------------------------------------------------------------------------*/
function FixDirectory(svOut,svIn)
INT len;
INT ctr;
NUMBER letter;
INT i;
begin
len = StrLength(svIn) - 1;
ctr = 0;
for i = 0 to len
GetByte(letter,svIn,i);
if (letter = 92)
then
SetByte(svOut,ctr,letter);
ctr = ctr + 1;
endif;
SetByte(svOut,ctr,letter);
ctr = ctr + 1;
endfor;
end;
|