如何从Windows XP Embedded中的C#访问性能计数器?
时间:2020-03-05 18:51:29 来源:igfitidea点击:
我有一个在Windows XP下运行的应用程序,正在访问处理器和内存性能计数器。当我尝试运行相同的代码并在XP Embedded上访问它们时,计数器似乎不存在。它们出现在图像中,我可以在perfmon中看到它们。这里缺少什么?
解决方案
回答
是否添加了所有WMI组件?据我所知,我们需要所有WMI组件才能访问计数器!
The Performance Counter Windows Management Instrumentation (WMI) Provider component provides a bridge between the performance registry interface and the WMI interface. This component allows WMI clients to access performance counters through WMI scripts, and allows management applications built using WMI to access performance counters. Without this component, applications must directly use the registry interface or the performance data helper interface to access performance counters.
感谢TimK提供的链接(http://msdn.microsoft.com/zh-cn/library/aa939695.aspx)
回答
看来这是我所缺少的:http://msdn.microsoft.com/zh-cn/library/aa939695.aspx