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

C#隱藏控制臺(tái)鍵盤(pán)輸入的方法

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

本文實(shí)例講述了C#隱藏控制臺(tái)鍵盤(pán)輸入的方法。分享給大家供大家參考。具體如下:

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;
  }
 }
}

希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

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

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

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

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

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

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

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

    C# 觀察者模式實(shí)例介紹

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

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

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

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

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

    C#中Dictionary類(lèi)使用實(shí)例

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

    C# 特性AttributeUsage簡(jiǎn)介與使用教程

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

    C#使用RabbitMQ的詳細(xì)教程

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

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

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

最新評(píng)論

崇义县| 襄樊市| 页游| 文化| 定安县| 文成县| 山丹县| 启东市| 江阴市| 龙山县| 内丘县| 虞城县| 互助| 铜鼓县| 会东县| 广灵县| 武威市| 望奎县| 南江县| 海晏县| 兴海县| 昆明市| 仙居县| 光山县| 临朐县| 建昌县| 麻城市| 苏尼特右旗| 新竹市| 榆中县| 延安市| 迭部县| 阳江市| 濮阳县| 木里| 桃园市| 宣汉县| 新泰市| 天台县| 儋州市| 平顺县|