Added runtime option for *not* setting the current working directory to the executable directory.

This commit is contained in:
LoRd_MuldeR 2024-09-29 14:06:21 +02:00
parent 9d27eb5a98
commit 02931280d0
5 changed files with 20 additions and 13 deletions

View File

@ -1,4 +1,4 @@
Copyright 2023 LoRd_MuldeR <mulder2@gmx.de>
Copyright 2024 LoRd_MuldeR <mulder2@gmx.de>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

View File

@ -147,7 +147,12 @@ Some options can be configured via the launcher executable's [STRINGTABLE](https
(If `ID_STR_HEAPMIN` is specified too, then this value **must** be greater than or equal to `ID_STR_HEAPMIN`).
* **`ID_STR_JAVAMIN` (0x8)**
* **`ID_STR_NSETCWD` (0x8)**
If set to a non-zero value, do ***not*** change the current working directory.
(By default, the current working directory is set to the directory where the executable file is located)
* **`ID_STR_JAVAMIN` (0x9)**
Specifies the ***minimum*** supported JRE version, in the **`w.x.y.z`** format (e.g. `11.0.0.0`).
This values is *inclusive*, i.e. the specified JRE version or any newer JRE version will be accepted.
If not specified, then the *default* minimum supported JRE version `8.0.0.0` applies.
@ -156,7 +161,7 @@ Some options can be configured via the launcher executable's [STRINGTABLE](https
(This option only applies to the “registry” variant of Launch5j)
* **`ID_STR_JAVAMAX` (0x9)**
* **`ID_STR_JAVAMAX` (0xA)**
Specifies the ***maximum*** supported JRE version, in the **`w.x.y.z`** format (e.g. `12.0.0.0`).
This values is *exclusive*, i.e. only JRE versions *older* than the specified JRE version will be accepted.
If not specified, then there is **no** upper limit on the supported JRE version.
@ -165,13 +170,13 @@ Some options can be configured via the launcher executable's [STRINGTABLE](https
(This option only applies to the “registry” variant of Launch5j)
* **`ID_STR_BITNESS` (0xA)**
* **`ID_STR_BITNESS` (0xB)**
Specifies the required ***bitness*** of the JRE. This can be either **`32`** (x86, aka i586) or **`64`** (x86-64).
If not specified, then 32-Bit *and* 64-Bit JREs are accepted, with a preference to 64-Bit.
(This option only applies to the “registry” variant of Launch5j)
* **`ID_STR_JAVAURL` (0xB)**
* **`ID_STR_JAVAURL` (0xC)**
The Java download URL that will ne suggested, if **no** suitable JRE could be detected on the machine.
If not specified, wes suggest downloading OpenJDK, as provided by the [Eclipse Adoptium](https://adoptium.net/) project.
@ -296,7 +301,7 @@ This project is partly inspired by the “Launch4j” project, even though it ha
This work has been released under the MIT license:
Copyright 2023 LoRd_MuldeR <mulder2@gmx.de>
Copyright 2024 LoRd_MuldeR <mulder2@gmx.de>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

View File

@ -44,6 +44,7 @@ BEGIN
ID_STR_MUTEXID L"?" /*single instance mutex ID*/
ID_STR_HEAPMIN L"?" /*min. heap size, in percent of phys. memory*/
ID_STR_HEAPMAX L"?" /*max. heap size, in percent of phys. memory*/
ID_STR_NSETCWD L"?" /*do not set current working directory*/
END
/////////////////////////////////////////////////////////////////////////////

View File

@ -1615,7 +1615,7 @@ static int launch5j_main(const HINSTANCE hinstance, const wchar_t *const cmd_lin
DWORD java_required_bitness = 0U, jvm_heap_percent_min = 0U, jvm_heap_percent_max = 0U, jvm_bitness = 0U;
ULONGLONG java_required_ver_min = 0ULL, java_required_ver_max = 0ULL, jvm_version = 0ULL;
HGDIOBJ splash_image = NULL;
BOOL have_screen_created = FALSE;
BOOL have_screen_created = FALSE, set_current_directory_enabled = TRUE;
PROCESS_INFORMATION process_info;
STARTUPINFOW startup_info;
@ -1693,7 +1693,7 @@ static int launch5j_main(const HINSTANCE hinstance, const wchar_t *const cmd_lin
}
// Set the current directory
if (_wcsicmp(executable_directory, L".") != 0)
if (set_current_directory_enabled = (!BOOLIFY(load_uint32(hinstance, ID_STR_NSETCWD, 0U))))
{
set_current_directory(executable_directory);
}
@ -1770,7 +1770,7 @@ static int launch5j_main(const HINSTANCE hinstance, const wchar_t *const cmd_lin
#endif
// Now actually start the process!
if (!CreateProcessW(NULL, (LPWSTR)command_line, NULL, NULL, FALSE, 0U, NULL, executable_directory, &startup_info, &process_info))
if (!CreateProcessW(NULL, (LPWSTR)command_line, NULL, NULL, FALSE, 0U, NULL, set_current_directory_enabled ? executable_directory : NULL, &startup_info, &process_info))
{
const wchar_t *const error_text = describe_system_error(GetLastError());
if (error_text)

View File

@ -38,9 +38,10 @@
#define ID_STR_MUTEXID 0x5
#define ID_STR_HEAPMIN 0x6
#define ID_STR_HEAPMAX 0x7
#define ID_STR_JAVAMIN 0x8
#define ID_STR_JAVAMAX 0x9
#define ID_STR_BITNESS 0xA
#define ID_STR_JAVAURL 0xB
#define ID_STR_NSETCWD 0x8
#define ID_STR_JAVAMIN 0x9
#define ID_STR_JAVAMAX 0xA
#define ID_STR_BITNESS 0xB
#define ID_STR_JAVAURL 0xC
#endif