EvtOpenEventMetadataEnum does not work with MSSQLSERVER

Why this code does not work? I'm running on Win 2008 R2 with MS SQL Server 2008 R2 installed. 0 = 0 accvio statement will not execute becase MSSQLSERVER event provider has no events to enum. When I opened EventViewer I see MSSQLSERVER events displays very well. What Miss me?

Thanks for any help,

SLDR

(Stephen L.) Of Rudder)

============================================Code Below================================

#include
#include
#include
#include
#include

#pragma how (lib, "wevtapi.lib")

int _tmain (int argc, _TCHAR * argv)
{
EVT_HANDLE hMetadata = NULL;
EVT_HANDLE hEvents = NULL;
EVT_HANDLE hEvent = NULL;
DWORD dwLastError = 0;

hMetadata = EvtOpenPublisherMetadata (NULL, "MSSQLSERVER", NULL, 0, 0 L);
If (hMetadata == NULL) {}
printf ("EvtOpenPublisherMetadata failed with %lu!\n", GetLastError() ");
Return 1;
}
hEvents = EvtOpenEventMetadataEnum (hMetadata, 0);
If (hEvents == NULL) {}
printf ("EvtOpenEventMetadataEnum failed with %lu!\n", GetLastError() ");
EvtClose (hMetadata);
return 2;
}
While (true) {}
hEvent = EvtNextEventMetadata (hEvents, 0);
If (hEvent == NULL) {}
dwLastError = GetLastError();
If (dwLastError == ERROR_NO_MORE_ITEMS) {}
break;
}
printf ("EvtNextEventMetadata failed with %lu!\n", dwLastError);
EvtClose (hEvents);
EvtClose (hMetadata);
return 3;
}
* (int *) 0 = 0;
EvtClose (hEvent);
}
EvtClose (hEvents);
EvtClose (hMetadata);
return 0;
}

Hello

 

Thanks for the post.

I suggest you to ask your question on the MSDN Forums.

http://social.msdn.Microsoft.com/forums/en-us/categories

I hope this helps.

Tags: Windows

Similar Questions

Maybe you are looking for