Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Runtime.InteropServices;
- using System.Diagnostics;
- using System.Security;
- using System.Threading;
- namespace PuttyShadow
- {
- class Program
- {
- static void Main(string[] args)
- {
- // Configure un nom unique au launcher puis le cache
- Console.Title = Guid.NewGuid().ToString();
- IntPtr hWnd = UnsafeNativeMethods.FindWindow(null, Console.Title);
- if (hWnd != IntPtr.Zero)
- UnsafeNativeMethods.ShowWindow(hWnd, 0);
- // Création du process a lancer
- Process p = new Process();
- p.StartInfo.FileName = "notepad";
- p.Start();
- // Histoire d'être sur que la window reste caché on met une boucle infinie qui la cache toute les 100ms
- while (true)
- {
- if (p.HasExited)
- break;
- IntPtr bWnd = UnsafeNativeMethods.FindWindow("Notepad", null);
- if (bWnd != IntPtr.Zero)
- UnsafeNativeMethods.ShowWindow(bWnd, 0);
- Thread.Sleep(100);
- }
- }
- }
- [SuppressUnmanagedCodeSecurity]
- internal static class UnsafeNativeMethods
- {
- [DllImport("user32.dll")]
- internal static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
- [DllImport("user32.dll", SetLastError = true)]
- internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement