Date: 02-16-2022
Return to Index
created by gbSnippets
'... this snippet is in work
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg,hIcon,hGraphic,hModule As Dword, ResourceName, ExeName As String
%IDC_Graphic = 300 : %IDC_Extract = 301 : %IDC_Select = 302 : %IDC_TextBox = 303
Function PBMain() As Long
ExeName = EXE.Path$ + "gblaunch.exe"
Dialog New Pixels, 0, "Icon Extractor",300,300,400,160, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Select, "Select File", 10,10,80,25
Control Add Button, hDlg, %IDC_Extract, "Extract Icon", 100,10,80,25
Control Add TextBox, hDlg, %IDC_TextBox, "gblaunch.exe",10,45,380,20
Control Add Graphic, hDlg, %IDC_Graphic,"", 10,75,32,32, %WS_Visible Or %WS_Border 'w,h will change once resources are read
Graphic Attach hDlg, %IDC_Graphic
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Select
Case %IDC_Extract
GetResourceName
GetImageDimensions
DisplayIcon
End Select
Case %WM_Destroy
FreeLibrary hModule
End Select
End Function
Function EnumResNameProc (ByVal hModule As Dword, ByVal lpszType As Asciiz Ptr, ByVal lpszName As Asciiz Ptr, ByVal lParam As Long) As Long
lParam = lpszName
Shift Right lParam, 16
ResourceName = IIf$(lParam,@lpszName, "#"+Format$(lpszName))
End Function
Sub GetResourceName
Control Get Text hDlg, %IDC_TextBox To ExeName
If InStr(ExeName,"\") = 0 Then ExeName = EXE.Path$ + ExeName
hModule = LoadLibrary ((ExeName))
EnumResourceNames GetModuleHandle((ExeName)), ByVal %RT_Group_Icon, CodePtr(EnumResNameProc), 0 'get first icon
End Sub
Sub GetImageDimensions
End Sub
Sub DisplayIcon
End Sub
'gbs_00885
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm