I am working with a plug-in for Visual Studios 2003. I am loading VS using a command line param so I canít just call CreateInstance from C / C++ to load it. My problem is that I need the command bar (Menu Bar to be specific) object model. I know it can be done but can't get the functionality to work correctly. Reading MSDN I found that AccessibleObjectFromWindow with the OBJID_NATIVEOM param specified should give you back an IDispatch * to the command bar object model. I get back an object with the command bar in it, but the problem is that the object is an IAccessible object and QueryInterface returns that the object does not support the command bar interface. HELP

I have posted the code with this post to help if my description is not clear.

STDMETHODIMP CUtils::GetMenu(IDispatch** ppMenu)
{
IDispatch * pDisp = NULL;

HWND hWnd = FindWindowEx(GetDesktopWindow(), NULL, "wndclass_desked_gsk",NULL);
hWnd = FindWindowEx(hWnd, NULL, "MsoCommandBarDock", "MsoDockTop");
hWnd = FindWindowEx(hWnd, NULL, "MsoCommandBar", "MenuBar");

AccessibleObjectFromWindow(hWnd, OBJID_NATIVEOM, IID_IDispatch, (void**) ppMenu);
return S_OK;
}

P.S. There are a hell of a lot more checks to make sure that the hWnd points to the correct, but to save on space I took them out of this example. This function resides in a com dll that is called from a VB.net client application. I know I hate VB.Net myself but I am being forced to use it because test developers donít like C or C++ and they donít want to learn C#.