使用 RegQueryValueEx 和 HKEY_PERFORMANCE_COUNTER 获取“磁盘字节/秒%”
我已经查找了示例和文档,但我仍然无法弄清楚...
如何使用 RegQueryValueEx
(不是 PdhXxx 函数)来查询某些内容就像磁盘字节/秒
?
我尝试了以下操作:
DWORD type;
static union { TCHAR Data[32 * 1024]; PERF_DATA_BLOCK Perf; } perf;//Stack buffer
DWORD cbData = sizeof(perf);
LSTATUS s = RegQueryValueEx(HKEY_PERFORMANCE_DATA,
_T("PhysicalDisk"), NULL, &type, (LPBYTE)&perf, &cbData);
PPERF_OBJECT_TYPE pObjType =
(PPERF_OBJECT_TYPE)((BYTE*)&perf + perf.Perf.HeaderLength);
但它只返回一个没有数据的标头。 :(
I've looked for examples and documentation, but I still can't figure this out...
How do you use RegQueryValueEx
(not the PdhXxx functions) to query for something like Disk Bytes/sec
?
I've tried the following:
DWORD type;
static union { TCHAR Data[32 * 1024]; PERF_DATA_BLOCK Perf; } perf;//Stack buffer
DWORD cbData = sizeof(perf);
LSTATUS s = RegQueryValueEx(HKEY_PERFORMANCE_DATA,
_T("PhysicalDisk"), NULL, &type, (LPBYTE)&perf, &cbData);
PPERF_OBJECT_TYPE pObjType =
(PPERF_OBJECT_TYPE)((BYTE*)&perf + perf.Perf.HeaderLength);
but it just returns a header with no data. :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能像这样通过名称查询数据。相反,您需要通过索引进行查询。 MSDN 可以帮助您编写一些代码找出要查询的适当索引。不幸的是,您需要在运行时确定哪个索引。
例如,以下内容应该检索处理器的性能数据。
You can't query for the data by name like that. Instead, you need to query by index. MSDN can help you with some code to find out the appropriate index to query. Unfortunately, you need to make the determination of which index at run-time.
For example, the following SHOULD retrieve the performance data for the processor.