![](/img/trans.png)
[英]C++ | How can i delete files in a folder located in (C:\Program Files (x86))
[英]How can I get the Nvidia driver version programatically in x86 program?
我認為您正在使用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.