// Insert or update <naming_context> with <name> relative to <this> context // (String version) int ACE_Registry::Naming_Context::bind_context (const ACE_TString &name, /* const */ Naming_Context &naming_context, u_long persistence, u_long security_access, LPSECURITY_ATTRIBUTES security_attributes) { u_long reason; long result = ACE_TEXT_RegCreateKeyEx (this->key_, name.c_str (), 0, 0, persistence, security_access, security_attributes, &naming_context.key_, &reason); if (result == ERROR_SUCCESS) { // Set the correct parent naming_context.parent (this->key_); // Set the correct name naming_context.name (name); } ACE_REGISTRY_CALL_RETURN (result); }
int Activator_Options::save_registry_options() { #if defined (ACE_WIN32) HKEY key = 0; // Create or open the parameters key LONG err = ACE_TEXT_RegCreateKeyEx (SERVICE_REG_ROOT, SERVICE_REG_PATH, 0, const_cast<ACE_TCHAR *> (ACE_TEXT("")), // class REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &key, 0 ); if (err != ERROR_SUCCESS) { return -1; } err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT("ORBInitOptions"), 0, REG_SZ, (LPBYTE) this->cmdline_.c_str (), (DWORD) this->cmdline_.length () + 1); ACE_ASSERT (err == ERROR_SUCCESS); err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT("IORFile"), 0, REG_SZ, (LPBYTE) this->ior_output_file_.c_str (), (DWORD) this->ior_output_file_.length () + 1); ACE_ASSERT (err == ERROR_SUCCESS); err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT("DebugLevel"), 0, REG_DWORD, (LPBYTE) &this->debug_ , sizeof (this->debug_)); ACE_ASSERT (err == ERROR_SUCCESS); err = ACE_TEXT_RegSetValueEx( key, ACE_TEXT("Name"), 0, REG_SZ, (LPBYTE) this->name_.c_str (), (DWORD) this->name_.length () + 1); ACE_ASSERT (err == ERROR_SUCCESS); DWORD tmpint = this->notify_imr_; err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT("NotifyImR"), 0, REG_DWORD, (LPBYTE) &tmpint , sizeof (tmpint)); ACE_ASSERT (err == ERROR_SUCCESS); tmpint = this->env_buf_len_; err = ACE_TEXT_RegSetValueEx(key, ACE_TEXT("EnvBufLen"), 0, REG_DWORD, (LPBYTE) &tmpint , sizeof(tmpint)); ACE_ASSERT(err == ERROR_SUCCESS); tmpint = this->max_env_vars_; err = ACE_TEXT_RegSetValueEx(key, ACE_TEXT("MaxEnvVars"), 0, REG_DWORD, (LPBYTE) &tmpint , sizeof(tmpint)); ACE_ASSERT(err == ERROR_SUCCESS); err = ::RegCloseKey (key); ACE_ASSERT (err == ERROR_SUCCESS); #endif return 0; }
// Insert <naming_context> with <name> relative to <this> context // (String version) int ACE_Registry::Naming_Context::bind_new_context (const ACE_TString &name, Naming_Context &naming_context, u_long persistence, u_long security_access, LPSECURITY_ATTRIBUTES security_attributes) { u_long reason; long result = ACE_TEXT_RegCreateKeyEx (this->key_, name.c_str (), 0, 0, persistence, security_access, security_attributes, &naming_context.key_, &reason); if (result == ERROR_SUCCESS) // If create succeeds { if (reason == REG_CREATED_NEW_KEY) // If new key: success { // Set the correct parent naming_context.parent (this->key_); // Set the correct name naming_context.name (name); } else // reason == REG_OPENED_EXISTING_KEY // Failed to make new key { // reset result to failure result = -1; // Close the key first ::RegCloseKey (naming_context.key_); // Reset key naming_context.key_ = (HKEY) 0; } } ACE_REGISTRY_CALL_RETURN (result); }
void TAO_NT_Notify_Service::arg_manip (char *args, DWORD arglen, bool query) { HKEY hkey = 0; // It looks in the NT Registry under // \\HKEY_LOCAL_MACHINE\SOFTWARE\ACE\TAO for the value of // "TaoNotifyServiceOptions" for any Notify Service options such as // "-ORBListenEndpoints". // Get/Set Notify Service options from the NT Registry. LONG result = ACE_TEXT_RegOpenKeyEx (REGISTRY_KEY_ROOT, TAO_REGISTRY_SUBKEY, 0, query ? KEY_READ : KEY_WRITE, &hkey); DWORD type = REG_EXPAND_SZ; if (query) { *args = '\0'; if (result == ERROR_SUCCESS) { result = ACE_TEXT_RegQueryValueEx (hkey, TAO_NOTIFY_SERVICE_OPTS_NAME, 0, &type, (BYTE *)args, &arglen); if (result != ERROR_SUCCESS) { this->report_error (ACE_TEXT ("Could not query %s, %s\n"), TAO_NOTIFY_SERVICE_OPTS_NAME, result); } } else { this->report_error (ACE_TEXT ("No key for %s, %s\n"), TAO_REGISTRY_SUBKEY, result); } } else { if (result != ERROR_SUCCESS) { result = ACE_TEXT_RegCreateKeyEx (REGISTRY_KEY_ROOT, TAO_REGISTRY_SUBKEY, 0, 0, 0, KEY_WRITE, 0, &hkey, 0); } DWORD bufSize = static_cast<DWORD>(ACE_OS::strlen (args) + 1); if (result == ERROR_SUCCESS) { result = ACE_TEXT_RegSetValueEx (hkey, TAO_NOTIFY_SERVICE_OPTS_NAME, 0, type, (BYTE *)args, bufSize); if (result != ERROR_SUCCESS) { this->report_error (ACE_TEXT ("Could not set %s, %s\n"), TAO_NOTIFY_SERVICE_OPTS_NAME, result); } } else { this->report_error (ACE_TEXT ("Could not create key %s, %s\n"), TAO_REGISTRY_SUBKEY, result); } } RegCloseKey (hkey); }