dedecms织梦内容管理系统    
首页 | java | C/C++ | PHP | 操作系统 | ajax | 脚本编程 | 安全技术 | 本站下载页 | flex | CRM | 专题 | QQ群 | 测试中心 | 会员中心 | 积分规则
  当前位置:主页>C/C++>C/C++技术资料>文章内容
开机密码
来源: 作者: 出处:百家拳

#include "conio.h"
#include "string.h"
#include "stdio.h"

void error()
{window(12,10,68,10);
textbackground(15);
textcolor(132);
clrscr();
cprintf("file or system error! you can't enter the system!!!");
while(1); /*若有错误不能通过程序*/
}

void look()
{FILE *fauto,*fbak;
char *pass="c:\\windows\\password.exe"; /*本程序的位置*/
char a[25],ch;
char *au="autoexec.bat",*bname="hecfback.^^^"; /*bname 是autoexec.bat 的备份*/
setdisk(2); /*set currently disk c:*/
chdir("\\"); /*set currently directory \*/
fauto=fopen(au,"r+");
if (fauto==NULL)
{fauto=fopen(au,"w+");
if (fauto==NULL) error();}
fread(a,23,1,fauto); /*读取autoexec.bat前23各字符*/
a[23]='\0';

if (strcmp(a,pass)==0) /*若读取的和pass指针一样就关闭文件,不然就添加*/
fclose(fauto);
else
{fbak=fopen(bname,"w+");
if (fbak==NULL) error();
fwrite(pass,23,1,fbak);
fputc('\n',fbak);
rewind(fauto);
while(!feof(fauto))
{ch=fgetc(fauto);
fputc(ch,fbak);}
rewind(fauto);
rewind(fbak);
while(!feof(fbak))
{ch=fgetc(fbak);
fputc(ch,fauto);}
fclose(fauto);
fclose(fbak);
remove(bname); /*del bname file*/
}
}

void pass()
{char *password="88888888";
char input[60];
int n;
while(1)
{window(1,1,80,25);
textbackground(0);
textcolor(15);
clrscr();

n=0;
window(20,12,60,12);
textbackground(1);
textcolor(15);
clrscr();
cprintf("password:");
while(1)
{input[n]=getch();
if (n>58) {putchar(7); break;} /*若字符多于58个字符就结束本次输入*/
if (input[n]==13) break;
if (input[n]>=32 && input[n]<=122) /*若字符是数字或字母才算数*/
{putchar('*');
n++;}
if (input[n]==8) /*删除键*/
if (n>0)
{cprintf("\b \b");
input[n]='\0';
n--;}
}
input[n]='\0';
if (strcmp(password,input)==0)
break;
else
{putchar(7);
window(30,14,50,14);
textbackground(15);
textcolor(132);
clrscr();
cprintf("password error!");
getch();}
}
}

main()
{look();
pass();
}


上一篇:印度员工目前薪资涨幅已经远超中国为全球最高   下一篇:讲述java语言中内部类的研究
[收藏] [推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
用户名: 新注册) 密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论
  热点文章
·C语言数组排序小结
·Python 与 C++ 程序的简单实例对
·c++ 数组与指针
·C++中的内存管理(new、delete、
·如何用C语言开发DSP嵌入式系统
·如何用C语言开发DSP嵌入式系统
·Linux下C语言编程
·学习arm的话先看哪本书?
·C++初学者应该关心的优秀图书一
·利用C语言小程序来解决大问题
·用C语言写PHP扩展的步骤
·用C语言扩展PHP功能
  相关文章
·C语言指针要搞清的4方面问题
·C++数组应用之特殊矩阵的压缩存
·C语言程序修改注册表的方法
·哲学家就餐问题 --C原代码
·宏比函数实现在时间上的优越性探
·用C语言实现键盘画图
·菜鸟问与答(指针)
·浅谈指针的特点
·正确使用指针
·指针详解-02
·指针详解-01
·深入理解C语言指针的奥秘
  相关信息
copy right @ 百家拳软件项目研究室 2007 辽ICP备07011763