constk

Some_C#_Just_for_kicks (I can hide console! Woah!)

Feb 27th, 2021
82
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Globalization;
  3. using System.Windows;
  4.  
  5. // To use magic
  6. using System.Runtime.InteropServices;
  7.  
  8. // Hide console
  9. //ShowWindow(handle, SW_HIDE);
  10.  
  11. // Show console
  12. //ShowWindow(handle, SW_SHOW
  13.  
  14. namespace CSharpTest
  15. {
  16.     class Program
  17.     {
  18.         // Magic
  19.         [DllImport("kernel32.dll")]
  20.         static extern IntPtr GetConsoleWindow();
  21.  
  22.         // Same
  23.         [DllImport("user32.dll")]
  24.         static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
  25.  
  26.         // There is normal code
  27.         static void Main(string[] args)
  28.         {
  29.             // A bit more magic
  30.             const int SW_HIDE = 0;
  31.             const int SW_SHOW = 5;
  32.             var handle = GetConsoleWindow();
  33.             ShowWindow(handle, SW_HIDE); // This thing should hide console
  34.  
  35.  
  36.             // ------------------------------ That's there my code starts ------------------------------
  37.             CultureInfo.CurrentCulture = new CultureInfo("en-US", false);
  38.  
  39.             var pay = 300.0;
  40.  
  41.             var userMessage = string.Format("{0:c}", pay);
  42.             userMessage = string.Format("Fisting is " + userMessage);
  43.             MessageBox.Show(userMessage);
  44.         }
  45.     }
  46. }
  47.  
RAW Paste Data