source: git/src/editwrap.c @ 53e12ee

RELEASE/1.2debug-cidebug-ci-sanitisersstereowalls-data
Last change on this file since 53e12ee was 53e12ee, checked in by Olly Betts <olly@…>, 13 years ago

src/editwrap.c: Convert to use wide-character Unicode.

git-svn-id: file:///home/survex-svn/survex/trunk@3558 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/* editwrap.c
2 * Run svxedit.tcl from the same directory as this program
3 * Copyright (C) 2002,2010 Olly Betts
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 */
19
20#ifdef HAVE_CONFIG_H
21#include <config.h>
22#endif
23
24#include <stdlib.h>
25#include <string.h>
26#include <windows.h>
27
28int APIENTRY
29WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
30{
31   DWORD len = 256;
32   wchar_t *buf = NULL, *p;
33   PWSTR cmd_line;
34   hInst = hInst; /* suppress compiler warning */
35   hPrevInst = hPrevInst; /* suppress compiler warning */
36   lpCmdLine = lpCmdLine; /* suppress compiler warning */
37   while (1) {
38       DWORD got;
39       buf = realloc(buf, len * 2);
40       if (!buf) exit(1);
41       got = GetModuleFileNameW(NULL, buf, len);
42       if (got + 12 < len) break;
43       len += len;
44   }
45   /* Strange Win32 nastiness - strip prefix "\\?\" if present */
46   if (wcsncmp(buf, L"\\\\?\\", 4) == 0) buf += 4;
47   p = wcsrchr(buf, L'\\');
48   if (p) ++p; else p = buf;
49   wcscpy(p, L"svxedit.tcl");
50   cmd_line = GetCommandLineW();
51   /* ShellExecute returns an HINSTANCE for some wacko reason - the docs say
52    * the only valid operation is to convert it to an int.  Marvellous. */
53   if ((int)ShellExecuteW(NULL, NULL, buf, cmd_line, NULL, nCmdShow) <= 32) {
54       ShellExecuteW(NULL, NULL, L"notepad", cmd_line, NULL, nCmdShow);
55   }
56   return 0;
57}
Note: See TracBrowser for help on using the repository browser.