当前手中开发的ADO程序在低版本的MDAC上无法正确运行,需要安装最新的MDAC,
问题是怎么通过程序判断当前系统的MDAC版本号?

解决方案 »

  1.   

    oh.我自己找到方法了.可以在HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/DataAccess/FullInstallVer 中可以找到它安裝的版本
      

  2.   

    void VersionX(void) 
    {
        HRESULT   hr = S_OK;    // Define string variables.
        _bstr_t strCnn("driver={SQL Server};server='MySqlServer';"
            "user id='MyUserId';password='MyPassword';database='pubs';");    // Define ADO object pointers.
        // Initialize pointers on define.
        // These are in the ADODB::  namespace.
        _ConnectionPtr    pConnection     = NULL;    try
        {
            // Open connection.
            TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
            pConnection->Open (strCnn, "", "", adConnectUnspecified);        printf("ADO Version   : %s\n\n",(LPCSTR) pConnection->Version);
            printf("DBMS Name   : %s\n\n",(LPCSTR) (_bstr_t) 
                pConnection->Properties->GetItem("DBMS Name")->Value);
            printf("DBMS Version   : %s\n\n",(LPCSTR) (_bstr_t)
                pConnection->Properties->GetItem("DBMS Version")->Value);
            printf("OLE DB Version   : %s\n\n",(LPCSTR) (_bstr_t) 
                pConnection->Properties->GetItem("OLE DB Version")->Value);
            printf("Provider Name   : %s\n\n",(LPCSTR) (_bstr_t) 
                pConnection->Properties->GetItem("Provider Name")->Value);
            printf("Provider Version   : %s\n\n",(LPCSTR) (_bstr_t) 
                pConnection->Properties->GetItem("Provider Version")->Value);
            printf("Driver Name   : %s\n\n",(LPCSTR) (_bstr_t) 
                pConnection->Properties->GetItem("Driver Name")->Value);
            printf("Driver Version   : %s\n\n",(LPCSTR) (_bstr_t) 
                pConnection->Properties->GetItem("Driver Version")->Value);
            printf("Driver ODBC Version   : %s\n\n",(LPCSTR) (_bstr_t) 
                pConnection->Properties->GetItem("Driver ODBC Version")->Value);    }    catch (_com_error &e)
        {
            // Notify the user of errors if any.
            PrintProviderError(pConnection);
            PrintComError(e);
        }    if (pConnection)
            if (pConnection->State == adStateOpen)
                pConnection->Close();
    }