Fonction Exploreur

Sujets variés concernant le développement en PureBasic
Anonyme2
Messages : 3518
Inscription : jeu. 22/janv./2004 14:31
Localisation : Sourans

Fonction Exploreur

Message par Anonyme2 »

Voilà,

lorsque l'on ouvre l'exploreur windows ou autre on a dans la fenêtre le nom du fichier/dossier, sa taille puis le type.


Ce type est une description sommaire et c'est ce que je recherche. Trouve-t-on ces infos dans la base de registre, ou y a-t-il une API qui m'échappe ? ou faut-il créer soit même cette chaîne ?
Anonyme2
Messages : 3518
Inscription : jeu. 22/janv./2004 14:31
Localisation : Sourans

Message par Anonyme2 »

Personne ? :oops:

Fred, tu as construits toi-même cette chaîne qui indique le type ou il existe une API qui va bien et que je n'ai pas trouvé ?

Merci
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Message par Le Soldat Inconnu »

avec SHGetFileInfo_()
· pszPath
Pointer to a buffer that contains the path and filename. Both absolute and relative paths are valid. If uFlags includes the SHGFI_PIDL, value pszPath must be the address of an ITEMIDLIST structure that contains the list of item identifiers that uniquely identifies the file within the shell’s name space.
This string can use either short (the 8.3 form) or long filenames.

· dwFileAttributes
Array of file attribute flags (FILE_ATTRIBUTE_ values). If uFlags does not include the SHGFI_USEFILEATTRIBUTES value, this parameter is ignored.

· psfi and cbFileInfo
Address and size, in bytes, of the SHFILEINFO structure that receives the file information.

· uFlags
Flag that specifies the file information to retrieve. This parameter can be a combination of the following values: SHGFI_ATTRIBUTES
Retrieves the file attribute flags. The flags are copied to the dwAttributes member of the structure specified by psfi.
SHGFI_DISPLAYNAME
Retrieves the display name for the file. The name is copied to the szDisplayName member of the structure specified by psfi.
The returned display name uses the long filename, if any, rather than the 8.3 form of the filename.
SHGFI_EXETYPE
Returns the type of the executable file if pszPath identifies an executable file. For more information, see the comments below.
SHGFI_ICON
Retrieves the handle of the icon that represents the file and the index of the icon within the system image list. The handle is copied to the hIcon member of the structure specified by psfi, and the index is copied to the iIcon member. The return value is the handle of the system image list.
SHGFI_ICONLOCATION
Retrieves the name of the file that contains the icon representing the file. The name is copied to the szDisplayName member of the structure specified by psfi.
SHGFI_LARGEICON
Modifies SHGFI_ICON, causing the function to retrieve the file’s large icon.
SHGFI_LINKOVERLAY
Modifies SHGFI_ICON, causing the function to add the link overlay to the file’s icon.
SHGFI_OPENICON
Modifies SHGFI_ICON, causing the function to retrieve the file’s open icon. A container object displays an open icon to indicate that the container is open.
SHGFI_PIDL
Indicates that pszPath is the address of an ITEMIDLIST structure rather than a path name.
SHGFI_SELECTED
Modifies SHGFI_ICON, causing the function to blend the file’s icon with the system highlight color.
SHGFI_SHELLICONSIZE
Modifies SHGFI_ICON, causing the function to retrieve a shell-sized icon. If this flag is not specified, the function sizes the icon according to the system metric values.
SHGFI_SMALLICON
Modifies SHGFI_ICON, causing the function to retrieve the file’s small icon.
SHGFI_SYSICONINDEX
Retrieves the index of the icon within the system image list. The index is copied to the iIcon member of the structure specified by psfi. The return value is the handle of the system image list.
SHGFI_TYPENAME
Retrieves the string that describes the file’s type. The string is copied to the szTypeName member of the structure specified by psfi.

SHGFI_USEFILEATTRIBUTES
Indicates that the function should use the dwFileAttributes parameter.

To retrieve the executable file type, uFlags must specify only SHGFI_EXETYPE. The return value specifies the type of the executable file:
0
Nonexecutable file or an error condition.
LOWORD = NE or PE
HIWORD = 3.0, 3.5, or 4.0
Windows application
LOWORD = MZ
HIWORD = 0
MS-DOS .EXE, .COM or .BAT file
LOWORD = PE
HIWORD = 0
Win32 console application
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Anonyme2
Messages : 3518
Inscription : jeu. 22/janv./2004 14:31
Localisation : Sourans

Message par Anonyme2 »

Merci Régis,

je fatigue car j'utilise cet API pour retrouver l'indice de l'icon dans la ListImage Système....

