• 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);
        }
    }
  • 相关阅读:
    ArrayList集合 、特殊集合
    二维数组 、多维数组
    一维数组
    类:String,Math,DateTime,Random
    while做法1.兔子生兔子 2.求100以内质数的和3.洗发水15元 牙膏5元 香皂2元 150元的算法
    博客迁移
    [WC2008]游览计划 「斯坦那树模板」
    [SDOI2009]HH去散步 「矩阵乘法计数」
    [HNOI2007]梦幻岛宝珠 「套路:分层 $DP$」
    多项式求逆
  • 原文地址:https://www.cnblogs.com/pbreak/p/1856341.html
Copyright © 2020-2023  润新知