Question posted by: Raymond H.
(Guest)
on
July 17th, 2005 10:17 PM
Hello,
I try to make work this code but there is an error that occurs in the
line number 500. What isn't work? I'd like to display the icone in a
listview with the name of each file of a directory.
Thank's in advance.
Raymond H.
===========================================
'File1
'ListView1
'ImageList1
'Picture1
'Into Module1
Option Explicit
Public Const MAX_PATH = 260
Type SHFILEINFO 'Public ajouté par rh
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
Public 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
ImageList
Public Const SHGFI_ICON = &H100
Public Const SHGFI_SYSICONINDEX = &H4000
Public Const SHGFI_SHELLICONSIZE = &H4
Public Const SHGFI_SMALLICON = &H1
Public Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias
"ExtractAssociatedIconA" (ByVal hInst As Long, ByVal lpIconPath As String,
lpiIcon As Long) As Long
Public 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 Boolean
Public Const DI_NORMAL = 3
'Into form1
Option Explicit
Private Sub Form_Load()
Dim FileName As String, i As Integer
Dim hIcon As Long, nIconIndex As Long, retval As Long
Dim shgFileInfo As SHFILEINFO
ListView1.ListItems.Clear
ListView1.View = lvwList
i = 0
For i = 0 To File1.ListCount - 1
FileName = File1.Path & "\" & File1.List(i)
500 'Error with this line:
retval = SHGetFileInfo(FileName, 0, shgFileInfo, Len(shgFileInfo),
SHGFI_SYSICONINDEX Or SHGFI_ICON Or SHGFI_SHELLICONSIZE Or SHGFI_SMALLICON)
Picture1.Cls
retval = DrawIconEx(Picture1.hdc, 0, 0, shgFileInfo.hIcon, 0, 0, 0,
0, DI_NORMAL)
ImageList1.ListImages.Add , "K" & i, Picture1.Image
Next
Set ListView1.SmallIcons = ImageList1
For i = 0 To File1.ListCount - 1
ListView1.ListItems.Add , , File1.List(i), , "K" & i
Next
End Sub
=====================================
--
_________________________________________________
Avec le logiciel AllCrypter, que vous pouvez utiliser gratuitement jusqu'en
l'an 2006 (
www.logicipc.com ), décryptez le message ci-dessous en utilisant
cette clef de 4 mots:[color=blue][color=green][color=darkred]
>>>>> Ceci est la clef <<<<<[/color][/color][/color]
Voici le message secret que vous devez coller dans AllCrypter, dans la
fenêtre du 3e onglet en mode 'Texte', puis décryptez-le en cliquant sur la
ligne de commande 'Décrypter le texte venant d'un courriel' :[color=blue][color=green][color=darkred]
>>>DébutAllCrypter>>>4C6F6769636950435F456E6372797074E90D0A3131309A9999 9EB8AB5891D8A5ADDED3999FF5EBDCE1B17AADF2C3DADCC5CD D0B24A5BC2C6D67F4475BA555B927AF6EE041913867B15F1F1 168F17A97A69F81012C9A0E6A194D7A8ACE76979F3E10BB8D8 7769201426CD70C4FBE8222910C8CF22E9CE0F867FC2B4>>>FinAllCrypter>>>[/color][/color][/color]
_________________________________________________