Merge pull request #998 from djtuBIG-MaliceX/bugfix/#643-win32-console-vs-gui-strategy

Issue #643 - Rewrite CLI vs GUI strategy (this matches another tracker)
This commit is contained in:
tildearrow 2023-02-25 03:36:29 -05:00 committed by GitHub
commit 6e3352e052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -780,6 +780,8 @@ endif()
if(ANDROID AND NOT TERMUX)
add_library(furnace SHARED ${USED_SOURCES})
elseif(WIN32)
add_executable(furnace WIN32 ${USED_SOURCES})
else()
add_executable(furnace ${USED_SOURCES})
endif()

View File

@ -342,12 +342,14 @@ void reportError(String what) {
// TODO: CoInitializeEx on Windows?
// TODO: add crash log
int main(int argc, char** argv) {
// Windows console thing - thanks MarioKart7z!
// Windows console thing - thanks dj.tuBIG/MaliceX
#ifdef _WIN32
DWORD winPID;
HWND winConsole=GetConsoleWindow();
GetWindowThreadProcessId(winConsole,&winPID);
if (GetCurrentProcessId()==winPID) FreeConsole();
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
freopen("CONIN$", "r", stdin);
}
#endif
initLog();