views:

290

answers:

1

Hi everyone!

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

A: 

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

chollida
Hi!Thanks for your reply. I had a look at the MSDN link you posted up. Would the steps also be valid for Windows Vista? Reason I ask is that I'd like my program to run on Windows XP as well as Vista.Thanks!
Most of the steps would be the same, with the exception of the 3 methods that the VISTA link mentions
chollida
Hi! Thanks. I think I managed to set up the infodata correctly. Whe n debugging, I get a cbsize of 28 when I set it manually. Does this look like a correct value for it to have (I'm unfamiliar by what numbers are considered 'normal'). Also, I set the GUI argument in the SetupDiCreateDeviceInfo to NULL. That is okay, yes? Since the argument is optional.From there, I'm not sure what to set the SPDRP_Xxx identifier to. I looked at the properties and none seem to have the information I need to retreive for the GPU.Thanks again for your help!