#include <Registry.h>
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. |
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 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 } |
|
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 } |