int _tmain(int argc, _TCHAR* argv[]) { DWORD dwResuming = 4, dwSuspend = 4, dwUnattended = 4; RegistryGetDWORD(HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Power\\State\\Resuming\\{98C5250D-C29A-4985-AE5F-AFE5367E5006}", L"Default", &dwResuming); RegistryGetDWORD(HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Power\\State\\Suspend\\{98C5250D-C29A-4985-AE5F-AFE5367E5006}", L"Default", &dwSuspend); RegistryGetDWORD(HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Power\\State\\Unattended\\{98C5250D-C29A-4985-AE5F-AFE5367E5006}", L"Default", &dwUnattended); if (dwResuming == 0) dwResuming = 1; if (dwSuspend == 0) dwSuspend = 1; if (dwUnattended == 0) dwUnattended = 1; DWORD dwKeepWifi = 0; if (dwResuming == 1 && dwSuspend == 1 && dwUnattended == 1) { dwKeepWifi = 1; } RegistrySetDWORD(HKEY_LOCAL_MACHINE, L"Comm\\BCMSDDHD1\\Parms", L"HTCKeepWifiOnWhenUnattended", dwKeepWifi); return 0; }
// Get cell signal percent from registry DWORD GetCellSignalPercent() { HKEY SN_SIGNALSTRENGTHRAW_ROOT = HKEY_LOCAL_MACHINE; LPCTSTR SN_SIGNALSTRENGTHRAW_PATH = L"\\System\\State\\Phone"; LPCTSTR SN_SIGNALSTRENGTHRAW_VALUE = L"Signal Strength Raw"; DWORD cCellSignalPercent = 0; HRESULT hr; hr = RegistryGetDWORD(SN_SIGNALSTRENGTHRAW_ROOT, SN_SIGNALSTRENGTHRAW_PATH, SN_SIGNALSTRENGTHRAW_VALUE, &cCellSignalPercent); if (SUCCEEDED(hr)) return cCellSignalPercent; else { /* MessageBox(NULL, L"Failed", L"Failed", MB_OK); */ return 0; } }
static HRESULT OnConnect(PWLAN_INFO psInfo, INT iItem) { HRESULT hr = S_OK; PCSHWZCNET pwzcnet = (PCSHWZCNET)GetListItemLPARAM(psInfo->hwndNetList, iItem); SHWZCNET wzcnet; BOOL fSecure; // The first item is "Add net settings...". It cannot be deleted. CBR(iItem > 0 && pwzcnet != NULL); memcpy(&wzcnet, pwzcnet, sizeof(SHWZCNET)); // If the item isn't preferred if (!(SHWZCF_NET_PREFERRED & wzcnet.dwFlags)) { DWORD dwNoFastConnect = 0; fSecure = BOOLIFY(wzcnet.dwFlags & SHWZCF_NET_8021X) || !( ( (Ndis802_11Encryption1Enabled != wzcnet.dwEncryptionType) && (Ndis802_11Encryption2Enabled != wzcnet.dwEncryptionType) && (Ndis802_11Encryption3Enabled != wzcnet.dwEncryptionType) ) && (Ndis802_11AuthModeOpen == wzcnet.dwAuthentication) ); // If secure or fastconnect is disabled, show the settings wizard, else connect RegistryGetDWORD(HKEY_LOCAL_MACHINE, WZC_REGKEY_BASE, WZC_REGKEY_DISABLEFASTCONNECT, &dwNoFastConnect); if (fSecure || dwNoFastConnect != 0) { CBR(OnNetworkProperties(psInfo, iItem)); } else { SHWZCSetNetwork(psInfo->hshwzc, &wzcnet, NULL, NULL, 0, SHWZCF_SETMASK_ALL); } } // disable SK1 Connect while we're attempting to connect for this network SHEnableSoftkey(psInfo->hwndNetListMB, 0, TRUE, FALSE); // Ensure that power is on. Ignore errors, this is a "Best-effort" attempt SHWZCSetPowerState(TRUE); // Now connect directly (we'll automatically get a refresh event) hr = SHWZCConnectNetwork(psInfo->hshwzc, wzcnet.szName, BOOLIFY(SHWZCF_NET_ADHOC & wzcnet.dwFlags)); CHR(hr); Error: if(FAILED(hr)) { // re-enable SK since something went wrong SHEnableSoftkey(psInfo->hwndNetListMB, 0, TRUE, TRUE); } return hr; }
VOID Settings_Read() { if (RegistryGetDWORD(UTASK_REG_BRANCH, UTASK_REG_SETTINGS_KEY, L"PositionFix_AutoMode", (DWORD*) &settingIsAutoFix) != S_OK) { settingIsAutoFix = 1; } if (RegistryGetDWORD(UTASK_REG_BRANCH, UTASK_REG_SETTINGS_KEY, L"PositionFix", (DWORD*) &settingPositionFixEnabled) != S_OK) { settingPositionFixEnabled = 1; } ExclusiveList_InitializeList(); sizeStatusBar = ThemeLoader_GetStatusBarSize(); sizeSoftkeyBar = ThemeLoader_GetSoftkeyBarSize(); HANDLE hService = GetServiceHandle(L"UTS0:", NULL, 0); systemIsServiceEnabled = (hService == INVALID_HANDLE_VALUE || hService == NULL) ? FALSE : TRUE; };
HRESULT GetWirelessStateFlags(DWORD *pdwStatus) { HRESULT hr = S_OK; CBR(pdwStatus); *pdwStatus = 0; CHR(RegistryGetDWORD(HKEY_LOCAL_MACHINE, c_szRegKeySSWifi, c_szRegValueSSWifi, pdwStatus)); Error: return hr; }
HRESULT SetWirelessStateFlags(UINT uMask, UINT uValue) { HRESULT hr = S_OK; DWORD dwData = 0; HKEY hKey = NULL; CBR(ERROR_SUCCESS == RegCreateKeyEx(HKEY_LOCAL_MACHINE, c_szRegKeySSWifi, 0, NULL, REG_OPTION_VOLATILE, 0, NULL, &hKey, NULL)); RegistryGetDWORD(hKey, NULL, c_szRegValueSSWifi, &dwData); dwData = (dwData & ~uMask) | (uMask & uValue); CHR(RegistrySetDWORD(hKey, NULL, c_szRegValueSSWifi, dwData)); Error: RegCloseKey(hKey); return hr; }
void CQuickLaunch::LoadLaunchItems(HKEY hKey, list<LaunchItem*>* pLaunchItems) { DWORD dwCount = 0; RegistryGetDWORD(hKey, NULL, L"Count", &dwCount); for (DWORD i = 0; i < dwCount; ++i) { WCHAR wzPath[10],wzCount[5]; DWORD dwSize = 0; _itow(i, wzCount, 10); StringCchCopy(wzPath, ARRAYSIZE(wzPath), wzCount); StringCchCat(wzPath, ARRAYSIZE(wzPath), L"_Path"); LaunchItem* pRecord = new LaunchItem(); bool bDelete = true; if (ERROR_SUCCESS == RegistryGetString(hKey, NULL, wzPath, pRecord->wzPath, ARRAYSIZE(pRecord->wzPath))) { pRecord->hIcon = GetApplicationIcon(pRecord->wzPath, false, NULL, NULL, NULL); // TODO: Load default icon if (!pRecord->hIcon) { pRecord->hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ICON1)); } bDelete = false; } if (bDelete) { delete pRecord; } else { pLaunchItems->push_back(pRecord); } } }
bool ProcessAction() { DWORD dwAction = Dynamics::SearchKeyAction::ACTION_BING; RegistryGetDWORD(HKEY_LOCAL_MACHINE, L"Software\\OEM\\WebSearchOverride", L"ActionType", &dwAction); bool processed = true; if (Dynamics::SearchKey::IsValidHash() == FALSE || Dynamics::SearchKey::IsSearchKeySettingsXapPresent() == false) return false; switch (dwAction) { case Dynamics::SearchKeyAction::ACTION_NO: { break; } case Dynamics::SearchKeyAction::ACTION_BING: { RunBing(NULL); break; } case Dynamics::SearchKeyAction::ACTION_SEARCH: { RunSearch(); break; } case Dynamics::SearchKeyAction::ACTION_RUNAPPLICATION: { wchar_t appUri[500] = {0}; RegistryGetString(HKEY_LOCAL_MACHINE, L"Software\\OEM\\WebSearchOverride", L"Uri", appUri, 500); Shell::Tasks::StartSession(appUri); break; } case Dynamics::SearchKeyAction::ACTION_EXE: { wchar_t exePath[500] = {0}; RegistryGetString(HKEY_LOCAL_MACHINE, L"Software\\OEM\\WebSearchOverride", L"ExePath", exePath, 500); wchar_t exeArgs[500] = {0}; RegistryGetString(HKEY_LOCAL_MACHINE, L"Software\\OEM\\WebSearchOverride", L"ExeArgs", exeArgs, 500); Diagnostics::Process::Start(exePath, exeArgs, NULL, true); break; } case Dynamics::SearchKeyAction::ACTION_URL: { RunBrowserUrl(); break; } case Dynamics::SearchKeyAction::ACTION_KEYEVENT: { DWORD dwKeyCode = 0; RegistryGetDWORD(HKEY_LOCAL_MACHINE, L"Software\\OEM\\WebSearchOverride", L"KeyCode", &dwKeyCode); if (dwKeyCode != 0) { keybd_event(dwKeyCode, 0, KEYEVENTF_SILENT, 0); Sleep(100); keybd_event(dwKeyCode, 0, KEYEVENTF_SILENT | KEYEVENTF_KEYUP, 0); } break; } default: processed = false; break; } return processed; }
static VOID InitRegistrySettings() { CNktSimpleLockNonReentrant cAccessLock(&nAccessLock); static const LPCWSTR szKeyW = L"Software\\Nektra\\Deviare2"; DWORD dwValue; HKEY hKey; if (nInitialized == 0) { if (::RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKeyW, 0, KEY_READ|KEY_WOW64_64KEY, &hKey) == ERROR_SUCCESS || ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKeyW, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { if (RegistryGetDWORD(&dwValue, hKey, L"DebugLevelMask") != FALSE) dwDebugLevelMask = (dwValue | DEFAULT_DBGLEVEL_MASK); //---- if (RegistryGetDWORD(&dwValue, hKey, L"MemMgrPoolMaxAge") != FALSE) dwMemMgrPoolMaxAge = dwValue; if (RegistryGetDWORD(&dwValue, hKey, L"MemMgrPoolCheckFrequency") != FALSE) dwMemMgrPoolCheckFrequency = dwValue; if (dwMemMgrPoolCheckFrequency < 10) dwMemMgrPoolCheckFrequency = 10; //---- if (RegistryGetDWORD(&dwValue, hKey, L"MaxTransportFreeListMessageCount") != FALSE) dwMaxFreeBufferList = dwValue; if (RegistryGetDWORD(&dwValue, hKey, L"SpyMgrMaxTransportMessageCount") != FALSE) dwMaxInUseMessageCount_SpyMgr = dwValue; if (RegistryGetDWORD(&dwValue, hKey, L"SpyMgrTransportMessageDelay") != FALSE) dwMaxInUseMessageDelay_SpyMgr = dwValue; if (RegistryGetDWORD(&dwValue, hKey, L"AgentMaxTransportMessageCount") != FALSE) dwMaxInUseMessageCount_Agent = dwValue; if (RegistryGetDWORD(&dwValue, hKey, L"AgentTransportMessageDelay") != FALSE) dwMaxInUseMessageDelay_Agent = dwValue; //---- if (RegistryGetDWORD(&dwValue, hKey, L"AgentLoadTimeout") != FALSE) dwAgentLoadTimeout = dwValue; //---- if (dwMaxFreeBufferList > 1048576) dwMaxFreeBufferList = 1048576; if (dwMaxInUseMessageCount_SpyMgr > 1048576) dwMaxInUseMessageCount_SpyMgr = 1048576; if (dwMaxInUseMessageCount_Agent > 1048576) dwMaxInUseMessageCount_Agent = 1048576; if (dwMaxInUseMessageDelay_SpyMgr < 5) dwMaxInUseMessageDelay_SpyMgr = 5; else if (dwMaxInUseMessageDelay_SpyMgr > 30000) dwMaxInUseMessageDelay_SpyMgr = 30000; if (dwMaxInUseMessageDelay_Agent < 5) dwMaxInUseMessageDelay_Agent = 5; else if (dwMaxInUseMessageDelay_Agent > 30000) dwMaxInUseMessageDelay_Agent = 30000; if (dwAgentLoadTimeout < 500) dwAgentLoadTimeout = 500; else if (dwAgentLoadTimeout > 60*60*1000) dwAgentLoadTimeout = 60*60*1000; //---- ::RegCloseKey(hKey); } NktInterlockedExchange(&nInitialized, 1); } return; }
void CDateTime::LoadSettings(IFlipperApp* pFlipper, HKEY hKey) { RegistryGetDWORD(hKey, NULL, REG_TimeOffset, &g_dwOffset); }
BOOL CALLBACK CDateTime::DateTimeProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { static HWND hwndTimeZone; static HKEY g_hKey = NULL; static CDlgAnchor g_dlgAnchor; switch (message) { case WM_SIZE : { g_dlgAnchor.OnSize(); } break; case WM_INITDIALOG: { g_dlgAnchor.Init(hwndDlg); g_dlgAnchor.Add(IDC_COMBO_TIMEZONE, ANCHOR_ALL &~ ANCHOR_BOTTOM); hwndTimeZone = GetDlgItem(hwndDlg, IDC_COMBO_TIMEZONE); TIME_ZONE_INFORMATION info = {0}; GetTimeZoneInformation(&info); int index = ComboBox_AddString(hwndTimeZone, info.StandardName); index = ComboBox_SetItemData(hwndTimeZone, index, info.StandardBias); g_hKey = (HKEY)lParam; DWORD dwOffset = 0; RegistryGetDWORD(g_hKey, NULL, REG_TimeOffset, &dwOffset); ComboBox_SetCurSel(hwndTimeZone, 0); SHINITDLGINFO shidi; // Create a Done button and size it. shidi.dwMask = SHIDIM_FLAGS; shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN; shidi.hDlg = hwndDlg; SHInitDialog(&shidi); SHMENUBARINFO mbi; memset(&mbi, 0, sizeof(SHMENUBARINFO)); mbi.cbSize = sizeof(SHMENUBARINFO); mbi.hwndParent = hwndDlg; mbi.nToolBarId = IDR_Flipper_SET_MENUBAR; mbi.hInstRes = CDateTime::g_hInstance; mbi.nBmpId = 0; mbi.cBmpImages = 0; SHCreateMenuBar(&mbi); SetFocus(hwndTimeZone); return 0; } break; case WM_COMMAND: { switch (LOWORD(wParam)) { case IDM_Flipper_SET_ACCEPT : case IDOK: { WCHAR wzName[MAX_PATH]; DWORD dwName = ARRAYSIZE(wzName); int index = ComboBox_GetCurSel(hwndTimeZone); DWORD dwTimeZone = ComboBox_GetItemData(hwndTimeZone, index); RegistrySetDWORD(g_hKey, NULL, REG_TimeOffset, dwTimeZone); EndDialog(hwndDlg, IDOK); } break; case IDM_Flipper_SET_CANCEL: { EndDialog(hwndDlg, IDOK); } break; } } break; case WM_DESTROY: { Sleep(0); } break; } return FALSE; }