ReportEvent返回错误'invalid parameter'

时间:2015-12-07 08:25:14

标签: windows winapi

我想知道将事件设置为现有的事件日志。这些是代码:

_ev_hndl = RegisterEventSource(NULL, L"Application");

WCHAR msg_[] = L"Hello";
if (!ReportEvent(_ev_hndl, ev_type, 1, 0, NULL, 1, 0, (LPCWSTR*)&msg_, NULL)) {
    std::cout << "error: " << GetLastError() << std::endl;
}

但我收到错误:87(参数无效)

1 个答案:

答案 0 :(得分:0)

问题接近于msg参数。正确的代码:

LPCTSTR strings[] = { TEXT("abcdefg") };

if (!ReportEvent(_ev_hndl, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, strings, NULL)) {...