+ // TODO:
+ // 1. translate '%s' to '%1' instead of always adding it
+ // 2. create DDEExec value if needed (undo GetCommand)
+ return rkey.Create() && rkey.SetValue(wxEmptyString, cmd + _T(" \"%1\"") );
+}
+
+/* // no longer used
+bool wxFileTypeImpl::SetMimeType(const wxString& mimeTypeOrig)
+{
+ wxCHECK_MSG( !m_ext.IsEmpty(), FALSE, _T("SetMimeType() needs extension") );
+
+ if ( !EnsureExtKeyExists() )
+ return FALSE;
+
+ // VZ: is this really useful? (FIXME)
+ wxString mimeType;
+ if ( !mimeTypeOrig )
+ {
+ // make up a default value for it
+ wxString cmd;
+ wxSplitPath(GetCommand(_T("open")), NULL, &cmd, NULL);
+ mimeType << _T("application/x-") << cmd;
+ }
+ else
+ {
+ mimeType = mimeTypeOrig;
+ }
+
+ wxRegKey rkey(wxRegKey::HKCR, m_ext);
+ return rkey.Create() && rkey.SetValue(_T("Content Type"), mimeType);
+}
+*/
+
+bool wxFileTypeImpl::SetDefaultIcon(const wxString& cmd, int index)
+{
+ wxCHECK_MSG( !m_ext.IsEmpty(), FALSE, _T("SetDefaultIcon() needs extension") );
+ wxCHECK_MSG( !m_strFileType.IsEmpty(), FALSE, _T("File key not found") );
+// the next line fails on a SMBshare, I think because it is case mangled
+// wxCHECK_MSG( !wxFileExists(cmd), FALSE, _T("Icon file not found.") );
+
+ if ( !EnsureExtKeyExists() )
+ return FALSE;
+
+ wxRegKey rkey(wxRegKey::HKCR, m_strFileType + _T("\\DefaultIcon"));
+
+ return rkey.Create() &&
+ rkey.SetValue(wxEmptyString,
+ wxString::Format(_T("%s,%d"), cmd.c_str(), index));
+}
+
+bool wxFileTypeImpl::SetDescription (const wxString& desc)
+{
+ wxCHECK_MSG( !m_strFileType.IsEmpty(), FALSE, _T("File key not found") );
+ wxCHECK_MSG( !desc.IsEmpty(), FALSE, _T("No file description supplied") );
+
+ if ( !EnsureExtKeyExists() )
+ return FALSE;
+
+ wxRegKey rkey(wxRegKey::HKCR, m_strFileType );
+
+ return rkey.Create() &&
+ rkey.SetValue(wxEmptyString, desc);
+}
+
+// ----------------------------------------------------------------------------
+// remove file association
+// ----------------------------------------------------------------------------
+
+bool wxFileTypeImpl::Unassociate()
+{
+ bool result = TRUE;
+ if ( !RemoveOpenCommand() )
+ result = FALSE;
+ if ( !RemoveDefaultIcon() )
+ result = FALSE;
+ if ( !RemoveMimeType() )
+ result = FALSE;
+ if ( !RemoveDescription() )
+ result = FALSE;
+
+/*
+ //this might hold other keys, eg some have CSLID keys
+ if ( result )
+ {
+ // delete the root key
+ wxRegKey key(wxRegKey::HKCR, m_ext);
+ if ( key.Exists() )
+ result = key.DeleteSelf();
+ }
+*/
+ return result;
+}
+
+bool wxFileTypeImpl::RemoveOpenCommand()
+{
+ return RemoveCommand(_T("open"));
+}
+
+bool wxFileTypeImpl::RemoveCommand(const wxString& verb)
+{
+ wxCHECK_MSG( !m_ext.IsEmpty() && !verb.IsEmpty(), FALSE,
+ _T("RemoveCommand() needs an extension and a verb") );
+
+ wxString sKey = m_strFileType;
+ wxRegKey rkey(wxRegKey::HKCR, GetVerbPath(verb));
+
+ // if the key already doesn't exist, it's a success
+ return !rkey.Exists() || rkey.DeleteSelf();
+}
+
+bool wxFileTypeImpl::RemoveMimeType()
+{
+ wxCHECK_MSG( !m_ext.IsEmpty(), FALSE, _T("RemoveMimeType() needs extension") );
+
+ wxRegKey rkey(wxRegKey::HKCR, m_ext);
+ return !rkey.Exists() || rkey.DeleteSelf();
+}
+
+bool wxFileTypeImpl::RemoveDefaultIcon()
+{
+ wxCHECK_MSG( !m_ext.IsEmpty(), FALSE,
+ _T("RemoveDefaultIcon() needs extension") );
+
+ wxRegKey rkey (wxRegKey::HKCR, m_strFileType + _T("\\DefaultIcon"));
+ return !rkey.Exists() || rkey.DeleteSelf();
+}
+
+bool wxFileTypeImpl::RemoveDescription()
+{
+ wxCHECK_MSG( !m_ext.IsEmpty(), FALSE,
+ _T("RemoveDescription() needs extension") );
+
+ wxRegKey rkey (wxRegKey::HKCR, m_strFileType );
+ return !rkey.Exists() || rkey.DeleteSelf();
+}
+
+#endif // wxUSE_MIMETYPE