+ 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(_T(""),
+ 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(_T(""), 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();