static void __fastcall  ChercheIcon(AnsiString Chemin,unsigned char * Chaine,int Length,
                                             WIN32_FIND_DATA * Win32FindData)
{
  HICON HIcon,GHIcon;
  int NbIcon,Cheksum,j,k;
  TIcon * Icon;
  ICONINFO InconInfo;
  TListItem  *ListIcon;
  unsigned char bbitmap[4096];
#define apiwin
  if( (int)(HIcon=ExtractIcon(HInstance,(Chemin.SubString(1,Chemin.Length()-3)+Win32FindData->cFileName).c_str(),
                    -1))>0)
  {
    NbIcon = (int)HIcon;
    DestroyIcon(HIcon );
    for(int i = 0; i<NbIcon && Form1->Stop== false;i++)
    {
      HIcon=ExtractIcon(HInstance,(Chemin.SubString(1,Chemin.Length()-3)+Win32FindData->cFileName).c_str(),
                    i);
      k=0;
      if(GetIconInfo(HIcon,&InconInfo))
      {
        k=GetBitmapBits( InconInfo.hbmColor,sizeof(bbitmap),&bbitmap[0]);
        if( InconInfo.hbmMask)
          DeleteObject( InconInfo.hbmMask );
        if(InconInfo.hbmColor)
          DeleteObject( InconInfo.hbmColor );
        Cheksum =0;
        for(int i =0 ; i<k; i++)
        {
          Cheksum +=bbitmap[i];
        }
        bool exist= false;
        for(j =0 ;j<Form1->ViewIcon->Items->Count && !exist;j++)
        {
          if(Form1->ViewIcon->Items->Item[j]->Data==  (void*)Cheksum)
          exist= true;
        }
        if(!exist && k!=0 )
        {
      #ifndef  apiwin
        Icon = new TIcon();
        Icon->ReleaseHandle();
        Icon->Handle = HIcon;
      #endif
        ListIcon = Form1->ViewIcon->Items->Add();
        ListIcon->Caption = Win32FindData->cFileName ;
      #ifdef  apiwin
        j= ImageList_AddIcon(Form1->Himagelist,HIcon);
      #else
        j= Form1->IconBuff->AddIcon(Icon);
      #endif
        ListIcon->ImageIndex = j ;
        ListIcon->Data =(void*)Cheksum;
      #ifndef  apiwin
        delete Icon;
      #endif
      }
      k= DestroyIcon(HIcon );
    }
  }
}
			
		
 
	
Partager