home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PROG_C
/
CENVIW9.ZIP
/
BOOTED1.CMM
< prev
next >
Wrap
Text File
|
1994-03-08
|
2KB
|
61 lines
/************************************************************
*** BootEd1 - Sample Cmm code to demonstrate uses of the ***
*** ver.1 WinExec() function. ***
************************************************************/
#include <WinExec.lib>
#include <MsgBox.lib>
#include <WinTools.lib>
MessageBox("This example CEnvi program will start\n"
"NotePad to edit both C:\\Config.sys and\n"
"C:\\Autoexec.bat, and then display them\n"
"both on the screen together. This example\n"
"is like BootEd2 but this uses WinExec().",
"BootEd1 - Description");
// start up two versions of notepad with the two files we care about
MustWinExec("NotePad.exe c:\\Config.sys");
MustWinExec("NotePad.exe c:\\AutoExec.bat");
// Give the two processes 3/4 second to start up
Suspend(750);
// Get the WindowHandles for both programs by searching for their name
Config = MustGetWindowHandle("NOTEPAD - CONFIG.SYS");
AutoExec = MustGetWindowHandle("NOTEPAD - AUTOEXEC.BAT");
// position these two windows to fill the top-half and the bottom-half of
// the screen
GetScreenSize(ScreenWidth,ScreenHeight);
WinPos.left = WinPos.top = 0;
WinPos.right = ScreenWidth - 1;
WinPos.bottom = ScreenHeight/2;
SetWindowRect(Config,WinPos);
WinPos.top = WinPos.bottom + 1;
WinPos.bottom = ScreenHeight - 1;
SetWindowRect(AutoExec,WinPos);
MustWinExec(command)
{
result = WinExec(command);
if ( result < 32 ) {
sprintf(ErrorMessage,"That call to WinExec returned error: %d",ErrorNumber);
MessageBox(ErrorMessage);
exit(1);
}
}
MustGetWindowHandle(title)
{
handle = GetWindowHandle(title);
if ( 0 == handle ) {
sprintf(ErrorMessage,"%s did not load.",title);
MessageBox(ErrorMessage);
exit(1);
}
return(handle);
}