void WinService::setDescription(const std::string& description) { std::string key(REGISTRY_KEY); key += _name; WinRegistryKey regKey(HKEY_LOCAL_MACHINE, key); regKey.setString(REGISTRY_DESCRIPTION, description); }
std::string WinService::getDescription() const { std::string key(REGISTRY_KEY); key += _name; WinRegistryKey regKey(HKEY_LOCAL_MACHINE, key, true); return regKey.getString(REGISTRY_DESCRIPTION); }
// // Read Data from registry or file // void TRecentFiles::Read() { TAPointer<tchar> srcKeyBuffer(new tchar[80]); TAPointer<tchar> menuText(new tchar[MaxRegValueLen]); if(UseRegistry){ TRegKey regKey(TRegKey::GetCurrentUser(), MruName.c_str()); uint32 size = sizeof(uint32); if(regKey.QueryValue((tchar*)CountKey, 0, (uint8*)&MruCount, &size) != ERROR_SUCCESS) return; if (MruCount > MaxFilesToSave) MruCount = MaxFilesToSave; for (int i = 0; i < MruCount; i++){ wsprintf(srcKeyBuffer, _T("%s%d"), MruPrefix, i); uint32 size = MaxRegValueLen; if(regKey.QueryValue((tchar*)srcKeyBuffer, 0, (uint8*)(tchar*)menuText, &size) != ERROR_SUCCESS) break; MruNames[i] = (tchar*)menuText; } } else{ TProfile profile(Section, MruName.c_str()); MruCount = profile.GetInt(CountKey, 0); if (MruCount > MaxFilesToSave) MruCount = MaxFilesToSave; for (int i = 0; i < MruCount; i++){ wsprintf(srcKeyBuffer, _T("%s%d"), MruPrefix, i); profile.GetString(srcKeyBuffer, menuText, MaxMenuItemLen, MenuItemDefault); MruNames[i] = (tchar*)menuText; } } }
// // Write data to registry or file // void TRecentFiles::Write() { TAPointer<tchar> dstKeyBuffer(new tchar[80]); if(UseRegistry){ //1. delete all old MRU TRegKey::GetCurrentUser().DeleteKey(MruName.c_str()); // 2. create new mru TRegKey regKey(TRegKey::GetCurrentUser(), MruName.c_str()); regKey.SetValue(CountKey, MruCount); for (int i = 0; i < MruCount; i++){ wsprintf(dstKeyBuffer, _T("%s%d"), MruPrefix, i); tstring fname = MruNames[i].GetParts(FullFileName); regKey.SetValue((tchar*)dstKeyBuffer, REG_SZ, (const uint8*)fname.c_str(), static_cast<uint32>(fname.length() * sizeof(tchar))); } } else{ TProfile profile(Section, MruName.c_str()); profile.WriteInt(CountKey, MruCount); for (int i = 0; i < MruCount; i++){ wsprintf(dstKeyBuffer, _T("%s%d"), MruPrefix, i); profile.WriteString(dstKeyBuffer, MruNames[i].GetParts(FullFileName)); } } }
wxString GetDedicatedProductCommandArguments(const wxString& arguments) { wxLogNull log; wxRegKey regKey(wxT("HKEY_CURRENT_USER\\Software\\Spark Engine")); wxString gameDirectory; if (regKey.Exists()) { regKey.QueryValue(wxT("Game Asset Directory"), gameDirectory); } wxString result; if (!gameDirectory.IsEmpty()) { result = wxT("-game \"") + gameDirectory + wxT("\""); } if (!arguments.IsEmpty()) { result += wxT(" ") + arguments; } return result; }
void UninstallAllThread::removeGameExplorerInfo() { gcString logStr("{0}\n", Managers::GetString("#DUN_THREAD_GAMEEXPLORER")); onLogEvent(logStr); m_iTotalPos++; std::pair<uint32,uint32> pair(m_iTotalPos*100/m_iTotal, 0); onProgressEvent(pair); std::vector<std::string> regKeys; UTIL::WIN::getAllRegKeys("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\GameUX\\Games", regKeys, true); for (size_t x=0; x<regKeys.size(); x++) { gcString regKey("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\GameUX\\Games\\{0}\\AppExePath", regKeys[x]); std::string value = UTIL::WIN::getRegValue(regKey, true); if (value.find("desura://") != 0) continue; regKey = gcString("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\GameUX\\Games\\{0}", regKeys[x]); UTIL::WIN::delRegTree(regKey.c_str(), true); } UTIL::FS::Path gdfFolder(UTIL::OS::getAppDataPath(), L"", false); gdfFolder += "GDF"; UTIL::FS::delFolder(gdfFolder); }
bool MiniLaunchBar::IsLaunchedOnStartup() { wxRegKey regKey(_T("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")); if (regKey.Exists()) { return regKey.HasValue(_T("Appetizer")); } else { ELOG(_T("Couldn't get HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")); } return false; }
wxString ExploreFrame::GetGameBasePath() const { wxString hlmPath; #if defined(__WXOSX__) hlmPath = wxFileName::GetHomeDir() + "/Library/Application Support/Steam/steamapps/common/Hotline Miami 2/HotlineMiami2.app/Contents/Resources/"; #elif defined(__WXMSW__) wxRegKey regKey(wxRegKey::HKCU, "Software\\Valve\\Steam"); if (regKey.Open(wxRegKey::Read)) { regKey.QueryValue("SteamPath", hlmPath); hlmPath += "\\SteamApps\\Common\\Hotline Miami 2"; } #endif return hlmPath; }
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { BYTE* b; b = new BYTE[MAX_KEYCOUNT]; ULONG size = MAX_KEYCOUNT; initKeysArray(b, MAX_KEYCOUNT); DWORD _timeOut=30; if(wcsstr(lpCmdLine, L"writereg")!=NULL){ writeReg(b, size); writeTimeout(_timeOut); } int iTimeOut=30; if(readTimeOut(&iTimeOut)==0) _timeOut=iTimeOut; int test=0; // wait until timeout (default 30 seconds) do{ Sleep(1000); test++; }while( test < _timeOut ); #ifndef DEBUG Sleep(10000); // wait for cprog to initialize #endif readReg(b, &size); UINT x=0; DWORD dwKey; while ( x < size ){ dwKey=b[x]; //unRegKey(dwKey); regKey(NULL, dwKey); //unRegKey and then RegKey x++; } MessageBeep(MB_ICONQUESTION); return 0; }
void MiniLaunchBar::SetLaunchOnStartup(bool launch) { wxRegKey regKey(_T("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")); if (!regKey.Exists()) { ELOG(_T("Couldn't get HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")); return; } if (launch) { wxString userDataPath; bool found = commandLine_.Found(_T("d"), &userDataPath); wxString appetizerCommand; appetizerCommand = _T("\"") + FilePaths::GetApplicationPath() + _T("\""); if (found) appetizerCommand += _T(" /d \"") + userDataPath + _T("\""); regKey.SetValue(_T("Appetizer"), appetizerCommand); } else { if (!regKey.HasValue(_T("Appetizer"))) return; regKey.DeleteValue(_T("Appetizer")); } }
void ValidateGamesInGameExplorer() { std::vector<std::string> regKeys; UTIL::WIN::getAllRegKeys("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\GameUX\\Games", regKeys, true); for (size_t x=0; x<regKeys.size(); x++) { gcString regKey("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\GameUX\\Games\\{0}\\AppExePath", regKeys[x]); std::string value = UTIL::WIN::getRegValue(regKey, true); if (value.find("desura://") != 0) continue; regKey = gcString("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\GameUX\\Games\\{0}\\ConfigGDFBinaryPath", regKeys[x]); value = UTIL::WIN::getRegValue(regKey, true); if (!UTIL::FS::isValidFile(value)) { regKey = gcString("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\GameUX\\Games\\{0}", regKeys[x]); UTIL::WIN::delRegTree(regKey.c_str(), true); } } }
void UninstallAllThread::removeUninstallInfo() { gcString logStr("{0}\n", Managers::GetString("#DUN_THREAD_UNINSTALL")); onLogEvent(logStr); m_iTotalPos++; std::pair<uint32,uint32> pair(m_iTotalPos*100/m_iTotal, 0); onProgressEvent(pair); std::vector<std::string> regKeys; UTIL::WIN::getAllRegKeys("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", regKeys); for (size_t x=0; x<regKeys.size(); x++) { std::string key = regKeys[x]; if (key.find("Desura") != 0) continue; gcString regKey("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{0}", key); UTIL::WIN::delRegTree(regKey.c_str()); } }
// Get hostname only (without domain name) bool wxGetHostName(wxChar *buf, int maxSize) { #if defined(__WXWINCE__) // GetComputerName() is not supported but the name seems to be stored in // this location in the registry, at least for PPC2003 and WM5 wxString hostName; wxRegKey regKey(wxRegKey::HKLM, wxT("Ident")); if ( !regKey.HasValue(wxT("Name")) || !regKey.QueryValue(wxT("Name"), hostName) ) return false; wxStrlcpy(buf, hostName.t_str(), maxSize); #else // !__WXWINCE__ DWORD nSize = maxSize; if ( !::GetComputerName(buf, &nSize) ) { wxLogLastError(wxT("GetComputerName")); return false; } #endif // __WXWINCE__/!__WXWINCE__ return true; }
int _tmain (int argc, _TCHAR **argv) { for (int i = 0; i < argc; ++i) { out << argv[i] << std::endl; } if (argc < 2) { showHelp (); return (0); } params_t params; if (!parseCmdLine (argc - 1, argv + 1, ¶ms)) { if (otUnknown == params.opType) { out << _T (" : unknown operation") << std::endl; } else { out << _T ("bad command line") << std::endl; } return (-1); } if (FAILED (initLicensing (AppInfo, params.basesPaths, CLicensingPolicy::cmKeyOnly))) { return (-1); } // synchronizeKeys (AppInfo, KeyFile1, 0); #if defined (_WIN32) SetThreadLocale (MAKELCID (MAKELANGID (LANG_ENGLISH, SUBLANG_NEUTRAL), SORT_DEFAULT)); CComLib comLib; #endif switch(params.opType) { case otKeyReg : case otKeyRegAdd : regKey (params.keyFileName, params.keyAddMode); break; case otKeyRevoke : revokeKey (params.serialNumber); break; case otCheckActiveKey : checkActiveKey (); break; case otKeyFileInfo : keyFileInfo (params.keyFileName); break; case otViewInstalledKeys : viewInstalledKeys (); break; case otViewBlacklist : viewBlacklist (params.blacklistName); break; case otCheckAgainstBlacklist: checkAgainstBlackList (params.blacklistName.c_str ()); break; case otCheckKeyBlacklist : checKeyBlacklist (params.keyFileName, params.blacklistName); break; case otCheckKeyFile : case otCheckKeyFileAdd : checkKeyFile (params.keyFileName, params.keyAddMode); break; default : break; } // recreateTest (AppInfo, params.basesPaths, CLicensingPolicy::cmFullCheck); return (0); }