source: release-kits/shared/launch4j/head_src/consolehead/consolehead.c@ 15024

Last change on this file since 15024 was 15024, checked in by oranfry, 14 years ago

putting launch4j in the shared area

File size: 1.9 KB
Line 
1/*
2 Launch4j (http://launch4j.sourceforge.net/)
3 Cross-platform Java application wrapper for creating Windows native executables.
4
5 Copyright (C) 2004, 2006 Grzegorz Kowal
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21
22 Compiled with Mingw port of GCC,
23 Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html)
24*/
25
26#include "../resource.h"
27#include "../head.h"
28
29int main(int argc, char* argv[])
30{
31 setConsoleFlag();
32 HMODULE hLibrary = NULL;
33 char cmdLine[BIG_STR] = {0};
34 int i; // causes error: 'for' loop initial declaration used outside C99 mode.
35 for (i = 1; i < argc; i++) {
36 BOOL quote = strchr(argv[i], ' ') != NULL;
37 if (quote) {
38 strcat(cmdLine, "\"");
39 }
40 strcat(cmdLine, argv[i]);
41 if (quote) {
42 strcat(cmdLine, "\"");
43 }
44 if (i < argc - 1) {
45 strcat(cmdLine, " ");
46 }
47 }
48 if (!prepare(hLibrary, cmdLine)) {
49 if (hLibrary != NULL) {
50 FreeLibrary(hLibrary);
51 }
52 return 1;
53 }
54 FreeLibrary(hLibrary);
55
56 int result = (int) execute(TRUE);
57 if (result == -1) {
58 char errMsg[BIG_STR];
59 strcpy(errMsg, "could not start the application: ");
60 strcat(errMsg, strerror(errno));
61 msgBox(errMsg);
62 return 1;
63 } else {
64 return result;
65 }
66}
Note: See TracBrowser for help on using the repository browser.