size_t wxFileTypeImpl::GetAllCommands(wxArrayString *verbs, wxArrayString *commands, const wxFileType::MessageParameters& params) const { wxCHECK_MSG( !m_ext.empty(), 0, wxT("GetAllCommands() needs an extension") ); if ( m_strFileType.empty() ) { // get it from the registry wxFileTypeImpl *self = wxConstCast(this, wxFileTypeImpl); wxRegKey rkey(wxRegKey::HKCR, m_ext); if ( !rkey.Exists() || !rkey.QueryValue(wxEmptyString, self->m_strFileType) ) { wxLogDebug(wxT("Can't get the filetype for extension '%s'."), m_ext.c_str()); return 0; } } // enum all subkeys of HKCR\filetype\shell size_t count = 0; wxRegKey rkey(wxRegKey::HKCR, m_strFileType + wxT("\\shell")); long dummy; wxString verb; bool ok = rkey.GetFirstKey(verb, dummy); while ( ok ) { wxString command = wxFileType::ExpandCommand(GetCommand(verb), params); // we want the open bverb to eb always the first if ( verb.CmpNoCase(wxT("open")) == 0 ) { if ( verbs ) verbs->Insert(verb, 0); if ( commands ) commands->Insert(command, 0); } else // anything else than "open" { if ( verbs ) verbs->Add(verb); if ( commands ) commands->Add(command); } count++; ok = rkey.GetNextKey(verb, dummy); } return count; }
bool wxFileTypeImpl::RemoveMimeType() { wxCHECK_MSG( !m_ext.empty(), false, wxT("RemoveMimeType() needs extension") ); wxRegKey rkey(wxRegKey::HKCR, m_ext); return !rkey.Exists() || rkey.DeleteSelf(); }
int hardwareGetInfo(Hardware_INFO *info) { int iReturnCode; try { WinRegKey rkey(HKEY_LOCAL_MACHINE,L"HARDWARE\\DESCRIPTION\\System\\BIOS"); info->systemProductName=rkey(L"SystemProductName"); info->systemManufacturer=rkey(L"SystemManufacturer"); iReturnCode=DIAGLIB_OK; } catch(WinRegKeyExeption rke) { iReturnCode=DIAGLIB_ERR_NOT_AVAILABLE; } return iReturnCode; }
bool wxFileTypeImpl::RemoveDescription() { wxCHECK_MSG( !m_ext.empty(), false, wxT("RemoveDescription() needs extension") ); wxRegKey rkey (wxRegKey::HKCU, CLASSES_ROOT_KEY + m_strFileType ); return !rkey.Exists() || rkey.DeleteSelf(); }
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::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); }
bool wxFileTypeImpl::EnsureExtKeyExists() { wxRegKey rkey(wxRegKey::HKCR, m_ext); if ( !rkey.Exists() ) { if ( !rkey.Create() || !rkey.SetValue(wxEmptyString, m_strFileType) ) { wxLogError(_("Failed to create registry entry for '%s' files."), m_ext.c_str()); return false; } } return true; }
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::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\"") ); }
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\"") ); }