I need to get a list of all currently opened MSACCESS instances in the system (windows) to be able to close any of them from within my app. I have no problems with EXCEL and WINWORD but can't hook up with Access.
I use Office 2016 and I see that MSACCESS creates separate procss for each opened database file. So I think I have to get application instances from window handles. I've tried to adapt this code: How to iterate through instance of Excel c#
I'm able to get all MSACCESS processes but the Excel or Word code isn't working for MSACCESS. The Code line:
if (buf.ToString() == "EXCEL7")
Always gives me the MsoCommandBarDock value. Any thoughts on how I can achieve this?
OMain(CS_OWNDC style). why should it beEXCEL7? be aware that this will be different between versions and may change at any time when MS choose to update. MsoCommandBarDock is one or two levels too deep in the window hierarchy.AccessibleObjectFromWindowwith the hWnd acquired from(int)p.MainWindowHandle. You can scrap all code enumerating child windows. I'd write up a short answer, but my C# is beginner level at best and I don't have a test environment handy, and this should get you started.