.NET/インストールされているODBCドライバ一覧を取得するサンプル
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../)
* C#でインストールされているODBCドライバの一覧を取得する ...
C#で odbccp32.dll の SQLGetInstalledDrivers API を呼び出...
* 動作確認環境 [#c3518923]
- Windows 10 バージョン 22H2
- Visual Studio 2019
- .NET Framework 4.7.2
* 参考サイト [#mc18c78e]
-ODBC Driver List from .NET~
https://stackoverflow.com/questions/6457973/odbc-driver-l...
* C# サンプルコード [#ff5303a8]
C#からodbccp32.dllのSQLGetInstalledDriversを呼び出すサン...
#br
#ref(Program.cs)
using System;
using System.Runtime.InteropServices;
namespace OdbcDriverList
{
static class Win32OdbcApi
{
[DllImport("odbccp32.dll", CharSet = CharSet.Uni...
internal static extern bool SQLGetInstalledDrive...
}
class Program
{
static void Main(string[] args)
{
string[] odbcDriverNames = null;
char[] driverNamesBuffer = new char[ushort.M...
bool succeeded = Win32OdbcApi.SQLGetInstalle...
driverNamesBuffer,
ushort.MaxValue,
out ushort size);
if (succeeded)
{
char[] driverNames = new char[size - 1];
Array.Copy(driverNamesBuffer, driverName...
odbcDriverNames = (new string(driverName...
Console.WriteLine(String.Join("\n",odbcD...
}
else
{
Console.Error.WriteLine("ERROR: SQLGetIn...
}
}
}
}
* 実行結果 [#n95c4f8b]
上記 C# コンソールアプリケーションの実行結果になります。~
#ref(01.png)
#br
以上、C#でODBCドライバの一覧を表示するサンプルコードの紹...
終了行:
#navi(../)
* C#でインストールされているODBCドライバの一覧を取得する ...
C#で odbccp32.dll の SQLGetInstalledDrivers API を呼び出...
* 動作確認環境 [#c3518923]
- Windows 10 バージョン 22H2
- Visual Studio 2019
- .NET Framework 4.7.2
* 参考サイト [#mc18c78e]
-ODBC Driver List from .NET~
https://stackoverflow.com/questions/6457973/odbc-driver-l...
* C# サンプルコード [#ff5303a8]
C#からodbccp32.dllのSQLGetInstalledDriversを呼び出すサン...
#br
#ref(Program.cs)
using System;
using System.Runtime.InteropServices;
namespace OdbcDriverList
{
static class Win32OdbcApi
{
[DllImport("odbccp32.dll", CharSet = CharSet.Uni...
internal static extern bool SQLGetInstalledDrive...
}
class Program
{
static void Main(string[] args)
{
string[] odbcDriverNames = null;
char[] driverNamesBuffer = new char[ushort.M...
bool succeeded = Win32OdbcApi.SQLGetInstalle...
driverNamesBuffer,
ushort.MaxValue,
out ushort size);
if (succeeded)
{
char[] driverNames = new char[size - 1];
Array.Copy(driverNamesBuffer, driverName...
odbcDriverNames = (new string(driverName...
Console.WriteLine(String.Join("\n",odbcD...
}
else
{
Console.Error.WriteLine("ERROR: SQLGetIn...
}
}
}
}
* 実行結果 [#n95c4f8b]
上記 C# コンソールアプリケーションの実行結果になります。~
#ref(01.png)
#br
以上、C#でODBCドライバの一覧を表示するサンプルコードの紹...
ページ名: