9x下通过执行文件名获得进程ID的方法

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 smile_tiger 的 blog

注:pe.szexefile有时候是全路经文件名,有时候只是文件名,原因有待考究,或者请哪位高手指教

dword getprocessidfromname(lpctstr name)
{
 processentry32 pe;
 dword id = 0;

 handle hsnapshot = createtoolhelp32snapshot(th32cs_snapprocess,0);
 pe.dwsize = sizeof(processentry32);
 if( !process32first(hsnapshot,&pe) )
  return 0;

 do
 {
  pe.dwsize = sizeof(processentry32);
  if( process32next(hsnapshot,&pe)==false )
   break;
  if(strcmp(pe.szexefile,name) == 0)
  {
   id = pe.th32processid;
   break;
  }

 } while(1);

 closehandle(hsnapshot);

 return id;
}

本文关键:9x下通过执行文件名获得进程ID的方法
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top