faustf Posted November 8, 2014 Share Posted November 8, 2014 hi guy i have a question example i want create a listview with , list of file , pdf , jpg ,avi ..... and want when a program find in folder a file recognise a right icon i saw exist in HKCU/software/classes/ a list of all file but i dont see or how can do for look a relative icon somthing can help me ? thankz alot Link to comment Share on other sites More sharing options...
jguinch Posted November 8, 2014 Share Posted November 8, 2014 _WinAPI_ShellGetFileInfo() ? faustf 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
faustf Posted November 8, 2014 Author Share Posted November 8, 2014 (edited) so probably i explain not so good suppose you have a list of file in txt , in this list you have pippo.avi , ciccio.pdf , mambo.mp3 ........... i want take this list and put in listview , and for each file associate the icon right , sure for do this i must look in registry hkcu/software/classes (because i use vlc , but other people use mediaplayer and i want a good association ). i look hkcu/software/classes/.avi and i see the first key = mplayerc.avi (is mediaplayer classic ) is not path of executable and i dont know how find a path for suck a icon thankz Edited November 8, 2014 by faustf Link to comment Share on other sites More sharing options...
BrewManNH Posted November 9, 2014 Share Posted November 9, 2014 (edited) First, you're looking in the wrong registry key. To find the program that is associated with a certain extension you need to look in HKCR. Lets take an example from my system (Windows 7 x64). File extension is .mp3. The first key you look in is: HKEY_CLASSES_ROOT.mp3 Then you look at the Default value of this file extension, on my computer it's listed as VLC.mp3 because VLC is the default program used to open mp3 files. Next you look in the key HKEY_CLASSES_ROOTVLC.mp3Shell The default value here tells you the default action to take when you double click on the file type, in my computer the default verb (action) is Open. So now we know what the default Verb is, we look in this key HKEY_CLASSES_ROOTVLC.mp3ShellOpenCommand Sometimes the default Verb isn't listed in the Shell key, the default Verb when it's not listed as default is usually Open, so even if it's blank, your best bet is to look in OpenCommand Inside the Command Key the default value listed is 99% of the time the program used to open it, and it's path to the program, on my computer the HKEY_CLASSES_ROOTVLC.mp3ShellOpenCommand default value is ""C:Program Files (x86)VideoLANVLCvlc.exe" --started-from-file "%1"" the part listed in red is the path and program name used in the Open verb to point to what opens this type of file. Edited November 9, 2014 by BrewManNH faustf 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 9, 2014 Moderators Share Posted November 9, 2014 I'd much rather use the shell info suggestion... but this may help as well. expandcollapse popup#include <Array.au3> ; for example only (_ArrayDisplay) Global $gs_TypeOfExtension = ".docx" ; $ga_DefaultIconData[1] = Default exe/dll/etc full path for icon ; $ga_DefaultIconData[2] = Icon number within exe/dll/etc to access Global $ga_DefaultIconData = _Reg_IconGetDefault($gs_TypeOfExtension) Switch @error Case 0 _ArrayDisplay($ga_DefaultIconData) Case 1 MsgBox(16 + 262144, "Error", "Could not find extension!") Case 2 MsgBox(16 + 262144, "Error", "Could not find path!") Case 3 MsgBox(16 + 262144, "Error", "File path does not exist!") EndSwitch Func _Reg_IconGetDefault($s_type) If StringLeft($s_type, 1) <> "." Then $s_type = "." & $s_type EndIf Local $s_root = "HKCR" If @AutoItX64 Then $s_root &= "64" $s_root &= "\" ; default icon location in registry Local $s_defaultico = RegRead($s_root & $s_type, "") If Not $s_defaultico Then Return SetError(1, 0, 0) ; provides location and what icon item to use Local $s_defaultlocation = RegRead($s_root & _ $s_defaultico & "\" & "DefaultIcon", "") If @error Or Not $s_defaultlocation Then Return SetError(2, @error, 0) EndIf Local $a_split = StringSplit($s_defaultlocation, ",") ; strip quotes For $i = 1 To UBound($a_split) - 1 $a_split[$i] = StringReplace($a_split[$i], '"', "") Next If Not FileExists($a_split[1]) Then Return SetError(3, 0, 0) EndIf Return $a_split EndFunc Keep in mind you'll be needing to understand _GUIImageList* functions a bit to accomplish what you're looking for. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
kylomas Posted November 9, 2014 Share Posted November 9, 2014 >This thread shows exactly how to implement what jguinch suggested. Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now