Función EnumerateTraceGuids (evntrace.h)

La función EnumerateTraceGuids recupera información sobre los proveedores de seguimiento de eventos que se ejecutan actualmente en el equipo.

Importante

Esta función se ha reemplazado por EnumerateTraceGuidsEx.

Sintaxis

ULONG WMIAPI EnumerateTraceGuids(
  [in, out] PTRACE_GUID_PROPERTIES *GuidPropertiesArray,
  [in]      ULONG                  PropertyArrayCount,
  [out]     PULONG                 GuidCount
);

Parámetros

[in, out] GuidPropertiesArray

Matriz de punteros a TRACE_GUID_PROPERTIES estructuras. Cada puntero de la matriz debe apuntar en un búfer con sala para almacenar una estructura de TRACE_GUID_PROPERTIES .

[in] PropertyArrayCount

Número de punteros de la matriz GuidPropertiesArray .

[out] GuidCount

Recibe el número real de proveedores de seguimiento de eventos registrados en el equipo.

Valor devuelto

Si la función se ejecuta correctamente, el valor devuelto es ERROR_SUCCESS.

Si se produce un error en la función, el valor devuelto es uno de los códigos de error del sistema. A continuación se muestran algunos errores comunes y sus causas.

  • ERROR_INVALID_PARAMETER

    Una de las siguientes condiciones se cumple:

    • PropertyArrayCount es cero
    • GuidPropertiesArray es NULL
  • ERROR_MORE_DATA

    La matriz de propiedades es demasiado pequeña para recibir información para todos los proveedores registrados (GuidCount es mayor que PropertyArrayCount). La función rellena GuidPropertiesArray con el número de estructuras especificadas en PropertyArrayCount.

Comentarios

Esta función devuelve información sobre los proveedores de seguimiento de eventos que se han iniciado (a través de RegisterTraceGuids, EventRegister) y que aún no se han detenido.

Nota

Para obtener información sobre los manifiestos de proveedor registrados en el sistema (es decir, manifiestos registrados a través wevtutilde ), use TdhEnumerateProviders.

Puede usar el TRACE_GUID_PROPERTIES. Miembro LoggerId para determinar qué sesión habilitó más recientemente el proveedor si TRACE_GUID_PROPERTIES. IsEnable es TRUE.

La lista no incluirá los proveedores de SystemTraceProvider.

Ejemplos

En el ejemplo siguiente se muestra cómo llamar a esta función.

#include <windows.h>
#include <evntrace.h>
#include <vector>
#include <stdio.h>

int
wmain()
{
    ULONG status = 0;

    try
    {
        ULONG guidCount;
        std::vector<TRACE_GUID_PROPERTIES> guidPropValues;
        std::vector<TRACE_GUID_PROPERTIES*> guidPropPointers;

        // First call is just to get the actual count, so allocate a small buffer.
        guidCount = 1;

        // May need to retry multiple times since new providers could be added
        // between calls.
        for (;;)
        {
            ULONG const allocated = guidCount;
            guidPropValues.resize(allocated);
            guidPropPointers.resize(allocated);

            // Initialize the pointers to point at the values.
            for (ULONG i = 0; i != allocated; i += 1)
            {
                guidPropPointers[i] = &guidPropValues[i];
            }

            guidCount = 0;
            status = EnumerateTraceGuids(guidPropPointers.data(), allocated, &guidCount);
            if (status != ERROR_MORE_DATA)
            {
                guidPropValues.resize(guidCount);
                break;
            }

        }

        if (status != ERROR_SUCCESS)
        {
            printf("EnumerateTraceGuids error: %u\n", status);
        }
        else
        {
            printf("GuidCount = %lu\n", guidCount);
            for (auto const& v : guidPropValues)
            {
                printf("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x - %hs\n",
                    v.Guid.Data1, v.Guid.Data2, v.Guid.Data3,
                    v.Guid.Data4[0], v.Guid.Data4[1],
                    v.Guid.Data4[2], v.Guid.Data4[3], v.Guid.Data4[4],
                    v.Guid.Data4[5], v.Guid.Data4[6], v.Guid.Data4[7],
                    v.IsEnable ? "Enabled" : "Disabled");
            }
        }
    }
    catch (std::bad_alloc const&)
    {
        printf("Out of memory!\n");
        status = ERROR_OUTOFMEMORY;
    }

    return status;
}

Requisitos

   
Cliente mínimo compatible Windows XP [solo aplicaciones de escritorio]
Servidor mínimo compatible Windows Server 2003 [solo aplicaciones de escritorio]
Plataforma de destino Windows
Encabezado evntrace.h
Library Advapi32.lib
Archivo DLL Advapi32.dll

Consulte también

EnumerateTraceGuidsEx

QueryAllTraces

TRACE_GUID_PROPERTIES