Changeset 4220 for trunk/nt/addpm.c

Show
Ignore:
Timestamp:
2008年04月04日 22時04分40秒 (8 months ago)
Author:
miyoshi
Message:

Sync up with Emacs22.2.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/nt/addpm.c

    r4190 r4220  
    11/* Add entries to the GNU Emacs Program Manager folder. 
    22   Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005, 
    3       2006, 2007  Free Software Foundation, Inc. 
     3      2006, 2007, 2008  Free Software Foundation, Inc. 
    44 
    55This file is part of GNU Emacs. 
     
    77GNU Emacs is free software; you can redistribute it and/or modify 
    88it under the terms of the GNU General Public License as published by 
    9 the Free Software Foundation; either version 2, or (at your option) 
     9the Free Software Foundation; either version 3, or (at your option) 
    1010any later version. 
    1111 
     
    3333#include <stdlib.h> 
    3434#include <stdio.h> 
     35#include <malloc.h> 
    3536 
    3637HDDEDATA CALLBACK 
     
    4748 
    4849#define REG_ROOT "SOFTWARE\\GNU\\Emacs" 
     50#define REG_GTK "SOFTWARE\\GTK\\2.0" 
     51#define REG_APP_PATH \ 
     52  "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\emacs.exe" 
    4953 
    5054static struct entry 
     
    7478  int i; 
    7579  BOOL ok = TRUE; 
     80  DWORD size; 
     81 
     82  /* Record the location of Emacs to the App Paths key if we have 
     83     sufficient permissions to do so.  This helps Windows find emacs quickly 
     84     if the user types emacs.exe in the "Run Program" dialog without having 
     85     emacs on their path.  Some applications also use the same registry key 
     86     to discover the installation directory for programs they are looking for. 
     87     Multiple installations cannot be handled by this method, but it does not 
     88     affect the general operation of other installations of Emacs, and we 
     89     are blindly overwriting the Start Menu entries already. 
     90  */ 
     91  if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, REG_APP_PATH, 0, "",  
     92                      REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, 
     93                      &hrootkey, NULL) == ERROR_SUCCESS) 
     94    { 
     95      int len; 
     96      char *emacs_path; 
     97      HKEY gtk_key = NULL; 
     98 
     99      len = strlen (path) + 15; /* \bin\emacs.exe + terminator.  */ 
     100      emacs_path = (char *) alloca (len); 
     101      sprintf (emacs_path, "%s\\bin\\emacs.exe", path); 
     102 
     103      RegSetValueEx (hrootkey, NULL, 0, REG_SZ, emacs_path, len); 
     104 
     105      /* Look for a GTK installation. If found, add it to the library search 
     106         path for Emacs so that the image libraries it provides are available 
     107         to Emacs regardless of whether it is in the path or not.  */ 
     108      if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, REG_GTK, REG_OPTION_NON_VOLATILE, 
     109                        KEY_READ, &gtk_key) == ERROR_SUCCESS) 
     110        { 
     111          if (RegQueryValueEx (gtk_key, "DllPath", NULL, NULL, 
     112                               NULL, &size) == ERROR_SUCCESS) 
     113            { 
     114              char *gtk_path = (char *) alloca (size); 
     115              if (RegQueryValueEx (gtk_key, "DllPath", NULL, NULL, 
     116                                   gtk_path, &size) == ERROR_SUCCESS) 
     117                { 
     118                  /* Make sure the emacs bin directory continues to be searched 
     119                     first by including it as well.  */ 
     120                  char *dll_paths; 
     121                  len = strlen (path) + 5 + size; 
     122                  dll_paths = (char *) alloca (size + strlen (path) + 1); 
     123                  sprintf (dll_paths, "%s\\bin;%s", path, gtk_path); 
     124                  RegSetValueEx (hrootkey, "Path", 0, REG_SZ, dll_paths, len); 
     125                } 
     126            } 
     127          RegCloseKey (gtk_key); 
     128        } 
     129      RegCloseKey (hrootkey); 
     130    } 
    76131 
    77132  /* Previous versions relied on registry settings, but we do not need