1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
   |  
bool __stdcall EnumProc(HWND hWnd,/*LPARAM*/long/*lp*/)
{
   unsigned long* pPid;   //LPDWORD
   unsigned long result;      //DWORD
   void *hg;                  //HGLOBAL
   unsigned long id;
 
   if(hWnd==NULL)
      return false;
 
   hg = GlobalAlloc(GMEM_SHARE,sizeof(unsigned long));
   pPid = (unsigned long *)GlobalLock(hg);
 
   result = GetWindowThreadProcessId(hWnd,pPid);
 
   if(result){
      char title[110];
      char className[95];
      char totalStr[256];
 
      GetClassName(hWnd,className,95); // <- extrait la class de l'application
      GetWindowText(hWnd,title,110); // <- extrait le titre de l'application
 
      id=*pPid;
      ultoa(id,totalStr,10);
      strcat(totalStr,"\t");
 
      if(title)
      {
         strcat(totalStr,title);
         strcat(totalStr,"\t");
      }
      strcat(totalStr,className);
      FormMaitre->ListBox1->Items->Add((AnsiString)totalStr);
 
   }
   else{
      GlobalUnlock(hg);
      GlobalFree(hg);
      return false;
   }
   GlobalUnlock(hg);
   GlobalFree(hg);
   return true;
} | 
Partager