Mercurial > emacs
annotate nt/runemacs.c @ 112287:c8102d1f162e
* strokes.el (strokes-read-stroke): Re-fill strokes buffer with
spaces if the frame was resized, so that the full visible buffer
serves as canvas for strokes.
author | Tassilo Horn <tassilo@member.fsf.org> |
---|---|
date | Sun, 16 Jan 2011 21:41:25 +0100 |
parents | ef719132ddfa |
children |
rev | line source |
---|---|
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
1 /* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
75249
4ad431d8e164
Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents:
73541
diff
changeset
|
2 Free Software Foundation, Inc. |
64890
3723093a21fd
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
54773
diff
changeset
|
3 |
3723093a21fd
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
54773
diff
changeset
|
4 This file is part of GNU Emacs. |
3723093a21fd
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
54773
diff
changeset
|
5 |
94795
188974bfdea0
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
79730
diff
changeset
|
6 GNU Emacs is free software: you can redistribute it and/or modify |
64890
3723093a21fd
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
54773
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
94795
188974bfdea0
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
79730
diff
changeset
|
8 the Free Software Foundation, either version 3 of the License, or |
188974bfdea0
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
79730
diff
changeset
|
9 (at your option) any later version. |
64890
3723093a21fd
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
54773
diff
changeset
|
10 |
3723093a21fd
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
54773
diff
changeset
|
11 GNU Emacs is distributed in the hope that it will be useful, |
3723093a21fd
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
54773
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
3723093a21fd
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
54773
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3723093a21fd
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
54773
diff
changeset
|
14 GNU General Public License for more details. |
3723093a21fd
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
54773
diff
changeset
|
15 |
3723093a21fd
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
54773
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
94795
188974bfdea0
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
79730
diff
changeset
|
17 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
64890
3723093a21fd
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
54773
diff
changeset
|
18 |
3723093a21fd
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
54773
diff
changeset
|
19 |
15139 | 20 /* |
21 Simple program to start Emacs with its console window hidden. | |
22 | |
23 This program is provided purely for convenience, since most users will | |
24 use Emacs in windowing (GUI) mode, and will not want to have an extra | |
25 console window lying around. */ | |
26 | |
15320
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
27 /* |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
28 You may want to define this if you want to be able to install updated |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
29 emacs binaries even when other users are using the current version. |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
30 The problem with some file servers (notably Novell) is that an open |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
31 file cannot be overwritten, deleted, or even renamed. So if someone |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
32 is running emacs.exe already, you cannot install a newer version. |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
33 By defining CHOOSE_NEWEST_EXE, you can name your new emacs.exe |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
34 something else which matches "emacs*.exe", and runemacs will |
73541
964e568f1d1d
(WinMain): Process all recognized arguments, not just the first one.
Juanma Barranquero <lekktu@gmail.com>
parents:
69378
diff
changeset
|
35 automatically select the newest emacs executable in the bin directory. |
15320
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
36 (So you'll probably be able to delete the old version some hours/days |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
37 later). |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
38 */ |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
39 |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
40 /* #define CHOOSE_NEWEST_EXE */ |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
41 |
15139 | 42 #include <windows.h> |
43 #include <string.h> | |
44 #include <malloc.h> | |
45 | |
109516
68ca98ae70fb
Make building under stricter warning flags somewhat cleaner.
Juanma Barranquero <lekktu@gmail.com>
parents:
109480
diff
changeset
|
46 static void set_user_model_id (void); |
103641
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
47 |
15139 | 48 int WINAPI |
49 WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow) | |
50 { | |
51 STARTUPINFO start; | |
52 SECURITY_ATTRIBUTES sec_attrs; | |
53 PROCESS_INFORMATION child; | |
54 int wait_for_child = FALSE; | |
19720
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
55 DWORD priority_class = NORMAL_PRIORITY_CLASS; |
15139 | 56 DWORD ret_code = 0; |
15320
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
57 char *new_cmdline; |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
58 char *p; |
15139 | 59 char modname[MAX_PATH]; |
60 | |
103641
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
61 set_user_model_id (); |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
62 |
15139 | 63 if (!GetModuleFileName (NULL, modname, MAX_PATH)) |
64 goto error; | |
65 if ((p = strrchr (modname, '\\')) == NULL) | |
66 goto error; | |
67 *p = 0; | |
68 | |
38139
b2e0c0638bf2
(WinMain): Add quotes around executable name.
Jason Rumney <jasonr@gnu.org>
parents:
31089
diff
changeset
|
69 new_cmdline = alloca (MAX_PATH + strlen (cmdline) + 3); |
b2e0c0638bf2
(WinMain): Add quotes around executable name.
Jason Rumney <jasonr@gnu.org>
parents:
31089
diff
changeset
|
70 /* Quote executable name in case of spaces in the path. */ |
b2e0c0638bf2
(WinMain): Add quotes around executable name.
Jason Rumney <jasonr@gnu.org>
parents:
31089
diff
changeset
|
71 *new_cmdline = '"'; |
b2e0c0638bf2
(WinMain): Add quotes around executable name.
Jason Rumney <jasonr@gnu.org>
parents:
31089
diff
changeset
|
72 strcpy (new_cmdline + 1, modname); |
15320
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
73 |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
74 #ifdef CHOOSE_NEWEST_EXE |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
75 { |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
76 /* Silly hack to allow new versions to be installed on |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
77 server even when current version is in use. */ |
15139 | 78 |
15320
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
79 char * best_name = alloca (MAX_PATH + 1); |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
80 FILETIME best_time = {0,0}; |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
81 WIN32_FIND_DATA wfd; |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
82 HANDLE fh; |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
83 p = new_cmdline + strlen (new_cmdline); |
38139
b2e0c0638bf2
(WinMain): Add quotes around executable name.
Jason Rumney <jasonr@gnu.org>
parents:
31089
diff
changeset
|
84 strcpy (p, "\\emacs*.exe\" "); |
15320
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
85 fh = FindFirstFile (new_cmdline, &wfd); |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
86 if (fh == INVALID_HANDLE_VALUE) |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
87 goto error; |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
88 do |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
89 { |
73541
964e568f1d1d
(WinMain): Process all recognized arguments, not just the first one.
Juanma Barranquero <lekktu@gmail.com>
parents:
69378
diff
changeset
|
90 if (wfd.ftLastWriteTime.dwHighDateTime > best_time.dwHighDateTime |
964e568f1d1d
(WinMain): Process all recognized arguments, not just the first one.
Juanma Barranquero <lekktu@gmail.com>
parents:
69378
diff
changeset
|
91 || (wfd.ftLastWriteTime.dwHighDateTime == best_time.dwHighDateTime |
964e568f1d1d
(WinMain): Process all recognized arguments, not just the first one.
Juanma Barranquero <lekktu@gmail.com>
parents:
69378
diff
changeset
|
92 && wfd.ftLastWriteTime.dwLowDateTime > best_time.dwLowDateTime)) |
964e568f1d1d
(WinMain): Process all recognized arguments, not just the first one.
Juanma Barranquero <lekktu@gmail.com>
parents:
69378
diff
changeset
|
93 { |
964e568f1d1d
(WinMain): Process all recognized arguments, not just the first one.
Juanma Barranquero <lekktu@gmail.com>
parents:
69378
diff
changeset
|
94 best_time = wfd.ftLastWriteTime; |
964e568f1d1d
(WinMain): Process all recognized arguments, not just the first one.
Juanma Barranquero <lekktu@gmail.com>
parents:
69378
diff
changeset
|
95 strcpy (best_name, wfd.cFileName); |
964e568f1d1d
(WinMain): Process all recognized arguments, not just the first one.
Juanma Barranquero <lekktu@gmail.com>
parents:
69378
diff
changeset
|
96 } |
15320
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
97 } |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
98 while (FindNextFile (fh, &wfd)); |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
99 FindClose (fh); |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
100 *p++ = '\\'; |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
101 strcpy (p, best_name); |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
102 strcat (p, " "); |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
103 } |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
104 #else |
38139
b2e0c0638bf2
(WinMain): Add quotes around executable name.
Jason Rumney <jasonr@gnu.org>
parents:
31089
diff
changeset
|
105 strcat (new_cmdline, "\\emacs.exe\" "); |
15320
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
106 #endif |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
107 |
19720
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
108 /* Append original arguments if any; first look for arguments we |
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
109 recognise (-wait, -high, and -low), and apply them ourselves. */ |
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
110 while (cmdline[0] == '-' || cmdline[0] == '/') |
15320
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
111 { |
19720
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
112 if (strncmp (cmdline+1, "wait", 4) == 0) |
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
113 { |
73541
964e568f1d1d
(WinMain): Process all recognized arguments, not just the first one.
Juanma Barranquero <lekktu@gmail.com>
parents:
69378
diff
changeset
|
114 wait_for_child = TRUE; |
964e568f1d1d
(WinMain): Process all recognized arguments, not just the first one.
Juanma Barranquero <lekktu@gmail.com>
parents:
69378
diff
changeset
|
115 cmdline += 5; |
964e568f1d1d
(WinMain): Process all recognized arguments, not just the first one.
Juanma Barranquero <lekktu@gmail.com>
parents:
69378
diff
changeset
|
116 } |
19720
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
117 else if (strncmp (cmdline+1, "high", 4) == 0) |
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
118 { |
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
119 priority_class = HIGH_PRIORITY_CLASS; |
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
120 cmdline += 5; |
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
121 } |
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
122 else if (strncmp (cmdline+1, "low", 3) == 0) |
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
123 { |
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
124 priority_class = IDLE_PRIORITY_CLASS; |
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
125 cmdline += 4; |
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
126 } |
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
127 else |
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
128 break; |
73541
964e568f1d1d
(WinMain): Process all recognized arguments, not just the first one.
Juanma Barranquero <lekktu@gmail.com>
parents:
69378
diff
changeset
|
129 /* Look for next argument. */ |
964e568f1d1d
(WinMain): Process all recognized arguments, not just the first one.
Juanma Barranquero <lekktu@gmail.com>
parents:
69378
diff
changeset
|
130 while (*++cmdline == ' '); |
19720
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
131 } |
73541
964e568f1d1d
(WinMain): Process all recognized arguments, not just the first one.
Juanma Barranquero <lekktu@gmail.com>
parents:
69378
diff
changeset
|
132 |
15139 | 133 strcat (new_cmdline, cmdline); |
134 | |
15320
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
135 /* Set emacs_dir variable if runemacs was in "%emacs_dir%\bin". */ |
15139 | 136 if ((p = strrchr (modname, '\\')) && stricmp (p, "\\bin") == 0) |
15320
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
137 { |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
138 *p = 0; |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
139 for (p = modname; *p; p++) |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
140 if (*p == '\\') *p = '/'; |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
141 SetEnvironmentVariable ("emacs_dir", modname); |
b76f57d4320b
(CHOOSE_NEWEST_EXE): New parameter macro.
Richard M. Stallman <rms@gnu.org>
parents:
15139
diff
changeset
|
142 } |
15139 | 143 |
144 memset (&start, 0, sizeof (start)); | |
145 start.cb = sizeof (start); | |
69378
45fbf2b25e1a
(WinMain): Set screen buffer to 80x25.
Jason Rumney <jasonr@gnu.org>
parents:
68648
diff
changeset
|
146 start.dwFlags = STARTF_USESHOWWINDOW | STARTF_USECOUNTCHARS; |
15139 | 147 start.wShowWindow = SW_HIDE; |
69378
45fbf2b25e1a
(WinMain): Set screen buffer to 80x25.
Jason Rumney <jasonr@gnu.org>
parents:
68648
diff
changeset
|
148 /* Ensure that we don't waste memory if the user has specified a huge |
45fbf2b25e1a
(WinMain): Set screen buffer to 80x25.
Jason Rumney <jasonr@gnu.org>
parents:
68648
diff
changeset
|
149 default screen buffer for command windows. */ |
45fbf2b25e1a
(WinMain): Set screen buffer to 80x25.
Jason Rumney <jasonr@gnu.org>
parents:
68648
diff
changeset
|
150 start.dwXCountChars = 80; |
45fbf2b25e1a
(WinMain): Set screen buffer to 80x25.
Jason Rumney <jasonr@gnu.org>
parents:
68648
diff
changeset
|
151 start.dwYCountChars = 25; |
15139 | 152 |
153 sec_attrs.nLength = sizeof (sec_attrs); | |
154 sec_attrs.lpSecurityDescriptor = NULL; | |
155 sec_attrs.bInheritHandle = FALSE; | |
156 | |
19720
8d429173786f
(WinMain): Allow Emacs process to be started with
Geoff Voelker <voelker@cs.washington.edu>
parents:
15848
diff
changeset
|
157 if (CreateProcess (NULL, new_cmdline, &sec_attrs, NULL, TRUE, priority_class, |
54773
a4825fc03ab1
(WinMain): Let emacs environment default to parent.
Jason Rumney <jasonr@gnu.org>
parents:
52401
diff
changeset
|
158 NULL, NULL, &start, &child)) |
15139 | 159 { |
160 if (wait_for_child) | |
161 { | |
162 WaitForSingleObject (child.hProcess, INFINITE); | |
163 GetExitCodeProcess (child.hProcess, &ret_code); | |
164 } | |
165 CloseHandle (child.hThread); | |
166 CloseHandle (child.hProcess); | |
167 } | |
168 else | |
169 goto error; | |
170 return (int) ret_code; | |
171 | |
172 error: | |
173 MessageBox (NULL, "Could not start Emacs.", "Error", MB_ICONSTOP); | |
174 return 1; | |
175 } | |
52401 | 176 |
109480
d12162869c07
Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
177 void |
d12162869c07
Convert some more functions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
178 set_user_model_id (void) |
103641
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
179 { |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
180 HMODULE shell; |
103716
7bad97f82eb6
* w32term.c (w32_initialize): Use standard types.
Jason Rumney <jasonr@gnu.org>
parents:
103641
diff
changeset
|
181 HRESULT (WINAPI * set_user_model) (wchar_t * id); |
103641
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
182 |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
183 /* On Windows 7 and later, we need to set the user model ID |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
184 to associate emacsclient launched files with Emacs frames |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
185 in the UI. */ |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
186 shell = LoadLibrary ("shell32.dll"); |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
187 if (shell) |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
188 { |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
189 set_user_model |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
190 = (void *) GetProcAddress (shell, |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
191 "SetCurrentProcessExplicitAppUserModelID"); |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
192 |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
193 /* If the function is defined, then we are running on Windows 7 |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
194 or newer, and the UI uses this to group related windows |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
195 together. Since emacs, runemacs, emacsclient are related, we |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
196 want them grouped even though the executables are different, |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
197 so we need to set a consistent ID between them. */ |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
198 if (set_user_model) |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
199 set_user_model (L"GNU.Emacs"); |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
200 |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
201 FreeLibrary (shell); |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
202 } |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
203 } |
48d529d3a5a4
bug#1849 - Windows 7 Taskbar Support
Jason Rumney <jasonr@gnu.org>
parents:
100954
diff
changeset
|
204 |