How to close process handle in C# -


i have process has 2 different handles. want close 1 or other based off of handle id. there way in c#.

use this:

public partial class testclass {     [dllimport("user32.dll")]     static extern bool enumwindows(enumwindowsproc lpenumfunc, intptr lparam);      public delegate bool enumwindowsproc(intptr hwnd, intptr lparam);      public static void testmethod() {         var targetname="acrord32.exe";          var processarray=(             process in process.getprocesses()             let modulename=(new func<process, string>(x => {                 try {                     return x.mainmodule.modulename;                 }                 catch(win32exception e) {                     return default(string);                 }             }))(process)             null!=modulename             0==string.compare(targetname, modulename, true)             select process).toarray();          enumwindows(             (hwnd, lparam) => {                 foreach(var process in processarray)                     if(process.mainwindowhandle==hwnd)                         return !process.closemainwindow();                  return true;             },             intptr.zero             );     } } 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

php - HTTP_REFERER woes: How can I allow access to a specific page, only when a visitor has visited another specific page beforehand? -

java Extracting Zip file -