{SHGetFileInfo_(Folder + PeekS(@FileInfos\cFileName[0]), 0, @InfosFile, SizeOf(SHFILEINFO), #SHGFI_SYSICONINDEX | #SHGFI_SMALLICON )}
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Message par Le Soldat Inconnu »

par contre, j'ai essayé et le résultat est bizarre.

si tu y arrives, tu donnes le code :D
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Anonyme2
Messages : 3518
Inscription : jeu. 22/janv./2004 14:31
Localisation : Sourans

Message par Anonyme2 »

Je poste un bout de code demain, ça marche.


Simplement la structure SHFILEINFO définie dans PB est fausse...
C'est pour ça que tu n'as pas les bons résultats.
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Message par Le Soldat Inconnu »

d'accord, mais quand je l'écrit moi même, ça rale ??

c'est le compiler ou c'est jaPBe.

Faut changer le nom pour que ça marche ?
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Anonyme2
Messages : 3518
Inscription : jeu. 22/janv./2004 14:31
Localisation : Sourans

Message par Anonyme2 »

Essaye ça

Code : Tout sélectionner

Structure SHFILEINFO_Ok ; la structure SHFILEINFO PB est fausse
   hIcon.l
   iIcon.l
   dwAttributes.l
   szDisplayName.b[#MAX_PATH]
   szTypeName.b[80]
EndStructure


Structure LVITEM ; La structure LV_ITEM est incomplète
   Mask.l
   iItem.l
   iSubItem.l
   State.l
   stateMask.l
   pszText.l
   cchTextMax.l
   iImage.l
   lParam.l
   iIndent.l
   iGroupId.l
   cColumns.l
   puColumns.l
EndStructure


If OpenWindow(0, 0, 0, 600, 400, #PB_Window_WindowCentered | #PB_Window_SystemMenu, "Mini Exploreur de fichiers")
   If CreateGadgetList(WindowID())
      IdListIcon = ListIconGadget(0, 10, 10, 580, 380, "Fichier", 575 / 2, #LVS_SHAREIMAGELISTS)
      AddGadgetColumn(0, 1, "Type", 575 / 2)
      
      ; Assign la listImage système à la listIcon
      CurrentDirectory.s = Space(#MAX_PATH)
      GetSystemDirectory_(CurrentDirectory, #MAX_PATH)
      hImageListS.l = SHGetFileInfo_(CurrentDirectory, 0, @InfosFile.SHFILEINFO_Ok, SizeOf(SHFILEINFO_Ok), #SHGFI_SYSICONINDEX | #SHGFI_SMALLICON)
      ImageList_SetBkColor_(hImageListS, #CLR_NONE)
      SendMessage_(IdListIcon, #LVM_SETIMAGELIST, #LVSIL_SMALL, hImageListS)
      NomFichier$ = Space(256)

      Dossier.s ="A:\"

      If ExamineDirectory(0, Dossier, "*.*")         
         Repeat
            Type = NextDirectoryEntry()
            If Type 
            NomFichier$ = DirectoryEntryName()
            
            ; on récupère les infos sur l'icône et sur la description du fichier
            SHGetFileInfo_(Dossier + NomFichier$, 0, @InfosFile, SizeOf(SHFILEINFO_Ok), #SHGFI_SYSICONINDEX | #SHGFI_SMALLICON | #SHGFI_TYPENAME)
            
            ; on affiche le 1er élément dans la listicongadget, soit le fichier + l'icône
            
            VarList.LVITEM\Mask = #LVIF_TEXT | #LVIF_IMAGE ; ; mask défini le type de données | #LVIF_PARAM
            VarList\iImage = InfosFile\iIcon ; l'index de l'icon dans la liste système
            VarList\pszText = @NomFichier$ ; la chaîne à afficher
            VarList\iSubItem = 0 ; indique que c'est le premier élément et pas un sous-élément
            
            ; on envoie le message pour afficher le premier élément
            SendMessage_(IdListIcon, #LVM_INSERTITEM, 0, @VarList)
            
            ; on envoie le message pour afficher le deuxième élément
            VarList\Mask = #LVIF_TEXT
            VarList\pszText = @InfosFile\szTypeName[0] ; la chaîne à afficher
            VarList\iSubItem = 1 ; indique que c'est le deuxième 

            ; on envoie le message
            SendMessage_(IdListIcon, #LVM_SETITEM, 0, @VarList)
            
            EndIf
         Until Type = 0

      EndIf
      
   EndIf
   
   
   Repeat
      
   Until WaitWindowEvent() = #PB_EventCloseWindow
EndIf
End
Dernière modification par Anonyme2 le mer. 12/mai/2004 8:18, modifié 1 fois.
Anonyme2
Messages : 3518
Inscription : jeu. 22/janv./2004 14:31
Localisation : Sourans

Message par Anonyme2 »

Tu peut changer le dossier, j'ai mis A:\ pour faire des essais


Met ce que tu veux
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Message par Le Soldat Inconnu »

ah ben voila, toi aussi, tu as trouvé cette structure de PB bizarre et tu la fait toi même.
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Répondre