获取PDH性能对象列表之三-------------获取性能对象的属性列表以及实例列表
来源:互联网 发布:湘潭大学网络教育 编辑:程序博客网 时间:2024/05/22 06:08
#define _UNICODE /*主要对C标准库函数,将宏替换为宽字节形式*/#define UNICODE /*主要对Windows API标准函数,将函数宏替换为宽字节形式*/#define WIN32_LEAN_AND_MEAN 1#include <windows.h>#include <malloc.h>#include <stdio.h>#include <pdh.h>#include <pdhmsg.h> /*存放PDH函数返回的错误代码*/#include <tchar.h> ///#pragma comment(lib, "pdh.lib")void main(){PCTSTR strObject=_T("Process");PDH_STATUS status = ERROR_SUCCESS;LPTSTR ptsCounterListBuffer = NULL;//属性列表DWORD dwCounterListSize = 0;LPTSTR ptsInstanceListBuffer = NULL;//实例列表DWORD dwInstanceListSize = 0;LPTSTR pTemp = NULL;// Determine the required buffer size for the data.status = PdhEnumObjectItems(NULL, // real-time sourceNULL, // local machinestrObject, // object to enumerateptsCounterListBuffer, // pass NULL and 0&dwCounterListSize, // to get required buffer sizeptsInstanceListBuffer, &dwInstanceListSize,PERF_DETAIL_WIZARD, // counter detail level0);if (status == PDH_MORE_DATA) {// Allocate the buffers and try the call again.ptsCounterListBuffer = (LPWSTR) malloc(dwCounterListSize * sizeof(WCHAR));ptsInstanceListBuffer = (LPWSTR) malloc(dwInstanceListSize * sizeof(WCHAR));if (NULL != ptsCounterListBuffer && NULL != ptsInstanceListBuffer) {status = PdhEnumObjectItems(NULL, // real-time sourceNULL, // local machinestrObject, // object to enumerateptsCounterListBuffer, &dwCounterListSize,ptsInstanceListBuffer, &dwInstanceListSize,PERF_DETAIL_WIZARD, // counter detail level0);if (status == ERROR_SUCCESS) {_tprintf(_T("Counters that the Process objects defines:\n\n"));//wprintf(L"Counters that the Process objects defines:\n\n");// Walk the counters list. The list can contain one// or more null-terminated strings. The list is terminated// using two null-terminator characters.for (pTemp = ptsCounterListBuffer; *pTemp != 0;pTemp += wcslen(pTemp) + 1) {_tprintf(_T("%s\n"),pTemp);//wprintf(L"%s\n", pTemp);}_tprintf(_T("\nInstances of the Process object:\n\n"));//wprintf(L"\nInstances of the Process object:\n\n");// Walk the instance list. The list can contain one// or more null-terminated strings. The list is terminated// using two null-terminator characters.for (pTemp = ptsInstanceListBuffer; *pTemp != 0;pTemp += wcslen(pTemp) + 1) {_tprintf(_T("%s\n"),pTemp);//wprintf(L"%s\n", pTemp);}} else {_tprintf(_T("Second PdhEnumObjectItems failed with %0x%x.\n"),status);//wprintf(L"Second PdhEnumObjectItems failed with %0x%x.\n",status);}} else {_tprintf(_T("Unable to allocate buffers.\n"));//wprintf(L"Unable to allocate buffers.\n");status = ERROR_OUTOFMEMORY;}} else {_tprintf(_T("\nPdhEnumObjectItems failed with 0x%x.\n"),status);//wprintf(L"\nPdhEnumObjectItems failed with 0x%x.\n", status);}if (ptsCounterListBuffer != NULL)free(ptsCounterListBuffer);if (ptsInstanceListBuffer != NULL)free(ptsInstanceListBuffer);)
0 0
- 获取PDH性能对象列表之三-------------获取性能对象的属性列表以及实例列表
- 获取PDH性能对象的列表之二------------获取Windows所有性能对象
- 获取PDH性能对象列表之一------------PDH简介
- 获取对象的属性列表
- iOS获取对象属性列表
- createSQLQuery获取对象列表
- PDH性能测试之四-----------获取每个对象的Counter和Instance
- runtime获取对象属性及方法列表
- 获取对象的类名,属性及方法列表
- Java列表对象的性能分析
- Java列表对象的性能分析
- Swift3.0 运行时获取对象属性列表
- 获取对象的属性名、属性值、属性特性,协议列表
- pdh相关的获取CPU性能API
- 获取属性列表
- 对象归档/属性列表
- Java列表对象的性能分析和测试
- Java列表对象的性能分析和测试
- WorkPlanning_1
- QxOrm 1.2.9 下载 以及编译方法 简介.
- Linux开启mysql远程连接
- CUGBACM14级喜迎开学第1场 解题报告
- 基于Xstream工具解决对象到xml文本的集合节点重复问题
- 获取PDH性能对象列表之三-------------获取性能对象的属性列表以及实例列表
- QT-Embedded-4.5.3在海思35xx上移植
- php实现邮件发送---实用的小功能(一)
- 打印万年历
- 机器学习&数据挖掘笔记_16(常见面试之机器学习算法思想简单梳理)
- 《Apache MINA 2.0 用户指南》第十五章: 代理
- 读取src下的配置文件
- Linux命令学习三
- listview 的onitemclick方法中的参数