CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Mar 2005
    Posts
    35

    Question Event Enumeration

    It complies and links but shows no output.It is suppose to enlist the application log files.
    Code:
    #include <windows.h>
    #include <stdio.h>
    
    
    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;
    
    }
    Last edited by Andreas Masur; March 21st, 2005 at 12:19 PM. Reason: Added code tags...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured