c# - Can't kill a still running Outlook instance -


i'm trying kill still running outlook instance(used in application not outlook itself), call following in deconstructor

        //_app = microsoft.office.interop.outlook.application         _app.quit();         marshal.finalreleasecomobject(_app);         marshal.finalreleasecomobject(_app.session);         gc.waitforpendingfinalizers();         gc.collect(); 

but nothing helps, there more ways kill , if so, how?

first import of user32.dll done able use getwindowthreadprocessid

then kill method receives outlook app parameter , obtains process , kills it

public static class outlookkiller {         [dllimport("user32.dll", entrypoint = "getwindowthreadprocessid", setlasterror = true, charset = charset.unicode, exactspelling = true, callingconvention = callingconvention.stdcall)]     private static extern long getwindowthreadprocessid(long hwnd, out long lpdwprocessid);      public static void kill(ref microsoft.office.interop.outlook.application app)     {         long processid = 0;         long apphwnd = (long)app.hwnd;          getwindowthreadprocessid(apphwnd, out processid);          process prc = process.getprocessbyid((int)processid);         prc.kill();     } } 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -