Click here to Skip to main content
16,014,892 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Get correct Time (Format) Pin
Programm3r11-Sep-07 21:27
Programm3r11-Sep-07 21:27 
AnswerRe: Get correct Time (Format) Pin
Nelek11-Sep-07 22:44
protectorNelek11-Sep-07 22:44 
Questioni have written my own collection class,some errors Pin
bhogavalli suresh11-Sep-07 19:56
bhogavalli suresh11-Sep-07 19:56 
AnswerRe: i have written my own collection class,some errors Pin
Cedric Moonen11-Sep-07 20:16
Cedric Moonen11-Sep-07 20:16 
AnswerRe: i have written my own collection class,some errors Pin
Hamid_RT11-Sep-07 20:47
Hamid_RT11-Sep-07 20:47 
AnswerRe: i have written my own collection class,some errors Pin
Nelek11-Sep-07 22:48
protectorNelek11-Sep-07 22:48 
AnswerRe: i have written my own collection class,some errors Pin
David Crow12-Sep-07 3:37
David Crow12-Sep-07 3:37 
QuestionGetting hold of certain event entries Pin
Programm3r11-Sep-07 19:46
Programm3r11-Sep-07 19:46 
Hi all,

I'm using the following function to read the Source of the System events. I'm trying to check if the source name is equal to "Windows Agent" or if the EventId is equal to 21. Which would indicate that the computer needs a restart. But I don't get any result and there is without a doubt such an entry in the event log.

oid DisplayEntries( )
{
    HANDLE h;
    EVENTLOGRECORD *pevlr; 
    BYTE bBuffer[BUFFER_SIZE]; 
	DWORD dwRead, dwNeeded, cRecords, dwThisRecord;
	int counter=0;
 
    // Open the Application event log. 
 
    h = OpenEventLog( NULL,    // use local computer
             "System");   // source name
	if (h == NULL)
	{
		Form1->msg = Form1->msg.sprintf("Could not open the Application event log.");
		Form1->Memo2->Lines->Add(Form1->msg);
    }
 
    pevlr = (EVENTLOGRECORD *) &bBuffer; 
 
    GetOldestEventLogRecord(h, &dwThisRecord);

    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) 
        { 
			printf("%02d  Event ID: 0x%08X ",
				dwThisRecord++, pevlr->EventID);
			printf("EventType: %d Source: %s\n",
				pevlr->EventType, (LPSTR) ((LPBYTE) pevlr +
				sizeof(EVENTLOGRECORD)));
			if ((LPSTR)((LPBYTE) pevlr + sizeof(EVENTLOGRECORD))=="Windows Agent")
			{
				MessageBox(NULL, "FOUND", "INFO",MB_OK);
			}
 
            dwRead -= pevlr->Length; 
            pevlr = (EVENTLOGRECORD *) 
				((LPBYTE) pevlr + pevlr->Length);
        } 
 
        pevlr = (EVENTLOGRECORD *) &bBuffer; 
    } 
 
    CloseEventLog(h); 
}


Many Thanks in advance
Regards,


The only programmers that are better that C programmers are those who code in 1's and 0's Green Alien | [Alien]

Smile | :) Programm3r

My Blog: ^_^

AnswerRe: Getting hold of certain event entries Pin
carrivick12-Sep-07 8:50
carrivick12-Sep-07 8:50 
QuestionProblems about how to explore a program's action? Pin
kcynic11-Sep-07 19:34
kcynic11-Sep-07 19:34 
AnswerRe: Problems about how to explore a program's action? Pin
Cedric Moonen11-Sep-07 20:31
Cedric Moonen11-Sep-07 20:31 
GeneralRe: Problems about how to explore a program's action? Pin
kcynic11-Sep-07 21:33
kcynic11-Sep-07 21:33 
AnswerRe: Problems about how to explore a program's action? Pin
Hamid_RT11-Sep-07 20:48
Hamid_RT11-Sep-07 20:48 
GeneralRe: Problems about how to explore a program's action? Pin
kcynic11-Sep-07 21:33
kcynic11-Sep-07 21:33 
AnswerRe: Problems about how to explore a program's action? Pin
carrivick12-Sep-07 8:52
carrivick12-Sep-07 8:52 
Questionhow to upload a file on a server at a perticular location? Pin
AnayKulkarni11-Sep-07 19:14
AnayKulkarni11-Sep-07 19:14 
AnswerRe: how to upload a file on a server at a perticular location? Pin
Jason Teagle11-Sep-07 22:16
Jason Teagle11-Sep-07 22:16 
GeneralRe: how to upload a file on a server at a perticular location? Pin
AnayKulkarni12-Sep-07 0:14
AnayKulkarni12-Sep-07 0:14 
QuestionRe: how to upload a file on a server at a perticular location? Pin
David Crow12-Sep-07 3:40
David Crow12-Sep-07 3:40 
QuestionHow to fixed such error?C2220 Pin
kcynic11-Sep-07 17:38
kcynic11-Sep-07 17:38 
AnswerRe: How to fixed such error?C2220 Pin
Stephen Hewitt11-Sep-07 17:46
Stephen Hewitt11-Sep-07 17:46 
AnswerRe: How to fixed such error?C2220 Pin
David Crow12-Sep-07 3:42
David Crow12-Sep-07 3:42 
QuestionGet and Set methods Pin
User 58385211-Sep-07 16:16
User 58385211-Sep-07 16:16 
AnswerRe: Get and Set methods Pin
George L. Jackson11-Sep-07 18:19
George L. Jackson11-Sep-07 18:19 
AnswerRe: Get and Set methods Pin
Nelek11-Sep-07 22:55
protectorNelek11-Sep-07 22:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.