Matthew Noel Posted October 12, 2020 Share Posted October 12, 2020 I Have a custom DOSBox version set for all my MS-DOS games (DOSBos-X), but when I try to run a configuration application for a game it uses built-in DOSBox 0.74. Also the "Open DOSBox..." menu option is the same. It's important to run the config programs in the same DOSBox as the game itself, especially if it lets you test or auto-detect hardware. Quote Link to comment Share on other sites More sharing options...
Matthew Noel Posted October 12, 2020 Author Share Posted October 12, 2020 (edited) My workaround for this is so dumb. Please help. I made a custom EXE that just redirects to DOSBox-x and overwrote the built-in one. Yes, I know I could just put DOSBox-x in the built-in folder and rename the EXE, but I'm stubborn. Here's the code if anyone's interested: Spoiler #include <cstring> #include <Windows.h> bool hasSpace(char *str) { while (*str != 0) { if (*str == ' ') { return true; } str++; } return false; } int main(int argc, char *argv[]) { char *command = static_cast<char *>(malloc(32767)); memset(command, 0, 32767); strcat_s(command, 32767, "dosbox-x.bat"); for (int i = 1; i < argc; ++i) { strcat_s(command, 32767, " "); if (hasSpace(argv[i])) { strcat_s(command, 32767, "\""); strcat_s(command, 32767, argv[i]); strcat_s(command, 32767, "\""); } else { strcat_s(command, 32767, argv[i]); } } // additional information STARTUPINFOA si; PROCESS_INFORMATION pi; // set the size of the structures ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi)); // start the program up if (!CreateProcess ( R"(..\..\..\DOSBox-X\0.83.6\bin\x64\Release SDL2\dosbox-x.bat)", // Path to executable command, // Command line nullptr, // Process handle not inheritable nullptr, // Thread handle not inheritable FALSE, // Set handle inheritance to FALSE INHERIT_CALLER_PRIORITY, // Inherit parent's priority nullptr, // Use parent's environment block R"(..\..\..\DOSBox-X\0.83.6\bin\x64\Release SDL2)", // Starting directory &si, // Pointer to STARTUPINFO structure &pi // Pointer to PROCESS_INFORMATION )) { // Close process and thread handles. CloseHandle(pi.hProcess); CloseHandle(pi.hThread); return 1; } free(command); auto exitcode = STILL_ACTIVE; while (exitcode == STILL_ACTIVE) { WaitForSingleObject(pi.hProcess, INFINITE); GetExitCodeProcess(pi.hProcess, &exitcode); } // Close process and thread handles. CloseHandle(pi.hProcess); CloseHandle(pi.hThread); return exitcode; } EDIT: Code cleanup. Edited October 12, 2020 by Matthew Noel Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.