用Imagelist如何获取如文件、打印等图标,过去用过,好像在操作系统目录下,今天怎么也找不到那个图标了.......
你搜索ICO图标
网上找一个取EXE文件中的图标的程序,走一下就可以了
可以从\windows\explorer.exe中提取图标。
使用以下的模块:
Attribute VB_Name = "ExtractIcon"
Option Explicit
Private Const MAX_PATH = 260
Private Const SHGFI_ICON = &H100
Private Const SHGFI_SYSICONINDEX = &H4000 get system icon index
Private Const SHGFI_LARGEICON = &H0 get large icon
Private Const SHGFI_SMALLICON = &H1 get small icon
Private Const ILD_TRANSPARENT = &H1 透明
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
Global lIcon&
Global sSourcePgm$
Global sDestFile$
Public Declare Function ExtractIconAPI Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex 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
Private Declare Function ImageList_Draw Lib "comctl32.dll" (ByVal himl&, ByVal i&, ByVal hDCDest&, ByVal x&, ByVal y&, ByVal flags&) As Long
Private Declare Function SHGetFileInfo Lib "shell32.dll" Alias "SHGetFileInfoA" (ByVal pszPath As String, ByVal dwFileAttributes As Long, psfi As SHFILEINFO, ByVal cbFileInfo As Long, ByVal uFlags As Long) As Long
Public Function GetIcon(ByVal sPath$, oPictureBox As PictureBox) As Long
Dim xPixels&, yPixels&
xPixels = Screen.TwipsPerPixelX
yPixels = Screen.TwipsPerPixelY
Dim himl&, rtn&
Dim shinfo As SHFILEINFO
Dim picLeft As Long
Dim pic As Long
himl = SHGetFileInfo(sPath, 0&, shinfo, Len(shinfo), SHGFI_SYSICONINDEX Or SHGFI_LARGEICON)
If himl <= 0 Then GetIconNogray = -1: Exit Function 没有图标就返回-1
picLeft = (oPictureBox.ScaleWidth / xPixels) / 2 - 16
pic = (oPictureBox.ScaleHeight / yPixels) / 2 - 16
oPictureBox.Picture = LoadPicture()
oPictureBox.AutoRedraw = True
rtn = ImageList_Draw(himl, shinfo.iIcon, oPictureBox.hdc, picLeft, pic, ILD_TRANSPARENT)
oPictureBox.Refresh
GetIconNogray = himl 返回图标句柄
End Function
你只需要按以下方法调用就以实现:
dim hIcon as long存放返回的图标句柄
hIcon=GetIcon("c:\windows\explorer.exe",aPictureBox)
第一个参数与你系统位置有关;第二个参数用于显示图标;返回值是一个图标句柄,用于其它地方引用。
系目录下去搜搜不就有了。。
*.ico
上网找,多了
QQ:105537693
发给你不久行了
我在c盘中查找就可以找到。
可以找到