ACE_Predefined_Naming_Contexts Class Reference

A factory for predefined registries, which exist by default on Win32 platforms. More...

#include <Registry.h>

List of all members.

Static Public Member Functions

int connect (ACE_Registry::Naming_Context &naming_context, HKEY predefined=HKEY_LOCAL_MACHINE, const ACE_TCHAR *machine_name=0)

Static Private Member Functions

int is_local_host (const ACE_TCHAR *machine_name)
 Check if machine_name is the local host.


Detailed Description

A factory for predefined registries, which exist by default on Win32 platforms.

This factory can connect to both local and remote predefined registries.

Definition at line 541 of file Registry.h.


Member Function Documentation

int ACE_Predefined_Naming_Contexts::connect ACE_Registry::Naming_Context naming_context,
HKEY  predefined = HKEY_LOCAL_MACHINE,
const ACE_TCHAR machine_name = 0
[static]
 

Factory method for connecting to predefined registries. This method works for both remote and local machines. However, for remote machines, HKEY_CLASSES_ROOT and HKEY_CURRENT_USER types are not allowed

Definition at line 1091 of file Registry.cpp.

References ACE_LIB_TEXT, ACE_REGISTRY_CALL_RETURN, ACE_TCHAR, is_local_host(), ACE_Registry::Naming_Context::key_, and ACE_OS::strcmp().

Referenced by ACE_Registry_Name_Space::open().

01094 {
01095 #if defined (ACE_HAS_WINCE)
01096   return -1;
01097 #else
01098   long result = -1;
01099 
01100   if (machine_name != 0 && ACE_OS::strcmp (ACE_LIB_TEXT ("localhost"), machine_name) == 0)
01101     machine_name = 0;
01102 
01103   if (predefined == HKEY_LOCAL_MACHINE || predefined == HKEY_USERS)
01104     result =
01105       ACE_TEXT_RegConnectRegistry (const_cast<ACE_TCHAR *> (machine_name),
01106                                    predefined,
01107                                    &naming_context.key_);
01108   if (predefined == HKEY_CURRENT_USER || predefined == HKEY_CLASSES_ROOT)
01109     // Make sure that for these types, the machine is local
01110     if (machine_name == 0 ||
01111         ACE_Predefined_Naming_Contexts::is_local_host (machine_name))
01112       {
01113         naming_context.key_ = predefined;
01114         result = 0;
01115       }
01116     else
01117       result = -1;
01118 
01119   ACE_REGISTRY_CALL_RETURN (result);
01120 #endif  // ACE_HAS_WINCE
01121 }

int ACE_Predefined_Naming_Contexts::is_local_host const ACE_TCHAR machine_name  )  [static, private]
 

Check if machine_name is the local host.

Definition at line 1126 of file Registry.cpp.

References ACE_TCHAR, ACE_OS::hostname(), MAXHOSTNAMELEN, and ACE_OS::strcmp().

Referenced by connect().

01127 {
01128   ACE_TCHAR local_host[MAXHOSTNAMELEN];
01129   int result = ACE_OS::hostname (local_host, sizeof local_host / sizeof (ACE_TCHAR));
01130   if (result == 0)
01131     result = !ACE_OS::strcmp (local_host, machine_name);
01132   else
01133     result = 0;
01134   return result;
01135 }


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:27:09 2006 for ACE by doxygen 1.3.6