diff options
| author | Geoff Voelker | 1995-06-10 02:24:19 +0000 |
|---|---|---|
| committer | Geoff Voelker | 1995-06-10 02:24:19 +0000 |
| commit | cef9e134b1f71fa66ec69c9b31542d262c17ddeb (patch) | |
| tree | da2d93792175803a51aac6513ecc707e0f32a43e | |
| parent | 01b96d5c134b42cfe943c32b4de1013e96957bd8 (diff) | |
| download | emacs-cef9e134b1f71fa66ec69c9b31542d262c17ddeb.tar.gz emacs-cef9e134b1f71fa66ec69c9b31542d262c17ddeb.zip | |
Initial revision
| -rw-r--r-- | nt/addpm.c | 193 | ||||
| -rw-r--r-- | nt/emacs.bat.in | 38 |
2 files changed, 231 insertions, 0 deletions
diff --git a/nt/addpm.c b/nt/addpm.c new file mode 100644 index 00000000000..395748f8a05 --- /dev/null +++ b/nt/addpm.c | |||
| @@ -0,0 +1,193 @@ | |||
| 1 | /* Add entries to the GNU Emacs Program Manager folder. | ||
| 2 | Copyright (C) 1995 Free Software Foundation, Inc. | ||
| 3 | |||
| 4 | This file is part of GNU Emacs. | ||
| 5 | |||
| 6 | GNU Emacs is free software; you can redistribute it and/or modify it | ||
| 7 | under the terms of the GNU General Public License as published by the | ||
| 8 | Free Software Foundation; either version 2, or (at your option) any later | ||
| 9 | version. | ||
| 10 | |||
| 11 | GNU Emacs is distributed in the hope that it will be useful, but WITHOUT | ||
| 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 14 | more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License along | ||
| 17 | with GNU Emacs; see the file COPYING. If not, write to the Free Software | ||
| 18 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /* addpm: Adds entries to the GNU Emacs Program Manager folder. | ||
| 22 | |||
| 23 | argv[1] = full path to program to execute | ||
| 24 | argv[2] = full path to icon for emacs (optional) | ||
| 25 | */ | ||
| 26 | |||
| 27 | #include <windows.h> // required for all Windows applications | ||
| 28 | #include <ddeml.h> // required for DDEML | ||
| 29 | #include <string.h> // required for strcpy and strlen | ||
| 30 | |||
| 31 | HDDEDATA EXPENTRY dde_callback (WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD); | ||
| 32 | BOOL send_shell_command (DWORD, LPSTR); | ||
| 33 | |||
| 34 | // Global variables | ||
| 35 | HANDLE gh_inst; // current instance | ||
| 36 | |||
| 37 | /**************************************************************************** | ||
| 38 | FUNCTION: WinMain() | ||
| 39 | |||
| 40 | PURPOSE: Calls initialization function, processes message loop | ||
| 41 | |||
| 42 | PARAMETERS: | ||
| 43 | HANDLE h_instance | ||
| 44 | HANDLE h_prev_instance | ||
| 45 | LPSTR lp_cmd_line | ||
| 46 | int n_cmd_show | ||
| 47 | |||
| 48 | RETURNS: | ||
| 49 | int | ||
| 50 | ****************************************************************************/ | ||
| 51 | |||
| 52 | int PASCAL | ||
| 53 | WinMain (HANDLE h_instance, // current instance | ||
| 54 | HANDLE h_prev_instance, // previous instance | ||
| 55 | LPSTR lp_cmd_line, // command line | ||
| 56 | int n_cmd_show) // show-window type (open/icon) | ||
| 57 | { | ||
| 58 | DWORD id_inst = 0L; // instance identifier | ||
| 59 | FARPROC lp_dde_proc; | ||
| 60 | char *path, *icon, *s; | ||
| 61 | char additem[MAX_PATH*2 + 100]; | ||
| 62 | |||
| 63 | gh_inst = h_instance; | ||
| 64 | |||
| 65 | for (path = NULL, s = lp_cmd_line; *s && isspace (*s); s++); | ||
| 66 | if (*s) | ||
| 67 | { | ||
| 68 | path = s; | ||
| 69 | while (*s && !isspace (*s)) | ||
| 70 | s++; | ||
| 71 | if (*s) | ||
| 72 | *(s++) = '\0'; | ||
| 73 | } | ||
| 74 | for (icon = NULL; *s && isspace (*s); s++); | ||
| 75 | if (*s) | ||
| 76 | { | ||
| 77 | icon = s; | ||
| 78 | while (*s && !isspace (*s)) | ||
| 79 | s++; | ||
| 80 | if (*s) | ||
| 81 | *(s++) = '\0'; | ||
| 82 | } | ||
| 83 | |||
| 84 | lp_dde_proc = MakeProcInstance ((FARPROC) dde_callback, gh_inst); | ||
| 85 | |||
| 86 | DdeInitialize (&id_inst, // receives instance ID | ||
| 87 | (PFNCALLBACK) lp_dde_proc, // address of callback function | ||
| 88 | APPCMD_CLIENTONLY, // this is a client app | ||
| 89 | 0L); // reserved | ||
| 90 | |||
| 91 | send_shell_command (id_inst, (LPSTR) "[CreateGroup(Gnu Emacs)]"); | ||
| 92 | |||
| 93 | send_shell_command (id_inst, (LPSTR) "[ReplaceItem(Emacs)]"); | ||
| 94 | |||
| 95 | sprintf (additem, "[AddItem(%s,Emacs%c%s)]", | ||
| 96 | path, (icon ? ',' : ' '), (icon ? icon : "")); | ||
| 97 | send_shell_command (id_inst, additem); | ||
| 98 | |||
| 99 | DdeUninitialize (id_inst); | ||
| 100 | |||
| 101 | return (0); | ||
| 102 | } | ||
| 103 | |||
| 104 | |||
| 105 | /**************************************************************************** | ||
| 106 | FUNCTION: dde_callback() | ||
| 107 | |||
| 108 | PURPOSE: Processes messages for DDEML conversation | ||
| 109 | |||
| 110 | PARAMETERS: | ||
| 111 | WORD w_type | ||
| 112 | WORD w_fmt | ||
| 113 | HCONV h_conv | ||
| 114 | HSZ hsz1 | ||
| 115 | HSZ hsz2 | ||
| 116 | HDDEDATA h_data | ||
| 117 | DWORD dw_data1 | ||
| 118 | DWORD dw_data2 | ||
| 119 | |||
| 120 | RETURNS: | ||
| 121 | HDDEDATA | ||
| 122 | ****************************************************************************/ | ||
| 123 | |||
| 124 | HDDEDATA EXPENTRY | ||
| 125 | dde_callback (WORD w_type, // transaction type | ||
| 126 | WORD w_fmt, // clipboard format | ||
| 127 | HCONV h_conv, // handle of the conversation | ||
| 128 | HSZ hsz1, // handle of a string | ||
| 129 | HSZ hsz2, // handle of a string | ||
| 130 | HDDEDATA h_data, // handle of a global memory object | ||
| 131 | DWORD dw_data1, // transaction-specific data | ||
| 132 | DWORD dw_data2) // transaction-specific data | ||
| 133 | { | ||
| 134 | // Nothing need be done here... | ||
| 135 | return (HDDEDATA) NULL; | ||
| 136 | } | ||
| 137 | |||
| 138 | |||
| 139 | /**************************************************************************** | ||
| 140 | FUNCTION: send_shell_command() | ||
| 141 | |||
| 142 | PURPOSE: Sends the given command string to Program Manager | ||
| 143 | |||
| 144 | PARAMETERS: | ||
| 145 | LPSTR - pointer to command string | ||
| 146 | |||
| 147 | RETURNS: | ||
| 148 | BOOL - TRUE if this function succeeds, FALSE otherwise | ||
| 149 | ****************************************************************************/ | ||
| 150 | |||
| 151 | BOOL | ||
| 152 | send_shell_command (DWORD id_inst, // instance identifier | ||
| 153 | LPSTR lp_command) // command string to execute | ||
| 154 | { | ||
| 155 | HSZ hsz_serv_top; // Service and Topic name are "PROGMAN" | ||
| 156 | HCONV hconv; // handle of conversation | ||
| 157 | int n_len; // length of command string | ||
| 158 | HDDEDATA h_data; // return value of DdeClientTransaction | ||
| 159 | DWORD dw_result; // result of transaction | ||
| 160 | BOOL b_result = FALSE; // TRUE if this function is successful | ||
| 161 | |||
| 162 | // create string handle to service/topic | ||
| 163 | hsz_serv_top = DdeCreateStringHandle (id_inst, "PROGMAN", CP_WINANSI); | ||
| 164 | |||
| 165 | // attempt to start conversation with server app | ||
| 166 | if ((hconv = DdeConnect (id_inst, hsz_serv_top, hsz_serv_top, NULL)) | ||
| 167 | != (HCONV) NULL) | ||
| 168 | { | ||
| 169 | // get length of the command string | ||
| 170 | n_len = lstrlen ((LPSTR) lp_command); | ||
| 171 | |||
| 172 | // send command to server app | ||
| 173 | h_data = DdeClientTransaction ((LPBYTE) lp_command, // data to pass | ||
| 174 | n_len + 1, // length of data | ||
| 175 | hconv, // handle of conversation | ||
| 176 | (HCONV) NULL, // handle of name-string | ||
| 177 | CF_TEXT, // clipboard format | ||
| 178 | XTYP_EXECUTE, // transaction type | ||
| 179 | 1000, // timeout duration | ||
| 180 | &dw_result); // transaction result | ||
| 181 | |||
| 182 | if (h_data) | ||
| 183 | b_result = TRUE; | ||
| 184 | |||
| 185 | // end conversation | ||
| 186 | DdeDisconnect (hconv); | ||
| 187 | } | ||
| 188 | |||
| 189 | // free service/topic string handle | ||
| 190 | DdeFreeStringHandle (id_inst, hsz_serv_top); | ||
| 191 | |||
| 192 | return b_result; | ||
| 193 | } | ||
diff --git a/nt/emacs.bat.in b/nt/emacs.bat.in new file mode 100644 index 00000000000..2894971516d --- /dev/null +++ b/nt/emacs.bat.in | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | |||
| 2 | REM Here begins emacs.bat.in | ||
| 3 | |||
| 4 | REM Set OS specific values. | ||
| 5 | set ARCH_SAVE=%PROCESSOR_ARCHITECTURE% | ||
| 6 | set PROCESSOR_ARCHITECTURE= | ||
| 7 | if "%ARCH_SAVE%" == "%PROCESSOR_ARCHITECTURE%" goto win95 | ||
| 8 | set PROCESSOR_ARCHITECTURE=%ARCH_SAVE% | ||
| 9 | set SHELL=cmd | ||
| 10 | goto next | ||
| 11 | |||
| 12 | :win95 | ||
| 13 | set SHELL=command | ||
| 14 | |||
| 15 | :next | ||
| 16 | |||
| 17 | set EMACSLOADPATH=%emacs_dir%\lisp | ||
| 18 | set EMACSDATA=%emacs_dir%\etc | ||
| 19 | set EMACSPATH=%emacs_dir%\bin | ||
| 20 | set EMACSLOCKDIR=%emacs_dir%\lock | ||
| 21 | set INFOPATH=%emacs_dir%\info | ||
| 22 | set EMACSDOC=%emacs_dir%\etc | ||
| 23 | set TERM=CMD | ||
| 24 | |||
| 25 | REM The variable HOME is used to find the startup file, ~\_emacs. Ideally, | ||
| 26 | REM this will not be set in this file but should already be set before | ||
| 27 | REM this file is invoked. If HOME is not set, use some generic default. | ||
| 28 | |||
| 29 | set HOME_SAVE=%HOME% | ||
| 30 | set HOME_EXISTS=yes | ||
| 31 | set HOME_DEFAULT=C:\ | ||
| 32 | set HOME= | ||
| 33 | if "%HOME%" == "%HOME_SAVE%" set HOME_EXISTS=no | ||
| 34 | if "%HOME_EXISTS%" == "yes" set HOME=%HOME_SAVE% | ||
| 35 | if "%HOME_EXISTS%" == "no" set HOME=%HOME_DEFAULT% | ||
| 36 | if "%HOME_EXISTS%" == "no" echo HOME is not set! Using %HOME% as a default... | ||
| 37 | |||
| 38 | %emacs_dir%\bin\emacs.exe %1 %2 %3 %4 %5 %6 %7 %8 %9 | ||