// 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); }
// Find <object> with <name> in <this> context // (String version) int ACE_Registry::Naming_Context::resolve (const ACE_TString &name, Object &object) { // Get object state u_long type; void *data = object.data (); u_long size = object.size (); long result = ACE_TEXT_RegQueryValueEx (this->key_, name.c_str (), 0, &type, (BYTE *)data, &size); if (result == ERROR_SUCCESS) { // Reset object state // No need to set object.data() object.type (type); object.size (size); } ACE_REGISTRY_CALL_RETURN (result); }
/* static */ int ACE_Predefined_Naming_Contexts::connect (ACE_Registry::Naming_Context &naming_context, HKEY predefined, const ACE_TCHAR *machine_name) { #if defined (ACE_HAS_WINCE) return -1; #else long result = -1; if (machine_name != 0 && ACE_OS::strcmp (ACE_TEXT ("localhost"), machine_name) == 0) machine_name = 0; if (predefined == HKEY_LOCAL_MACHINE || predefined == HKEY_USERS) result = ACE_TEXT_RegConnectRegistry (const_cast<ACE_TCHAR *> (machine_name), predefined, &naming_context.key_); if (predefined == HKEY_CURRENT_USER || predefined == HKEY_CLASSES_ROOT) // Make sure that for these types, the machine is local if (machine_name == 0 || ACE_Predefined_Naming_Contexts::is_local_host (machine_name)) { naming_context.key_ = predefined; result = 0; } else result = -1; ACE_REGISTRY_CALL_RETURN (result); #endif // ACE_HAS_WINCE }
// Remove naming_context with <name> from <this> context // (String version) int ACE_Registry::Naming_Context::unbind_context (const ACE_TString &name) { long result = ACE_TEXT_RegDeleteKey (this->key_, name.c_str ()); ACE_REGISTRY_CALL_RETURN (result); }
// Same as unbind_context() with <this> as naming_context int ACE_Registry::Naming_Context::destroy (void) { // hopefully the parent_key_ is still open long result = ACE_TEXT_RegDeleteKey (this->parent_key_, this->name_.c_str ()); ACE_REGISTRY_CALL_RETURN (result); }
// Insert or update <object> with <name> into <this> context // (String version) int ACE_Registry::Naming_Context::bind (const ACE_TString &name, const Object &object) { long result = ACE_TEXT_RegSetValueEx (this->key_, name.c_str (), 0, object.type (), (const BYTE *) object.data (), object.size ()); ACE_REGISTRY_CALL_RETURN (result); }
// 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); }
// Find <naming_context> with <name> in <this> context // (String version) int ACE_Registry::Naming_Context::resolve_context (const ACE_TString &name, Naming_Context &naming_context, u_long security_access) { long result = ACE_TEXT_RegOpenKeyEx (this->key_, name.c_str (), 0, security_access, &naming_context.key_); 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); }
// Close the handle of the context int ACE_Registry::Naming_Context::close (void) { long result = this->key_ ? ::RegCloseKey (this->key_) : ERROR_SUCCESS; ACE_REGISTRY_CALL_RETURN (result); }
// Sync content of context to disk int ACE_Registry::Naming_Context::flush (void) { long result = ::RegFlushKey (this->key_); ACE_REGISTRY_CALL_RETURN (result); }