+bool wxFileTypeImpl::SetDefaultIcon(const wxString& cmd, int index)
+{
+ wxCHECK_MSG( !m_ext.empty(), false, _T("SetDefaultIcon() needs extension") );
+ wxCHECK_MSG( !m_strFileType.empty(), 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.empty(), false, _T("File key not found") );
+ wxCHECK_MSG( !desc.empty(), 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.empty() && !verb.empty(), false,
+ _T("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, _T("RemoveMimeType() needs extension") );
+
+ wxRegKey rkey(wxRegKey::HKCR, m_ext);
+ return !rkey.Exists() || rkey.DeleteSelf();
+}
+
+bool wxFileTypeImpl::RemoveDefaultIcon()
+{
+ wxCHECK_MSG( !m_ext.empty(), 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.empty(), false,
+ _T("RemoveDescription() needs extension") );
+
+ wxRegKey rkey (wxRegKey::HKCR, m_strFileType );
+ return !rkey.Exists() || rkey.DeleteSelf();
+}
+
+#endif // wxUSE_MIMETYPE