Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function EnumResourceNames Lib "kernel32" Alias "EnumResourceNamesA" (ByVal hModule As Long, ByVal lpType As String, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function EnumResourceNamesById Lib "kernel32" Alias "EnumResourceNamesA" (ByVal hModule As Long, ByVal lpType As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function EnumResourceTypes Lib "kernel32" Alias "EnumResourceTypesA" (ByVal hModule As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function LoadLibraryEx Lib "kernel32" Alias "LoadLibraryExA" (ByVal lpLibFileName As String, ByVal hFile As Long, ByVal dwFlags As Long) As Long
Private Const LOAD_LIBRARY_AS_DATAFILE = 2
Private Const RT_CURSOR = 1&
Private Const RT_BITMAP = 2&
Private Const RT_ICON = 3&
Private Const RT_MENU = 4&
Private Const RT_DIALOG = 5&
Private Const RT_STRING = 6&
Private Const RT_FONTDIR = 7&
Private Const RT_FONT = 8&
Private Const RT_ACCELERATOR = 9&
Private Const RT_RCDATA = 10&
Private Const RT_MESSAGETABLE = 11
Private Const RT_GROUP_CURSOR = 12
Private Const RT_GROUP_ICON = 14
Private Const RT_VERSION = 16
Private Const RT_DLGINCLUDE = 17
Private Const RT_PLUGPLAY = 19
Private Const RT_VXD = 20
Dim modulehandle&
' This callback represents the EnumResourceTypes callback
' lval1 is the module handle.
' lval2 is the type.
' lval3 is user defined.
Private Sub Callback1_cbxLLL(lval1 As Long, lval2 As Long, lval3 As Long, retval As Long)
' If the high word is zero, this is a standard
' resource type.
If (lval2 And &HFFFF0000) = 0 Then
Select Case lval2
Case RT_CURSOR
lstTypes.AddItem "Cursors"
Case RT_BITMAP
lstTypes.AddItem "Bitmaps"
Case RT_ICON
lstTypes.AddItem "Icons"
Case RT_MENU
lstTypes.AddItem "Menu"
Case RT_DIALOG
lstTypes.AddItem "Dialog"
Case RT_STRING
lstTypes.AddItem "String"
Case RT_FONTDIR
lstTypes.AddItem "Font Directory"
Case RT_FONT
lstTypes.AddItem "Font"
Case RT_ACCELERATOR
lstTypes.AddItem "Accelerator"
Case RT_RCDATA
lstTypes.AddItem "RCData"
Case RT_MESSAGETABLE
lstTypes.AddItem "Message Table"
Case RT_GROUP_CURSOR
lstTypes.AddItem "Cursor (hardware independent)"
Case RT_GROUP_ICON
lstTypes.AddItem "Icon (hardware independent)"
Case RT_VERSION
lstTypes.AddItem "Version"
Case RT_PLUGPLAY
lstTypes.AddItem "Plug & Play Info"
Case Else
lstTypes.AddItem Hex$(lval2)
End Select
lstTypes.ItemData(lstTypes.NewIndex) = lval2
Else ' The resource type is defined by a string
lstTypes.AddItem agGetStringFromPointer(lval2)
lstTypes.ItemData(lstTypes.NewIndex) = 0
End If
retval = True
End Sub
' The cbkNames callback is used for EnumResourceNames
' lval1 is the module handle
' lval2 is the resource type
' lval3 is the resource name or id
' lval4 is user defined
Private Sub cbkNames_cbxLLLL(lval1 As Long, lval2 As Long, lval3 As Long, lval4 As Long, retval As Long)
' The resource has a name or identifier depending on whether
' the high word is zero.
If (lval3 And &HFFFF0000) <> 0 Then
' Show the resource name
lstNames.AddItem agGetStringFromPointer(lval3)
Else
' Show the resource Identifier
lstNames.AddItem Hex$(lval3)
End If
retval = True
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
Dim res&
' Free the previous library if present
If modulehandle <> 0 Then
Call FreeLibrary(modulehandle)
End If
' Load in the file into the address space, but don't allow it to