Getting GPU clock speeds with SetupDiEnumDeviceInfo

2k Views Asked by At

I posted a question earlier regarding obtaining GPU clock speeds, but I guess the thread appeared as already answered since someone had replied to it.

I'd been advised by one of your members to try extracting GPU clock speeds using SetupDiEnumDeviceInfo.

However, I looked around at some examples, like this one: http://www.codeproject.com/KB/system/DevMgr.aspx

and nothing seemed to be displayed about the clock speed.

Could someone please elaborate on how to achieve this, if at all possible?

Thanks again

1

There are 1 best solutions below

3
On

You will want to check out this msdn article:

http://msdn.microsoft.com/en-us/library/bb742655.aspx

Specifically, follow these steps:

Call SetupDiGetDeviceRegistryProperty to retrieve the size, in bytes, of the property  value. Supply the following parameter values:
Set DeviceInfoSet to a handle to a device information set that contains the device instance for which to retrieve the requested property value. 
Set DeviceInfoData to a pointer to an SP_DEVINFO_DATA structure that represents the  device instance for which to retrieve the requested property value. 
Set Property to an SPDRP_Xxx identifier. For a list of these identifiers and a description of the corresponding device properties, see the description of the Property parameter that is included with SetupDiSetDeviceRegistryProperty. 
   Set PropertyRegDataType to a pointer to a DWORD-typed variable. 
   Set PropertyBuffer to NULL. 
   Set PropertyBufferSize to zero. 
   Set RequiredSize to a pointer to a DWORD-typed variable that receives, the size, in bytes of the property value. 

In response to the call to SetupDiSetDeviceRegistryProperty, SetupDiGetDeviceRegistryProperty sets *RequiredSize to the size, in bytes, of the buffer that is required to retrieve the property value, logs the error code ERROR_INSUFFICIENT_BUFFER, and returns FALSE. A subsequent call to GetLastError will return the most recently logged error code.

Call SetupDiGetDeviceRegistryProperty again and supply the same parameter values that were supplied in the first call, except for the following changes:

Set PropertyBuffer to a pointer to a BYTE-typed buffer that receives the requested property value. Set PropertyBufferSize to the the size, in bytes, of the PropertyBuffer buffer. The first call to SetupDiGetDeviceRegistryProperty retrieved the required size of the PropertyBuffer buffer in *RequiredSize.

This link shows how to get to the point where you've got the required strucutres to call SetupDiGetDeviceRegistryProperty.

http://www.pinvoke.net/default.aspx/setupapi/SetupDiEnumDeviceInfo.html