zoukankan      html  css  js  c++  java
  • C++ 写Windows日志文件

    环境 VC6.0

    代码
    #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);
        }
    }
  • 相关阅读:
    [USACO07DEC]观光奶牛Sightseeing Cows
    洛谷 U3348 A2-回文数
    LOJ #2037. 「SHOI2015」脑洞治疗仪
    1441 士兵的数字游戏
    BZOJ 1108: [POI2007]天然气管道Gaz
    P3047 [USACO12FEB]附近的牛Nearby Cows
    POJ 3061 Subsequence
    Hdu 5776 sum
    1052 最大M子段和
    1288 埃及分数
  • 原文地址:https://www.cnblogs.com/pbreak/p/1856341.html
Copyright © 2011-2022 走看看