[EDIT]
I didn't read to carefully. The compiler is so old it doesn't create Win32 exes. You'll have to use a utilit like HiddenStart: http://www.ntwind.com/software/utilities/hstart.html.
The following changes the subsystem type for Win32 exes.
[/EDIT]
#include <stdio.h>
#include <stdlib.h>
#define then
int main( int argc, char **argv ) {
FILE *f;
unsigned long v = 0;
unsigned short i = 0;
char sig[ 4 ];
if (argc != 2) {
printf( "%s",
"usage:\n"
" chss EXEFILE\n\n"
" Changes the subsystem type of the named exe file and reports the new\n"
" status: console or gui.\n\n"
" The file MUST be a PE32 or PE32+. No checking is done to verify that!\n"
);
return 0;
}
if ((f = fopen( argv[ 1 ], "rb+" )) == NULL) {
fprintf( stderr, "Couldn't open %s", argv[ 1 ] );
return 1;
}
/* addr of PE header signature */
fseek( f, 60, SEEK_SET );
fread( &v, 4, 1, f );
fseek( f, v, SEEK_SET );
fread( sig, 4, 1, f );
if ((sig[ 0 ] != 'P') || (sig[ 1 ] != 'E') || (sig[ 2 ] != 0) || (sig[ 3 ] != 0)) {
fprintf( stderr, "%s is not a PE32 or PE32+", argv[ 1 ] );
return 1;
}
/* addr of subsystem code */
v += 4 + 20 + 68;
/* get current code */
fseek( f, v, SEEK_SET );
fread( &i, 2, 1, f );
if (i == 3)
then { …