稳定盈利的期货交易方法-量化趋势交易

alantop -专业量化投资者

爱好:量化投资,逆向工程,渗透
随笔 - 595, 文章 - 0, 评论 - 921, 引用 - 0
数据加载中……

写系统日志中注意的问题

HANDLE m_hEventSource = ::RegisterEventSource(NULL,  // local machine
        ("NT Service Demonstration")); // source name

 

在使用RegisterEventSource这个函数,第二个参数必须是

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application]

中sources中含有的。

 

下图点击放大。

image

 

 

自我感悟,每个消息的是从source中找他的消息ID的。所以应用程序改是没有什么用的。

用自带的.mc经消息编译器编译后,生成的那些都没有用。

.mc文件经过编译生成三个文件 .h, .rc, msg00001.bin文件。

 

void LogEvent(WORD wType, DWORD dwID,
              const char* pszS1 = NULL,
              const char* pszS2 = NULL,
              const char* pszS3 = NULL);

int main( )
{
    LogEvent(EVENTLOG_INFORMATION_TYPE, EVMSG_DEMO1, "WMIAdapter");
    return 0;

}

void LogEvent(WORD wType, DWORD dwID,
                          const char* pszS1,
                          const char* pszS2,
                          const char* pszS3)
{
    const char* ps[3];
    ps[0] = pszS1;
    ps[1] = pszS2;
    ps[2] = pszS3;

    int iStr = 0;
    for (int i = 0; i < 3; i++) {
        if (ps[i] != NULL) iStr++;
    }

    // Check the event source has been registered and if
    // not then register it now

    HANDLE m_hEventSource = ::RegisterEventSource(NULL,  // local machine
            ("WMIAdapter")); // source name

    bool bi;
    if (m_hEventSource) {
         bi = ::ReportEvent(m_hEventSource,
            wType,
            0,
            dwID,
            NULL, // sid
            iStr,
            0,
            ps,
            NULL);
    }
}

posted on 2007-07-12 14:49 AlanTop 阅读(666) 评论(2)  编辑 收藏 引用 所属分类: VC++

评论

# re: 写系统日志中注意的问题  回复  更多评论   

怎么都没附件的形式?
2007-07-13 17:25 | 谢红园

# re: 写系统日志中注意的问题  回复  更多评论   

没有空间,忘见谅。要是要什么详细信息,可以来电子邮件,发给你。
2007-07-14 14:38 | AlanTop

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理