Opened 4 years ago

Closed 23 months ago

#12302 closed defect (fixed)

Respect "UserChoice" registry key in wxFileType::GetOpenCommand()

Reported by: botg Owned by:
Priority: normal Milestone: 3.0.0
Component: wxMSW Version: stable-latest
Keywords: registry association mimetype simple Cc:
Blocked By: Blocking:
Patch: no

Description

Changes made to file associations in Windows 7 through Explorer are not reflected by wxFileType::GetOpenCommand.

wx looks for the Progid value in HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\<ext>\ whereas Windows 7 stores the association in HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\<ext>\UserChoice

With the attached patch, the secon key is searched as well when getting the open command.

I have attached patches for both 2.8 as well as trunk.

Attachments (3)

opencommand_28.patch download (2.0 KB) - added by botg 4 years ago.
opencommand_trunk.patch download (2.0 KB) - added by botg 4 years ago.
opencommand_28_v2.patch download (2.5 KB) - added by botg 4 years ago.

Download all attachments as: .zip

Change History (11)

Changed 4 years ago by botg

Changed 4 years ago by botg

comment:2 Changed 4 years ago by vadz

  • Keywords registry association mimetype simple added
  • Patch unset
  • Status changed from new to confirmed
  • Version set to 2.9-svn

I've just tested it and creating a new association in the Explorer doesn't create User Choice subkey in the registry. It's true that some of the keys do have it but by no means all (in fact relatively few do) and I don't know what is it for. The officially sanctioned way is to add the progid of the program that can be used to open this type of files under OpenWithProgids subkey and AFAICS both Windows XP and Windows 7 do use it.

I think we should use it as well at least for the versions of Windows >= XP. BTW I have no idea where does the current code work because I don't see any progids directly under the extension subkey at all.

Do you have any documentation saying that UserChoice should be used? If not, I think we should use OpenWithProgids.

comment:3 Changed 4 years ago by botg

Unfortunately I could not find any relevant information on the Microsoft website.

However, I found a pattern. It appears that the UserChoice key only appears on extensions that have multiple progids listed under OpenWithProgids.

I think the correct order is to first check UserChoice. If there is no such item, get the first value under OpenWithProgids (since there is no UserChoice, there should be at most one valye under OpenWithProgids). Last but not least, search all the other locations already searched by wx.

I'll update the patch accordingly later today.

comment:4 Changed 4 years ago by botg

  • Patch set

Here's the updated patch.

Changed 4 years ago by botg

comment:5 Changed 4 years ago by vadz

  • Milestone set to 3.0

Should the trunk patch be modified in the same way?

TIA!

comment:6 Changed 3 years ago by vadz

  • Patch unset
  • Summary changed from wxFileType::GetOpenCommand on Windows 7 to Respect "UserChoice" registry key in wxFileType::GetOpenCommand()

Tim, do you have any plans for upgrading the trunk version of the patch? TIA!

comment:7 Changed 23 months ago by vadz

After more searching (2 years later there is still no official information about these keys) and experimenting, it seems that the only change needed in the trunk is to look under the correct key: as I wrote in comment:2, the current code simply looks for the ProgID in the wrong place.

As for using OpenWithProgids, it doesn't seem to be needed finally, as it's created only programmatically and all programs seem to create both it and the traditional keys under HKCR. So only UserChoice really needs to be taken into account.

comment:8 Changed 23 months ago by VZ

  • Resolution set to fixed
  • Status changed from confirmed to closed

(In [73106]) Correct lookup of Explorer-specific file association information.

The code added in r52154 never worked because it was looking for the Progid
value in a wrong place, look for it under UserChoice subkey where it really
is.

Also add a way to look up the command to open files with the given extension
to the exec sample.

Closes #12302.

Note: See TracTickets for help on using tickets.