I want to get the URL from the running IE. I attached a small Win32 app that was supposed to do it. I see the GetActiveObject returns 0x800401e3 - operation unavailable.
I've read MSDN:
Retrieves a pointer to a running object that has been registered with OLE.
So Internet Explorer is noit registered?
Where is the mistake?
I see few threads on EE with GetActiveObject in the accepted solutions.
I tested the same in an MFC application too. More then it, I found the Edit in IE and I cannot get the URL with GetWindowText too.
It is IE 8. I see the problem on Vista and XP.
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPWSTR lpCmdLine, int nCmdShow)
HRESULT hr = CoInitialize(NULL);
//CLSIDFromProgID( L"InternetExplorer.Application", &clsid);
//hr = GetActiveObject(clsid, NULL, &pUnknown);
hr = GetActiveObject(CLSID_InternetExplorer, NULL, &pUnknown);
hr = pUnknown->QueryInterface(IID_IWebBrowser2, (LPVOID*)&pBrowser);
BSTR str = NULL;
hr = pBrowser->get_LocationURL(&str);