7,763
社区成员
发帖
与我相关
我的任务
分享
Private Declare Function extracticon& Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByValnIconIndex As Long)
Private Declare Function DrawIcon& Lib "user32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal hIcon As Long)
Private Sub Command1_Click()
'获取程序图标
Dim X As Integer, myval As Integer
CommonDialog1.Filter = "EXE 文件|*.EXE"
CommonDialog1.ShowOpen
Picture1.Cls
hIcon = extracticon(0, CommonDialog1.filename, 0)
X = DrawIcon(Picture1.hDC, 5, 5, hIcon)
End Sub
Private Sub Command2_Click()
'图标另存为
Dim filename As String
On Error Resume Next
Picture1.Picture = Picture1.Image
CommonDialog1.DialogTitle = "保存"
CommonDialog1.Flags = cdlOFNHideReadOnly Or cdlOFNOverwritePrompt
CommonDialog1.Filter = "位图文件(*.ico)|*.ico"
CommonDialog1.ShowSave
If Err = 32755 Then Exit Sub
filename = CommonDialog1.filename
If filename <> "" Then
SavePicture Picture1.Picture, filename
End If
End Sub