VISUAL FOLDER MANAGER ( GESTION DE FICHIERS AVEC FILESYSTEMOBJECT + EXPLORATEUR

ScSami Messages postés 1488 Date d'inscription mercredi 5 février 2003 Statut Membre Dernière intervention 3 décembre 2007 - 31 mars 2005 à 01:06
XelectroX Messages postés 209 Date d'inscription samedi 11 novembre 2000 Statut Membre Dernière intervention 6 novembre 2009 - 19 août 2008 à 19:14
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.

https://codes-sources.commentcamarche.net/source/30438-visual-folder-manager-gestion-de-fichiers-avec-filesystemobject-explorateur-treeview

XelectroX Messages postés 209 Date d'inscription samedi 11 novembre 2000 Statut Membre Dernière intervention 6 novembre 2009
19 août 2008 à 19:14
@ScSami : J'ai ce qu'il te faut mais en VB.NET. Je l'ai trouvé je sais plus où mais bon ...
Récupères-en ce qu'il te faut ;)

Public Class AdvancedFileInfo
Inherits System.IO.FileSystemInfo
' Enumération des valeurs dispo pour le paramètre flag de SHGetFileInfo
<Flags()> Private Enum SHGFI
SmallIcon = &H1
LargeIcon = &H0
Icon = &H100
DisplayName = &H200
Typename = &H400
SysIconIndex = &H4000
UseFileAttributes = &H10
End Enum
Public Enum IconType
SmallIcon = True
LargeIcon = False
End Enum
' Structure contenant les informations sur un objet du filesystem
<StructLayout(LayoutKind.Sequential)> _
Private Structure SHFILEINFO
Public hIcon As IntPtr
Public iIcon As Integer
Public dwAttributes As Integer
<MarshalAs(UnmanagedType.LPStr, SizeConst:=260)> _
Public szDisplayName As String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=80)> _
Public szTypeName As String
Public Sub New(ByVal B As Boolean)
hIcon = IntPtr.Zero
iIcon = 0
dwAttributes = 0
szDisplayName = vbNullString
szTypeName = vbNullString
End Sub
End Structure

' Permet de retourver les informations sur un fichier, un répertoire, un disque
Private Declare Auto Function SHGetFileInfo Lib "shell32" ( _
ByVal pszPath As String, ByVal dwFileAttributes As Integer, _
ByRef psfi As SHFILEINFO, ByVal cbFileInfo As Integer, ByVal uFlagsn As SHGFI) As Integer
Public Overrides ReadOnly Property Name() As String
Get
Dim Info As New FileInfo(Me.OriginalPath)
Name = Info.Name
Info = Nothing
End Get
End Property
Public Overrides Sub Delete()
Dim Info As New FileInfo(Me.OriginalPath)
Info.Delete()
Info = Nothing
End Sub
Public Overrides ReadOnly Property Exists() As Boolean
Get
Dim Info As New FileInfo(Me.OriginalPath)
Exists = Info.Exists
Info = Nothing
End Get
End Property
Public ReadOnly Property AssociatedIcon(ByVal IconSize As IconType, Optional ByVal MustExist As Boolean = True) As Icon
Get
If MustExist Then
If Me.Exists Then
AssociatedIcon = GetIcon(Me.OriginalPath, IconSize)
Else
AssociatedIcon = Nothing
End If
Else
AssociatedIcon = GetIcon(Me.OriginalPath, IconSize)
End If
End Get
End Property
Public ReadOnly Property TypeName()
Get
Dim hsubKey As RegistryKey
Dim sApplication As String
TypeName = ""
Dim extension = New FileInfo(Me.OriginalPath).Extension
hsubKey = Registry.ClassesRoot.OpenSubKey(extension)
If Not hsubKey Is Nothing Then
sApplication = hsubKey.GetValue("")
hsubKey.Close()
Try
TypeName = Registry.ClassesRoot.OpenSubKey(sApplication).GetValue("")
Catch
End Try
End If
hsubKey = Nothing
End Get
End Property
Private Function GetIcon(ByVal Path As String, Optional ByVal Ico As IconType = True) As Icon
Dim info As New SHFILEINFO(True)
Dim cbSizeInfo As Integer = Marshal.SizeOf(info)
Dim flags As SHGFI = SHGFI.Icon Or SHGFI.UseFileAttributes
If Ico = True Then
flags += SHGFI.SmallIcon
Else
flags += SHGFI.LargeIcon
End If
SHGetFileInfo(Path, 256, info, cbSizeInfo, flags)
Dim hIcon = info.hIcon
info = Nothing
Return Icon.FromHandle(hIcon)
End Function
Private Function ExtractDefaultIcon() As String
Dim hsubKey As RegistryKey
Dim sApplication As String
ExtractDefaultIcon = ""
hsubKey = Registry.ClassesRoot.OpenSubKey(Me.Extension)
If Not hsubKey Is Nothing Then
sApplication = hsubKey.GetValue("")
hsubKey.Close()
hsubKey = Registry.ClassesRoot.OpenSubKey(sApplication & "\DefaultIcon")
If Not hsubKey Is Nothing Then
ExtractDefaultIcon = hsubKey.GetValue("")
hsubKey.Close()
End If
End If
hsubKey = Nothing
End Function
Public Sub New(ByVal FileName As String)
Me.OriginalPath = FileName
End Sub
End Class
thomas nares Messages postés 7 Date d'inscription mercredi 12 janvier 2005 Statut Membre Dernière intervention 28 mars 2006
3 avril 2005 à 12:50
J'ai fait une mise a jour de mon code mais en tant que nouvelle source ...Car le concept change un peut (2 explorateurs)

http://www.vbfrance.com/code.aspx?ID=30509

A+
Tom.
thomas nares Messages postés 7 Date d'inscription mercredi 12 janvier 2005 Statut Membre Dernière intervention 28 mars 2006
1 avril 2005 à 18:23
Pour ca desolé, je sais pas faire !

A+
ScSami Messages postés 1488 Date d'inscription mercredi 5 février 2003 Statut Membre Dernière intervention 3 décembre 2007 24
31 mars 2005 à 23:34
Pour extraire des icones, ça, je sais faire!!!

Non, moi je parles d'utiliser ceux que Windows chargent en mémoire (dans l'Image-List system par exemple).

Faut quand même le dire, c'est con que Microsoft n'est pas mis les 2 contrôles constituant un explorateur de fichier (modern) dans le VB...
ludovicanceaux Messages postés 440 Date d'inscription mardi 21 octobre 2003 Statut Membre Dernière intervention 6 mai 2010
31 mars 2005 à 13:07
Franchement le concept est pas mal!!!!!!!!!!! à évoluer
thomas nares Messages postés 7 Date d'inscription mercredi 12 janvier 2005 Statut Membre Dernière intervention 28 mars 2006
31 mars 2005 à 10:17
Sous xp ,ils sont dans c:\windows\system32\shell32.dll
Tu peut les extraire avec quickicongrabber :

http://www.01net.com/telecharger/windows/Personnaliser/Icone/fiches/2445.html
ScSami Messages postés 1488 Date d'inscription mercredi 5 février 2003 Statut Membre Dernière intervention 3 décembre 2007 24
31 mars 2005 à 01:06
Salut, Moi je suis sous VB6... Et, justement, je cherche également à faire un explorateur de fichiers.

Mais voilà, je suis confronté à un problème :
Saurais-tu comment obtenir les icones du bureau, poste de travail, corbeille et co ???
Rejoignez-nous