head.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. Launch4j (http://launch4j.sourceforge.net/)
  3. Cross-platform Java application wrapper for creating Windows native executables.
  4. Copyright (c) 2004, 2015 Grzegorz Kowal,
  5. Ian Roberts (jdk preference patch)
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. Except as contained in this notice, the name(s) of the above copyright holders
  15. shall not be used in advertising or otherwise to promote the sale, use or other
  16. dealings in this Software without prior written authorization.
  17. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. THE SOFTWARE.
  24. */
  25. #ifndef _WIN32_WINNT
  26. #define _WIN32_WINNT 0x0501
  27. #endif // _WIN32_WINNT
  28. #ifndef _LAUNCH4J_HEAD__INCLUDED_
  29. #define _LAUNCH4J_HEAD__INCLUDED_
  30. #define WIN32_LEAN_AND_MEAN // VC - Exclude rarely-used stuff from Windows headers
  31. // Windows Header Files:
  32. #include <windows.h>
  33. // C RunTime Header Files
  34. #include <stdlib.h>
  35. #include <malloc.h>
  36. #include <memory.h>
  37. #include <tchar.h>
  38. #include <shellapi.h>
  39. #include <direct.h>
  40. #include <fcntl.h>
  41. #include <stdio.h>
  42. #include <sys/stat.h>
  43. #include <io.h>
  44. #include <process.h>
  45. #define LAUNCH4j "Launch4j"
  46. #define VERSION "3.50"
  47. #define JRE_VER_MAX_DIGITS_PER_PART 3
  48. #define JAVA_NOT_FOUND 0
  49. #define JAVA_FOUND 1
  50. #define KEY_WOW64_64KEY 0x0100
  51. #define HKEY_STR "HKEY"
  52. #define HKEY_CLASSES_ROOT_STR "HKEY_CLASSES_ROOT"
  53. #define HKEY_CURRENT_USER_STR "HKEY_CURRENT_USER"
  54. #define HKEY_LOCAL_MACHINE_STR "HKEY_LOCAL_MACHINE"
  55. #define HKEY_USERS_STR "HKEY_USERS"
  56. #define HKEY_CURRENT_CONFIG_STR "HKEY_CURRENT_CONFIG"
  57. #define STR 128
  58. #define BIG_STR 1024
  59. #define MAX_VAR_SIZE 32767
  60. #define MAX_ARGS 32768
  61. #define TRUE_STR "true"
  62. #define FALSE_STR "false"
  63. #define ERROR_FORMAT "Error:\t\t%s\n"
  64. #define debug(args...) if (hLog != NULL) fprintf(hLog, ## args);
  65. #define debugAll(args...) if (debugAll && hLog != NULL) fprintf(hLog, ## args);
  66. typedef void (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
  67. BOOL initGlobals(BOOL jni);
  68. FILE* openLogFile(const char* exePath, const int pathLen);
  69. void closeLogFile();
  70. BOOL initializeLogging(const char *lpCmdLine, const char* exePath, const int pathLen);
  71. void msgBox(const char* text);
  72. void signalError();
  73. BOOL loadString(const int resID, char* buffer);
  74. BOOL loadBool(const int resID);
  75. int loadInt(const int resID);
  76. BOOL regQueryValue(const char* regPath, unsigned char* buffer,
  77. unsigned long bufferLength);
  78. void formatJavaVersion(char* version, const char* originalVersion);
  79. void regSearch(const char* keyName, const int searchType);
  80. BOOL isRegistryJavaHomeValid(const char* keyName, const int searchType);
  81. BOOL isLauncherPathValid(const char* path);
  82. void regSearchWow(const char* keyName);
  83. BOOL findRegistryJavaHome(char* path);
  84. int getExePath(char* exePath);
  85. void appendPath(char* basepath, const char* path);
  86. void appendLauncher(char* jrePath);
  87. void appendAppClasspath(char* dst, const char* src);
  88. BOOL expandVars(char *dst, const char *src, const char *exePath, const int pathLen);
  89. void appendHeapSizes(char *dst);
  90. void appendHeapSize(char *dst, const int megabytesID, const int percentID,
  91. const DWORDLONG availableMemory, const char *option);
  92. void setJvmOptions(char *jvmOptions, const char *exePath);
  93. BOOL createMutex();
  94. void setWorkingDirectory(const char *exePath, const int pathLen);
  95. void removeChar(char *src, const char toRemove);
  96. BOOL pathJreSearch(const char *exePath, const int pathLen);
  97. BOOL registryJreSearch();
  98. void createJreSearchError();
  99. BOOL jreSearch(const char *exePath, const int pathLen);
  100. BOOL appendToPathVar(const char* path);
  101. BOOL appendJreBinToPathVar();
  102. void setEnvironmentVariables(const char *exePath, const int pathLen);
  103. void setMainClassAndClassPath(const char *exePath, const int pathLen);
  104. void setCommandLineArgs(const char *lpCmdLine);
  105. int prepare(const char *lpCmdLine, BOOL jni);
  106. void closeProcessHandles();
  107. BOOL execute(const BOOL wait, DWORD *dwExitCode);
  108. const char* getJavaHome();
  109. const char* getMainClass();
  110. const char* getLauncherArgs();
  111. void getVersionFromOutput(HANDLE outputRd, char *version, int versionLen, BOOL *is64Bit);
  112. BOOL CreateChildProcess(char *cmdline, HANDLE outputWr);
  113. BOOL isJavaVersionGood(const char* version, BOOL is64Bit);
  114. BOOL isJavaPathVersionGood(const char *path, BOOL *is64Bit);
  115. #endif // _LAUNCH4J_HEAD__INCLUDED_