dlgTextEntry_Keyboard: rename to TouchTextEntry
[xcsoar.git] / src / LaunchXCSoar.cpp
blobee147c1c8d8b4a26f57a72ef093a4bb4aa49c37f
1 /*
2 Copyright_License {
4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 /**
25 * This is a program launcher for Windows CE, to be used as an AutoRun
26 * binary. It searches for XCSoar.exe and executes it.
28 * This has been tested on the Naviter Oudie 2. Copy this program to
29 * the Oudie's storage (right next to XCSoar.exe) and rename it to
30 * OudiePocketFMSStart.exe.
33 #include "OS/PathName.hpp"
34 #include "Compiler.h"
36 #include <assert.h>
37 #include <windows.h>
38 #include <tchar.h>
39 #include <stdio.h>
41 static bool
42 LaunchExe(const TCHAR *exe, const TCHAR *cmdline)
44 TCHAR buffer[256];
45 _sntprintf(buffer, 256, _T("\"%s\" %s"), exe, cmdline);
47 PROCESS_INFORMATION pi;
48 if (!CreateProcess(exe, buffer, nullptr, nullptr, false,
49 0, nullptr, nullptr, nullptr, &pi))
50 return false;
52 CloseHandle(pi.hProcess);
53 CloseHandle(pi.hThread);
54 return true;
57 static bool
58 FindAndLaunchXCSoar(const TCHAR *cmdline)
60 TCHAR buffer[MAX_PATH];
61 if (GetModuleFileName(nullptr, buffer, MAX_PATH) <= 0)
62 return false;
64 ReplaceBaseName(buffer, _T("XCSoar.exe"));
65 return LaunchExe(buffer, cmdline);
68 int WINAPI
69 WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
70 #ifdef _WIN32_WCE
71 gcc_unused LPWSTR lpCmdLine,
72 #else
73 gcc_unused LPSTR lpCmdLine2,
74 #endif
75 int nCmdShow)
77 return FindAndLaunchXCSoar(_T("-fly")) ? 0 : 1;