Hello,

I have created an active X control using Active Qt framework which is loaded inside an IE browser. Now i want to retrieve the URL from the browser.

My active X code will look something like this

Qt Code:
  1. class ActiveX : public QObject, public QAxBindable
  2. {
  3. ...
  4. }
  5.  
  6. class ObjectSafetyImpl : public QAxAggregated,
  7. public IObjectSafety
  8. {
  9. public:
  10. ObjectSafetyImpl() {}
  11.  
  12. long queryInterface( const QUuid &iid, void **iface )
  13. {
  14. *iface = 0;
  15. if ( iid == IID_IObjectSafety )
  16. *iface = (IObjectSafety*)this;
  17. else
  18. return E_NOINTERFACE;
  19.  
  20. AddRef();
  21. return S_OK;
  22. }
  23.  
  24. QAXAGG_IUNKNOWN;
  25.  
  26. HRESULT WINAPI GetInterfaceSafetyOptions( REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions )
  27. {
  28. *pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACESAFE_FOR_UNTRUSTED_CALLER;
  29. *pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACESAFE_FOR_UNTRUSTED_CALLER;
  30. return S_OK;
  31. }
  32. HRESULT WINAPI SetInterfaceSafetyOptions( REFIID riid, DWORD pdwSupportedOptions, DWORD pdwEnabledOptions )
  33. {
  34. return S_OK;
  35. }
  36. };
  37.  
  38. QAxAggregated *ActiveX::createAggregate()
  39. {
  40. return new ObjectSafetyImpl();
  41. }
To copy to clipboard, switch view to plain text mode 

Now it try to get the browser instance using the following piece of code

Qt Code:
  1. IWebBrowser2 *webBrowser = 0;
  2. clientSite()->QueryInterface(IID_IWebBrowser2, (void **)&webBrowser);
  3. BSTR* strHostURL = 0;
  4. if(webBrowser)
  5. webBrowser->get_LocationURL(strHostURL);
To copy to clipboard, switch view to plain text mode 

But the webBrowser object always turns out to be NULL. Any help???


Thanks,
Vasudev, Balu