Property Value

The InstanceId property uniquely identifies an event entry for a configured event source. The InstanceId for an event log entry represents the full 32-bit resource identifier for the event in the message resource file for the event source. The EventID property equals the InstanceId with the top two bits masked off. Two event log entries from the same source can have matching EventID values, but have different InstanceId values due to differences in the top two bits of the resource identifier.

If the application wrote the event entry using one of the WriteEntry methods, the InstanceId property matches the optional eventId parameter. If the application wrote the event using WriteEvent, the InstanceId property matches the resource identifier specified in the InstanceId of the instance parameter. If the application wrote the event using the Win32 API ReportEvent, the InstanceId property matches the resource identifier specified in the dwEventID parameter.

For details about defining event messages and building event log resource files, see the "Message Compiler" topic in the Platform SDK documentation at http://msdn.microsoft.com. For details about event log identifiers, see the "Event Identifiers" topic in the Platform SDK.

The following code example searches an event log for entries with a particular resource identifier. The code example displays the event message for each matching entry, and counts the total number of matching entries in the log. The message text for each entry may or may not be the same; each event message depends on the event source message file, insertion strings, and parameters used when it was written.