以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  请教  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=151434)

--  作者:hb8888
--  发布时间:2020/6/23 11:57:00
--  请教
大师:请问为何下面的api获取不到图标
Public Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long


--  作者:有点蓝
--  发布时间:2020/6/23 14:31:00
--  
我测试也获取不了,至于为什么我也不懂,换种用法


全局

Public Declare Function ExtractIconEx Lib "shell32.dll" Alias  "ExtractIconEx" (lpszFile As String , niconIndex As Integer, phiconLarge() As Long,phiconSmall() As Long, nIcons As Integer) As Integer

调用,按钮click

Dim appPath = "C:\\Program Files (x86)\\Tencent\\TIM\\Bin\\QQScLauncher.exe"
Dim IconCount As Integer = ExtractIconEx(appPath , -1, Nothing, Nothing, 0)
Output.Show(IconCount )

Dim largeIcons(IconCount) As Long
    
Dim smallIcons(IconCount) As Long

ExtractIconEx(appPath, 0, largeIcons,smallIcons, IconCount)

Dim icon = system.drawing.Icon.FromHandle(largeIcons(0))
e.Sender.Image = icon .Tobitmap


--  作者:hb8888
--  发布时间:2020/6/23 19:50:00
--  
谢谢!如果我要通过api函数发送WM_SETICON消息,改变某一窗口的图标,怎么搞?
--  作者:有点蓝
--  发布时间:2020/6/23 20:03:00
--  
没用过。这种请自行百度学习