网站首页  词典首页

请输入您要查询的函数:

 

术语 queryalltraces
释义 QueryAllTraces
语法:
C++
ULONG QueryAllTraces(
__out PEVENT_TRACE_PROPERTIES *PropertyArray,
__in ULONG PropertyArrayCount,
__out PULONG SessionCount
);
QueryAllTraces功能
该QueryAllTraces函数检索的所有跟踪计算机上启动会议的事件属性和统计。
参数
PropertyArray [out]
一个指针数组EVENT_TRACE_PROPERTIES结构得到了会议的事件追查会话属性和统计。
您只需要设置EVENT_TRACE_PROPERTIES结构Wnode.BufferSize成员。既然您可能不知道在会议名称的实际长度和日志文件每次会议的名称,可以使用的最大会话名称(1,024字)和最大日志文件的名称(1,024字)的长度来计算的缓冲区大小和偏移量,如果不众所周知的。
PropertyArrayCount [in]
一些机构在PropertyArray数组。此值必须小于或等于64,事件的最大数量跟踪会话ETW支持。
Windows 2000中:此值必须小于或等于32。
SessionCount [out]
实际数字事件跟踪计算机上启动会议。
返回值
如果函数成功,返回值是ERROR_SUCCESS。
如果函数失败,返回值是系统错误代码之一。下表列出了一些常见的错误及其原因。
返回codeDescription
以下ERROR_INVALID_PARAMETEROne是正确的:
PropertyArrayCount是零或大于所支持的会话的最大数目更大
PropertyArray为NULL
ERROR_MORE_DATAThe属性数组太小,无法接收所有会话信息(SessionCount比PropertyArrayCount更大)。填充函数与在PropertyArrayCount一些特定财产结构的属性数组。
ERROR_ACCESS_DENIEDOnly具有管理权限的用户,在性能日志用户组的用户,服务本地系统,本地服务运行,是NetworkService可以查询事件跟踪会话。要授予受限用户能够查询跟踪会话,将它们添加到性能日志用户组或见EventAccessControl。
Windows XP和Windows 2000:任何人都可以控制跟踪会话。
备注
事件跟踪控制器调用这个函数。
此函数不返回私人日志会话。
要检索一个会话信息,使用ControlTrace功能,并设置ControlCode参数EVENT_TRACE_CONTROL_QUERY。
实例
下面的示例显示了如何调用此函数。
#include
#include
#include // Required
#include
#define MAX_SESSIONS 64
#define MAX_SESSION_NAME_LEN 1024
#define MAX_LOGFILE_PATH_LEN 1024
void wmain(void)
{
PEVENT_TRACE_PROPERTIES pSessions[MAX_SESSIONS]; //Array of pointers to property structures
PEVENT_TRACE_PROPERTIES pBuffer = NULL; //Buffer that contains all the property structures
ULONG SessionCount = 0; //Actual number of sessions started on the computer
ULONG rc = ERROR_SUCCESS;
ULONG BufferSize = 0;
ULONG PropertiesSize = 0;

//The size of the session name and log file name used by the
//controllers are not known, therefore create a properties structure that allows
//for the maximum size of both.
PropertiesSize = sizeof(EVENT_TRACE_PROPERTIES) +
(MAX_SESSION_NAME_LEN*sizeof(WCHAR)) +
(MAX_LOGFILE_PATH_LEN*sizeof(WCHAR));
BufferSize = PropertiesSize * MAX_SESSIONS;
pBuffer = (PEVENT_TRACE_PROPERTIES) malloc(BufferSize);
if (pBuffer)
{
ZeroMemory(pBuffer, BufferSize);
for (USHORT i=0; i < MAX_SESSIONS; i++)
{
pSessions[i] = (EVENT_TRACE_PROPERTIES*)((BYTE*)pBuffer + (i*PropertiesSize));
pSessions[i]->Wnode.BufferSize = PropertiesSize;
pSessions[i]->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
pSessions[i]->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES) + (MAX_SESSION_NAME_LEN*sizeof(WCHAR));
}
}
else
{
wprintf(L"Error allocating memory for properties.\\n");
goto cleanup;
}
rc = QueryAllTraces(pSessions, (ULONG)MAX_SESSIONS, &SessionCount);
if (ERROR_SUCCESS == rc || ERROR_MORE_DATA == rc)
{
wprintf(L"Requested session count, %d. Actual session count, %d.\\n\\n", MAX_SESSIONS, SessionCount);
for (USHORT i=0; i < SessionCount; i++)
{
wprintf(L"Session #%d\\nSession name: %s\\nLog file: %s\\nmin buffers: %d\\n"
L"max buffers: %d\\nbuffers: %d\\nbuffers written: %d\\nbuffers lost: %d\\n"
L"events lost: %d\\n\\n",
i,
(LPWSTR)((char*)pSessions[i] + pSessions[i]->LoggerNameOffset),
(LPWSTR)((char*)pSessions[i] + pSessions[i]->LogFileNameOffset),
pSessions[i]->MinimumBuffers,
pSessions[i]->MaximumBuffers,
pSessions[i]->NumberOfBuffers,
pSessions[i]->BuffersWritten,
pSessions[i]->LogBuffersLost,
pSessions[i]->EventsLost);
}
}
else
{
wprintf(L"Error calling QueryAllTraces, %d.\\n", rc);
goto cleanup;
}
cleanup:
if (pBuffer)
free(pBuffer);
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderEvntrace.h
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode和ANSI namesQueryAllTracesW(Unicode)和QueryAllTracesA(ANSI)的
参见
ControlTrace
EnumerateTraceGuids
EVENT_TRACE_PROPERTIES
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月30日
==英文原文==QueryAllTraces Function
The QueryAllTraces function retrieves the properties and statistics for all event tracing sessions started on the computer.
Syntax
C++
ULONG QueryAllTraces(
__out PEVENT_TRACE_PROPERTIES *PropertyArray,
__in ULONG PropertyArrayCount,
__out PULONG SessionCount
);
Parameters
PropertyArray [out]
An array of pointers to EVENT_TRACE_PROPERTIES structures that receive session properties and statistics for the event tracing sessions.
You only need to set the Wnode.BufferSize member of the EVENT_TRACE_PROPERTIES structure. Since you may not know the actual length of the session name and log file name for each session, you can use the maximum session name (1,024 characters) and maximum log file name (1,024 characters) lengths to calculate the buffer size and offsets if not known.
PropertyArrayCount [in]
Number of structures in the PropertyArray array. This value must be less than or equal to 64, the maximum number of event tracing sessions that ETW supports.
Windows 2000: The value must be less than or equal to 32.
SessionCount [out]
Actual number of event tracing sessions started on the computer.
Return Value
If the function succeeds, the return value is ERROR_SUCCESS.
If the function fails, the return value is one of the system error codes . The following table includes some common errors and their causes.
Return codeDescription
ERROR_INVALID_PARAMETEROne of the following is true:
PropertyArrayCount is zero or greater than the maximum number of supported sessions
PropertyArray is NULL
ERROR_MORE_DATAThe property array is too small to receive information for all sessions (SessionCount is greater than PropertyArrayCount). The function fills the property array with the number of property structures specified in PropertyArrayCount.
ERROR_ACCESS_DENIEDOnly users with administrative privileges, users in the Performance Log Users group, and services running as LocalSystem, LocalService, NetworkService can query event tracing sessions. To grant a restricted user the ability to query trace sessions, add them to the Performance Log Users group or see EventAccessControl .
Windows XP and Windows 2000: Anyone can control a trace session.

