//Defination static bool WriteEventLog(LPCTSTR szEventMsg,WORD wEventType = NULL,LPCTSTR szSourceName = ""); bool CPrjReadWriteEventViewerDlg::WriteEventLog(LPCTSTR szEventMsg, WORD wEventType, LPCTSTR szSourceName) { HANDLE hEventLog; bool bSuccesful; bool bReturn = true; //------------------------------------------------------------------------- if("" == szSourceName) { szSourceName = AfxGetApp()->m_pszExeName; } hEventLog = RegisterEventSource(NULL,szSourceName); if(NULL == hEventLog) { AfxMessageBox("RegisterEventSource Failed"); return false; } bSuccesful = ReportEvent(hEventLog, wEventType, NULL, NULL, NULL, 1, 0, &szEventMsg, NULL); if(false == bSuccesful) { AfxMessageBox("ReportEvent Failed"); bReturn = false; } DeregisterEventSource(hEventLog); return bReturn; } //Invoke Method void CPrjReadWriteEventViewerDlg::OnLButtonDblClk(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default WriteEventLog("sdfsdfdsfdsfeeedcd"); WriteEventLog("sdfsdfdsfdsfeeedcd",NULL,"eeeeeeeeee"); WriteEventLog("sdfsdfdsfdsfeeedcd",EVENTLOG_SUCCESS,"seeee"); WriteEventLog("sdfsdfdsfdsfeeedcd",EVENTLOG_AUDIT_FAILURE,"seeee"); WriteEventLog("sdfsdfdsfdsfeeedcd",EVENTLOG_AUDIT_SUCCESS,"seeee"); WriteEventLog("sdfsdfdsfdsfeeedcd",EVENTLOG_ERROR_TYPE,"seeee"); WriteEventLog("sdfsdfdsfdsfeeedcd",EVENTLOG_INFORMATION_TYPE,"seeee"); WriteEventLog("sdfsdfdsfdsfeeedcd",EVENTLOG_WARNING_TYPE,"seeee"); CDialog::OnLButtonDblClk(nFlags, point); }