VB里怎么把某个程序的图标,导入的IMAGE里。
我是想做个程序,就是把常用的软件,都添加到这个程序里来,以后启动的时候方便点。不用再去很多图标里找...
我是想做个程序,就是把常用的软件,都添加到这个程序里来,以后启动的时候方便点。不用再去很多图标里找
展开
1个回答
2013-09-21
展开全部
你的意思是即时获得某个EXE文件的图标是吧。我的程序里是这样实现的,效果很好哦。支持XP下的图标透明效果。不能使用IMAGE,必须使用PICTURE。Private Type SHFILEINFO
hIcon As Long ' out: icon
iIcon As Long ' out: icon index
dwAttributes As Long ' out: SFGAO_ flags
szDisplayName As String * MAX_PATH ' out: display name (or path)
szTypeName As String * 80 ' out: type name
End Type '得到文件信息
Private Declare Function SHGetFileInfo Lib "shell32" Alias "SHGetFileInfoA" (ByVal pszPath As String, ByVal dwFileAttributes As Long, psfi As SHFILEINFO, ByVal cbFileInfo As Long, ByVal uFlags As Long) As Long '获得文件透明图标
Public Declare Function DrawIcon Lib "user32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal hIcon As Long) As Long
Public Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long Public Function GetFileIco(FileName As String, icon_size As Long) As Long '得到透明图标
On Error Resume Next
Const SHGFI_ICON = &H100
Dim hIcon As Long
Dim sh_info As SHFILEINFO SHGetFileInfo FileName, 0, sh_info, Len(sh_info), SHGFI_ICON + icon_size
hIcon = sh_info.hIcon
GetFileIco = hIcon
End Function
hIcon As Long ' out: icon
iIcon As Long ' out: icon index
dwAttributes As Long ' out: SFGAO_ flags
szDisplayName As String * MAX_PATH ' out: display name (or path)
szTypeName As String * 80 ' out: type name
End Type '得到文件信息
Private Declare Function SHGetFileInfo Lib "shell32" Alias "SHGetFileInfoA" (ByVal pszPath As String, ByVal dwFileAttributes As Long, psfi As SHFILEINFO, ByVal cbFileInfo As Long, ByVal uFlags As Long) As Long '获得文件透明图标
Public Declare Function DrawIcon Lib "user32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal hIcon As Long) As Long
Public Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long Public Function GetFileIco(FileName As String, icon_size As Long) As Long '得到透明图标
On Error Resume Next
Const SHGFI_ICON = &H100
Dim hIcon As Long
Dim sh_info As SHFILEINFO SHGetFileInfo FileName, 0, sh_info, Len(sh_info), SHGFI_ICON + icon_size
hIcon = sh_info.hIcon
GetFileIco = hIcon
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询