#include <stdafx.h>
#include <windows.h>
#include "sample.h"
void __cdecl wmain(int argc, LPWSTR *argv)
{
wchar_t *sourceName = L"SampleEventSourceName"; // The event source name.
DWORD dwEventID = MSG_BAD_COMMAND; // The event identifier.
WORD cInserts = 1; // The count of insert strings.
LPCWSTR szMsg = L"insertString"; // The insert strings.
HANDLE h;
// Get a handle to the event log.
h = RegisterEventSource(NULL, // Use local computer.
sourceName); // Event source name.
if (h == NULL)
{
printf("Cannot register the event source.");
return;
}
// Report the event.
if (!ReportEvent(h, // Event log handle.
EVENTLOG_ERROR_TYPE, // Event type.
NULL, // Event category.
dwEventID, // Event identifier.
NULL, // No user security identifier.
cInserts, // Number of substitution strings.
0, // No data.
&szMsg, // Pointer to strings.
NULL)) // No data.
{
printf("Cannot report the event.");
}
DeregisterEventSource(h);
return;
}