intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Listing Installed ODBC Drivers

Chia sẻ: Bui Tuan | Ngày: | Loại File: PDF | Số trang:2

75
lượt xem
5
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

[ Team LiB ] Recipe 10.16 Listing Installed ODBC Drivers Problem You need a list of the ODBC drivers installed on the computer running your code. Solution Consult the registry. The sample code uses the Microsoft.Win32.

Chủ đề:
Lưu

Nội dung Text: Listing Installed ODBC Drivers

  1. [ Team LiB ] Recipe 10.16 Listing Installed ODBC Drivers Problem You need a list of the ODBC drivers installed on the computer running your code. Solution Consult the registry. The sample code uses the Microsoft.Win32.Registry class to display a list of all installed ODBC drivers. The C# code is shown in Example 10-17. Example 10-17. File: OdbcDriversForm.cs // Namespaces, variables, and constants using System; using System.Text; using Microsoft.Win32; // . . . StringBuilder result = new StringBuilder( ); // Get the HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers key. RegistryKey keyLocalMachine = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers", false); string[] valueNames = keyLocalMachine.GetValueNames( ); for(int i = 0; i < valueNames.Length; i++) result.Append(valueNames[i] + Environment.NewLine); resultTextBox.Text = result.ToString( ); Discussion The .NET Framework classes that manipulate the registry are found in the
  2. Microsoft.Win32 namespace. The registry key HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers contains a value name for each installed ODBC driver. [ Team LiB ]
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2