簡體   English   中英

如何在x86程序中以編程方式獲取Nvidia驅動程序版本?

[英]How can I get the Nvidia driver version programatically in x86 program?

我需要的是在c++程序中檢索到的2號版本的Nvidia驅動程序(例如368.39)。 使用Windows 7 64b。

是使用Nvidia的NVML庫在64位應用程序中執行此操作的方法。

但是,隨Nvidia驅動程序nvml.dll分發的nvml.dll僅是64位。 沒有辦法在我的32位程序中動態加載此庫。 這是假設您的計算機是64位的。 我尚未在32位計算機上對此進行測試。

到目前為止,NVML似乎是唯一允許檢索此信息的庫。 還有什么其他方法可以得到這個?

我認為您正在使用Windows,因為您提到了“ .dll”。在Windows中,您應該能夠使用WMI來獲取所需的任何硬件信息。 對於顯示適配器,請使用Win32_VideoController WMI類,該類具有一個名為driverversion的字符串字段,該字段應具有所需的內容。

https://msdn.microsoft.com/en-us/library/aa394512(v=vs.85).aspx

    // ---------------------------------------------------------------------

    // (windows) how to get the nvidea driver version?

    // ---------------------------------------------------------------------

    #define C(a) {std::cout<<a<<std::endl;} // for easy print out to console

    template <class T> inline std::string TOSTR(const T fp){    // a macro
      std::ostringstream o;
      o.setf(std::ios_base::fixed, std::ios_base::floatfield);
      o << fp;  // << ends; (null-terminator character)
      return std::string(o.str());
    }

    // ---------------------------------------------------------------------

    #pragma comment(lib,"nvapi.lib")    // needed !

    #include <nvapi.h>  // needed !

    // you have to start nvapi:

    NvAPI_Status ret(NVAPI_OK);
    ret = NvAPI_Initialize();
    if(ret != NVAPI_OK) {
      NvAPI_ShortString string;
      NvAPI_GetErrorMessage(ret, string);
      printf("NVAPI NvAPI_Initialize: %s\n", string);
    }

    NvAPI_Status s;
    NvU32 v;    // version
    NvAPI_ShortString b;    // branch
    s = NvAPI_SYS_GetDriverAndBranchVersion(&v, b);
    if(s != NVAPI_OK) {
      NvAPI_ShortString string;
      NvAPI_GetErrorMessage(s, string);
      printf("NvAPI_SYS_GetDriverAndBranchVersion: %s\n", string);
    }   

    C("Nvidea driver version: " + TOSTR(v));    // app, console output


// ...hope i can help ....

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM