+ // 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 + wxT(" \"%1\"") );
+}
+
+/* // no longer used
+bool wxFileTypeImpl::SetMimeType(const wxString& mimeTypeOrig)
+{
+ wxCHECK_MSG( !m_ext.empty(), false, wxT("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;
+ wxFileName::SplitPath(GetCommand(wxT("open")), NULL, &cmd, NULL);
+ mimeType << wxT("application/x-") << cmd;
+ }
+ else
+ {
+ mimeType = mimeTypeOrig;
+ }
+
+ wxRegKey rkey(wxRegKey::HKCR, m_ext);
+ return rkey.Create() && rkey.SetValue(wxT("Content Type"), mimeType);
+}
+*/
+
+bool wxFileTypeImpl::SetDefaultIcon(const wxString& cmd, int index)
+{
+ wxCHECK_MSG( !m_ext.empty(), false, wxT("SetDefaultIcon() needs extension") );
+ wxCHECK_MSG( !m_strFileType.empty(), false, wxT("File key not found") );
+// the next line fails on a SMBshare, I think because it is case mangled
+// wxCHECK_MSG( !wxFileExists(cmd), false, wxT("Icon file not found.") );
+
+ if ( !EnsureExtKeyExists() )
+ return false;
+
+ wxRegKey rkey(wxRegKey::HKCR, m_strFileType + wxT("\\DefaultIcon"));
+
+ return rkey.Create() &&
+ rkey.SetValue(wxEmptyString,
+ wxString::Format(wxT("%s,%d"), cmd.c_str(), index));
+}
+
+bool wxFileTypeImpl::SetDescription (const wxString& desc)
+{
+ wxCHECK_MSG( !m_strFileType.empty(), false, wxT("File key not found") );
+ wxCHECK_MSG( !desc.empty(), false, wxT("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(wxT("open"));
+}
+
+bool wxFileTypeImpl::RemoveCommand(const wxString& verb)
+{
+ wxCHECK_MSG( !m_ext.empty() && !verb.empty(), false,
+ wxT("RemoveCommand() needs an extension and a verb") );
+
+ 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.empty(), false, wxT("RemoveMimeType() needs extension") );
+
+ wxRegKey rkey(wxRegKey::HKCR, m_ext);
+ return !rkey.Exists() || rkey.DeleteSelf();
+}
+
+bool wxFileTypeImpl::RemoveDefaultIcon()
+{
+ wxCHECK_MSG( !m_ext.empty(), false,
+ wxT("RemoveDefaultIcon() needs extension") );
+
+ wxRegKey rkey (wxRegKey::HKCR, m_strFileType + wxT("\\DefaultIcon"));
+ return !rkey.Exists() || rkey.DeleteSelf();
+}
+
+bool wxFileTypeImpl::RemoveDescription()
+{
+ wxCHECK_MSG( !m_ext.empty(), false,
+ wxT("RemoveDescription() needs extension") );
+
+ wxRegKey rkey (wxRegKey::HKCR, m_strFileType );
+ return !rkey.Exists() || rkey.DeleteSelf();
+}
+
+#endif // wxUSE_MIMETYPE