首页/技术开发/内容

用Visual Basic提取图标资源

技术开发2022-07-19 阅读()
*.exe"

  CommonDialog1.ShowOpen

  icon_filename = CommonDialog1.FileName

  Picture1.Cls

  hmodule = GetModuleHandle(icon_filename) '取得文件句柄

  icon_num = ExtractIcon(hmodule, icon_filename, -1) '得到文件内图标总数

  HScroll1.Max = icon_num

  Label1.Caption = Str(icon_num)

  If icon_num - 1 > 0 Then

  HScroll1.Enabled = True

  Else

  HScroll1.Enabled = False

  End If

  icon_n = ExtractIcon(hmodule, icon_filename, 0) '提取第一个图标

  x = DrawIcon(Picture1.hdc, 0, 0, icon_n) '画出图标

  If icon_num = 0 Then

  HScroll1.Value = 0

  Else

  HScroll1.Value = 1

  End If

  Label2.Caption = HScroll1.Value

  End Sub

  Private Sub Command2_Click()

  End

  End Sub

  Private Sub HScroll1_Change()

  Picture1.Cls

  icon_n = HScroll1.Value

  hmodule = GetModuleHandle(icon_filename)

  icon_n = ExtractIcon(hmodule, icon_filename, icon_n - 1)

  Label2.Caption = HScroll1.Value

  x = DrawIcon(Picture1.hdc, 0, 0, icon_n)

  End Sub 

第1页  第2页 

……

相关阅读