最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#隱藏控制臺鍵盤輸入的方法

 更新時間:2015年04月18日 13:58:53   作者:work24  
這篇文章主要介紹了C#隱藏控制臺鍵盤輸入的方法,涉及C#針對系統(tǒng)底層調(diào)用的相關技巧,非常具有實用價值,需要的朋友可以參考下

本文實例講述了C#隱藏控制臺鍵盤輸入的方法。分享給大家供大家參考。具體如下:

using System;
namespace RobvanderWoude
{
 class HideInput
 {
  static int Main( string[] args )
  {
   try
   {
    bool clearscreen = false;
    if ( args.Length > 1 )
    {
     return WriteError( "Too many command line arguments" );
    }
    if ( args.Length == 1 )
    {
     switch ( args[0].ToUpper( ) )
     {
      case "/C":
       clearscreen = true;
       break;
      case "/?":
       return WriteError( );
      default:
       return WriteError( "Invalid command line argument \"" + args[0] + "\"" );
     }
    }
    // Set console foreground color to background color to hide what's being typed
    ConsoleColor color = Console.ForegroundColor;
    Console.ForegroundColor = Console.BackgroundColor;
    // Read 1 line of input from the console
    string input = Console.ReadLine( );
    // Restore the original console foreground color
    Console.ForegroundColor = color;
    // Clear the screen id specified on the command line
    if ( clearscreen )
    {
     Console.Clear( );
    }
    // Display the input - which should be redirected for this program to be of any use
    Console.WriteLine( input );
    // Returncode 0 for success, or 1 if the input was empty or whitespace only
    if ( string.IsNullOrWhiteSpace( input ) )
    {
     return 1;
    }
    else
    {
     return 0;
    }
   }
   catch ( Exception e )
   {
    return WriteError( e.Message );
   }
  }
  public static int WriteError( string errorMessage = "" )
  {
   Console.ResetColor( );
   if ( string.IsNullOrEmpty( errorMessage ) == false )
   {
    Console.Error.WriteLine( );
    Console.ForegroundColor = ConsoleColor.Red;
    Console.Error.Write( "ERROR: " );
    Console.ForegroundColor = ConsoleColor.White;
    Console.Error.WriteLine( errorMessage );
    Console.ResetColor( );
   }
   Console.Error.WriteLine( );
   Console.Error.WriteLine( "HideInput, Version 1.10" );
   Console.Error.WriteLine( "Batch utility to read 1 line of input while hiding what's being typed, by" );
   Console.Error.WriteLine( "temporarily setting the console foreground color equal to its background color" );
   Console.Error.WriteLine( );
   Console.Error.Write( "Usage: FOR /F \"tokens=*\" %%A IN ('" );
   Console.ForegroundColor = ConsoleColor.White;
   Console.Error.Write( "HIDEINPUT" );
   Console.ResetColor( );
   Console.Error.WriteLine( "') DO SET password=%%A" );
   Console.Error.Write( "  or: FOR /F \"tokens=*\" %%A IN ('" );
   Console.ForegroundColor = ConsoleColor.White;
   Console.Error.Write( "HIDEINPUT /C" );
   Console.ResetColor( );
   Console.Error.WriteLine( "') DO SET password=%%A" );
   Console.Error.WriteLine( );
   Console.Error.Write( "Where: " );
   Console.ForegroundColor = ConsoleColor.White;
   Console.Error.Write( "/C" );
   Console.ResetColor( );
   Console.Error.WriteLine( " clears the screen to remove what's typed from the screen buffer" );
   Console.Error.WriteLine( );
   Console.Error.WriteLine( "Written by Rob van der Woude" );
   return 1;
  }
 }
}

希望本文所述對大家的C#程序設計有所幫助。

相關文章

  • c# SendMail發(fā)送郵件實例代碼

    c# SendMail發(fā)送郵件實例代碼

    這篇文章介紹了c# SendMail發(fā)送郵件實例代碼,有需要的朋友可以參考一下
    2013-09-09
  • C#中Equals和GetHashCode使用及區(qū)別

    C#中Equals和GetHashCode使用及區(qū)別

    這篇文章主要介紹了C#中Equals和GetHashCode使用及區(qū)別,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-02-02
  • C# ListView 點擊表頭對數(shù)據(jù)進行排序功能的實現(xiàn)代碼

    C# ListView 點擊表頭對數(shù)據(jù)進行排序功能的實現(xiàn)代碼

    這篇文章主要介紹了C# ListView 點擊表頭對數(shù)據(jù)進行排序功能的實現(xiàn)代碼,需要的朋友可以參考下
    2017-04-04
  • C# 觀察者模式實例介紹

    C# 觀察者模式實例介紹

    一個簡單的例子,比如說貓叫,老鼠跑,主人被驚醒,在不知道觀察者模式之前,我們的代碼可能是這樣的
    2012-10-10
  • 詳解三種C#實現(xiàn)數(shù)組反轉(zhuǎn)方式

    詳解三種C#實現(xiàn)數(shù)組反轉(zhuǎn)方式

    本篇文章主要介紹了詳解三種C#實現(xiàn)數(shù)組反轉(zhuǎn)方式,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-04-04
  • C#中使用CliWrap讓命令行交互舉重若輕

    C#中使用CliWrap讓命令行交互舉重若輕

    這篇文章介紹了C#中使用CliWrap讓命令行交互舉重若輕,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-12-12
  • C#中Dictionary類使用實例

    C#中Dictionary類使用實例

    這篇文章主要介紹了C#中Dictionary類使用實例,本文直接給出一個使用實例,包含一些Dictionary的基本用法,需要的朋友可以參考下
    2015-06-06
  • C# 特性AttributeUsage簡介與使用教程

    C# 特性AttributeUsage簡介與使用教程

    這篇文章主要介紹了C# 特性AttributeUsage簡介與使用教程,本文通過示例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-05-05
  • C#使用RabbitMQ的詳細教程

    C#使用RabbitMQ的詳細教程

    RabbitMQ?是一個功能強大的消息隊列系統(tǒng),可用于在分布式系統(tǒng)中進行可靠的消息傳遞,本篇博客將詳細介紹如何在?C#?中使用?RabbitMQ?實現(xiàn)各種消息隊列操作,并通過代碼介紹的非常詳細,需要的朋友可以參考下
    2024-08-08
  • 詳解C#數(shù)據(jù)類型及其轉(zhuǎn)換

    詳解C#數(shù)據(jù)類型及其轉(zhuǎn)換

    這篇文章主要介紹了C#數(shù)據(jù)類型及其轉(zhuǎn)換詳解,在C#中,數(shù)據(jù)類型可以分為幾種類型,今天小編通過本文給大家詳細介紹,需要的朋友可以參考下
    2020-07-07

最新評論

宁武县| 安泽县| 望江县| 开封市| 山阴县| 乌兰察布市| 漾濞| 阿合奇县| 天气| 博湖县| 千阳县| 望城县| 阿拉善盟| 仙游县| 东丽区| 商水县| 嘉黎县| 夏邑县| 镇雄县| 南昌市| 图木舒克市| 开阳县| 平安县| 金秀| 德州市| 宕昌县| 特克斯县| 海阳市| 阜阳市| 彰武县| 黄石市| 上饶市| 偃师市| 温泉县| 南漳县| 麦盖提县| 内江市| 绍兴市| 台东县| 民权县| 榕江县|