diff --git a/setup/windows/CMakeLists.txt b/setup/windows/CMakeLists.txt
index 4f1ec280..2dbba390 100644
--- a/setup/windows/CMakeLists.txt
+++ b/setup/windows/CMakeLists.txt
@@ -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)
diff --git a/setup/windows/main.cpp b/setup/windows/main.cpp
index 4f2121b3..26e7fd75 100644
--- a/setup/windows/main.cpp
+++ b/setup/windows/main.cpp
@@ -19,12 +19,15 @@
** along with this program. If not, see .
*/
+#ifndef UNICODE
+#define UNICODE
+#endif
+
#include
#include
-#include
-#include
-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;
}