我有一个在MinTTY(cygwin的shell)下运行的程序,并且对GetConsoleMode
/ SetConsoleMode
的调用失败。 _getch
回到控制台。这是一个原生的win32应用程序,没有绑定到cygwin环境,所以任何cygwin功能都没有。如何关闭回声以便输入密码?
答案 0 :(得分:1)
我基本上通过popen
模仿了以下内容:
save_state=$(stty -g) /bin/echo -n "Account: " read acct /bin/echo -n "Password: " stty -echo read password # this won't echo stty "$save_state" echo "" echo account = $acct and password = $password Read more at http://www.askdavetaylor.com/how_to_read_password_without_echoing_c.html#Z3FtcTtMHe0gJdES.99