comparison nt/addpm.c @ 19396:d0ffa428c6e3

(env_vars): Set SHELL to cmdproxy. (main): Initialize idDde to 0. Determine emacs_path from module file name. Prompt for install.
author Geoff Voelker <voelker@cs.washington.edu>
date Sun, 17 Aug 1997 01:44:27 +0000
parents 0a7ce510e9c5
children 11f3ea181591
comparison
equal deleted inserted replaced
19395:cf115b0c7458 19396:d0ffa428c6e3
53 } 53 }
54 env_vars[] = 54 env_vars[] =
55 { 55 {
56 {"emacs_dir", NULL}, 56 {"emacs_dir", NULL},
57 {"EMACSLOADPATH", "%emacs_dir%/lisp;%emacs_dir%/site-lisp"}, 57 {"EMACSLOADPATH", "%emacs_dir%/lisp;%emacs_dir%/site-lisp"},
58 {"SHELL", "%COMSPEC%"}, 58 {"SHELL", "%emacs_dir/bin/cmdproxy.exe%"},
59 {"EMACSDATA", "%emacs_dir%/etc"}, 59 {"EMACSDATA", "%emacs_dir%/etc"},
60 {"EMACSPATH", "%emacs_dir%/bin"}, 60 {"EMACSPATH", "%emacs_dir%/bin"},
61 {"EMACSLOCKDIR", "%emacs_dir%/lock"}, 61 {"EMACSLOCKDIR", "%emacs_dir%/lock"},
62 {"INFOPATH", "%emacs_dir%/info"}, 62 {"INFOPATH", "%emacs_dir%/info"},
63 {"EMACSDOC", "%emacs_dir%/etc"}, 63 {"EMACSDOC", "%emacs_dir%/etc"},
104 int 104 int
105 main (argc, argv) 105 main (argc, argv)
106 int argc; 106 int argc;
107 char *argv[]; 107 char *argv[];
108 { 108 {
109 DWORD idDde; 109 DWORD idDde = 0;
110 HCONV HConversation; 110 HCONV HConversation;
111 HSZ ProgMan; 111 HSZ ProgMan;
112 char modname[MAX_PATH];
112 char additem[MAX_PATH*2 + 100]; 113 char additem[MAX_PATH*2 + 100];
113 char *lpext; 114 char *lpext;
115 char *emacs_path;
116 char *p;
114 117
118 /* If no args specified, use our location to set emacs_path. */
119 #if 0
115 if (argc < 2 || argc > 3) 120 if (argc < 2 || argc > 3)
116 { 121 {
117 fprintf (stderr, "usage: addpm emacs_path [icon_path]\n"); 122 fprintf (stderr, "usage: addpm emacs_path [icon_path]\n");
118 exit (1); 123 exit (1);
119 } 124 }
125 #endif
120 126
121 lpext = add_registry (argv[1]) ? "exe" : "bat"; 127 if (argc > 1)
128 emacs_path = argv[1];
129 else
130 {
131 if (!GetModuleFileName (NULL, modname, MAX_PATH) ||
132 (p = strrchr (modname, '\\')) == NULL)
133 {
134 fprintf (stderr, "fatal error");
135 exit (1);
136 }
137 *p = 0;
138
139 /* Set emacs_path to emacs_dir if we are in "%emacs_dir%\bin". */
140 if ((p = strrchr (modname, '\\')) && stricmp (p, "\\bin") == 0)
141 {
142 *p = 0;
143 emacs_path = modname;
144 }
145 else
146 {
147 fprintf (stderr, "usage: addpm emacs_path [icon_path]\n");
148 exit (1);
149 }
150
151 /* Tell user what we are going to do. */
152 {
153 char msg[ MAX_PATH ];
154 sprintf (msg, "Install Emacs at %s?\n", emacs_path);
155 if (!MessageBox (NULL, msg, "Install Emacs", MB_OKCANCEL | MB_ICONQUESTION))
156 {
157 fprintf (stderr, "Install cancelled\n");
158 exit (1);
159 }
160 }
161 }
162
163 lpext = add_registry (emacs_path) ? "exe" : "bat";
122 164
123 DdeInitialize (&idDde, (PFNCALLBACK)DdeCallback, APPCMD_CLIENTONLY, 0); 165 DdeInitialize (&idDde, (PFNCALLBACK)DdeCallback, APPCMD_CLIENTONLY, 0);
124 166
125 ProgMan = DdeCreateStringHandle (idDde, "PROGMAN", CP_WINANSI); 167 ProgMan = DdeCreateStringHandle (idDde, "PROGMAN", CP_WINANSI);
126 168
127 if (HConversation = DdeConnect (idDde, ProgMan, ProgMan, NULL)) 169 if (HConversation = DdeConnect (idDde, ProgMan, ProgMan, NULL))
128 { 170 {
129 DdeCommand ("[CreateGroup (Gnu Emacs)]"); 171 DdeCommand ("[CreateGroup (Gnu Emacs)]");
130 DdeCommand ("[ReplaceItem (Emacs)]"); 172 DdeCommand ("[ReplaceItem (Emacs)]");
131 sprintf (additem, "[AddItem (%s\\bin\\runemacs.%s, Emacs%c%s)]", 173 sprintf (additem, "[AddItem (%s\\bin\\runemacs.%s, Emacs%c%s)]",
132 argv[1], lpext, (argc>2 ? ',' : ' '), 174 emacs_path, lpext, (argc>2 ? ',' : ' '),
133 (argc>2 ? argv[2] : "")); 175 (argc>2 ? argv[2] : ""));
134 DdeCommand (additem); 176 DdeCommand (additem);
135 177
136 DdeDisconnect (HConversation); 178 DdeDisconnect (HConversation);
137 } 179 }