home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
POLYEDIT.LZH
/
MODEL
/
WINETC.CPP
< prev
Wrap
C/C++ Source or Header
|
1996-05-22
|
3KB
|
130 lines
//
// ダイアログ処理関数
//
// 1996.1.16 M.Takatsu
//
#include <owl\owlpch.h>
#pragma hdrstop
#include <toolhelp.h>
#include <io.h>
#include "model.h"
extern TWindow *GetModelWindow(void);
extern char ExecPath[];
extern "C" void WinInternalError(char *mess);
extern "C" void WinMessage(char *mess);
extern "C" unsigned long WinGetTimer(void);
extern "C" int printf(const char *fmt, ...);
void WinExecWait(char *lpszCmdLine, UINT fuCmdShow)
{
STARTUPINFO StartInfo;
PROCESS_INFORMATION ProcInfo;
unsigned long ExitCode;
long begintime;
memset(&StartInfo, 0, sizeof(STARTUPINFO));
StartInfo.cb = sizeof(STARTUPINFO);
StartInfo.wShowWindow = fuCmdShow;
if (CreateProcess(NULL, lpszCmdLine, NULL, NULL,
FALSE, 0, NULL, NULL, &StartInfo, &ProcInfo) == FALSE) {
return;
}
CloseHandle(ProcInfo.hThread);
begintime = WinGetTimer();
while (GetExitCodeProcess(ProcInfo.hProcess, &ExitCode)
&& ExitCode == STILL_ACTIVE
&& WinGetTimer() < begintime + 60 * 1000) {
GetModelWindow()->GetApplication()->PumpWaitingMessages();
}
CloseHandle(ProcInfo.hProcess);
}
/*
* 子プロセスを呼び出す。
*
*/
void ChildExec( char *comline, int waitflag, int iconify )
{
char *p, filename[F_NAME_LEN];
int nCmdShow;
if (iconify) {
nCmdShow = SW_MINIMIZE;
} else {
nCmdShow = SW_SHOWDEFAULT;
}
strcpy(filename, ExecPath);
strcat(filename, comline);
if ((p = strchr(filename, ' ')) != NULL) {
*p = '\0';
}
if ((p = strchr(filename, '\t')) != NULL) {
*p = '\0';
}
p = filename + strlen(filename);
if (access(filename, 0) == 0
|| (strcpy(p, ".COM"), access(filename,0) == 0)
|| (strcpy(p, ".EXE"), access(filename,0) == 0)
|| (strcpy(p, ".BAT"), access(filename,0) == 0)
|| (strcpy(p, ".PIF"), access(filename,0) == 0)) {
if (p-filename> 4 && p[-4] == '.' && toupper(p[-3]) == 'H'
&& toupper(p[-2]) == 'L' && toupper(p[-1]) == 'P') {
GetModelWindow()->WinHelp(filename, HELP_CONTENTS, 0L);
} else {
strcpy(filename, ExecPath);
strcat(filename, comline);
if (waitflag) {
WinExecWait(filename, nCmdShow);
} else {
WinExec(filename, nCmdShow);
}
}
} else {
p = comline + strlen(comline);
if (access(comline, 0) == 0
&& p-comline> 4 && p[-4] == '.' && toupper(p[-3]) == 'H'
&& toupper(p[-2]) == 'L' && toupper(p[-1]) == 'P') {
GetModelWindow()->WinHelp(comline, HELP_CONTENTS, 0L);
} else {
if (waitflag) {
WinExecWait(comline, nCmdShow);
} else {
WinExec(comline, nCmdShow);
}
}
}
}
void WinMessage(char *mess)
{
printf("%s\n", mess);
// GetModelWindow()->MessageBox(mess, "Model", MB_OK);
}
static int fatal = 0;
void WinInternalError(char *mess)
{
WinMessage(mess);
if (++fatal == 2) {
exit(1);
}
}
unsigned long WinGetTimer(void)
{
#if 1
return timeGetTime();
#else
TIMERINFO info;
info.dwSize = sizeof(TIMERINFO);
TimerCount(&info);
return info.dwmsThisVM;
#endif
}