Merge pull request #2991 from myk002/myk_launchdf

add launchdf binary so steam has an exe to launch
develop
Myk 2023-03-07 22:22:59 -08:00 committed by GitHub
commit 562eec55b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 0 deletions

@ -615,3 +615,5 @@ if(BUILD_SIZECHECK)
add_subdirectory(depends/sizecheck) add_subdirectory(depends/sizecheck)
add_dependencies(dfhack sizecheck) add_dependencies(dfhack sizecheck)
endif() endif()
add_subdirectory(package/windows)

@ -0,0 +1,7 @@
project(package_windows)
if(WIN32)
add_executable(launchdf WIN32 launchdf.c)
install(TARGETS launchdf
DESTINATION ${DFHACK_DATA_DESTINATION})
endif()

@ -0,0 +1,42 @@
#include <windows.h>
int WINAPI wWinMain(HINSTANCE hi, HINSTANCE hpi, PWSTR cmd, int ns)
{
STARTUPINFOA si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
CHAR dfdir[1024];
if (GetFullPathNameA("..", 1024, dfdir, NULL) == 0)
{
MessageBoxA(NULL, "could not get current directory", NULL, 0);
exit(1);
}
if (SetCurrentDirectoryA(dfdir) == 0)
{
MessageBoxA(NULL, "could not change to DF directory", NULL, 0);
exit(1);
}
if (CreateProcessA("Dwarf Fortress.exe",
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi) == 0)
{
MessageBoxA(NULL, "could not launch 'Dwarf Fortress.exe'", NULL, 0);
exit(1);
}
exit(0);
}