> こんにちは。 > > インストールされているMDACのバージョンを > 取得できませんか? 参照設定で Microsoft Data Access Component Installed Version にチェックを入れて、以下のコードで取得できます。 Dim objMDACVer As MDACVer.Version Set objMDACVer = New MDACVer.Version Call MsgBox(objMDACVer.String)
> また、コントロールパネルのODBCデータソースの > ユーザデータソースの情報を取得する方法、 ODBC API と呼ばれるものを使えば出来ます。
Option Explicit
Private Declare Function SQLAllocEnv Lib "odbc32.dll" ( _ ByRef phEnv As Long _ ) As Integer
Private Declare Function SQLFreeEnv Lib "odbc32.dll" ( _ ByVal hEnv As Long _ ) As Integer
Private Declare Function SQLDataSources Lib "odbc32.dll" _ Alias "SQLDataSourcesA" ( _ ByVal hEnv As Long, _ ByVal fDirection As Integer, _ ByVal szDSN As String, _ ByVal cbDSNMax As Integer, _ ByRef pcbDSN As Integer, _ ByVal szDescription As String, _ ByVal cbDescriptionMax As Integer, _ ByRef pcbDescription As Integer _ ) As Integer
Private Const SQL_SUCCESS = 0 Private Const SQL_SUCCESS_WITH_INFO = 1 Private Const SQL_NO_DATA_FOUND = 100
Private Const SQL_FETCH_FIRST = 2 Private Const SQL_FETCH_NEXT = 1
Private Sub Command1_Click() Dim hEnv As Long Dim szDSN As String * 256 Dim cbDSN As Integer Dim szDescription As String * 256 Dim cbDescription As Integer Dim fDirection As Integer Dim nRet As Integer fDirection = SQL_FETCH_FIRST nRet = 0 Call SQLAllocEnv(hEnv) Do While nRet >= 0 nRet = SQLDataSources( _ hEnv, _ fDirection, _ szDSN, _ 256, _ cbDSN, _ szDescription, _ 256, _ cbDescription) If nRet = SQL_NO_DATA_FOUND Then Exit Do End If Debug.Print LeftB(szDSN, InStrB(szDSN, Chr$(0))) & vbTab & szDescription fDirection = SQL_FETCH_NEXT Loop Call SQLFreeEnv(hEnv) End Sub
|