文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>C++ 写Windows日志文件

C++ 写Windows日志文件

时间:2010-10-20  来源:zhouli

代码 #include "windows.h"
#define SVC_ERROR    ((DWORD)0xC0020001L)

void WriteReportEvent(LPTSTR szName,LPTSTR szFunction) 

    HANDLE hEventSource;
    LPCTSTR lpszStrings[2];
    unsigned int len = sizeof(szFunction);
    char *Buffer = new char[len];
    
    hEventSource = RegisterEventSource(NULL, szName);
    
    if( NULL != hEventSource )
    {
        //StringCchPrintf(Buffer, 80, TEXT("%s failed with %d"), szFunction, GetLastError());
        strcpy(Buffer,szFunction);
        lpszStrings[0] = szName;
        lpszStrings[1] = Buffer;
        //详细请参考MSDN
        ReportEvent(hEventSource,        // event log handle
            EVENTLOG_ERROR_TYPE, // event type
            0,                   // event category
            SVC_ERROR,           // event identifier
            NULL,                // no security identifier
            2,                   // size of lpszStrings array
            0,                   // no binary data
            lpszStrings,         // array of strings
            NULL);               // no binary data    
        DeregisterEventSource(hEventSource);
    }
}

 

 

相关阅读 更多 +
排行榜 更多 +
雷电觉醒安卓版

雷电觉醒安卓版

飞行射击 下载
3D幻影飞车最新版

3D幻影飞车最新版

飞行射击 下载
星河一号战队

星河一号战队

飞行射击 下载