提取可执行文件内部所有图标VB源码程序,程序员在编程的过程中可以参考学习使用,希望对IT程序员有用,此源码程序简单易懂、方便阅读,有很好的学习价值!
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "从可执行文件或动态库文件中提取内部所有图标"
ClientHeight = 2190
ClientLeft = 5955
ClientTop = 5130
ClientWidth = 4215
Icon = "ExtractIcon.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2190
ScaleWidth = 4215
StartUpPosition = 2 '屏幕中心
Begin MSComDlg.CommonDialog Dlg
Left = 3360
Top = 120
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command2
Caption = "选择图标源"
Height = 375
Left = 600
TabIndex = 3
ToolTipText = "Select a different resource"
Top = 1440
Width = 1335
End
Begin VB.VScrollBar VScroll1
Height = 640
Left = 2640
TabIndex = 2
Top = 360
Width = 255
End
Begin VB.CommandButton Command1
Caption = "保存图标&Save"
Height = 375
Left = 2280
TabIndex = 1
ToolTipText = "Save the currently selected image into a file"
Top = 1440
Width = 1335
End
Begin VB.PictureBox Picture1
AutoRedraw = -1 'True
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 630
Left = 1200
ScaleHeight = 630
ScaleWidth = 630
TabIndex = 0
ToolTipText = "Use the scroll bar to view the images"
Top = 360
Width = 630
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "文件内部所含图标个数"
Height = 180
Left = 120
TabIndex = 4
Top = 0
Width = 1800
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
On Error Resume Next
With Dlg
.FileName = sDestFile
.CancelError = True
.Action = 2
If Err Then
Err.Clear
Exit Sub
End If
sDestFile = .FileName
SavePicture Picture1.Image, sDestFile
End With
End Sub
Private Sub Command2_Click()
Dim a%
On Error Resume Next
With Dlg
.FileName = sSourcePgm
.CancelError = True
.DialogTitle = "Select a DLL or EXE which includes Icons"
.Filter = "Icon Resources (*.ico;*.exe;*.dll)|*.ico;*.exe;*.dll|All files|*.*"
.Action = 1
If Err Then
Err.Clear
Exit Sub
End If
sSourcePgm = .FileName
DestroyIcon lIcon
Do
lIcon = ExtractIcon(App.hInstance, sSourcePgm, a)
If lIcon = 0 Then Exit Do
a = a + 1
DestroyIcon lIcon
Loop
If a = 0 Then
MsgBox "No Icons in this file!"
End If
Label1.Caption = "本文件内部共有 " & a & IIf(a = 1, " 个图标", " 个图标Images")
VScroll1.Max = IIf(a = 0, 0, a - 1)
VScroll1.Value = 0
VScroll1_Change
End With
End Sub
Private Sub VScroll1_Change()
DestroyIcon lIcon
Picture1.Cls
lIcon = ExtractIcon(App.hInstance, sSourcePgm, VScroll1.Value)
Picture1.AutoSize = True
Picture1.AutoRedraw = True
DrawIcon Picture1.hdc, 0, 0, lIcon
Picture1.Refresh
End Sub