| | 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, >k_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 | } |
|---|