[Part 3] Logging with C/C++ applications

Check out the codes in GitHub.

If you remember in part 2, we compiled our manifest file with

mc -um <manifest_file>.man

and we got a header file as one of the outputs. We just have to include that header file to our sources and we are good to go.

#include ...
#include "<manifest_file>.h"

int main(...)
{
    EventRegister<provider_name_in_manifest>();
    ...
    CreateFile(...);
    // Example of using the LastError event in our manifest file
    EventWriteLastError(L"THIS_EXE", __FILE__, __FUNC__, L"CreateFile", GetLastError());
    ...
    EventUnregister<provider_name_in_manifest>();
}

Notes

Check out part 4.

---
If you have any questions or feedback, please reach out @flowerinthenyt.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.