在winXP中如何创建一个隐藏进程窗口(从任务栏)的进程?用CreateProcess函数?

发布于 2024-10-13 15:30:06 字数 546 浏览 4 评论 0 原文

 /* 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.... // run 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);
 /* 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.... // run 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);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

后eg是否自 2024-10-20 15:30:06

您可以尝试设置 dwFlags 成员="noreferrer">STARTUPINFO 结构为 STARTF_USESHOWWINDOWwShowWindow 成员为 SW_HIDE

这将使 CreateProcess() 将 0 作为 WinMain。但是,并非所有 Windows 应用程序都表现良好并使用此值来初始调用 ShowWindow()

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().

演出会有结束 2024-10-20 15:30:06

不是您(新进程的创建者)将新进程注册到任务栏中。这是创建一个顶级窗口的新进程,该窗口决定是否位于任务栏中。该决定基于该顶级窗口的扩展样式,该样式由新进程决定。

换句话说,您必须在另一个进程中查看顶级窗口才能执行此操作。

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.

韬韬不绝 2024-10-20 15:30:06

您可以找到与启动的进程关联的窗口(请参阅FindWindowEnumWindows),并调用 ShowWindow 函数与 SW_HIDE。或者,您可以通过删除 WS_EX_APPWINDOW 并添加 WS_EX_TOOLWINDOW 来修改窗口的扩展样式。

如果启动的进程遵循设置,最简单的方法仍然是使用第一个答案中所述的 STARTUPINFO 。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文