c++ 可执行文件的进程未正确关闭
Process of c++ executable doesn't close correctly
在我的程序中,我在同一窗口中启动其他C 应用程序,以关闭上一个。有时,我在任务管理器中看到的过程不会关闭。因此,我将有许多同名的过程。我如何避免这种情况?
startup("../folder/c++_executable.exe");
exit(0);
void startup(LPCTSTR lpApplicationName)
{
// additional information
STARTUPINFO si;
PROCESS_INFORMATION pi;
// set the size of the structures
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// start the program up
CreateProcess( lpApplicationName, // the path
"", // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi ) // Pointer to PROCESS_INFORMATION structure
;
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
}
我认为您需要检查为什么它不关闭 - 获取VisualStudio/windbg并连接到未关闭的过程并检查其悬挂的位置。
相关文章:
- 如何将不同的可执行文件合并到一个窗口框架中进行编码?像浏览器一样
- 如何使 windows 命令提示符在C++可执行文件上显示返回值?
- CMake:如何将库 A 链接到库 B,然后将可执行文件链接到库 A
- 如何使字符串出现在编译的二进制可执行文件的开头?
- 程序在使用 system() 启动另一个可执行文件时停止
- 如何更改使用 CPack 安装的可执行文件的名称?
- 在Linux上使用Clang / OLLVM交叉编译helloworld Windows可执行文件时的问题
- CMake:我们可以为一组不形成可执行文件或库的特定文件指定包含目录吗?
- 如何将图像传入C++可执行文件并将输出图像存储在新目录中?
- 共享库 (.so) 没有扩展名的 Linux 可执行文件之间的区别?
- 如何在 linux 可执行文件中使用静态库
- 错误:当我从"WinDbg"打开可执行文件时,找不到符号文件。默认导出 ntdll 的符号.dll
- 编译的C可执行文件被Windows defender检测为病毒
- Linux 可执行文件通过 dlopen 在emplace_back崩溃打开共享库
- c++ 可执行文件的进程未正确关闭
- 执行一个新的完全独立的进程,该进程封装在一个可执行文件中,而不需要为独立进程将文件写入磁盘
- c++,总是运行进程或调用可执行文件
- 从c++可执行文件中获取启动提示符的进程Id
- 在c++的同一进程空间内执行外部可执行文件
- 获取HPUX上正在运行的进程的可执行文件的完整路径