调用CreateProcess运行外部程序test.exe,test.exe是在windows类似命令行窗口显示的一个监控程序。程序运行后STARTUPINFO标题、大小、位置等参数没起作用 STARTUPINFO sInfo;
memset(&sInfo,0,sizeof(STARTUPINFO));
PROCESS_INFORMATION pi;
memset(&pi,0,sizeof(PROCESS_INFORMATION)); CString strTitle = "Client:";
strTitle += strClientName;
strTitle += " IP:";
strTitle += terminalIP; sInfo.cb = sizeof(STARTUPINFO);
sInfo.lpTitle = strTitle.GetBuffer();
sInfo.dwFlags = STARTF_USEPOSITION|STARTF_USESIZE|STARTF_USESTDHANDLES;
sInfo.dwX = 0;
sInfo.dwY = 0;
sInfo.dwXSize = 256;
sInfo.dwYSize = 192;
sInfo.wShowWindow = SW_SHOWNORMAL; CString strExt = "test.exe";
CString strCmd;
strCmd.Format("test %s",terminalIP);
// Start the child process
if(CreateProcess(strExt,
strCmd.GetBuffer(),
NULL,
NULL,
TRUE,
NULL ,
NULL,
NULL,
&sInfo,
&pi))
{
//MessageBox("Run!");
::CloseHandle(pi.hProcess);
::CloseHandle(pi.hThread);
}
else
{
MessageBox("Failed!");
printf("%d\n",::GetLastError());
return;
}
memset(&sInfo,0,sizeof(STARTUPINFO));
PROCESS_INFORMATION pi;
memset(&pi,0,sizeof(PROCESS_INFORMATION)); CString strTitle = "Client:";
strTitle += strClientName;
strTitle += " IP:";
strTitle += terminalIP; sInfo.cb = sizeof(STARTUPINFO);
sInfo.lpTitle = strTitle.GetBuffer();
sInfo.dwFlags = STARTF_USEPOSITION|STARTF_USESIZE|STARTF_USESTDHANDLES;
sInfo.dwX = 0;
sInfo.dwY = 0;
sInfo.dwXSize = 256;
sInfo.dwYSize = 192;
sInfo.wShowWindow = SW_SHOWNORMAL; CString strExt = "test.exe";
CString strCmd;
strCmd.Format("test %s",terminalIP);
// Start the child process
if(CreateProcess(strExt,
strCmd.GetBuffer(),
NULL,
NULL,
TRUE,
NULL ,
NULL,
NULL,
&sInfo,
&pi))
{
//MessageBox("Run!");
::CloseHandle(pi.hProcess);
::CloseHandle(pi.hThread);
}
else
{
MessageBox("Failed!");
printf("%d\n",::GetLastError());
return;
}
If dwFlags specifies STARTF_USEPOSITION, this member is the x offset of the upper left corner of a window if a new window is created, in pixels. Otherwise, this member is ignored.The offset is from the upper left corner of the screen. For GUI processes, the specified position is used the first time the new process calls CreateWindow to create an overlapped window if the x parameter of CreateWindow is CW_USEDEFAULT.dwY
If dwFlags specifies STARTF_USEPOSITION, this member is the y offset of the upper left corner of a window if a new window is created, in pixels. Otherwise, this member is ignored.The offset is from the upper left corner of the screen. For GUI processes, the specified position is used the first time the new process calls CreateWindow to create an overlapped window if the y parameter of CreateWindow is CW_USEDEFAULT.dwXSize
If dwFlags specifies STARTF_USESIZE, this member is the width of the window if a new window is created, in pixels. Otherwise, this member is ignored.For GUI processes, this is used only the first time the new process calls CreateWindow to create an overlapped window if the nWidth parameter of CreateWindow is CW_USEDEFAULT.dwYSize
If dwFlags specifies STARTF_USESIZE, this member is the height of the window if a new window is created, in pixels. Otherwise, this member is ignored.For GUI processes, this is used only the first time the new process calls CreateWindow to create an overlapped window if the nHeight parameter of CreateWindow is CW_USEDEFAULT.
程序完全可以不理会这些东西,用自己想要的位置和大小
sInfo.lpTitle = strTitle.GetBuffer();
也没有起作用哦
这个没起作用