Windows launcher, attempt 2 (#2199)

This commit is contained in:
Veronica Berglyd Olsen authored and GitHub committed 2025-01-21 00:02:32 +01:00
commit 3672ae8be6
5 files changed
+21 -19

No files matched your search

+1 -2
View File
@@ -1,5 +1,4 @@
cmake_minimum_required(VERSION 3.14)
project(novelWriter LANGUAGES CXX)
add_executable(novelWriter main.cpp launcher.rc)
set_target_properties(novelWriter PROPERTIES WIN32_EXECUTABLE True)
+4 -4
View File
@@ -1,7 +1,7 @@
IDI_ICON1 ICON DISCARDABLE "novelWriter.ico"
1 VERSIONINFO
FILEVERSION 1,1,0,0
PRODUCTVERSION 1,1,0,0
FILEVERSION 1,2,0,0
PRODUCTVERSION 1,2,0,0
FILEOS 0x4
FILETYPE 0x1
{
@@ -9,11 +9,11 @@ FILETYPE 0x1
BLOCK "040904b0" {
VALUE "CompanyName", "Veronica Berglyd Olsen\0"
VALUE "FileDescription", "novelWriter Launcher\0"
VALUE "FileVersion", "1.1.0.0\0"
VALUE "FileVersion", "1.2.0.0\0"
VALUE "LegalCopyright", "(c) 2025 Veronica Berglyd Olsen\0"
VALUE "OriginalFilename", "novelWriter.exe\0"
VALUE "ProductName", "novelWriter\0"
VALUE "ProductVersion", "1.1.0.0\0"
VALUE "ProductVersion", "1.2.0.0\0"
}
}
BLOCK "VarFileInfo" {
+13 -13
View File
@@ -19,12 +19,15 @@
** along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef UNICODE
#define UNICODE
#endif
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <iostream>
void _tmain(int argc, TCHAR *argv[]) {
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) {
STARTUPINFO si;
PROCESS_INFORMATION pi;
@@ -32,21 +35,18 @@ void _tmain(int argc, TCHAR *argv[]) {
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
TCHAR path[MAX_PATH];
auto pathlen = GetModuleFileName(NULL, path, MAX_PATH);
wchar_t path[MAX_PATH];
auto pathlen = GetModuleFileNameW(NULL, path, MAX_PATH);
path[pathlen - 15] = 0;
SetCurrentDirectory(path);
std::cout << "WorkDir: " << path << std::endl;
TCHAR cmd[MAX_PATH] = TEXT("pythonw.exe novelWriter.pyw");
if (argc > 1) {
_tcscat_s(cmd, TEXT(" "));
_tcscat_s(cmd, argv[1]);
wchar_t cmd[MAX_PATH] = L"pythonw.exe novelWriter.pyw";
if (__argc > 1) {
wcsncat_s(cmd, L" ", 1);
wcsncat_s(cmd, __wargv[1], MAX_PATH-28);
}
std::cout << "Command: " << cmd << std::endl;
std::cout << "Launching novelWriter GUI" << std::endl;
CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
return;
return 0;
}
Binary file not shown.
+3
View File
@@ -209,6 +209,9 @@ def main(args: argparse.Namespace) -> None:
installRequirements(libDir)
removeRedundantQt(libDir)
print("Copy redistributable to root ...")
shutil.copyfile(libDir / "PyQt6" / "Qt6" / "bin" / "msvcp140.dll", outDir / "msvcp140.dll")
print("Updating starting script ...")
writeFile(outDir / "novelWriter.pyw", (
"#!/usr/bin/env python3\n"