Advertisement
Manu404

ExLauncherInvisible

Jun 6th, 2011
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Runtime.InteropServices;
  6. using System.Diagnostics;
  7. using System.Security;
  8. using System.Threading;
  9.  
  10. namespace PuttyShadow
  11. {
  12.     class Program
  13.     {
  14.         static void Main(string[] args)
  15.         {
  16.             // Configure un nom unique au launcher puis le cache
  17.             Console.Title = Guid.NewGuid().ToString();
  18.             IntPtr hWnd = UnsafeNativeMethods.FindWindow(null, Console.Title);
  19.             if (hWnd != IntPtr.Zero)
  20.                 UnsafeNativeMethods.ShowWindow(hWnd, 0);
  21.  
  22.             // Création du process a lancer
  23.             Process p = new Process();
  24.             p.StartInfo.FileName = "notepad";
  25.             p.Start();
  26.            
  27.             // Histoire d'être sur que la window reste caché on met une boucle infinie qui la cache toute les 100ms
  28.             while (true)
  29.             {
  30.                 if (p.HasExited)
  31.                     break;
  32.  
  33.                 IntPtr bWnd = UnsafeNativeMethods.FindWindow("Notepad", null);
  34.                 if (bWnd != IntPtr.Zero)
  35.                     UnsafeNativeMethods.ShowWindow(bWnd, 0);
  36.  
  37.                 Thread.Sleep(100);
  38.             }
  39.         }
  40.     }
  41.  
  42.     [SuppressUnmanagedCodeSecurity]
  43.     internal static class UnsafeNativeMethods
  44.     {
  45.         [DllImport("user32.dll")]
  46.         internal static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
  47.  
  48.         [DllImport("user32.dll", SetLastError = true)]
  49.         internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement