总算知道怎样从ImageMagick生成的数据转换成HICON: MagickGetImageBlob & LookupIconIdFromDirectoryEx
MagickSetImageFormat(mw, "ICO"); //设置这个后, MagickGetImageBlob 才能返回正确的值 size_t length; PBYTE pIcoData = MagickGetImageBlob(mw, &length); //printf("length:%ld\n", length); //HICON hIcon = NULL; int offset = LookupIconIdFromDirectoryEx(pIcoData, TRUE, width_thumbnail, height_thumbnail, LR_DEFAULTCOLOR); //printf("offset:%d\n", offset); if(offset != 0) { *hIcon = CreateIconFromResourceEx(pIcoData + offset, 0, TRUE, 0x30000, width_thumbnail, height_thumbnail, LR_DEFAULTCOLOR); } MagickRelinquishMemory(pIcoData); //注意Blob使用完后,释放内存