public static void CloseAllWindowsOfProcess(int processId) { EnumWindowsCallbackDelegate d = delegate(IntPtr hWnd, UInt32 lParam) { UInt32 pid; ProcessNativeMethods.GetWindowThreadProcessId(hWnd, out pid); if ((int)pid == processId) { ProcessNativeMethods.PostMessage(hWnd, ProcessNativeConstants.WM_CLOSE, 0, 0); } return(true); }; ProcessNativeMethods.EnumWindows(d, 0); }
private static extern int EnumWindows(EnumWindowsCallbackDelegate callback, IntPtr lParam);
private static extern bool EnumChildWindows(IntPtr hwndParent, EnumWindowsCallbackDelegate lpEnumFunc, IntPtr lParam);
public static extern void EnumWindows(EnumWindowsCallbackDelegate d, UInt32 lParam);
static extern bool EnumWindows(EnumWindowsCallbackDelegate callback, int parameter);
static extern bool EnumChildWindows(IntPtr handle, EnumWindowsCallbackDelegate callback, int parameter);
public static extern int EnumChildWindows(IntPtr hWnd, EnumWindowsCallbackDelegate callback, int lParam);
public static extern int EnumWindows(EnumWindowsCallbackDelegate callback, int lParam);