환경: C++ Builder XE2
CreateProcess()함수를 이용해 콘솔 프로그램을 실행 시킵니다.
그런데,
실행 시킬 때마다 작업관리자에서 보면 핸들이 지속적으로 증가합니다.
156 => 158 => 160 => ...
왜 이런 증상이 발생하나요?
24시간 운영되는 S/W라 리소스 소모에 민감하네요.
고수님들~!
미리 감사합니다.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
bool flag;
STARTUPINFO si;
memset(&si, 0, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESTDHANDLES;
PROCESS_INFORMATION pi;
UnicodeString Dir = GetCurrentDir();
UnicodeString File = "abcd.exe";
UnicodeString x = Dir + "\\" + File + " D:\\201807200120.adx";
AnsiString xx = x;
flag = CreateProcess(NULL,x.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
if(!flag) {
ShowMessage("Fail to create process.");
} else {
ShowMessage("Executed..");
}
}
콘솔 프로그램 소스는 아래와 같습니다.(샘플로 만든 콘솔 어플입니다.)
#pragma hdrstop
#pragma argsused
#include
int main(int argc, wchar_t **argv)
{
int i = 0;
for (i = 0 ; i < argc ; ++i)
printf("%s\n", argv[i]);
return 0;
}
|