Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Event enumeration:compiles,links no output

Event enumeration:compiles,links no output

Scheduled Pinned Locked Moved C / C++ / MFC
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brilliant101
    wrote on last edited by
    #1

    It complies and links but shows no output.It is suppose to enlist the application log files. #include #include void DisplayEntries( ) { const int BUFFER_SIZE=1000; HANDLE h; EVENTLOGRECORD *pevlr; BYTE bBuffer[BUFFER_SIZE]; DWORD dwRead, dwNeeded, cRecords, dwThisRecord = 0; // Open the Application event log. h = OpenEventLog( NULL, // use local computer "Application"); // source name if (h == NULL) { printf("yahooo1");} // ErrorExit("Could not open the Application event log."); pevlr = (EVENTLOGRECORD *) &bBuffer; // Opening the event log positions the file pointer for this // handle at the beginning of the log. Read the records // sequentially until there are no more. while (ReadEventLog(h, // event log handle EVENTLOG_FORWARDS_READ | // reads forward EVENTLOG_SEQUENTIAL_READ, // sequential read 0, // ignored for sequential reads pevlr, // pointer to buffer BUFFER_SIZE, // size of buffer &dwRead, // number of bytes read &dwNeeded)) // bytes in next record { while (dwRead > 0) { // Print the event identifier, type, and source name. // The source name is just past the end of the // formal structure. printf("%02d Event ID: 0x%08X ", dwThisRecord++, pevlr->EventID); printf("EventType: %d Source: %s\n", pevlr->EventType, (LPSTR) ((LPBYTE) pevlr + sizeof(EVENTLOGRECORD))); dwRead -= pevlr->Length; pevlr = (EVENTLOGRECORD *) ((LPBYTE) pevlr + pevlr->Length); } pevlr = (EVENTLOGRECORD *) &bBuffer; } CloseEventLog(h); } int WINAPI WinMain(HINSTANCE h,HINSTANCE p,LPSTR l,int n) { DisplayEntries(); return 0; }

    B D 2 Replies Last reply
    0
    • B brilliant101

      It complies and links but shows no output.It is suppose to enlist the application log files. #include #include void DisplayEntries( ) { const int BUFFER_SIZE=1000; HANDLE h; EVENTLOGRECORD *pevlr; BYTE bBuffer[BUFFER_SIZE]; DWORD dwRead, dwNeeded, cRecords, dwThisRecord = 0; // Open the Application event log. h = OpenEventLog( NULL, // use local computer "Application"); // source name if (h == NULL) { printf("yahooo1");} // ErrorExit("Could not open the Application event log."); pevlr = (EVENTLOGRECORD *) &bBuffer; // Opening the event log positions the file pointer for this // handle at the beginning of the log. Read the records // sequentially until there are no more. while (ReadEventLog(h, // event log handle EVENTLOG_FORWARDS_READ | // reads forward EVENTLOG_SEQUENTIAL_READ, // sequential read 0, // ignored for sequential reads pevlr, // pointer to buffer BUFFER_SIZE, // size of buffer &dwRead, // number of bytes read &dwNeeded)) // bytes in next record { while (dwRead > 0) { // Print the event identifier, type, and source name. // The source name is just past the end of the // formal structure. printf("%02d Event ID: 0x%08X ", dwThisRecord++, pevlr->EventID); printf("EventType: %d Source: %s\n", pevlr->EventType, (LPSTR) ((LPBYTE) pevlr + sizeof(EVENTLOGRECORD))); dwRead -= pevlr->Length; pevlr = (EVENTLOGRECORD *) ((LPBYTE) pevlr + pevlr->Length); } pevlr = (EVENTLOGRECORD *) &bBuffer; } CloseEventLog(h); } int WINAPI WinMain(HINSTANCE h,HINSTANCE p,LPSTR l,int n) { DisplayEntries(); return 0; }

      B Offline
      B Offline
      brilliant101
      wrote on last edited by
      #2

      it uses windows.h and stdio.h headers

      1 Reply Last reply
      0
      • B brilliant101

        It complies and links but shows no output.It is suppose to enlist the application log files. #include #include void DisplayEntries( ) { const int BUFFER_SIZE=1000; HANDLE h; EVENTLOGRECORD *pevlr; BYTE bBuffer[BUFFER_SIZE]; DWORD dwRead, dwNeeded, cRecords, dwThisRecord = 0; // Open the Application event log. h = OpenEventLog( NULL, // use local computer "Application"); // source name if (h == NULL) { printf("yahooo1");} // ErrorExit("Could not open the Application event log."); pevlr = (EVENTLOGRECORD *) &bBuffer; // Opening the event log positions the file pointer for this // handle at the beginning of the log. Read the records // sequentially until there are no more. while (ReadEventLog(h, // event log handle EVENTLOG_FORWARDS_READ | // reads forward EVENTLOG_SEQUENTIAL_READ, // sequential read 0, // ignored for sequential reads pevlr, // pointer to buffer BUFFER_SIZE, // size of buffer &dwRead, // number of bytes read &dwNeeded)) // bytes in next record { while (dwRead > 0) { // Print the event identifier, type, and source name. // The source name is just past the end of the // formal structure. printf("%02d Event ID: 0x%08X ", dwThisRecord++, pevlr->EventID); printf("EventType: %d Source: %s\n", pevlr->EventType, (LPSTR) ((LPBYTE) pevlr + sizeof(EVENTLOGRECORD))); dwRead -= pevlr->Length; pevlr = (EVENTLOGRECORD *) ((LPBYTE) pevlr + pevlr->Length); } pevlr = (EVENTLOGRECORD *) &bBuffer; } CloseEventLog(h); } int WINAPI WinMain(HINSTANCE h,HINSTANCE p,LPSTR l,int n) { DisplayEntries(); return 0; }

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        brilliant101 wrote: printf("%02d Event ID: 0x%08X ", ... int WINAPI WinMain(HINSTANCE h,HINSTANCE p,LPSTR l,int n) These are mutually exclusive statements. WinMain() assumes a GUI application whereas printf() assumes a console application. For testing purposes, I would change WinMain() to be main() instead.


        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups