root/swishctl/src/setup/setup.cpp

Revision 1255, 18.4 kB (checked in by augur, 5 years ago)

Changed setup program to write the correct registry keys.
Removed left-over references to ACCIndex.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 // setup.cpp : Defines the entry point for the application.
2 //
3 #include "stdafx.h"
4 #include "resource.h"
5 #include <string>
6
7 #include "paths.h"
8
9 using namespace std;
10
11 #include "../regkey.h"
12
13 // One day I'll get around to doing the
14 // ugly GetFileVersion code...
15 #define SWISHCTL_VERSION ("1007")
16
17 const char *AUTORUN = "AutoRun";
18
19 // Global Variables:
20 enum dllnames { SWISHCTL=0, ZLIB=1 };
21
22
23 // Names of files to be installed in System directory
24 char * installdlls[] = {
25                 "SwishCtl.dll", "zlib.dll" };
26
27 const char registrykey[] = "Software\\SWISH-E Team\\SwishCtl\\Options";
28
29 static const char uninstallkey[] =
30         "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" ;
31
32
33 // Foward declarations of functions included in this code module:
34 LRESULT CALLBACK SetupHandler(HWND, UINT, WPARAM, LPARAM);
35
36
37 /* - - - - - - - - - - - - - - - - - - - - - - - - - - -
38  * class SetupApp manages application instance data
39  * and Ole initialisation
40  * - - - - - - - - - - - - - - - - - - - - - - - - - - - */
41 class SetupApp {
42 public:
43         static HINSTANCE getInstance() {return hInst;};
44         ~SetupApp();
45         SetupApp(HINSTANCE hInstance);
46         static HINSTANCE hInst;                 // current instance
47
48 };
49
50 SetupApp::SetupApp(HINSTANCE hInstance)
51 {
52         hInst = hInstance; // Store instance handle in our global variable
53         OleInitialize(NULL);
54
55 }
56
57 SetupApp::~SetupApp()
58 {
59         OleUninitialize();     
60 }
61
62 HINSTANCE SetupApp::hInst = 0; // static instance variable
63
64 /* - - - - - - - - - - - - - - - - - - - - - - - - - - -
65  * end of Setup App class
66  * - - - - - - - - - - - - - - - - - - - - - - - - - - - */
67
68
69 /* - - - - - - - - - - - - - - - - - - - - - - - - - - -
70  * LibModule class
71  * encapsulates instance loaded with LoadLibrary
72  * - - - - - - - - - - - - - - - - - - - - - - - - - - - */
73 class LibModule {
74 public:
75         LibModule() {m_hLib = NULL;};
76         ~LibModule();
77         bool LoadLibrary( const char *pathname );
78         HINSTANCE getInstance(){ return m_hLib;};
79
80 private:
81         HINSTANCE m_hLib;
82 };
83
84 LibModule::~LibModule()
85 {
86         if (m_hLib) ::FreeLibrary(m_hLib); //ensure FreeLibrary gets called
87 }
88
89 bool LibModule::LoadLibrary( const char *pathname )
90 {
91         m_hLib = ::LoadLibrary(pathname);
92         return m_hLib != NULL;
93 }
94 /* - - - - - - - - - - - - - - - - - - - - - - - - - - -
95  * end of LibModule class
96  * - - - - - - - - - - - - - - - - - - - - - - - - - - - */
97
98
99 typedef enum InstallResult { INSTALL_OK, ERR_INUSE, ERR_FAIL, ERR_ONREBOOT };
100
101
102 // Add a new Folder (FolderName) to Start | Programs
103 // appends the Programs folder path to give FullPathToFolder
104 // Make sure FullPathToFolder is big enough to hold the path
105 bool AddStartProgramsFolder(char *FolderName, char *FullPathToFolder)
106 {
107         LPITEMIDLIST   pidlPrograms;
108
109         //get the pidl for Start|Programs
110         SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAMS, &pidlPrograms);
111
112         if ( !SHGetPathFromIDList( pidlPrograms, FullPathToFolder) )
113         {
114                 return false;
115         }
116
117         strcat( FullPathToFolder, FolderName);
118         //create the folder
119         CreateDirectory(FullPathToFolder, NULL);
120         SHChangeNotify(SHCNE_MKDIR, SHCNF_PATH, FullPathToFolder, 0);
121
122         return true;
123 }
124
125
126 HRESULT CreateShortcut(  LPCSTR Source,
127                      LPSTR Target,
128                      LPSTR Description)
129 {
130         HRESULT hresult;
131         IShellLink* ShellLink;
132
133         //CoInitialize must be called before this
134         // Get a pointer to the IShellLink interface.
135         hresult = CoCreateInstance(   
136                 CLSID_ShellLink,
137                 NULL,
138                 CLSCTX_INPROC_SERVER,
139                 IID_IShellLink,
140                 (LPVOID*)&ShellLink);
141         if (SUCCEEDED(hresult))
142         {
143                 IPersistFile* PersistFile;
144
145                 // Set the path to the shortcut target, and add the description.
146                 ShellLink->SetPath(Source);
147                 ShellLink->SetDescription(Description);
148
149                 // Query IShellLink for the IPersistFile interface for saving the
150                 // shortcut in persistent storage.
151                 hresult = ShellLink->QueryInterface(IID_IPersistFile, (LPVOID*)&PersistFile);
152
153                 if (SUCCEEDED(hresult))
154                 {
155                         WCHAR WideTarget[MAX_PATH];
156
157                         // Ensure that the string is ANSI.
158                         MultiByteToWideChar( CP_ACP,
159                                                            0,
160                                                            Target,
161                                                            -1,
162                                                            WideTarget,
163                                                            MAX_PATH);
164
165                         // Save the link by calling IPersistFile::Save.
166                         hresult = PersistFile->Save(WideTarget, TRUE);
167
168
169                         PersistFile->Release();
170                   }
171
172                 ShellLink->Release();
173         }
174
175         return hresult;
176 }
177
178 // Remove the SwishCtl key from the registry
179 // should remove the "SWISH-E Team" key if it is empty
180 bool UnregisterIndexFile()
181 {
182         RegKey key(HKEY_LOCAL_MACHINE);
183
184         if ( ! key.OpenKey( "Software\\SWISH-E Team"  ) ) return false;
185         return key.DeleteKey( "SwishCtl" );
186 }
187
188 // Create the SwishCtl registry key and add the
189 // IndexLocation, IndexFiles and DLLVersion keys
190 bool RegisterIndexFile(char *indexdir, char *indexname)
191 {
192         RegKey key(HKEY_LOCAL_MACHINE);
193         string keyname(registrykey);
194         if ( ! key.CreateKey( keyname.c_str() ) ) return false;
195        
196         bool kv = key.SetValue( "IndexLocation", indexdir );
197         kv &= key.SetValue( "IndexFiles", indexname );
198
199         kv &= key.SetValue( "DLLVersion", SWISHCTL_VERSION );
200
201         return kv;
202 }
203
204 // Remove reference to SwishCtl from the Uninstall section
205 // of the registry
206 bool UnregisterUninstall()
207 {
208         RegKey key(HKEY_LOCAL_MACHINE);
209
210         if ( ! key.OpenKey( uninstallkey ) ) return false;
211         return key.DeleteKey( "SwishCtl" );
212 }
213
214 // Register Setup.exe /u in the registry Uninstall section
215 bool RegisterUninstall(const char *uninstallcommand)
216 {
217
218         string keyname(uninstallkey);
219         keyname += "SwishCtl";
220
221         RegKey key(HKEY_LOCAL_MACHINE);
222         if ( ! key.CreateKey( keyname.c_str() ) ) return false;
223        
224         bool result = key.SetValue( "DisplayName", "ACC Index Search Tool" );
225         result &= key.SetValue( "UninstallString", uninstallcommand );
226
227         return result;
228 }
229
230 BOOL LaunchUrl( HWND hwnd, char *url )
231 {
232    if (ShellExecute(
233                 hwnd,
234                 "open",
235                 url,
236                 NULL, NULL, SW_SHOWNORMAL) < (HINSTANCE)32 )
237    {
238                 char *buff[256] ;
239                 sprintf( (char *) buff,
240                         "Setup could not launch the search page (%s) \n"
241                         "please try opening the file from within Internet Explorer.",
242                         url
243                 );
244                 MessageBox(
245                                 NULL, // should pass in the dialog box handle
246                                 (char *) buff,
247                                 "Swish Control Setup",
248                                 MB_OK | MB_ICONASTERISK );
249                 return FALSE;
250    }
251    return TRUE;
252 }
253
254 // remove the shortcuts in the start menu
255 bool DeleteShortcuts(char *shortcut, char *subdir)
256 {
257         CStartProgramsDirectory startprograms;
258        
259         CDirectory newdir = startprograms + subdir;
260
261         CPath Shortcut = newdir + shortcut;
262
263         bool result = DeleteFile( Shortcut.getBuffer()) != 0;
264        
265         RemoveDirectory( newdir.getBuffer());
266         return result;
267
268 }
269
270 // add a shortcut to the search page in the startmenu
271 bool AddShortcut(CDirectory &appdir)
272 {
273         CStartProgramsDirectory startprograms;
274        
275         CDirectory newdir = startprograms.CreateChild( "ACC Index" );
276
277         CPath Shortcut = newdir + "index.lnk";
278         CPath IndexPage = appdir + "index.htm";
279
280
281         CreateShortcut( IndexPage.getBuffer(), Shortcut.getBuffer(),
282                         "ACC Index database" );
283         startprograms.NotifyChanged();
284         return true;
285 }
286
287
288 typedef HRESULT (STDAPICALLTYPE *CTLREGPROC)() ; // Requires stdole.h
289
290 //
291 bool registerOleDll( const char * pathname )
292 {
293         LibModule dll;
294         if ( ! dll.LoadLibrary(pathname) ) return false;
295
296         CTLREGPROC lpDllEntryPoint;
297         lpDllEntryPoint = (CTLREGPROC) GetProcAddress (dll.getInstance(),
298                                                                                                 _T("DllRegisterServer"));
299
300         if (!lpDllEntryPoint) return false;     //unable to locate entry point
301
302         HRESULT res = (*lpDllEntryPoint)();
303         return res == NOERROR;
304 }
305
306 //
307 bool unregisterOleDll( const char * pathname )
308 {
309         LibModule dll;
310         if ( ! dll.LoadLibrary(pathname) ) return false;
311
312         CTLREGPROC lpDllEntryPoint;
313         lpDllEntryPoint = (CTLREGPROC)GetProcAddress (  dll.getInstance(),
314                                                                                                   _T("DllUnregisterServer"));
315         if (!lpDllEntryPoint) return false;
316
317         HRESULT res = (*lpDllEntryPoint)(); //unable to locate entry point
318         return res == NOERROR;
319 }
320
321 // Check whether the Class ID is present
322 bool AppIsRegistered()
323 {
324         CLSID clsid;
325     return CLSIDFromProgID(L"SwishCtl.CSwishCtl", &clsid) == S_OK;   
326 }
327
328 BOOL ShowInstallDialog()
329 {
330         return DialogBox (SetupApp::getInstance (),
331                                                 (LPCTSTR) IDD_SETUP,
332                                                 NULL,
333                                                 (DLGPROC) SetupHandler);
334 }
335
336 void SetAutorun( bool on )
337 {
338                 RegKey key(HKEY_CURRENT_USER);
339                 key.OpenKey( registrykey, KEY_ALL_ACCESS );
340                 if (on) {
341                         key.SetValue( AUTORUN, "true" );
342                 } else {
343                         key.SetValue( AUTORUN, "false" );
344                 }
345 }
346
347 typedef enum VERSION_AGE { NO_VER, OLDER_VER, CURRENT_VER, NEWER_VER };
348
349 VERSION_AGE CheckInstalledVersion()
350 {
351         RegKey hkcu(HKEY_LOCAL_MACHINE) ;
352         if (!hkcu.OpenKey( registrykey, KEY_READ )) {
353                 return NO_VER;
354         }
355         string verstring = hkcu.QueryValue( "DLLVersion" );
356
357         int installed = atoi( verstring.c_str() );
358         int current = atoi( SWISHCTL_VERSION );
359         if ( !installed ) {
360                 return NO_VER;
361         } else if (installed < current) {
362                 return OLDER_VER;
363         } else if (installed == current) {
364                 return CURRENT_VER;
365         } else {
366                 return NEWER_VER;
367         }
368 }
369
370 bool AllowAutorun()
371 {
372         // look up autorun key for this user.
373         RegKey hkcu(HKEY_CURRENT_USER) ;
374         if (hkcu.OpenKey( registrykey, KEY_READ )) {
375                 string autorun = hkcu.QueryValue( AUTORUN );
376                 if ( autorun != "true") {
377                         return false;
378                 }
379         }
380         return true;
381 }
382
383 DWORD FindFile (char *filename, CDirectory &curdir, CDirectory &destdir)
384 {
385         CWinDirectory win;
386         unsigned int curdirsize = curdir.getSize();
387         unsigned int destdirsize =  destdir.getSize();
388         DWORD result = VerFindFile( VFFF_ISSHAREDFILE,     
389                                                 filename, win.getBuffer(), win.getBuffer(),     //appdir=null - directory for related files
390                                                 curdir.getBuffer(), &curdirsize ,
391                                                 destdir.getBuffer(), &destdirsize);
392
393         return result;
394 }
395
396 bool ConfirmDiskAccessRetry(const char * windir)
397 {
398         char *buff[256] ;
399         sprintf( (char *) buff,
400                 "An error occured trying to write to your Windows drive "
401                 "you don't appear to have the correct access priviledges "
402                 "to write to %s, are you sure you want to replace the file?",
403                 windir
404         );
405
406         int choice = MessageBox(
407                 NULL, // should pass in the dialog box handle
408                 (char *) buff, "Swish Control Installation",
409                 MB_YESNO | MB_DEFBUTTON2 | MB_ICONINFORMATION );
410         return ( choice == IDYES ) ;
411 }
412
413 bool NoSpaceConfirmRetry()
414 {
415         int choice = MessageBox(
416                 NULL, // should pass in the dialog box handle
417                 "Your Windows drive appears to be out of disk space"
418                 " - try emptying your recycle bin or deleting some files "
419                 "and try again...",
420                 "Swish Control Installation",
421                 MB_RETRYCANCEL | MB_DEFBUTTON2 | MB_ICONINFORMATION );
422         return ( choice == IDRETRY ) ;
423 }
424
425 bool InUseConfirmRetry(const char * filename)
426 {
427         char *buff[256] ;
428         sprintf( (char *) buff,
429                 "A file (%s) is in use, please close any open applications and retry.",
430                 filename
431         );
432
433         int choice = MessageBox(
434                 NULL, // should pass in the dialog box handle
435                 (char *) buff, "Swish Control Installation",
436                 MB_RETRYCANCEL | MB_DEFBUTTON2 | MB_ICONINFORMATION );
437         return ( choice == IDRETRY ) ;
438 }
439
440 bool ConfirmOverwriteOlder(const char * filename)
441 {
442         char *buff[256] ;
443         sprintf( (char *) buff,
444                 "An newer version of the file (%s) is already installed "
445                 "are you sure you want to overwrite it?",
446                 filename
447         );
448         int  choice = MessageBox(
449                         NULL, // should pass in the dialog box handle
450                         (char *) buff,
451                         "Swish Control Installation",
452                         MB_YESNO | MB_ICONASTERISK | MB_DEFBUTTON2 );
453         return ( choice == IDYES );
454        
455 }
456
457 void MissingSourceFile( char *filename, char * sourcedir )
458 {
459         char *buff[256] ;
460         sprintf( (char *) buff,
461                 "A required file (%s) is missing from the setup directory (%s). "
462                 "Please obtain an original copy of all the setup files "
463                 " and rerun Setup.",
464                 filename, sourcedir
465         );
466         MessageBox(
467                         NULL, // should pass in the dialog box handle
468                         (char *) buff,
469                         "Swish Control Installation",
470                         MB_OK | MB_ICONASTERISK );
471        
472 }
473
474 bool InstallFile (char * filename,
475                                   CDirectory &SourceDir, CDirectory &DestDir)
476 {
477         CPath TempFile;
478         unsigned int buffsize = TempFile.getSize();
479
480         // ROUND ONE - try a simple install
481         DWORD flags = VIFF_DONTDELETEOLD;
482         DWORD result = VerInstallFile(
483                   flags,       // bit flags that condition function behavior
484                   filename,    // file to install
485                   filename,    // new name of file to install
486                   SourceDir.getBuffer(),    // source directory of file to install
487                   DestDir.getBuffer(),      // directory in which to install file
488                   NULL,        // directory where file is currently installed
489                   TempFile.getBuffer(),     // receives name of temporary copy of file
490                                                                     // used during installation
491                   &buffsize                             // size of string in szTmpFile
492                 );
493
494         while ( result ) {
495                 flags = VIFF_DONTDELETEOLD;
496                 bool retry = false;
497
498                 if ( (result & VIF_FILEINUSE) && InUseConfirmRetry(filename) )
499                 {
500                                 retry = true;
501                 }
502                 else if ( result & VIF_CANNOTREADSRC ) // fatal error
503                 {
504                                 MissingSourceFile(filename, SourceDir.getBuffer());
505                 }
506                 else if ( (result & VIF_SRCOLD ) && ConfirmOverwriteOlder(filename) )
507                 {
508                                 flags |= VIFF_FORCEINSTALL;
509                                 retry = true;
510                
511                 }
512                 else if ( result & VIF_TEMPFILE  ) {
513                         // todo: work out what to do with the tempfile?
514
515                 } else if ( result
516                         & (VIF_SHARINGVIOLATION|VIF_WRITEPROT|VIF_ACCESSVIOLATION) )
517                 {
518                         if ( ConfirmDiskAccessRetry( DestDir.getBuffer() ) ) {
519                                 retry = true;
520                                 flags |= VIFF_FORCEINSTALL;
521                         }
522
523                 } else if ( (result & VIF_OUTOFSPACE) && NoSpaceConfirmRetry()  ) {
524                         retry = true;
525                 }
526                 if ( ! retry ) break;
527                
528                 result = VerInstallFile(
529                   flags, filename,  filename,
530                   SourceDir.getBuffer(), DestDir.getBuffer(),
531                   NULL, TempFile.getBuffer(), &buffsize);
532                
533         }
534         return (result == 0);
535 }
536
537 void ShowRegistrationFailed(HWND hwnd)
538 {
539         MessageBox(
540                         hwnd, // should pass in the dialog box handle
541                         "An (OLE) error occured registering the search application "
542                         "on your system. Setup cannot continue.",
543                         "Swish Control Installation",
544                         MB_OK | MB_ICONASTERISK );
545
546 }
547
548 bool Uninstall( HWND hwnd )
549 {
550         CDirectory curdir, destdir;
551         FindFile( installdlls[SWISHCTL], curdir, destdir );
552
553         CPath swishctlpath = curdir + installdlls[SWISHCTL];
554
555         unregisterOleDll(swishctlpath.getBuffer());
556         UnregisterUninstall();
557
558         BOOL result = DeleteFile( swishctlpath.getBuffer() );
559
560         // don't worry about deleting these too much
561         swishctlpath = curdir + installdlls[PCRE];
562         DeleteFile( swishctlpath.getBuffer() );
563         swishctlpath = curdir + installdlls[PCRE];
564         DeleteFile( swishctlpath.getBuffer() );
565        
566         DeleteShortcuts("index.lnk", "ACC Index");
567        
568         if (result) {
569
570                 MessageBox( hwnd,
571                                 "ACC Index Search Tool has been uninstalled",
572                                 "Swish Control Setup",
573                                 MB_OK
574                            );
575         } else {
576                 MessageBox( hwnd,
577                                 "ACC Index Search Tool has been uninstalled"
578                                 " but some files could not be deleted perhaps"
579                                 " they have been removed already." ,
580                                 "Swish Control Setup",
581                                 MB_OK
582                            );
583         }
584
585         return TRUE;
586 }
587
588
589 bool Install( HWND hwnd )
590 {
591         CDirectory curdir, destdir;
592         CAppDirectory sourcedir(SetupApp::getInstance());
593
594         FindFile( installdlls[SWISHCTL], curdir, destdir );
595         if (!InstallFile( installdlls[SWISHCTL], sourcedir, destdir )) return false;
596
597         CPath swishctlpath = destdir + installdlls[SWISHCTL];
598
599         if (!registerOleDll( swishctlpath.getBuffer()))
600         {
601                 ShowRegistrationFailed(hwnd);
602                 return false;
603         }
604
605
606         if ( ! RegisterIndexFile(sourcedir.getBuffer(), "docs.idx") ) {
607                 MessageBox( hwnd,
608                                 "Setup was not able to write configuration details to "
609                                 "your system registry. Please try running setup again",
610                                 "Swish Control Setup Error",
611                                 MB_OK | MB_ICONEXCLAMATION
612                            );
613                 return false;
614         }
615         FindFile( installdlls[PCRE], curdir, destdir );
616         if (!InstallFile( installdlls[PCRE], sourcedir, destdir )) return false;
617
618         FindFile( installdlls[ZLIB], curdir, destdir );
619         if(!InstallFile( installdlls[ZLIB], sourcedir, destdir )) return false;
620
621         AddShortcut(sourcedir);
622
623         CPath uninstaller = sourcedir + "setup.exe /u";
624         RegisterUninstall(uninstaller.getBuffer());
625
626         MessageBox( hwnd,
627                         "Setup Complete",
628                         "Swish Control Setup",
629                         MB_OK | MB_ICONINFORMATION
630                    );
631         return true;
632 }
633
634
635 #if 0
636 void DoTests()
637 {
638         char curdir[_MAX_PATH];
639         char destdir[_MAX_PATH];
640         UINT curdirlen = _MAX_PATH;
641         UINT destdirlen = _MAX_PATH;
642
643         AppDir appdir;
644         char *ad = appdir.c_str();
645
646         FilePath fp("C:\\CRAP", _MAX_PATH);
647         fp = fp + (const char *)"crap.exe";
648
649         FilePath fp2;
650
651         fp2 = fp2 + (const char *)"whatever";
652
653         fp2 = fp + fp2;
654        
655
656         FilePath fp3(NULL, _MAX_PATH);
657         DWORD copied = GetModuleFileName( SetupApp::getInstance(),
658                 fp3.c_str(), fp3.getSize());
659
660         string fname(_MAX_PATH, '\0');
661
662         copied = GetModuleFileName( SetupApp::getInstance(),
663                 (char *)fname.c_str(), fname.length());
664 }
665 #endif
666
667 bool ConfirmUpgrade()
668 {
669         int  choice = MessageBox(
670                         GetDesktopWindow(), // could try GetDesktopWindow()
671                         "An older version of the search tool is installed."
672                         " Would you like to upgrade?",
673                         "Swish Control Installation",
674                         MB_YESNO | MB_ICONQUESTION );
675         return ( choice == IDYES );
676 }
677
678 BOOL LaunchSearchPage( )
679 {
680         CAppDirectory appdir( SetupApp::getInstance());
681         CPath indexfile = appdir + "index.htm";
682         return LaunchUrl( NULL, indexfile.getBuffer() );       
683
684 }
685
686 // - - - - - - - - - - - - - - - - - - - - - - - - - - -
687 // WinMain
688 // Check the command line and registry options
689 // to decide what to do or whether to do nothing at all!
690 // - - - - - - - - - - - - - - - - - - - - - - - - - - -
691 int APIENTRY WinMain(HINSTANCE hInstance,
692                      HINSTANCE hPrevInstance,
693                      LPSTR     lpCmdLine,
694                      int       nCmdShow)
695 {
696
697        
698         // Perform application initialization:
699         SetupApp _app( hInstance );
700
701         //      TestPathsModule(SetupApp::getInstance());
702         //  DoTests(); return 0;
703
704         // Check for [/u] (uninstall) on command line
705         if ( strstr( lpCmdLine, "/U" ) || strstr( lpCmdLine, "/u" )) {
706                 return Uninstall(NULL);
707         }
708
709         // Check for [/f] (force display of dialog) on command line
710         if ( strstr( lpCmdLine, "/F" )
711                 || strstr( lpCmdLine, "/f" )
712                 || !AppIsRegistered() )
713         {
714                 if( ShowInstallDialog() ) {
715                         LaunchSearchPage ();
716                 }
717                 return 0;
718         }
719
720         switch ( CheckInstalledVersion() ) {
721         case NO_VER:
722                 if( ShowInstallDialog() ) {
723                         LaunchSearchPage ();
724                 }
725                 break;
726         case OLDER_VER:
727                 if ( !ConfirmUpgrade() ) break;
728
729                 if( ShowInstallDialog() ) {
730                         LaunchSearchPage ();
731                 }
732                 break;
733         case CURRENT_VER:
734                 if ( AllowAutorun() )
735                 {
736                         LaunchSearchPage ();
737                 }
738                 break;
739         case NEWER_VER:
740                 if ( AllowAutorun() )
741                 {
742                         LaunchSearchPage ();
743                 }
744                 break;
745         }
746         return 0;
747 }
748
749
750 // Mesage handler for about box.
751 // does the actual install !
752 LRESULT CALLBACK SetupHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
753 {
754         switch (message)
755         {
756                 case WM_INITDIALOG:
757                                 return TRUE;
758
759                 case WM_COMMAND:
760                         if (LOWORD(wParam) == IDOK )
761                         {
762                                 bool autorun =
763                                         (IsDlgButtonChecked (hDlg, IDC_AUTORUN) != BST_CHECKED);
764
765                                 SetAutorun( autorun );
766
767                                 Install( hDlg );
768
769                                 EndDialog(hDlg, (BOOL) autorun );
770                                 return TRUE;                                   
771                         }
772                         else if ( LOWORD(wParam) == IDC_EXIT)
773                         {
774                                 EndDialog(hDlg, FALSE);
775                                 return TRUE;
776                         }
777                         break;
778         }
779     return FALSE;
780 }
781
782
Note: See TracBrowser for help on using the browser.