Event tracing for windows example, windows 7 home

Source: Internet
Author: User
Code // EventLogging. cpp: Defines the entry point for the console application.
//

# Include "stdafx. h"

# Include <windows. h>
# Include <evntprov. h> // ETW Publishing header
# Include <winevt. h> // EventLog Header.

# Include "Manifest \ manifest. h"

Int _ tmain (int argc, _ TCHAR * argv [])
{
// First step-register the event
REGHANDLE hPub = NULL;
ULONG res = EventRegister (& DOTNETPERFORMANCE_TECHNICALWRITING_PUBLISHER, NULL, NULL, & hPub );
If (ERROR_SUCCESS! = Res ){
_ Tprintf (_ T ("cocould not register event \ n "));
}
Else {
_ Tprintf (_ T ("Event registered successfully \ n "));
}

EVENT_DATA_DESCRIPTOR opEventDesc;
PWSTR pwsOp = L "My Operational Event ";
EventDataDescCreate (& opEventDesc, pwsOp, (ULONG) wcslen (pwsOp) + 1) * sizeof (WCHAR ));

Res = EventWrite (hPub, & DNP_OP_EVENT, 1, & opEventDesc );
If (ERROR_SUCCESS! = Res ){
_ Tprintf (_ T ("cocould not raise operational event Error = % I \ n"), res );
}
Else {
_ Tprintf (_ T ("Operational event successfully raised \ n "));
}

EVENT_DATA_DESCRIPTOR debugEventDesc;
PWSTR pwsDebug = L "My Debug Event ";
EventDataDescCreate (& debugEventDesc, pwsDebug, (ULONG) wcslen (pwsDebug) + 1) * sizeof (WCHAR ));

Res = EventWrite (hPub, & DNP_DEBUG_EVENT, 1, & debugEventDesc );
If (ERROR_SUCCESS! = Res ){
_ Tprintf (_ T ("cocould not raise debug event. Error = % I \ n"), res );
}
Else {
_ Tprintf (_ T ("Debug event successfully raised \ n "));
}

EventUnregister (hPub );

Return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.