从RES文件中直接加载JPG的函数

VB:从RES文件中直接加载JPG的函数
先新建一个RES文件,然后放上若干JPG图片

.

'以下存为ModRes_Load_Jpg.mod

'*************************************************************************
'**模 块 名:ModRes_Load_Jpg
'**说    明:丹心软件在线设计 版权所有2007 - 2008(C)
'**创 建 人:丹心
'**日    期:2007-11-14 21:42:55
'**版    本:V1.0.0
'**博客地址:http://hi.baidu.com/starwork/
'**QQ 号码:121877114
'**E - mail:cnstarwork@126.com
'*************************************************************************

Option Explicit

Public Enum CBoolean ' enum members are Long data types
    CFalse = 0
    CTrue = 1
End Enum

Public Const S_OK = 0    ' indicates successful HRESULT

Public Declare Function CreateStreamOnHGlobal Lib "ole32" _
                            (ByVal hGlobal As Long, _
                            ByVal fDeleteOnRelease As CBoolean, _
                            ppstm As Any) As Long

Public Declare Function OleLoadPicture Lib "olepro32" _
                            (pStream As Any, _
                            ByVal lSize As Long, _
                            ByVal fRunmode As CBoolean, _
                            riid As GUID, _
                            ppvObj As Any) As Long

Public Type GUID    ' 16 bytes (128 bits)
    dwData1 As Long    ' 4 bytes
    wData2 As Integer    ' 2 bytes
    wData3 As Integer    ' 2 bytes
    abData4(7) As Byte ' 8 bytes, zero based
End Type

Public Declare Function CLSIDFromString Lib "ole32" (ByVal lpsz As Any, pclsid As GUID) As Long

Public Const sIID_IPicture = "{7BF80980-BF32-101A-8BBB-00AA00300CAB}"
Public Const GMEM_MOVEABLE = &H2

Public Declare Function GlobalAlloc Lib "kernel32" (ByVal uFlags As Long, ByVal dwBytes As Long) As Long
Public Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
Public Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
Public Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long

Public Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal dwLength As Long)



例子下载:
https://files.cnblogs.com/starwork/res_jpg_test.rar

 

丹心版权所有,转载请注明出处!

posted @ 2007-11-16 00:02  丹心在线设计  阅读(823)  评论(1编辑  收藏  举报