示例#1
0
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();
}
示例#2
0
bool wxFileTypeImpl::SetCommand(const wxString& cmd,
                                const wxString& verb,
                                bool WXUNUSED(overwriteprompt))
{
    wxCHECK_MSG( !m_ext.empty() && !verb.empty(), false,
                 wxT("SetCommand() needs an extension and a verb") );

    if ( !EnsureExtKeyExists() )
        return false;

    wxRegKey rkey(wxRegKey::HKCU, CLASSES_ROOT_KEY + GetVerbPath(verb));

    // 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\"") );
}
示例#3
0
bool wxFileTypeImpl::SetCommand(const wxString& cmd,
                                const wxString& verb,
                                bool WXUNUSED(overwriteprompt))
{
    wxCHECK_MSG( !m_ext.empty() && !verb.empty(), false,
                 wxT("SetCommand() needs an extension and a verb") );

    if ( !EnsureExtKeyExists() )
        return false;

    wxRegKey rkey(wxRegKey::HKCR, GetVerbPath(verb));
#if 0
    if ( rkey.Exists() && overwriteprompt )
    {
#if wxUSE_GUI
        wxString old;
        rkey.QueryValue(wxEmptyString, old);
        if ( wxMessageBox
             (
                wxString::Format(
                    _("Do you want to overwrite the command used to %s "
                      "files with extension \"%s\" ?\nCurrent value is \n%s, "
                      "\nNew value is \n%s %1"), // bug here FIX need %1 ??
                    verb.c_str(),
                    m_ext.c_str(),
                    old.c_str(),
                    cmd.c_str()),
                _("Confirm registry update"),
                wxYES_NO | wxICON_QUESTION
             ) != wxYES )
#endif // wxUSE_GUI
        {
            // cancelled by user
            return false;
        }
    }
#endif
    // 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\"") );
}