test.cpp
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// mozilla specific headers
#include "nsEmbedAPI.h"
#include "nsCOMPtr.h"
#include "nsStringAPI.h"
#include "nsEmbedString.h"

#include "nsComponentManagerUtils.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMUIEvent.h"
#include "nsXPCOMGlue.h"
#include "nsCWebBrowser.h"
#include "nsIWebBrowserChrome.h"
#include "nsIWebBrowser.h"
#include "nsIWebNavigation.h"
#include "nsILocalFile.h"

int main(int argc,char **argv)
{
    printf("hello world\n");
   nsresult rv;
    nsCOMPtr<nsILocalFile> greDir = nsnull;
    char* grePath ="/home/brightman/mozilla/dist/bin";
    rv = NS_NewLocalFile(nsEmbedString((const
PRUnichar*)grePath),PR_TRUE,getter_AddRefs(greDir));
    if (NS_FAILED(rv)){
        fprintf(stdout, "Couldn't set greDir.(rv = 0x%08x)\n",rv);
        exit(1);
    }

    rv  = NS_InitEmbedding(greDir,nsnull);
    if(NS_FAILED(rv)){
        fprintf(stdout, "Couldn't start XPCOM.(rv = 0x%08x)\n",rv);
        exit(1);
    }
    nsCOMPtr<nsIWebBrowser> nsWebBrowser;
    nsCOMPtr<nsIWebNavigation>  nsNav;
    nsWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID,&rv);
    if(NS_FAILED(rv)){
        fprintf(stdout, "Couldn't create nsIWebBrowser.\n");
        nsWebBrowser = nsnull;
        return 1;
    }
    nsNav = do_QueryInterface(nsWebBrowser,&rv);
    if(NS_FAILED(rv)){
        fprintf(stdout, "Couldn't create nsINav.\n");
        return 1;
    }
    printf("start load url\n");
    char *url = "http://www.baidu.com";;
    rv = nsNav->LoadURI((const PRUnichar*)(url),
nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull);

    if (NS_FAILED(rv)) {
        printf("LoadURI FAILED (rv = 0x%08x)\n", rv);
    }
    else {
        printf("LoadURI SUCCEEDED (rv = 0x%08x)\n", rv);
    }

}


[EMAIL PROTECTED]:~/mozilla/embedding/examples$ ./test
hello world
Couldn't set greDir.(rv = 0xc1f30001)

thanks first

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

Reply via email to