How to get registry information in C #

Source: Internet
Author: User
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.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.