CreateProcess 隐藏窗口启动一个进程? STARTUPINFO si;
PROCESS_INFORMATION pi;
memset(&si,0, sizeof(si) );   
si.cb = sizeof(si);  
si.lpReserved = NULL;
si.lpDesktop = NULL;
si.lpTitle = NULL;
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
si.cbReserved2 = NULL;
si.lpReserved2 = NULL;
si.lpDesktop = "";
memset(&pi,0, sizeof(pi) );


CreateProcess( NULL, "dlg.exe", NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi );
相关代码如上,但是窗口还是显示?请教了

解决方案 »

  1.   

    最近也遇到了跟楼主一样的问题,我解决的方法是将CreateProcess新创建的线程的窗口放到另外一个桌面上去就可以了,在楼主的代码中修改一句: si.lpDesktop="NewDesktop";//si.lpDesktop只要不是空的字符串就行。具体原理可以参考:http://user.qzone.qq.com/1253270204/infocenter#!app=2&via=QZ.HashRefresh&pos=1348625802
    或者http://blog.163.com/madengyao_super/blog/static/2859822020093249493150/
      

  2.   

    并非所有的程序都理会 WinMain 的第四个参数的.
      

  3.   

    wShowWindow 
    Ignored unless dwFlags specifies STARTF_USESHOWWINDOW. The wShowWindow member can be any of the SW_ constants defined in WINUSER.H. For GUI processes, wShowWindow specifies the default value the first time ShowWindow is called. The nCmdShow parameter of ShowWindow is ignored. In subsequent calls to ShowWindow, the wShowWindow member is used if the nCmdShow parameter of ShowWindow is set to SW_SHOWDEFAULT. 
    ------------------
    你的程序是console的么?