Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows ReportEvent返回错误';无效参数';_Windows_Winapi - Fatal编程技术网

Windows ReportEvent返回错误';无效参数';

Windows ReportEvent返回错误';无效参数';,windows,winapi,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() &

我想知道如何将事件设置到已有的事件日志中。以下是代码:

_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;
}
\u ev\u hndl=RegisterEventSource(NULL,L“应用程序”);
WCHAR msg_[]=L“你好”;
if(!ReportEvent(_ev_hndl,ev_type,1,0,NULL,1,0,(LPCWSTR*)&消息,NULL)){

std::cout问题与msg参数有关。正确代码:

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

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

您调用
GetLastError
太晚了。请在Windows API调用失败后立即调用它(如果文档中有说明).I在调用
ReportEvent
后失败,
RegisterEventSource
返回有效的handleYes。您调用
GetLastError
太晚了。您看不到在
ReportEvent
返回和调用
GetLastError
之间调用了其他函数吗。