From: bcmatusz@vela.acs.oakland.edu (Brian Matusz)
Subject: Starting Windows, Debug Kernels ...
Organization: Oakland University, Rochester MI.
Date: Tue, 5 Jan 1993 17:37:13 GMT

Being posted for a friend ... followup to center03@cps201.cps.cmich.edu
-----------------------------------------------------------------------

I have come up with a use(less|ful) utility to start Windows when using
the Debug Kernels.  Since the kernels make BCW unbearably slow with the
syntax highlighting, I got tired of running them when I didn't need
them.  This simple C program prompts you for your intended Win mode
at startup.  Here's what I do:

1.  Compile winmode.c and put it in the path (somewhere)
2.  Create win.bat (see notes)
3.  Create current.mod files (see notes)
4.  Type "win" for windows as usual

Notes:

2.  Rename win.com to _win.com.  Create win.bat that contains:

@echo off
winmode \windows \c7
if errorlevel 1 goto Quit
_win %1 %2 %3 %4 %5
:Quit

Insert your Windows and C7 directories correctly on the command line
to winmode (don't add trailing backslashes!)

3.  Create the current.mod files:

This is easy ... in the DEBUG and NODEBUG directories of C7, create a
file called current.mod.  In DEBUG, it contains D[CR][CTRL-Z], and in
NODEBUG it contains N[CR][CTRL-Z] ... these files get copied into your
Windows system directory so winmode can find them and determine what
mode you're in!

NOTES:

It may seem petty, and some work to do it at that, but it's been worth
it for me.  When I type WIN now, I know what mode I was in, and know
what mode I'm going to be in.  If you don't want it, ignore it.

Brad Wilson
center03@cps201.cps.cmich.edu

---------- 8<  Clip here for winmode.c  >8 -----------

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main( int argc, char *argv[] )
{
  char  answer, szTemp[ 128 ], current;
  FILE *file;

  if( argc != 3 )
  {
    printf( "usage: winmode windir sdk31dir\n" );
    return 1;
  }

  sprintf( szTemp, "%s\\system\\current.mod", argv[ 1 ]);
  file = fopen( szTemp, "r" );

  if( file )
  {
    fgets( szTemp, sizeof szTemp, file );
    fclose( file );
    current = toupper( szTemp[ 0 ]);
  }
  else
    current = '?';

  printf( "\nWindows 3.1 Execution Options:\n" );
  printf( "  [D] Debugging kernels        %s\n", 
    current == 'D' ? "(default)" : "" );
  printf( "  [N] Non-debugging kernels    %s\n", 
    current == 'N' ? "(default)" : "" );
  printf( "  [A] Abort, don't run Windows\n\n" );
  printf( "Selection: " );

  scanf( "%c", &answer );

  switch( toupper( answer ))
  {
  case 'D':
    if( current != 'D' )
    {
      printf( "\nInstalling debugging kernels ... " );
      sprintf( szTemp, "xcopy %s\\debug %s\\system > nul", 
        argv[ 2 ], argv[ 1 ]);
      system( szTemp );
    }
    return 0;

  case 'N':
    if( current != 'N' )
    {
      printf( "\nInstalling retail kernels ... " );
      sprintf( szTemp, "xcopy %s\\nodebug %s\\system > nul", 
        argv[ 2 ], argv[ 1 ]);
      system( szTemp );
    }
    return 0;

  case 'A':
    return 1;

  default:
    return 0;
  }
}
-- 

---
bcmatusz@vela.acs.oakland.edu
"Use DEVICE=EXXON to screw up your environment."
Newsgroups: comp.os.ms-windows.programmer.misc