当前位置:首页 » 多媒体相关

如何知道一个应用程序是否运行?


如何在我自己的程序中通过函数判断一个其他的应用程序是否运行,  
  比如说有一个应用程序xxxx.exe在任务管理器->进程:映象名称中的名字也是  
  xxxx.exe,我怎么判断它是否已经运行?  
 

推荐阅读

  • 299刻录机不超值 三星18X光雕降价 [详细内容]
  • 中国电子政务市场进入整合时代 [详细内容]
  • 来电铃声之缺陷 [详细内容]
  • 9.18日 AM2全线涨价 内存继续波动 [详细内容]
  • 手机进入直播时代 中国日报网首尝WAP奶酪 [详细内容]
  • TCPMP播放小bug [详细内容]
  • AM2好搭挡 冠盟GMNC51-94E2P-MGN [详细内容]
  • 网友回答:
    网友:kingzai

    http://www.codeguru.com/system/plist.html  
      single   interface   to   enumerate   processes  
       
      //enum   process   to   find   a   certain   module  
      void   cptbview::isapprun(cstring   modulename)  
      {  
      dword   buf[4096];  
      dword   num;  
      tchar   filenamebuf[_max_path+1];  
      hmodule   hmodule;  
      dword   cbreturned;  
      bool   bret=enumprocesses(buf,4095,&num);  
      bool   bfound=false;  
      cstring   msg;  
       
      if(!bret)  
      {  
      afxmessagebox("error   enumprocesses");  
      return;  
      }  
       
      for(int   i=0;i<(int)num;i++)  
      {  
      handle   hprocess   =openprocess(process_query_information&brvbar;   process_vm_read,false,buf[i]);  
      if(hprocess   ==null)  
      continue;  
      bret=enumprocessmodules(hprocess   ,&hmodule,   sizeof(hmodule),   &cbreturned   );  
      if(bret)  
      {  
      dword   dwret=getmodulefilenameex(hprocess   ,hmodule,filenamebuf,_max_path);  
      closehandle(   hprocess     )   ;  
      if(dwret==0)  
      {  
      msg.format("%d",getlasterror());  
      afxmessagebox(msg);  
      break;  
      }  
      else  
      {  
      tchar*   pfind=_tcsstr(filenamebuf,modulename);  
      if(pfind)  
      {  
      bfound=true;  
      break;  
      }  
      }  
      }  
      }  
      if(bfound)  
      afxmessagebox("found   it");  
      else  
      afxmessagebox("not   found");  
      }  
       
      void   cptbview::onviewcheckrun()  
      {  
      isapprun("notepad.exe");  
      }  
     

    .

    讨论区

    Login