i want to focus a program from my c# application.i searched lot and found some examples.but i got error .i'm using visual studio.ShowWindow(hWnd, SW_HIDE);
line gives me an error "showwindow(system.IntPtr,int) has some invalid argument"
plz where is the problem of this code
[DllImport("user32.dll")]
internal static extern IntPtr SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
internal static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
private void FocusProcess()
{
int hWnd;
Process[] processRunning = Process.GetProcesses();
foreach (Process pr in processRunning)
{
if (pr.ProcessName == "notepad")
{
hWnd = pr.MainWindowHandle.ToInt32();
ShowWindow(hWnd, 3);//error line
}
}
}