一个模拟金山毒霸等软件查毒过程的小程序

来源:互联网 发布:凯撒贝利亚act淘宝 编辑:程序博客网 时间:2024/04/29 18:18

//--一个模拟金山毒霸等软件查毒过程的小程序
//--参考了JIURL朋友的程序
//--04/28/2006 Friday
//--Computer Lab
//--Micro_lee
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>


void main()
{
 HANDLE hOut;
 hOut=GetStdHandle(STD_OUTPUT_HANDLE);
 SetConsoleTextAttribute(hOut,FOREGROUND_GREEN);//设置颜色

 int i=0;
 int interval=5000;
 srand( (unsigned)time( NULL ) );

 while(1){

     SetConsoleTextAttribute(hOut,FOREGROUND_GREEN);

  if(rand()%10==0) SetConsoleTextAttribute(hOut,FOREGROUND_INTENSITY|FOREGROUND_GREEN);
  if(rand()%2) printf(" ");  //一次打印:一半可能是空格
  else printf("%d",rand()%2);  //一次打印:四分之一可能是1,四分之一可能是0。
 
  for(i=0; i<rand(); i++)
  {
   __asm nop
  }
  //用for来控制时间,不用Sleep(),
  //是因为Sleep()在时间间隔非常小的时候是不起作用的。
  //当然能用Sleep()时,还是用Sleep()这种for循环很费CPU资源。

  if(kbhit()) break; //按键退出
 }

 return;
}

//--下载源码之后使用VC建立Win32 Console Application的project进行编译。

原创粉丝点击