回答了论坛中的一个问题,顺便记下来。
//----------------------------------------------------------------------
CreateNewConsole(AnsiString& name, int x,int y, int width,int height)
{
PROCESS_INFORMATION pi;
STARTUPINFO si;
SECURITY_ATTRIBUTES sa;
ZeroMemory(&si,sizeof(si));
si.cb=sizeof(si);
si.wShowWindow = SW_SHOW;
si.dwFlags = STARTF_USESHOWWINDOW |STARTF_USEPOSITION | STARTF_USESIZE ;
si.dwX = x;
si.dwY = y;
si.dwXSize = width;
si.dwYSize = height;
CreateProcess(NULL,
name.c_str(),
NULL,
NULL,
true,
CREATE_NEW_CONSOLE,
NULL,
NULL,
&si,
&pi);
}
//----------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int x,y,width,height ;
x = 10; y = 50;
width = 10;height = 5;
for(int i = 0; i <5 ;i++)
{
CreateNewConsole("cmd.exe",x,y, width,height);
x += 150;
}
}
博客记录了论坛问题的解答,给出了创建新控制台窗口的代码。定义了CreateNewConsole函数,设置了进程信息、启动信息和安全属性等,还展示了按钮点击事件中多次调用该函数创建多个控制台窗口的代码。
172万+

被折叠的 条评论
为什么被折叠?



