SQLGetInstalledDrivers 获取ODBC已经安装的驱动列表

时间:2021-03-26 04:43:49


#include <ODBCINST.H>
void GetSQLDriverList()
{
  TCHAR szDrivers[4096];
  memset(szDrivers, 0, sizeof(szDrivers));
  WORD wRet = 0;
  if(SQLGetInstalledDrivers(szDrivers, sizeof(szDrivers), &wRet))
  {
    TRACE(_T("Installed driver list:\n"));
    LPTSTR pszDrv = szDrivers;
    while(*pszDrv)
    {
      TRACE(_T("%s\n"), pszDrv);
      
      pszDrv += _tcslen(pszDrv) + 1;
    }
    TRACE(_T("\n"));      
  }
}

//调试输出

Installed driver list:
SQL Server
Microsoft Access Driver (*.mdb)
Microsoft Text Driver (*.txt; *.csv)
Microsoft Excel Driver (*.xls)
Microsoft dBase Driver (*.dbf)
Microsoft Paradox Driver (*.db )
Microsoft Visual FoxPro Driver
Microsoft FoxPro VFP Driver (*.dbf)
Microsoft dBase VFP Driver (*.dbf)
Microsoft Access-Treiber (*.mdb)
Microsoft Text-Treiber (*.txt; *.csv)
Microsoft Excel-Treiber (*.xls)
Microsoft dBase-Treiber (*.dbf)
Microsoft Paradox-Treiber (*.db )
Microsoft Visual FoxPro-Treiber
Driver do Microsoft Access (*.mdb)
Driver da Microsoft para arquivos texto (*.txt; *.csv)
Driver do Microsoft Excel(*.xls)
Driver do Microsoft dBase (*.dbf)
Driver do Microsoft Paradox (*.db )
Driver para o Microsoft Visual FoxPro
Microsoft ODBC for Oracle
Microsoft FoxPro Driver (*.dbf)
SQL Native Client