Get encoder clsid

来源:互联网 发布:js函数封装与调用 编辑:程序博客网 时间:2024/06/15 03:41

int CTools::GetEncoderClsid(const WCHAR *format, CLSID *pClsid)
{
 UINT     num   =   0;                     //   number   of   image   encoders   
 UINT     size   =   0;                   //   size   of   the   image   encoder   array   in   bytes  

 ImageCodecInfo*   pImageCodecInfo   =   NULL;  

 GetImageEncodersSize(&num,   &size);   
 if(size   ==   0)   
  return   -1;     //   Failure  

 pImageCodecInfo   =   (ImageCodecInfo*)(malloc(size));   
 if(pImageCodecInfo   ==   NULL)   
  return   -1;     //   Failure  

 GetImageEncoders(num,   size,   pImageCodecInfo);  

 for(UINT   j   =   0;   j   <   num;   ++j)   
 {   
  if(   wcscmp(pImageCodecInfo[j].MimeType,   format)   ==   0   )   
  {   
   *pClsid   =   pImageCodecInfo[j].Clsid;   
   free(pImageCodecInfo);   
   return   j;     //   Success   
  }           
 }  

 free(pImageCodecInfo);   
 return   -1;     //   Failed 
}

原创粉丝点击