C语言编写简单病毒检测程序
来源:网络收集 点击: 时间:2024-02-24首先打开VC++6.0

选择文件,新建

选择C++ source file 新建一个空白文档

先声明头文件
#includestdio.h
#includectype.h
#includedos.h
#includedir.h
#includestat.h
#includeio.h
#includestring.h

主函数
int main()
{
struct ffblk ffblock;
struct date today;
struct time now;
FILE *fp;
register long int dfv;
char pat;
int virus=0,vsize=0;
clrscr();
printf(*********************************\n);
printf(| This is a virus test function |\n);
printf(*********************************\n\n);
printf(Testing virus.................\n\n);
/*取得当前工作路径*/
getcwd(pat,128);
/*切换目录*/
chdir(pat);
/*找到文件COMMAND.COM*/
dfv=findfirst(\\*.*,ffblock,23);
while(!dfv)
{
if(!strcmp(ffblock.ff_name,COMMAND.COM));
vsize=ffblock.ff_fsize/100;
dfv=findnext(ffblock);
}
if(vsize!=0vsize!=478vsize!=232vsize!=253vsize!=2237159vsize!=252)
{
vsize=0;
printf(This is virus in your computer\n);
virus=1;
}
if((fp=fopen(record.txt,w))==NULL)
{
printf(Cant open the file record.txt\n);
exit(0);
}
/*取得日期时间*/
getdate(today);
gettime(now);
/*记录病毒信息到文件 record.txt*/
if(virus==1)
fprintf(fp,%d-%d-%d-%d:%0d,today.da_year,today.da_mon,today.da_day,now.ti_hour,now.ti_min);
else
printf(Dont find virus in your computer\n);
fclose(fp);
getch();
return 0;
}

版权声明:
1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。
2、本站仅提供信息发布平台,不承担相关法律责任。
3、若侵犯您的版权或隐私,请联系本站管理员删除。
4、文章链接:http://www.1haoku.cn/art_142433.html