#include <stdio.h>
#include <windows.h>
int DelLog(char *szLogName)
{
int flag = 0;
HANDLE hLog = OpenEventLog(NULL,szLogName);//打开相应事件日志
if(!hLog)
{
return 0;
}
if(ClearEventLog(hLog,NULL))//清除
{
flag = 1;
}
CloseEventLog(hLog);
return flag;
}
{
char strLogName[3][16] = {"Application","Security","System"};//3种日志文件类型
for(int i=0; i<3; i++)
{
if(DelLog(strLogName[i]))//调用清除函数
{
printf("Clear %s Log success\n",strLogName[i]);
}
}
return 0;
}
#include <windows.h>
int DelLog(char *szLogName)
{
int flag = 0;
HANDLE hLog = OpenEventLog(NULL,szLogName);//打开相应事件日志
if(!hLog)
{
return 0;
}
if(ClearEventLog(hLog,NULL))//清除
{
flag = 1;
}
CloseEventLog(hLog);
return flag;
}
{
char strLogName[3][16] = {"Application","Security","System"};//3种日志文件类型
for(int i=0; i<3; i++)
{
if(DelLog(strLogName[i]))//调用清除函数
{
printf("Clear %s Log success\n",strLogName[i]);
}
}
return 0;
}