|
-
Aug 22nd, 2001, 03:22 AM
#1
Thread Starter
New Member
GetConsoleMode and SetConsoleMode example help
I'm going batty .... !
Wrote this snippet of code in C to block echoing in console window app. It works. Can't get the same thing to work in VB!!! No matter how many times I set the console mode it still echoes... Does anybody have an EXAMPLE of how to switch console input echoing on and off in Visual Basic? Much appreciated!
Ian
#include <windows.h>
#include <stdio.h>
int main(int argc, char **argv)
{
char passwd[128];
char usrinput[128];
HANDLE h;
int md;
/* set no echo */
h = GetStdHandle(STD_INPUT_HANDLE);
GetConsoleMode(h, &md);
SetConsoleMode(h, md & ~ENABLE_ECHO_INPUT);
printf("Password:"); fflush(stdout);
fgets(passwd, sizeof(passwd), stdin);
/* reset echo */
SetConsoleMode(h, md);
printf("\n"); fflush(stdout);
printf("got '%s'\n", passwd);
fgets(usrinput, sizeof(usrinput), stdin);
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|