调用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;
    } 

解决方案 »

  1.   

    dwX
    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.
    程序完全可以不理会这些东西,用自己想要的位置和大小
      

  2.   

    哦,位置和大小明白如何设置了,需要改test.exe源程序的创建窗口函数参数但是标题呢
    sInfo.lpTitle = strTitle.GetBuffer();
    也没有起作用哦
      

  3.   

    这里面的好几个参数对于已经大部分写的程序是无效的,特别是GUI你可以CreateProcess之后SetWindowPos
      

  4.   

    现在只剩一个问题,就是标题没改到sInfo.lpTitle = strTitle.GetBuffer();
    这个没起作用
      

  5.   

    lpTitle只对于真正的控制台程序有效