First, the production of pure DLL resources
Open VC6.0 Create a Win32-based dynamic link library
In the next step, choose A SINMPLE DLL Project
Then loading resources (note that the bitmap of more than 256 colors, the VC cannot be edited, but this does nothing)
You can load bitmaps, icons, strings, etc., this is after loading, after the resource is added, compiled. (It is best to set it to the publishing mode) This, a pure resource DLL is completed.
Second, VB dynamic call resource DLL call is simple, the source code is as follows: '****************************************** **************************************** Yeofan Sail No. 9CBS: Yefanqiu '** -------------------------------------------------- --------------------- '** Ye Fan blog: http://blog.9cbs.net/yefanqiu' ****************** *********************************************************** ************* Option Explicit Private Const IDS_STRING1 As Long = 1Private Const IDS_STRING2 As Long = 2Private Const IDS_STRING3 As Long = 3Private Const IDI_ICON1 As Long = 101Private Const IDB_BITMAP1 As Long = 102Private Const IDB_BITMAP2 As Long = 103 Private Const DST_BITMAP = 4Private Const OBJ_BITMAP = 7 'bitmap structure Private Type BITMAPINFOHEADER '40 bytes biSize As Long biWidth As Long biHeight As Long biPlanes As Integer biBitCount As Integer biCompression As Long biSizeImage As Long biXPelsPerMeter As Long biYPelsPerMeter As Long biClrUsed As Long Biclrimport ant As LongEnd TypePrivate Type RGBQUAD rgbBlue As Byte rgbGreen As Byte rgbRed As Byte rgbReserved As ByteEnd TypePrivate Type BITMAPINFO bmiHeader As BITMAPINFOHEADER bmiColors As RGBQUADEnd Type Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As LongPrivate Declare Function Freelibrary Lib "kernel32" (Byval Hlibmodule As Long) As longprivate declare function loadstring lib "user32" alias "loadingstringa"
(ByVal hInstance As Long, ByVal wID As Long, ByVal lpBuffer As String, ByVal nBufferMax As Long) As LongPrivate Declare Function LoadBitmap Lib "user32" Alias "LoadBitmapA" (ByVal hInstance As Long, ByVal lpBitmapName As Long) As LongPrivate Declare Function LoadIcon lib "user32" Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As Long) As LongPrivate Declare Function GetObjectType lib "gdi32" (ByVal hgdiobj As Long) As LongPrivate Declare Function GetObject lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As LongPrivate Declare Function DrawIcon Lib "user32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As LongPrivate Declare Function DrawState Lib "user32 "Alias" DrawStatea "(Byval Hbrush As Long, Byval LPDrawStateProc As Long, Byval LParam As Long, Byval WParam As Long, BYVAL N1 As Long, Byval N2 As Long, Byval N3 As Long, BYVAL N4 As long , BYVAL UN As long, As Longprivate Declar E FUNCTION DELETEOBJECT LIB "GDI32" (Byval Hobject As Long) AS Long '****************************************** ************************************** ** function name: loadres' **入: No '** output: No' ** function description: Resource loading '** global variable:' ** Call Module: '** Server: Ye Fan' ** Japan: 2005-03-15 12 : 27: 34 '** Modifier:' ** Japan: '** Edition: v1.0.0' *********************** ***************************************************************************** SUB Loadres () DIM HRES AS Long Dim Strdata As String Dim HBMP AS Long Dim Hicon As Long Dim Bitbmp as BitmapInfo 'Load DLL HRES =
LoadLibrary (Combo1.Text) 'string strData = Space (255) LoadString hRes, IDS_STRING1, strData, 255 Label1 (0) .Caption = Trim (strData) strData = Space (255) LoadString hRes, IDS_STRING2, strData, 255 Label1 ( 1) .Caption = Trim (strData) strData = Space (255) LoadString hRes, IDS_STRING3, strData, 255 Label1 (2) .Caption = Trim (strData) 'bitmap hBmp = LoadBitmap (hRes, IDB_BITMAP1) If GetObjectType (hBmp) = Obj_bitmap dam, Bitbmp DrawState Picture1 (0) .hdc, 0, BYVAL 0, HBMP, 0, 0, 0, Bitbmp.Bmiheader.biwidth, Bitbmp.Bmiheader.biheight, DST_bitmap endiffs icon Hicon = loading (hres, idi_icon1) Drawicon Picture1 (1) .hdc, 0, 0, Hicon 'release resource deleteObject HBMP DeleteObject Hicon' release DLL FREELIBRARY HRESEND SUB '*************** *********************************************************** ******** '** function name: Combo1_click' ** input: no '** output: no' ** function description: Replace DLL '** global variable:' ** Call Module: ' ** Author: Ye Fan '** Japan: 2005- 03-15 12:28:49 ** Modify: '** Japan:' ** version: v1.0.0 '****************** *********************************************************** *** Private sub combo1_click () loadresend sub '************************************************* ********************************** ** function name: form_load '** input: no' * * Out: no '** function description: Initialization' ** global variable: '** Call Module:' ** Author: Ye Fan '** Japan: 2005-03-15 12: 28: 58' * * Modify: '** Japan:' ** version: v1.0.0 '
*********************************************************** ******************************** Private Sub Form_Load () Combo1.listIndex = 0 loadresend sub '*************** *********************************************************** ********* '** function name: Picture1_paint' ** input: index (integer) - '** output: no' ** function description: Refresh "** global variable: '** Calling module: '** Author: Ye Fan' ** Japanese period: 2005-03-15 12:29:03 '** Modify:' ** Japan: '** version: v1.0.0' * *********************************************************** ******************************* * Private Sub Picture1_paint (INDEX AS INTEGER) Loadresend Sub Running Sub Running: Running Download Address: http: // Www.sky-walker.com.cn/yefan/sourcecode/dllres.rar