Hi, All:
    I have a big trouble to get URL from XPCOM/C++/plugin. It is very simple 
to get URL from IE with interface IWebBrowser2. I want to do samething 
within a mozilla browser like firefox and netscape, but I can't.
    Here is some code I wrote to get
nsresult rv;

nsIComponentManager *pIComponentManager = NULL;

nsIDOMDocument *pIDOMDocument = NULL;

nsISupports *pISupports = NULL;

nsIURL *pIURL = NULL;

do

{

rv = NS_GetComponentManager(&pIComponentManager);

if(pIComponentManager == NULL)

break;

rv = 
pIComponentManager->GetClassObjectByContractID("@mozilla.org/network/standard-url;1",

NS_GET_IID(nsISupports), (void**)&pISupports);

if(pISupports == NULL)

{

rv = pISupports->QueryInterface(NS_GET_IID(nsIURL), (void**)&pIURL); //<---  
fails here with no interface available

}

if(pISupports != NULL)

{

pISupports->Release();

pISupports = NULL;

}

rv = 
pIComponentManager->GetClassObjectByContractID("@mozilla.org/xul/xul-document;1",

NS_GET_IID(nsISupports), (void**)&pISupports);

if(pISupports)

rv = pISupports->QueryInterface(NS_GET_IID(nsIDOMDocument), 
(void**)&pIDOMDocument); //<--- fails here with no interface available

}while(false);

if(pIDOMDocument != NULL)

pIDOMDocument->Release();

if(pIURL != NULL)

pIURL->Release();

if(pISupports != NULL)

pISupports->Release();

if(pIComponentManager != NULL)

pIComponentManager->Release();



    With the above code, I can get the components nsISupports and but can 
not get expected interfaces. What is wrong with the above code? Why does my 
code fail? I can not find any clues from Internet by doing Yahoo and Google 
searches.

    Please give me a help!




_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to