一.EvtOpenLog

The EvtOpenLog function opens an exported or live event log and returns a handle that can be used to access the log. The returned handle can be used by subsequent calls to the EvtGetLogInfo function.

示例:

EVT_HANDLE log = NULL;
LPCWSTR logPath = L"SimpleOperationalChannel";log = EvtOpenLog( NULL, logPath, EvtOpenChannelPath);if(log == NULL)
{wprintf(L"Error opening the log: 0x%x \n", GetLastError());return 1;
}

二.EvtClose

The EvtClose function closes an open event object handle that was previously returned from a Windows Event Log function. Any handle that is returned by a Windows Event Log function must be closed using this function call when the user is finished with the handle. The handle that is passed into this function becomes invalid after this function is successfully called.

EVT_HANDLE log = NULL;
LPCWSTR logPath = L"SimpleOperationalChannel";log = EvtOpenLog( NULL, logPath, EvtOpenChannelPath);
...
EvtClose(log);

三.EvtGetLogInfo

The EvtGetEventInfo function allows the caller to determine which clause in an event query or subscription filter selected a given event or to determine the channel or log that the event came from.

可查询的字段

typedef enum _EVT_LOG_PROPERTY_ID
{EvtLogCreationTime = 0,             // EvtVarTypeFileTimeEvtLogLastAccessTime,               // EvtVarTypeFileTimeEvtLogLastWriteTime,                // EvtVarTypeFileTimeEvtLogFileSize,                     // EvtVarTypeUInt64EvtLogAttributes,                   // EvtVarTypeUInt32EvtLogNumberOfLogRecords,           // EvtVarTypeUInt64EvtLogOldestRecordNumber,           // EvtVarTypeUInt64EvtLogFull,                         // EvtVarTypeBoolean} EVT_LOG_PROPERTY_ID;

示例:

EVT_VARIANT* logProperty = (EVT_VARIANT*) malloc (sizeof (EVT_VARIANT));
DWORD bufferSize = sizeof(EVT_VARIANT);if( !EvtGetLogInfo(log, EvtLogNumberOfLogRecords, bufferSize, logProperty, &bufferSize))
{   //...
}if(logProperty->Type == EvtVarTypeNull)
{wprintf(L"The value of the log number of events property is NULL.\n");
}
else
{wprintf(L"The value of the log number of events property is: %I64u \n", logProperty->UInt64Val);
}

四.日志操作维护

1.EvtClearLog

The EvtClearLog function clears all events from an active log and exports the events to a target log file.

示例:

if ( !EvtClearLog(NULL, L"Application",L"c:\\temp\\MyClearedEvents.log", 0 ))return GetLastError();

注意点:目录必须存在

2.EvtExportLog

The EvtExportLog function exports selected events from a channel or from a log file to a target log file based on an event query.

if ( !EvtExportLog(NULL, L"Application",L"*",L"c:\\MyExportedEvents.log", EvtExportLogChannelPath ))return GetLastError();

3.EvtArchiveExportedLog

The EvtArchiveExportedLog function archives localized information associated with the events in specified logs that have been created by either the EvtClearLog function or the EvtExportLog function.

示例:

if ( !EvtArchiveExportedLog(NULL, L"c:\\MyExportedEvents.log", MAKELCID( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT ),0 ))return GetLastError();

存档的日志在此目录下:C:\Windows\System32\winevt\Logs

Windows Event Log相关函数使用(1)相关推荐

  1. windows 系统无法启动windows event log 服务

    windows 系统无法启动windows event log 服务 关键词:无法启动系统事件日志 尝试解决步骤 [1]权限:把如图中logsfile文件等都给local service [2]把C: ...

  2. 无法打开计算机上的event log服务,Win7系统下启用Windows event log服务发生4201错误的正确解决方法...

    Windows event log服务会把程序与系统发送的错误消息记录在日志中,其中还包含了部分有用的诊断信息,近期有Win7用户在启用windows event log服务的时候,发生4201错误提 ...

  3. 无法启动 Windows Event Log vpdn 无法启动 附带无法启动MYSQL服务”1067 进程意外终止”

    无法启动 Windows Event Log 毛病就出在c:\windows\system32\logfiles\wmi\RTbackup这个文件夹上,进到目录中,找到RTbackup这个文件夹, 右 ...

  4. windows event log 错误2 的解决办法(电脑网络连接图标消失的罪魁祸首)

    电脑开机右下角发现网络连接图标消失,电脑无法连接网络,定位问题后发现是前置的windows event log服务未启动导致网络连接无法正常运行 但手动启动windows event log服务时,提 ...

  5. ORA-28056: Writing audit records to Windows Event Log failed解决办法

    一般遇到这个问题,很大可能就是非正常关机,或者非正常停止oracle数据库,解决办法如下: 1.开始-cmd进入dos窗口,然后输入sqlplus/nolog,正常sql*plus的信息: 2.接下来 ...

  6. 无法打开计算机上的event log服务,Windows event log服务意外终止,windows必须立即重新启动???怎么处理?要...

    换个软件补充回答: 今天启动任务管理器时,启动后出现"任务计划程序服务不可用--",后面是什么读取数据失败,重新尝试数据连接等提示. 操作中发现,其实任务管理服务是开启的,也能设置 ...

  7. 无法打开计算机上的event log服务,解决Win7 Windows Event Log服务无法启动问题

    当我们的电脑在使用时,或多或少都会遇到些问题,遇到这些问题我们不要着急,要懂得方法去解决,这里学下:Windows Event Log服务无法启动解决方法? 工具/原料 电脑:台式机.系统:win7旗 ...

  8. 无法打开计算机上的eventlog服务,Win7系统如何启动Windows Event Log服务解决故障问题...

    Win7系统中的Windows Event Log服务,会将程序和系统发送的出错消息记录在日志中,其中还包含部分有用的诊断信息,通常情况下这个服务是被禁用的,但有些时候在网络无法启动的情况下,我们还是 ...

  9. 无法打开计算机上的event log服务,Win7电脑Windows Event Log服务无法启动错误1747的修复教程...

    最近有一些小伙伴使用win7操作系统的时候遇到了一个问题,提示了Windows Event Log服务无法启动成功,错误1747,导致有些Win7电脑无法正常运行,该怎么办呢?这让用户感到很头疼.于是 ...

最新文章

  1. js笔记 - ajax中的get和post说明
  2. 【Python-ML】SKlearn库集成学习器Bagging
  3. javaweb学习总结(四十四)——监听器(Listener)学习
  4. ACM学习历程—HDU 2112 HDU Today(map spfa 优先队列)
  5. 知乎问答 | 如何在同一坐标系下绘制多幅图形
  6. 【九天教您南方cass 9.1】 08 绘制等高线及对其处理
  7. Fireworks 激活序列码--网上找的 不定时无法使用
  8. 【读书笔记】合理的设计
  9. FFmpeg合并ts文件为mp4文件
  10. 如何制作微信答题小程序(微信答题考试小程序开发制作功能介绍)
  11. 计算机三维艺术设计基础,计算机艺术设计基础(修订版)
  12. 带疑问的歌词有哪些_带有(我)字的歌词有哪些
  13. 优酷投屏显示无法找到服务器,优酷投屏突然不能用了(优酷版权限制无法投屏)...
  14. JDK的下载安装(含安装文件)
  15. 【操作系统】Oranges学习笔记(一) 第一章、第二章
  16. 《17天搞定GRE单词》
  17. Tobii眼动仪插件和案例
  18. 爬虫学习笔记:天猫(淘宝)评论数据爬虫
  19. IMvigor210CoreBiologies的安装以及数据获取
  20. h0143. 铺砖问题 (20 分)

热门文章

  1. 《C语言及程序设计》实践参考——间隔选职工
  2. 浅谈linux性能调优之六:IO调度算法的选择
  3. Sendmail服务器的配置
  4. [C++]出错member access into incomplete type
  5. 程序员怎样练出倒三角身材
  6. Q87:间接光照(Indirect Illumination)的高光反射(Glossy Reflcetion)
  7. 水很深的深度学习(四)——卷积神经网络CNN
  8. 深度学习推荐模型-NFM
  9. 数据可视化平台由哪些要素组成
  10. 大数据分析平台的安全如何保障