现在的位置: 首页 > 综合 > 正文

ShellExecute,ShellExecuteEx, WinExec ,CreateProcess区别

2012年06月02日 ⁄ 综合 ⁄ 共 494字 ⁄ 字号 评论关闭

ShellExecute,ShellExecuteEx, WinExec ,CreateProcess区别: 
    
  WinExec 使用最简单,此功能提供了16位Windows的兼容性,估计内部调用了 ShellExecute 。

   
  ShellExecute 与 ShellExecuteEx 的区别是 ShellExecuteEx 可以返回新创建进程的句柄,ShellExecute在创建进程后立即调用 CloseHandle 关闭新进程句柄,而ShellExecuteEx将返回新进程序句柄。

 

  ShellExecute不仅能打开机器上的文件,还能打开Internet的站点地址。

   
  CreateProcess应该是ShellExecute / ShellExecuteEx 实现的基础。  
   
  注意调用CreateProcess/ShellExecuteEx   这类返回新进程句柄(CreateProcess 还返回新进程的主线程句柄),如果不需要访问这些内核对象,应该立即调用CloseHandle关闭这些句柄,否则即使新进程终止执行,保存他的状态的内核对象仍不会被清除。

抱歉!评论已关闭.