home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / CENVIW9.ZIP / BOOTED1.CMM < prev    next >
Text File  |  1994-03-08  |  2KB  |  61 lines

  1. /************************************************************
  2.  *** BootEd1 - Sample Cmm code to demonstrate uses of the ***
  3.  *** ver.1     WinExec() function.                        ***
  4.  ************************************************************/
  5.  
  6. #include <WinExec.lib>
  7. #include <MsgBox.lib>
  8. #include <WinTools.lib>
  9.  
  10. MessageBox("This example CEnvi program will start\n"
  11.            "NotePad to edit both C:\\Config.sys and\n"
  12.            "C:\\Autoexec.bat, and then display them\n"
  13.            "both on the screen together.  This example\n"
  14.            "is like BootEd2 but this uses WinExec().",
  15.            "BootEd1 - Description");
  16.  
  17. // start up two versions of notepad with the two files we care about
  18. MustWinExec("NotePad.exe c:\\Config.sys");
  19. MustWinExec("NotePad.exe c:\\AutoExec.bat");
  20.  
  21. // Give the two processes 3/4 second to start up
  22. Suspend(750);
  23.  
  24. // Get the WindowHandles for both programs by searching for their name
  25. Config = MustGetWindowHandle("NOTEPAD - CONFIG.SYS");
  26. AutoExec = MustGetWindowHandle("NOTEPAD - AUTOEXEC.BAT");
  27.  
  28. // position these two windows to fill the top-half and the bottom-half of
  29. // the screen
  30. GetScreenSize(ScreenWidth,ScreenHeight);
  31.  
  32. WinPos.left = WinPos.top = 0;
  33. WinPos.right = ScreenWidth - 1;
  34. WinPos.bottom = ScreenHeight/2;
  35. SetWindowRect(Config,WinPos);
  36. WinPos.top = WinPos.bottom + 1;
  37. WinPos.bottom = ScreenHeight - 1;
  38. SetWindowRect(AutoExec,WinPos);
  39.  
  40.  
  41. MustWinExec(command)
  42. {
  43.    result = WinExec(command);
  44.    if ( result < 32 ) {
  45.       sprintf(ErrorMessage,"That call to WinExec returned error: %d",ErrorNumber);
  46.       MessageBox(ErrorMessage);
  47.       exit(1);
  48.    }
  49. }
  50.  
  51. MustGetWindowHandle(title)
  52. {
  53.    handle = GetWindowHandle(title);
  54.    if ( 0 == handle ) {
  55.       sprintf(ErrorMessage,"%s did not load.",title);
  56.       MessageBox(ErrorMessage);
  57.       exit(1);
  58.    }
  59.    return(handle);
  60. }
  61.