.NET 4.x Скрытие окон чужого процесса - C#
Формулировка задачи:
Подскажите пожалуйста, буду благодарен..
как можно скрыть чужой процесс при запуске (например notepad)
Просто скрыть, и что бы его развернуть нельзя было, в процессах пусть висит...
Вот обнаружение процесса, нужен только код скрытие и раскрытие процесса, или заблокировать его как-то что-ли)
string proc = "notepad";
if (Process.GetProcessesByName(proc.ToString()).Length != 0)
{
}
Или можно сделать типа, сделать тёмным рабочий стол и заблокировать доступ к нему, а доступна будет только область окна программы, а потом разблкировать...
Решение задачи: «.NET 4.x Скрытие окон чужого процесса»
textual
Листинг программы
private void button1_Click ( object sender, EventArgs e )
{
IntPtr hWindow = WindowsFinder.FindWindow( null, "Калькулятор" );
if ( !IsValidHandle( hWindow ) )
throw new Win32Exception( Marshal.GetLastWin32Error() );
hWindow = WindowsFinder.FindWindowEx( hWindow, IntPtr.Zero, "CalcFrame", null );
if ( !IsValidHandle( hWindow ) )
throw new Win32Exception( Marshal.GetLastWin32Error() );
hWindow = WindowsFinder.FindWindowEx( hWindow, IntPtr.Zero, "#32770", null );
if ( !IsValidHandle( hWindow ) )
throw new Win32Exception( Marshal.GetLastWin32Error() );
hWindow = WindowsFinder.FindWindowEx( hWindow, IntPtr.Zero, "Static", null );
}
static bool IsValidHandle ( IntPtr hWnd )
{
return hWnd != IntPtr.Zero;
}
}
public static class WindowsFinder
{
[DllImport( "user32.dll", SetLastError = true, CharSet = CharSet.Unicode )]
public static extern IntPtr FindWindow ( string lpClassName, string lpWindowName );
[DllImport( "user32.dll", SetLastError = true, CharSet = CharSet.Unicode )]
public static extern IntPtr FindWindowEx ( IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle );
[DllImport( "user32.dll", SetLastError = true, CharSet = CharSet.Unicode )]
public static extern int GetClassName ( IntPtr hWnd, StringBuilder lpClassName, int nMaxCount );
}