comparison src/dosinst.c @ 2287:573da4dac306 vim73

Make the dos installer work with more compilers.
author Bram Moolenaar <bram@vim.org>
date Wed, 07 Jul 2010 15:14:03 +0200
parents 144aa6167799
children ccda151dde4e
comparison
equal deleted inserted replaced
2286:144aa6167799 2287:573da4dac306
137 "plugin", 137 "plugin",
138 "syntax", 138 "syntax",
139 }; 139 };
140 140
141 /* 141 /*
142 * Copy a directory name from "dir" to "buf", doubling backslashes.
143 * Also make sure it ends in a double backslash.
144 */
145 static void
146 double_bs(char *dir, char *buf)
147 {
148 char *d = buf;
149 char *s;
150
151 for (s = dir; *s; ++s)
152 {
153 if (*s == '\\')
154 *d++ = '\\';
155 *d++ = *s;
156 }
157 /* when dir is not empty, it must end in a double backslash */
158 if (d > buf && d[-1] != '\\')
159 {
160 *d++ = '\\';
161 *d++ = '\\';
162 }
163 *d = NUL;
164 }
165
166 /*
167 * Obtain a choice from a table. 142 * Obtain a choice from a table.
168 * First entry is a question, others are choices. 143 * First entry is a question, others are choices.
169 */ 144 */
170 static int 145 static int
171 get_choice(char **table, int entries) 146 get_choice(char **table, int entries)
440 fclose(fd); 415 fclose(fd);
441 } 416 }
442 else 417 else
443 { 418 {
444 printf("Failed to open %s\n", fname); 419 printf("Failed to open %s\n", fname);
445 Sleep(2000); 420 sleep(2);
446 } 421 }
447 } 422 }
448 423
449 static int num_windows; 424 static int num_windows;
450 425
580 /* Count the number of windows with a title that match 555 /* Count the number of windows with a title that match
581 * the installer, so that we can check when it's done. 556 * the installer, so that we can check when it's done.
582 * The uninstaller copies itself, executes the copy 557 * The uninstaller copies itself, executes the copy
583 * and exits, thus we can't wait for the process to 558 * and exits, thus we can't wait for the process to
584 * finish. */ 559 * finish. */
585 Sleep(1000); /* wait for uninstaller to start up */ 560 sleep(1); /* wait for uninstaller to start up */
586 num_windows = 0; 561 num_windows = 0;
587 EnumWindows(window_cb, 0); 562 EnumWindows(window_cb, 0);
588 Sleep(1000); /* wait for windows to be counted */ 563 sleep(1); /* wait for windows to be counted */
589 if (num_windows == 0) 564 if (num_windows == 0)
590 { 565 {
591 /* Did not find the uninstaller, ask user to press 566 /* Did not find the uninstaller, ask user to press
592 * Enter when done. Just in case. */ 567 * Enter when done. Just in case. */
593 printf("Press Enter when the uninstaller is finished\n"); 568 printf("Press Enter when the uninstaller is finished\n");
601 { 576 {
602 printf("."); 577 printf(".");
603 fflush(stdout); 578 fflush(stdout);
604 num_windows = 0; 579 num_windows = 0;
605 EnumWindows(window_cb, 0); 580 EnumWindows(window_cb, 0);
606 Sleep(1000); /* wait for windows to be counted */ 581 sleep(1); /* wait for windows to be counted */
607 } while (num_windows > 0); 582 } while (num_windows > 0);
608 } 583 }
609 printf("\nDone!\n"); 584 printf("\nDone!\n");
610 585
611 /* Check if an uninstall reg key was deleted. 586 /* Check if an uninstall reg key was deleted.
1374 choices[choice_count].installfunc = NULL;; 1349 choices[choice_count].installfunc = NULL;;
1375 choices[choice_count].active = (*oldvimrc == NUL); 1350 choices[choice_count].active = (*oldvimrc == NUL);
1376 ++choice_count; 1351 ++choice_count;
1377 } 1352 }
1378 1353
1379 #if defined(DJGPP) || defined(WIN3264) || defined(UNIX_LINT) 1354 #if defined(WIN3264)
1355 /*
1356 * Modern way of creating registry entries, also works on 64 bit windows when
1357 * compiled as a 32 bit program.
1358 */
1359 # ifndef KEY_WOW64_64KEY
1360 # define KEY_WOW64_64KEY 0x0100
1361 # endif
1362
1380 static LONG 1363 static LONG
1381 reg_create_key( 1364 reg_create_key(
1382 HKEY root, 1365 HKEY root,
1383 const char *subkey, 1366 const char *subkey,
1384 PHKEY phKey) 1367 PHKEY phKey)
1523 if (ERROR_SUCCESS == lRet) 1506 if (ERROR_SUCCESS == lRet)
1524 lRet = reg_create_key_and_value(hRootKey, appname, 1507 lRet = reg_create_key_and_value(hRootKey, appname,
1525 "UninstallString", uninstall_string); 1508 "UninstallString", uninstall_string);
1526 return lRet; 1509 return lRet;
1527 } 1510 }
1528 #endif /* if defined(DJGPP) || defined(WIN3264) || defined(UNIX_LINT) */ 1511 #endif /* WIN3264 */
1529 1512
1530 /* 1513 /*
1531 * Add some entries to the registry: 1514 * Add some entries to the registry:
1532 * - to add "Edit with Vim" to the context * menu 1515 * - to add "Edit with Vim" to the context * menu
1533 * - to add Vim to the "Open with..." list 1516 * - to add Vim to the "Open with..." list
1534 * - to uninstall Vim 1517 * - to uninstall Vim
1535 */ 1518 */
1536 /*ARGSUSED*/ 1519 /*ARGSUSED*/
1537 static LONG 1520 static int
1538 install_registry(void) 1521 install_registry(void)
1539 { 1522 {
1523 #ifdef WIN3264
1540 LONG lRet = ERROR_SUCCESS; 1524 LONG lRet = ERROR_SUCCESS;
1541 #if defined(DJGPP) || defined(WIN3264) || defined(UNIX_LINT)
1542 const char *vim_ext_ThreadingModel = "Apartment"; 1525 const char *vim_ext_ThreadingModel = "Apartment";
1543 const char *vim_ext_name = "Vim Shell Extension"; 1526 const char *vim_ext_name = "Vim Shell Extension";
1544 const char *vim_ext_clsid = "{51EEE242-AD87-11d3-9C1E-0090278BBD99}"; 1527 const char *vim_ext_clsid = "{51EEE242-AD87-11d3-9C1E-0090278BBD99}";
1545 char buf[BUFSIZE]; 1528 char buf[BUFSIZE];
1546 char vim_exe_path[BUFSIZE]; 1529 char vim_exe_path[BUFSIZE];
1564 1547
1565 lRet = register_inproc_server( 1548 lRet = register_inproc_server(
1566 HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name, 1549 HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name,
1567 bufg, vim_ext_ThreadingModel); 1550 bufg, vim_ext_ThreadingModel);
1568 if (ERROR_SUCCESS != lRet) 1551 if (ERROR_SUCCESS != lRet)
1569 return lRet; 1552 return FAIL;
1570 lRet = register_shellex( 1553 lRet = register_shellex(
1571 HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name, vim_exe_path); 1554 HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name, vim_exe_path);
1572 if (ERROR_SUCCESS != lRet) 1555 if (ERROR_SUCCESS != lRet)
1573 return lRet; 1556 return FAIL;
1574 } 1557 }
1575 1558
1576 if (install_openwith) 1559 if (install_openwith)
1577 { 1560 {
1578 printf("Creating \"Open with ...\" list entry\n"); 1561 printf("Creating \"Open with ...\" list entry\n");
1579 1562
1580 lRet = register_openwith(HKEY_CLASSES_ROOT, vim_exe_path); 1563 lRet = register_openwith(HKEY_CLASSES_ROOT, vim_exe_path);
1581 if (ERROR_SUCCESS != lRet) 1564 if (ERROR_SUCCESS != lRet)
1582 return lRet; 1565 return FAIL;
1583 } 1566 }
1584 1567
1585 printf("Creating an uninstall entry\n"); 1568 printf("Creating an uninstall entry\n");
1586 1569
1587 /* For the NSIS installer use the generated uninstaller. */ 1570 /* For the NSIS installer use the generated uninstaller. */
1599 lRet = register_uninstall( 1582 lRet = register_uninstall(
1600 HKEY_LOCAL_MACHINE, 1583 HKEY_LOCAL_MACHINE,
1601 "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Vim " VIM_VERSION_SHORT, 1584 "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Vim " VIM_VERSION_SHORT,
1602 display_name, 1585 display_name,
1603 uninstall_string); 1586 uninstall_string);
1604 1587 if (ERROR_SUCCESS != lRet)
1605 #endif /* if defined(DJGPP) || defined(WIN3264) || defined(UNIX_LINT) */ 1588 return FAIL;
1606 return lRet; 1589 #endif /* WIN3264 */
1590
1591 return OK;
1607 } 1592 }
1608 1593
1609 static void 1594 static void
1610 change_popup_choice(int idx) 1595 change_popup_choice(int idx)
1611 { 1596 {
2567 get_vim_env(); 2552 get_vim_env();
2568 2553
2569 /* When nothing found exit quietly. If something found wait for 2554 /* When nothing found exit quietly. If something found wait for
2570 * a little while, so that the user can read the messages. */ 2555 * a little while, so that the user can read the messages. */
2571 if (i) 2556 if (i)
2572 Sleep(3000); 2557 sleep(3);
2573 exit(0); 2558 exit(0);
2574 } 2559 }
2575 #endif 2560 #endif
2576 2561
2577 printf("This program sets up the installation of Vim " 2562 printf("This program sets up the installation of Vim "
2643 command_line_setup_choices(argc, argv); 2628 command_line_setup_choices(argc, argv);
2644 install(); 2629 install();
2645 2630
2646 /* Avoid that the user has to hit Enter, just wait a little bit to 2631 /* Avoid that the user has to hit Enter, just wait a little bit to
2647 * allow reading the messages. */ 2632 * allow reading the messages. */
2648 Sleep(2000); 2633 sleep(2);
2649 } 2634 }
2650 2635
2651 return 0; 2636 return 0;
2652 } 2637 }