首页   |   IT资讯   |   综合资讯   |   开发   |   软件   |   问答   |   网络技术   |   网络综合
更多:
当前位置:首页 » 手机数码
文章正文

******来者有分(在线等待)******

类型:转载   责任编辑:asp   日期:2007/03/01

    

如何在一个程序中结束另一个正在运行的程序。

推荐阅读

  • 传说中的小林子:从李宇春到罗德曼 [详细内容]
  • 微软游戏首席策划者开发XBOX2游戏 [详细内容]
  • 我跟我的爱姬的故事之打扫卫生 [详细内容]
  • 秃顶即将流行 让美发师设计个IPOD头型 [详细内容]
  • 微软索尼宣布将推华文Xbox在线游戏 [详细内容]
  • 关于V10电池激活的问题 [详细内容]
  • 好兆头!一线主板厂商三季度出货大增 [详细内容]
  • 网友回答:
    网友:outer2000

    sendmessage(handle,wm_close)

    网友:haoco

    大家用得最多的是发消息,即两个程序都定义同样值的消息。在这边程序发送这个消息给另外一个程序。当这个程序得到这个消息后就关闭自己。

    网友:winder_008

    uses   tlhelp32;  
      假设要终止的程序的文件名为:project2.exe,那么例程如下:  
      var  
      lppe:tprocessentry32;  
      sshandle:thandle;  
      hh:hwnd;  
      found:boolean;  
      begin  
      sshandle:=createtoolhelp32snapshot(th32cs_snapall,0);  
      found:=process32first(sshandle,lppe);  
      while   found   do  
      begin  
          //进行你的处理其中lppe.szexefile就是程序名。  
          if   uppercase(extractfilename(lppe.szexefile))=project2.exe   then  
          begin  
              hh:=openprocess(process_all_access,true,lppe.th32processid);  
              terminateprocess(hh,0);  
          end;  
          found:=process32next(sshandle,lppe);  
      end;  
      end;  
      ********************  
      handle   hprocess  
      windows   nt/2000:   the   handle   must   have   process_terminate   access.    
      for   more   information,   see   process   security   and   access   rights.    
       
      所以要先使用    
      dword   setsecurityinfo(  
          handle   handle,                                           //   handle   to   object  
          se_object_type   objecttype,                   //   object   type  
          security_information   securityinfo,   //   buffer  
          psid   psidowner,                                         //   new   owner   sid  
          psid   psidgroup,                                         //   new   primary   group   sid  
          pacl   pdacl,                                                 //   new   dacl  
          pacl   psacl                                                   //   new   sacl  
      );  
       
     

    .
      最佳浏览:1024X768 MSIE
    ©2007 jqmk.com.cn All Rights Reserved