vb中picture控件怎么调用程序里的图标啊
比如:123.exe,能不能picture1.picture=LoadPicture("123.exe内部的图标文件")...
比如:123.exe,能不能
picture1.picture = LoadPicture("123.exe内部的图标文件") 展开
picture1.picture = LoadPicture("123.exe内部的图标文件") 展开
2个回答
展开全部
下面的方法可以实现,看下应该会用吧!
你上面写的不能,API可以,如下
Option Explicit
Const DI_MASK = &H1
Const DI_IMAGE = &H2
Const DI_NORMAL = DI_MASK Or DI_IMAGE
Private Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias "ExtractAssociatedIconA" (ByVal hInst As Long, ByVal lpIconPath As String, lpiIcon As Long) As Long
Private Declare Function DrawIconEx Lib "user32" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
Private Sub Picture1_Paint()
Dim mIcon As Long
mIcon = ExtractAssociatedIcon(App.hInstance, "C:\WINDOWS\regedit.exe", 2)
DrawIconEx Picture1.hdc, 0, 0, mIcon, 0, 0, 0, 0, DI_NORMAL
DestroyIcon mIcon
End Sub
你上面写的不能,API可以,如下
Option Explicit
Const DI_MASK = &H1
Const DI_IMAGE = &H2
Const DI_NORMAL = DI_MASK Or DI_IMAGE
Private Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias "ExtractAssociatedIconA" (ByVal hInst As Long, ByVal lpIconPath As String, lpiIcon As Long) As Long
Private Declare Function DrawIconEx Lib "user32" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
Private Sub Picture1_Paint()
Dim mIcon As Long
mIcon = ExtractAssociatedIcon(App.hInstance, "C:\WINDOWS\regedit.exe", 2)
DrawIconEx Picture1.hdc, 0, 0, mIcon, 0, 0, 0, 0, DI_NORMAL
DestroyIcon mIcon
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询