1

I cannot find a solution anywhere to this problem. I've only seen bits and pieces of code that barely work to get some exe files associated in the registry to that particular extension.

What I want is the exact list the Windows Explorer context menu will give you if you go to the Open With item. If I have to do it with p/invoke that is fine, I just want the exact list that explorer would show. That would include the friendly name as well as the path to associated program.

The list I want to retrieve for a pdf:

PDF program associations

The list I want to retrieve for a png:

PNG program associations

It may be worth noting that Microsoft calls it the "Recommended Programs" if you attempt to choose by clicking "Choose default program..."

PNG recommended programs

So how is that dialog populated? Because it must be using the same method for the Open With context menu.

There are some popular answers to this question on SO, but most of them only half work.

If the AssocQueryString function returned multiple results it'd be close to an answer, however I believe it can only get the actual program associated with it.

Community
  • 1
  • 1
test
  • 2,589
  • 2
  • 24
  • 52
  • https://msdn.microsoft.com/en-us/library/windows/desktop/bb761400(v=vs.85).aspx – Iłya Bursov Nov 10 '15 at 18:19
  • @Lashane I have personally only seen that interface used to retrieve a single, default application associated to a file extension. If you have a resource that shows that interface being used to retrieve the recommended programs for a file extension I'd be interested in seeing it. – test Nov 10 '15 at 18:28
  • the first example answer works well by using `Registry.ClassesRoot.OpenSubKey("." + ext)` instead of `Registry.CurrentUser.....`. – Fᴀʀʜᴀɴ Aɴᴀᴍ Nov 10 '15 at 18:52
  • @FarhanAnam I'm not trying to be difficult, but I don't want close. I want to get the exact results that Windows gets. – test Nov 10 '15 at 20:03
  • yes that fetches proper things for me. – Fᴀʀʜᴀɴ Aɴᴀᴍ Nov 10 '15 at 20:32

0 Answers0