]> git.saurik.com Git - wxWidgets.git/commitdiff
Take into account explorer associations and CurVer when finding the command to execute.
authorJulian Smart <julian@anthemion.co.uk>
Wed, 27 Feb 2008 18:07:30 +0000 (18:07 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Wed, 27 Feb 2008 18:07:30 +0000 (18:07 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52154 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/mimetype.cpp

index 0649f09ed732b39a8c6dfc3089bb5c4076ad9597..e10c79bd5171871e38fdd8387be381affe537487 100644 (file)
@@ -200,16 +200,47 @@ bool wxFileTypeImpl::EnsureExtKeyExists()
 // get the command to use
 // ----------------------------------------------------------------------------
 
+static wxString wxFileTypeImplGetCurVer(const wxString& progId)
+{
+    wxRegKey key(wxRegKey::HKCR, progId + wxT("\\CurVer"));
+    if (key.Exists())
+    {
+        wxString value;
+        if (key.QueryValue(wxEmptyString, value))
+            return value;
+    }
+    return progId;
+}
+
 wxString wxFileTypeImpl::GetCommand(const wxString& verb) const
 {
     // suppress possible error messages
     wxLogNull nolog;
     wxString strKey;
 
-    if ( wxRegKey(wxRegKey::HKCR, m_ext + _T("\\shell")).Exists() )
+    {
+        wxRegKey explorerKey(wxRegKey::HKCU, wxT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\") + m_ext);
+        if (explorerKey.Exists())
+        {
+            if (explorerKey.Open(wxRegKey::Read))
+            {
+                if (explorerKey.QueryValue(wxT("Progid"), strKey))
+                {
+                    strKey = wxFileTypeImplGetCurVer(strKey);
+                }
+            }
+        }
+    }
+
+    if (!strKey && wxRegKey(wxRegKey::HKCR, m_ext + _T("\\shell")).Exists())
         strKey = m_ext;
-    if ( wxRegKey(wxRegKey::HKCR, m_strFileType + _T("\\shell")).Exists() )
-        strKey = m_strFileType;
+
+    if ( !strKey && !m_strFileType.empty())
+    {
+        wxString fileType = wxFileTypeImplGetCurVer(m_strFileType);
+        if (wxRegKey(wxRegKey::HKCR, fileType + _T("\\shell")).Exists())
+            strKey = fileType;
+    }
 
     if ( !strKey )
     {