开发者

How could i Create a process with hiding the process window (from the task bar) in winXP? with CreateProcess function?

 /* CreateProcess initialization */
 STARTUPINFO si;
 PROCESS_INFORMATION pi;

 memset(&si, 0, sizeof(si));
 memset(&pi, 0, sizeof(pi));
 si.cb = sizeof(si);

 long ret;
 // si.wShowWindow = SW_HIDE;
 // hide process window.... // ru开发者_开发百科n in background..

 si.dwFlags = STARTF_USESHOWWINDOW;
 si.wShowWindow = SW_HIDE;

 if (!CreateProcess(0, exe,
        0, 0, 1, NORMAL_PRIORITY_CLASS, 0, 0, &si, &pi)) {
    return;
 }
 //int prez = WaitForSingleObject(pi.hProcess, INFINITE);

 //CloseHandle(pi.hProcess);


You can attempt to set the dwFlags member of your STARTUPINFO structure to STARTF_USESHOWWINDOW and the wShowWindow member to SW_HIDE.

This will make CreateProcess() pass 0 as the nCmdShow parameter of WinMain. However, not all Windows application are well behaved and use this value to the initial call to ShowWindow().


It's not you, the creator of the new process, that registers the new process into the task bar. It's the new process that creates a top-level window that decides whether or not to be in the taskbar. This decision is based on the extended style of that top-level window, which is determined by the new process.

In other words, you'd have to poke at the top-level window in this other process in order to do this.


You can find the window associated with the started process (see FindWindow and EnumWindows), and call ShowWindow function with SW_HIDE. Alternatively you can modify the extended style of the window by removing WS_EX_APPWINDOW and adding WS_EX_TOOLWINDOW.

The simplest way is still to use STARTUPINFO as described in the first answer, if the started process respects the setting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