forked from serpi90/fakew3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First attempt, does not wait for child process
- Loading branch information
0 parents
commit cf12506
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.exe | ||
*.o |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include <windows.h> | ||
#include <stdio.h> | ||
|
||
#define MAX_SIZE 1024 | ||
|
||
/** | ||
* Used to wrap around GameRanger restrictions, to run Warcraft III in windowed mode. | ||
* Currently GameRanger requres a file named War3x.mpq to be present in the folder to allow it to be selected as Warcraft III: Frozen Throne | ||
* | ||
* Attempt to read configFile. If file is missing or there is an error reading it. Attempt to use default W3 location. | ||
* | ||
* The configuration file only has the command line to execute. Example: | ||
* "D:\Warcraft III\Frozen Throne.exe" -window | ||
* | ||
* Remember to wrap the path with quotes. | ||
*/ | ||
|
||
int launchGame( const char commandLine[] ) { | ||
switch( WinExec( commandLine, SW_SHOWDEFAULT ) ) { | ||
case 0: | ||
fprintf( stderr, "The system is out of memory or resources\r\n" ); | ||
return -1; | ||
case ERROR_BAD_FORMAT: | ||
fprintf( stderr, "The .exe file is invalid\r\n" ); | ||
return -1; | ||
case ERROR_FILE_NOT_FOUND: | ||
fprintf( stderr, "The specified file was not found\r\n" ); | ||
return -1; | ||
case ERROR_PATH_NOT_FOUND: | ||
fprintf( stderr, "The specified path was not found\r\n" ); | ||
return -1; | ||
default: | ||
return 0; | ||
} | ||
} | ||
|
||
int main ( ) { | ||
const char defaultCommandLine[] = "\"C:\\Program Files ( x86)\\Warcraft III\\Frozen Throne.exe\" -window"; | ||
const char configFileName[] = "fakew3.txt"; | ||
char commandLine[MAX_SIZE]; | ||
FILE * configFile = fopen( configFileName, "r" ); | ||
|
||
if( configFile == NULL ) { | ||
return launchGame( defaultCommandLine ); | ||
} else if( fgets( commandLine, MAX_SIZE, configFile ) == NULL ) { | ||
printf( "Error reading configuration file %s, using default %s\r\n", configFileName, defaultCommandLine ); | ||
fclose( configFile ); | ||
return launchGame( defaultCommandLine ); | ||
} else { | ||
printf( commandLine ); | ||
printf( "\r\n" ); | ||
fclose( configFile ); | ||
return launchGame( commandLine ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"C:\Program Files (x86)\Warcraft III\Frozen Throne.exe" -window |