Remarks
Event trace controllers call this function.
This function does not return private logging sessions.
To retrieve information for a single session, use the ControlTrace function and set the ControlCode parameter to EVENT_TRACE_CONTROL_QUERY.
Examples
The following example shows how to call this function.
#include
#include
#include // Required
#include
#define MAX_SESSIONS 64
#define MAX_SESSION_NAME_LEN 1024
#define MAX_LOGFILE_PATH_LEN 1024
void wmain(void)
{
PEVENT_TRACE_PROPERTIES pSessions[MAX_SESSIONS]; //Array of pointers to property structures
PEVENT_TRACE_PROPERTIES pBuffer = NULL; //Buffer that contains all the property structures
ULONG SessionCount = 0; //Actual number of sessions started on the computer
ULONG rc = ERROR_SUCCESS;
ULONG BufferSize = 0;
ULONG PropertiesSize = 0;

//The size of the session name and log file name used by the
//controllers are not known, therefore create a properties structure that allows
//for the maximum size of both.
PropertiesSize = sizeof(EVENT_TRACE_PROPERTIES) +
(MAX_SESSION_NAME_LEN*sizeof(WCHAR)) +
(MAX_LOGFILE_PATH_LEN*sizeof(WCHAR));
BufferSize = PropertiesSize * MAX_SESSIONS;
pBuffer = (PEVENT_TRACE_PROPERTIES) malloc(BufferSize);
if (pBuffer)
{
ZeroMemory(pBuffer, BufferSize);
for (USHORT i=0; i < MAX_SESSIONS; i++)
{
pSessions[i] = (EVENT_TRACE_PROPERTIES*)((BYTE*)pBuffer + (i*PropertiesSize));
pSessions[i]->Wnode.BufferSize = PropertiesSize;
pSessions[i]->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
pSessions[i]->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES) + (MAX_SESSION_NAME_LEN*sizeof(WCHAR));
}
}
else
{
wprintf(L"Error allocating memory for properties.\\n");
goto cleanup;
}
rc = QueryAllTraces(pSessions, (ULONG)MAX_SESSIONS, &SessionCount);
if (ERROR_SUCCESS == rc || ERROR_MORE_DATA == rc)
{
wprintf(L"Requested session count, %d. Actual session count, %d.\\n\\n", MAX_SESSIONS, SessionCount);
for (USHORT i=0; i < SessionCount; i++)
{
wprintf(L"Session #%d\\nSession name: %s\\nLog file: %s\\nmin buffers: %d\\n"
L"max buffers: %d\\nbuffers: %d\\nbuffers written: %d\\nbuffers lost: %d\\n"
L"events lost: %d\\n\\n",
i,
(LPWSTR)((char*)pSessions[i] + pSessions[i]->LoggerNameOffset),
(LPWSTR)((char*)pSessions[i] + pSessions[i]->LogFileNameOffset),
pSessions[i]->MinimumBuffers,
pSessions[i]->MaximumBuffers,
pSessions[i]->NumberOfBuffers,
pSessions[i]->BuffersWritten,
pSessions[i]->LogBuffersLost,
pSessions[i]->EventsLost);
}
}
else
{
wprintf(L"Error calling QueryAllTraces, %d.\\n", rc);
goto cleanup;
}
cleanup:
if (pBuffer)
free(pBuffer);
}
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderEvntrace.h
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode and ANSI namesQueryAllTracesW (Unicode) and QueryAllTracesA (ANSI)
See Also
ControlTrace
EnumerateTraceGuids
EVENT_TRACE_PROPERTIES
Send comments about this topic to Microsoft
Build date: 7/30/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa364102(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 13:20:32