Registration Form
Implementation: Use the Registry class provided by the Microsoft.Win32 class to access the system registry to obtain a list of ODBC data services.
Specific implementation:
MICROSOFT.WIN32 provides a RegistryKey class to access the system's registry.
Define Registry Child Path
String strregpath = @ "Software\odbc\odbc. INI\ODBC Data Sources ";
Create two RegistryKey classes, one will point to root path, and the other will point to child path
RegistryKey Regrootkey;
RegistryKey Regsubkey;
Define root point to registry HKEY_LOCAL_MACHINE node
Regrootkey = Registry.localmachine;
The Registry enumeration class provides the following
/*
Registry.classesroot--------------> point to Registry HKEY_CLASSES_ROOT node
Registry.currentconfig--------------> point to Registry Hkey_current_config node
Registry.currentuser--------------> point to Registry HKEY_CURRENT_USER node
Registry.dyndata--------------> point to Registry Hkey_dyn_data node (dynamic Registry data)
Registry.localmachine--------------> point to Registry HKEY_LOCAL_MACHINE node
Registry.PerformanceData--------------> point to Registry Hkey_performance_data node
Registry.users--------------> point to Registry HKEY_USERS node
*/
Regsubkey = Regrootkey.opensubkey (Strregpath);
string[] strdsnlist = Regsubkey.getvaluenames ();
Shut down
Regsubkey.close ();
Regrootkey.close ();
This enables the DSN Service list to be read.