void launch_program() { STARTUPINFO startup_info; PROCESS_INFORMATION proc_info; LPCSTR location = "C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe"; ZeroMemory( &startup_info,sizeof(startup_info)); startup_info.cb = sizeof(startup_info); ZeroMemory( &proc_info,sizeof(proc_info)); CreateProcess( location,NULL,FALSE,&startup_info,&proc_info); }
我用https://msdn.microsoft.com/en-us/library/windows/desktop/ms682512(v=vs.85).aspx作为参考.
PS我只是使用Internet Explorer作为填充程序
[编辑]完整性:
CloseHandle(proc_info.hProcess); CloseHandle(proc_info.hThread);
The thread and process handles are created with full access rights,although access can be restricted if you specify security descriptors. When you no longer need these handles,close them by using the CloseHandle function.
[编辑]为了强调*应该*关闭部分,这可能在文档中没有足够强烈地说明,这里引用@ RaymondChen的博客:
Why do some process stay in Task Manager after they’ve been killed?
After all the drivers have acknowledged the death of the process,the “meat” of the process finally goes away. All that remains is the “process object”,which lingers until all handles to the process and all the threads in the process have been closed. (You did remember to CloseHandle the handles returned in the PROCESS_INFORMATION structure that you passed to the CreateProcess function,didn’t you?)