BOOL AutoPlayConfig::IsEnabled(BOOL &enable) { const TCHAR config_key_path[] = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"); const TCHAR config_value_name[] = TEXT("NoDriveTypeAutoRun"); ULONG no_autoplay_drive_types = 0; if (!RegQueryDWORD(HKEY_LOCAL_MACHINE, config_key_path, config_value_name, no_autoplay_drive_types)) { } enable = no_autoplay_drive_types != 0xff; if (enable) { if (!RegQueryDWORD(HKEY_CURRENT_USER, config_key_path, config_value_name, no_autoplay_drive_types)) { return FALSE; } enable = no_autoplay_drive_types != 0xff; } return TRUE; }
InstanceManager::InstanceConfig InstanceManager::ReadConfig(HKEY key, const string & id) { InstanceConfig config; config.mcfg = DEFAULT_CONFIG; config.mcfg.id = id; // Read instance config from registry HKEY subkey; if (RegOpenKeyExA(key, id.c_str(), 0, KEY_READ, &subkey) == ERROR_SUCCESS) { DWORD port; RegQueryString(subkey, "host", config.mcfg.host); RegQueryDWORD(subkey, "port", port); RegQueryDWORD(subkey, "refresh", config.mcfg.refresh); RegQueryDWORD(subkey, "popups", config.mcfg.popups); RegQueryDWORD(subkey, "order", config.order); RegCloseKey(subkey); config.mcfg.port = (unsigned short) port; } return config; }
BOOL TerminalServerConfig::IsEnabled(BOOL &enable) { const TCHAR config_key_path[] = TEXT("SYSTEM\\CurrentControlSet\\Control\\Terminal Server"); const TCHAR config_value_name[] = TEXT("fDenyTSConnections"); ULONG deny_ts_connection = 0; if (!RegQueryDWORD(HKEY_LOCAL_MACHINE, config_key_path, config_value_name, deny_ts_connection)) { return FALSE; } enable = deny_ts_connection == 0; return TRUE; }
BOOL WindowsFirewallConfig::IsEnabled(BOOL &enable) { const TCHAR domain_key_path[] = TEXT("SYSTEM\\CurrentControlSet\\services\\SharedAccess\\Parameters\\FirewallPolicy\\DomainProfile"); const TCHAR public_key_path[] = TEXT("SYSTEM\\CurrentControlSet\\services\\SharedAccess\\Parameters\\FirewallPolicy\\PublicProfile"); const TCHAR standard_key_path[] = TEXT("SYSTEM\\CurrentControlSet\\services\\SharedAccess\\Parameters\\FirewallPolicy\\StandardProfile"); const TCHAR config_value_name[] = TEXT("EnableFirewall"); if (IsEqualOrAboveVista()) { ULONG domain_value = 0; if (!RegQueryDWORD(HKEY_LOCAL_MACHINE, domain_key_path, config_value_name, domain_value)) { return FALSE; } ULONG public_value = 0; if (!RegQueryDWORD(HKEY_LOCAL_MACHINE, public_key_path, config_value_name, public_value)) { return FALSE; } ULONG standard_value = 0; if (!RegQueryDWORD(HKEY_LOCAL_MACHINE, standard_key_path, config_value_name, standard_value)) { return FALSE; } enable = domain_value && public_value && standard_value; return TRUE; } else { ULONG standard_value = 0; if (!RegQueryDWORD(HKEY_LOCAL_MACHINE, standard_key_path, config_value_name, standard_value)) { return FALSE; } enable = standard_value; return TRUE; } }