以下代码示例显示当前在应用事件日志和系统事件日志中的事件记录数。
/ *打开系统日志。*/
h = OpenEventLog(NULL, /* uses local computer */
"System"); /* source name */
if (h == NULL)
ErrorExit("could not open System event log");
/ *获取系统事件日志中的记录数。*/
if(!GetNumberOfEventLogRecords(h,& cRecords))
ErrorExit
("could not get number of records");
printf("There are %d records in the System event log.\n", cRecords);
CloseEventLog(h);
/ *打开应用程序日志。*/
h = OpenEventLog(NULL, /* uses local computer */
"Application"); /* source name */
if (h == NULL)
ErrorExit("could not open Application event log");
/ *获取应用程序事件日志中的记录数。*/
if(!GetNumberOfEventLogRecords(h,& cRecords))
ErrorExit("could not get number of records");
printf(“应用程序事件日志中有%d条记录。\\ n”,
cRecords);
CloseEventLog(h);