标题:C代码:文件病毒检测
取消只看楼主
终结者C
Rank: 2
等 级:论坛游民
帖 子:34
专家分:23
注 册:2013-3-3
结帖率:100%
 问题点数:0 回复次数:0 
C代码:文件病毒检测
#include<stdio.h>
#include<ctype.h>
#include<dos.h>
#include<dir.h>
#include<stat.h>
#include<io.h>
#include<string.h>

int main()
{
    struct ffblk ffblock;
    struct date today;
    struct time now;
    FILE *fp;
    register long int dfv;
    char pat[128];
    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);
    /*找到文件*/
    dfv=findfirst("\\*.*",&ffblock,23);
    while(!dfv)
    {
        if(!strcmp(ffblock.ff_name,"));
        vsize=ffblock.ff_fsize/100;
        dfv=findnext(&ffblock);
    }
    if(vsize!=0&&vsize!=478&&vsize!=232&&vsize!=253&&vsize!=2237&&159&&vsize!=252)
    {
        vsize=0;
        printf("This is virus in your computer\n");
        virus=1;
    }
    if((fp=fopen("record.txt","w"))==NULL)
    {
        printf("Can't 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("Don't find virus in your computer\n");
    fclose(fp);
    getch();
    return 0;
}
搜索更多相关主题的帖子: 病毒 function register include 
2013-03-05 07:35



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-399768-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.103807 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved