网站首页  词典首页

请输入您要查询的函数:

 

术语 pdhexpandcounterpath
释义 PdhExpandCounterPath
语法:
C++
PDH_STATUS PdhExpandCounterPath(
__in LPCTSTR szWildCardPath,
__out LPTSTR mszExpandedPathList,
__inout LPDWORD pcchPathListLength
);
PdhExpandCounterPath功能
检查指定的计算机(或本地计算机上,如果没有指定的计数器和计数器实例)符合在计数器路径通配符的字符串。
注意:此功能所取代PdhExpandWildCardPath功能。
参数
szWildCardPath [in]
null结尾的字符串,其中包含计数器路径扩大。函数搜查的比赛路径中指定的计算机。如果路径没有指定的计算机,功能搜索本地计算机。计数器的路径的最大长度为PDH_MAX_COUNTER_PATH。
mszExpandedPathList [out]
来电分配的缓冲区,它接收的扩大计数器路径列表匹配szWildCardPath通配符规范。列表中的每个计数器路径是终止空字符。该清单将终止两个NULL字符。设置为NULL,如果pcchPathListLength是零。
pcchPathListLength [ in , out ]
的大小mszExpandedPathList缓冲区,在TCHARs。如果零输入,该函数返回PDH_MORE_DATA,并设置此参数所需的缓冲区大小。如果缓冲区比所需的大小,功能设置此参数的时候,往往有人使用的缓冲区的实际大小。如果在输入指定的大小是大于零,但比所需的大小少,您不应该依靠返回的大小重新分配缓冲区。
注意您必须添加一个到Windows XP和Windows 2000所需的大小。
返回值
如果函数成功,它返回ERROR_SUCCESS。
如果函数失败,返回值是一个系统错误代码或一种PDH错误代码。
返回codeDescription
PDH_MORE_DATAThe mszExpandedPathList buffer is too small to contain the list of paths.这个返回值,预计如果pcchPathListLength是在输入为零。如果在输入指定的大小是大于零,但比所需的大小少,您不应该依靠返回的大小重新分配缓冲区。
PDH_INVALID_ARGUMENTA参数无效。例如,在某些版本中您可以收到此错误如果在输入指定的大小是大于零但小于所需的大小。
PDH_MEMORY_ALLOCATION_FAILUREUnable分配内存支持这一功能。
备注
您应该调用这个函数两次,第一次获得所需的缓冲区大小(设置mszExpandedPathList为NULL和pcchPathListLength为0),和第二次获取数据。
一般路径的格式如下:
\\\\computer\\object(parent/instance#index)\\counter
The parent, instance, index, and counter components of the counter path may contain either a valid name or a wildcard character. The computer, parent, instance, and index components are not necessary for all counters.
The counter paths that you must use is determined by the counter itself. For example, the LogicalDisk object has an instance index, so you must provide the #index, or a wildcard. Therefore, you could use the following format:
\\LogicalDisk(*/*#*)\\*
In comparison, the Process object does not require an instance index. Therefore, you could use the following format:
\\Process(*)\\ID Process
The following is a list of the possible formats:
\\\\computer\\object(parent/instance#index)\\counter
\\\\computer\\object(parent/instance)\\counter
\\\\computer\\object(instance#index)\\counter
\\\\computer\\object(instance)\\counter
\\\\computer\\object\\counter
\\object(parent/instance#index)\\counter
\\object(parent/instance)\\counter
\\object(instance#index)\\counter
\\object(instance)\\counter
\\object\\counter
If a wildcard character is specified in the parent name, all instances of the specified object that match the specified instance and counter fields will be returned.
If a wildcard character is specified in the instance name, all instances of the specified object and parent object will be returned if all instance names corresponding to the specified index match the wildcard character.
If a wildcard character is specified in the counter name, all counters of the specified object are returned.
Partial counter path string matches (for example, "pro*") are not supported.
Examples
The following example demonstrates how to this function.
#define UNICODE
#include
#include
#include
#include
#include
#pragma comment(lib, "pdh.lib")
CONST PWSTR WILDCARD_PATH = L"\\\\Processor(*)\\\\*";
void wmain(void)
{
PDH_STATUS Status;
PWSTR EndOfPaths;
PWSTR Paths = NULL;
DWORD BufferSize = 0;
Status = PdhExpandCounterPath(WILDCARD_PATH, Paths, &BufferSize);
while (Status == PDH_MORE_DATA)
{
Paths = (PWSTR)malloc(BufferSize * sizeof(WCHAR));
Status = PdhExpandCounterPath(WILDCARD_PATH, Paths, &BufferSize);
}
if (Status != ERROR_SUCCESS)
{
wprintf(L"\\nPdhExpandCounterPath failed with status 0x%x", Status);
goto Cleanup;
}
if (Paths == NULL)
{
wprintf(L"\\nThe counter path %s cannot be expanded.", WILDCARD_PATH);
goto Cleanup;
}
EndOfPaths = Paths + BufferSize;
// On Vista and later operating systems, the buffer is terminated with two
// null-terminator characters; however, on earlier systems, the buffer is
// not terminated with two null-terminator characters. This covers both cases.
for (PWSTR p = Paths; ((p != EndOfPaths) && (*p != L'\\0')); p += wcslen(p) + 1)
{
wprintf(L"\\n%s", p);
}
Cleanup:
if (Paths)
{
free(Paths);
}
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderPdh.h
LibraryPdh.lib
DLLPdh.dll
Unicode和ANSI namesPdhExpandCounterPathW(Unicode)和PdhExpandCounterPathA(ANSI)的
参见
PdhMakeCounterPath
PdhExpandWildCardPath
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月23日
==英文原文==PdhExpandCounterPath Function
Examines the specified computer (or local computer if none is specified) for counters and instances of counters that match the wildcard strings in the counter path.
Note This function is superseded by the PdhExpandWildCardPath function.
Syntax
C++
PDH_STATUS PdhExpandCounterPath(
__in LPCTSTR szWildCardPath,
__out LPTSTR mszExpandedPathList,
__inout LPDWORD pcchPathListLength
);
Parameters
szWildCardPath [in]
Null-terminated string that contains the counter path to expand. The function searches the computer specified in the path for matches. If the path does not specify a computer, the function searches the local computer. The maximum length of a counter path is PDH_MAX_COUNTER_PATH.
mszExpandedPathList [out]
Caller-allocated buffer that receives the list of expanded counter paths that match the wildcard specification in szWildCardPath. Each counter path in this list is terminated by a null character. The list is terminated with two NULL characters. Set to NULL if pcchPathListLength is zero.
pcchPathListLength [in, out]
Size of the mszExpandedPathList buffer, in TCHARs. If zero on input, the function returns PDH_MORE_DATA and sets this parameter to the required buffer size. If the buffer is larger than the required size, the function sets this parameter to the actual size of the buffer that was used. If the specified size on input is greater than zero but less than the required size, you should not rely on the returned size to reallocate the buffer.
Note You must add one to the required size on Windows XP and Windows 2000.
Return Value
If the function succeeds, it returns ERROR_SUCCESS.
If the function fails, the return value is a system error code or a PDH error code .
Return codeDescription
PDH_MORE_DATAThe mszExpandedPathList buffer is too small to contain the list of paths. This return value is expected if pcchPathListLength is zero on input. If the specified size on input is greater than zero but less than the required size, you should not rely on the returned size to reallocate the buffer.
PDH_INVALID_ARGUMENTA parameter is not valid. For example, on some releases you could receive this error if the specified size on input is greater than zero but less than the required size.
PDH_MEMORY_ALLOCATION_FAILUREUnable to allocate memory to support this function.

Remarks
You should call this function twice, the first time to get the required buffer size (set mszExpandedPathList to NULL and pcchPathListLength to 0), and the second time to get the data.
The general counter path format is as follows:
\\\\computer\\object(parent/instance#index)\\counter
The parent, instance, index, and counter components of the counter path may contain either a valid name or a wildcard character. The computer, parent, instance, and index components are not necessary for all counters.
The counter paths that you must use is determined by the counter itself. For example, the LogicalDisk object has an instance index, so you must provide the #index, or a wildcard. Therefore, you could use the following format:
\\LogicalDisk(*/*#*)\\*
In comparison, the Process object does not require an instance index. Therefore, you could use the following format:
\\Process(*)\\ID Process
The following is a list of the possible formats:
\\\\computer\\object(parent/instance#index)\\counter
\\\\computer\\object(parent/instance)\\counter
\\\\computer\\object(instance#index)\\counter
\\\\computer\\object(instance)\\counter
\\\\computer\\object\\counter
\\object(parent/instance#index)\\counter
\\object(parent/instance)\\counter
\\object(instance#index)\\counter
\\object(instance)\\counter
\\object\\counter
If a wildcard character is specified in the parent name, all instances of the specified object that match the specified instance and counter fields will be returned.
If a wildcard character is specified in the instance name, all instances of the specified object and parent object will be returned if all instance names corresponding to the specified index match the wildcard character.
If a wildcard character is specified in the counter name, all counters of the specified object are returned.
Partial counter path string matches (for example, "pro*") are not supported.
Examples
The following example demonstrates how to this function.
#define UNICODE
#include
#include
#include
#include
#include
#pragma comment(lib, "pdh.lib")
CONST PWSTR WILDCARD_PATH = L"\\\\Processor(*)\\\\*";
void wmain(void)
{
PDH_STATUS Status;
PWSTR EndOfPaths;
PWSTR Paths = NULL;
DWORD BufferSize = 0;
Status = PdhExpandCounterPath(WILDCARD_PATH, Paths, &BufferSize);
while (Status == PDH_MORE_DATA)
{
Paths = (PWSTR)malloc(BufferSize * sizeof(WCHAR));
Status = PdhExpandCounterPath(WILDCARD_PATH, Paths, &BufferSize);
}
if (Status != ERROR_SUCCESS)
{
wprintf(L"\\nPdhExpandCounterPath failed with status 0x%x", Status);
goto Cleanup;
}
if (Paths == NULL)
{
wprintf(L"\\nThe counter path %s cannot be expanded.", WILDCARD_PATH);
goto Cleanup;
}
EndOfPaths = Paths + BufferSize;
// On Vista and later operating systems, the buffer is terminated with two
// null-terminator characters; however, on earlier systems, the buffer is
// not terminated with two null-terminator characters. This covers both cases.
for (PWSTR p = Paths; ((p != EndOfPaths) && (*p != L'\\0')); p += wcslen(p) + 1)
{
wprintf(L"\\n%s", p);
}
Cleanup:
if (Paths)
{
free(Paths);
}
}
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderPdh.h
LibraryPdh.lib
DLLPdh.dll
Unicode and ANSI namesPdhExpandCounterPathW (Unicode) and PdhExpandCounterPathA (ANSI)
See Also
PdhMakeCounterPath
PdhExpandWildCardPath
Send comments about this topic to Microsoft
Build date: 7/23/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa372605(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:25:58