How do I get the icon associated with a file type?

CodeProject has some classes you can download. First get the FileAssociationInfo, and from that get the ProgramAssociationInfo. The pai object can give you the icon. FileAssociationInfo fai = new FileAssociationInfo(“.bob”); ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID); ProgramIcon icon = pai.DefaultIcon;

How to get recommended programs associated with file extension in C#

I wrote a small routine: public IEnumerable<string> RecommendedPrograms(string ext) { List<string> progs = new List<string>(); string baseKey = @”Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.” + ext; using (RegistryKey rk = Registry.CurrentUser.OpenSubKey(baseKey + @”\OpenWithList”)) { if (rk != null) { string mruList = (string)rk.GetValue(“MRUList”); if (mruList != null) { foreach (char c in mruList.ToString()) progs.Add(rk.GetValue(c.ToString()).ToString()); } } } using (RegistryKey rk … Read more

MacOSX – File extension associate with application – Programmatically

To register a new file extension with an application use the following defaults command. Replace PUT_FILE_EXTENSION_HERE_WITHOUT_PERIOD with the file extension i.e. txt. Replace org.category.program with the com/org name of your program i.e. com.apple.itunes. $ defaults write com.apple.LaunchServices LSHandlers -array-add \ “<dict><key>LSHandlerContentTag</key> <string>PUT_FILE_EXTENSION_HERE_WITHOUT_PERIOD</string><key>LSHandlerContentTagClass</key> <string>public.filename-extension</string><key>LSHandlerRoleAll</key> <string>org.category.program</string></dict>” Once you have added the file extension to the launch services, … Read more

Open file with associated application

Just write System.Diagnostics.Process.Start(@”file path”); example System.Diagnostics.Process.Start(@”C:\foo.jpg”); System.Diagnostics.Process.Start(@”C:\foo.doc”); System.Diagnostics.Process.Start(@”C:\foo.dxf”); … And shell will run associated program reading it from the registry, like usual double click does.

Windows is not passing command line arguments to Python programs executed from the shell

I think I solved this. For some reason there is a SECOND place in the registry (besides that shown by the file associations stored in HKEY_CLASSES_ROOT\Python.File\shell\open\command): [HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command] @=”\”C:\\Python25\\python.exe\” \”%1\” %*” This seems to be the controlling setting on my system. The registry setting above adds the “%*” to pass all arguments to python.exe (it was … Read more