Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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 Methods

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

Static Private Methods

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


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 1087 of file Registry.cpp.

References ACE_LIB_TEXT, ACE_REGISTRY_CALL_RETURN, ACE_TCHAR, is_local_host, ACE_Registry::Naming_Context::key_, ACE_Registry::Binding_Iterator::naming_context, and ACE_OS_String::strcmp.

Referenced by ACE_Registry_Name_Space::open.

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

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 1121 of file Registry.cpp.

References ACE_TCHAR, ACE_OS::hostname, MAXHOSTNAMELEN, and ACE_OS_String::strcmp.

Referenced by connect.

01122 {
01123   ACE_TCHAR local_host[MAXHOSTNAMELEN];
01124   int result = ACE_OS::hostname (local_host, sizeof local_host / sizeof (ACE_TCHAR));
01125   if (result == 0)
01126     result = !ACE_OS::strcmp (local_host, machine_name);
01127   else
01128     result = 0;
01129   return result;
01130 }


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:54:12 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002