#include <Registry.h>
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... | |
This factory can connect to both local and remote predefined registries.
Definition at line 541 of file Registry.h.
|
||||||||||||||||
|
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 }
|
|
|
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 }
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002