|
- // Instantiate the secure string.
- SecureString securePwd = new SecureString();
- ConsoleKeyInfo key;
- Console.Write("Enter password: ");
- do
- {
- key = Console.ReadKey(true);
- // Ignore any key out of range.
- if (((int)key.Key) >= 48 && ((int)key.Key <= 90))
- {
- // Append the character to the password.
- securePwd.AppendChar(key.KeyChar);
- Console.Write("*");
- }
- // Exit if Enter key is pressed.
- } while (key.Key != ConsoleKey.Enter);
- Console.WriteLine();
- try
- {
- Process.Start("Notepad.exe", "calvin", securePwd, "PC-05");
- }
- catch (Win32Exception e)
- {
- Console.WriteLine(e.Message);
- }
复制代码
|
|