注册 登录
编程论坛 VB6论坛

vb 提取 ico 图标怎么失真了

Ez330阿牛 发布于 2014-09-05 11:32, 586 次点击
用以下代码我测试时在图像框里面显示的是真彩色,怎么保存为ico后变成灰色了,在百度上找了几天都找不到答案,希望在这里能得到解答
程序代码:
Public Function GetIconFromFile(Filename As String, IconIndex As Long, UseLargeIcon As Boolean) As Picture
*参数:
*FileName - 包含有图标的文件 (EXE or DLL)
*IconIndex - 欲提取的圉标的索引,从零开始
*UseLargeIcon-如设置为True,则提取大图标,否则提取小图标
*返回值: 包含标标的Picture对象
Dim hlargeicon As Long
Dim hsmallicon As Long
Dim selhandle As Long
* IPicture requires a reference to "Standard OLE Types."
Dim pic As PicBmp
Dim IPic As IPicture
Dim IID_IDispatch As GUID
If ExtractIconEx(Filename, IconIndex, hlargeicon, hsmallicon, 1) > 0 Then
If UseLargeIcon Then
selhandle = hlargeicon
Else
selhandle = hsmallicon
End If
* Fill in with IDispatch Interface ID.
With IID_IDispatch
.Data1 = &H20400
.Data4(0) = &HC0
.Data4(7) = &H46
End With
* Fill Pic with necessary parts.
With pic
.Size = Len(pic) * Length of structure.
.tType = vbPicTypeIcon * Type of Picture (bitmap).
.hBmp = selhandle * Handle to bitmap.
End With
* Create Picture object.
Call OleCreatePictureIndirect(pic, IID_IDispatch, 1, IPic)
* Return the new Picture object.
Set GetIconFromFile = IPic
DestroyIcon hsmallicon
DestroyIcon hlargeicon
End If
End Function
0 回复
1