XPCOM to running Netscape

"RL Clippard" <[email protected]>
Newsgroups gmane.comp.mozilla.devel.xpcom
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
Hey, how do I attach to the currently Netscape application from a C++
program? I am betting it is with XPCOM but how do I use the services it
exposes (or does that happen automatically and I am juts really confised).

For example I thought the code below would give me the User Agent string but
it fails (GetMostRecentWindow() does not set window). By the way, I have
Netscape 6 running while I run the code below.

    const char *path =
"D:\\Netscape\\Mozilla\\mozilla.v0.9.9\\mozilla\\dist\\WIN32_O.OBJ\\bin";

    nsCOMPtr<nsILocalFile> componentPath;
    NS_NewLocalFile(path, PR_TRUE, getter_AddRefs(componentPath));

//-initXPCOM
    nsIServiceManager *serviceManager=0;
    nsResult = NS_InitXPCOM2(&serviceManager, componentPath, nsnull);

//-nsIWindowsMediator
    nsCOMPtr<nsIWindowMediator> mediator=0;
    mediator = do_GetService(NS_RDF_DATASOURCE_CONTRACTID_PREFIX
"window-mediator");

//-nsIDOMWindowInternal
    nsIDOMWindowInternal* window=0;
    nsResult = mediator->GetMostRecentWindow(nsnull,&window);            //
window is 0 after this call?

//-nsIDOMNavigator
    nsIDOMNavigator* navigator=0;
    nsResult = window->GetNavigator(&navigator);

    nsString userAgent;
    nsResult = navigator->GetUserAgent(userAgent);
    printf("User Agent: '%p'\n",userAgent.get());


I am trying to attach to Netscape but I am pointing things to Mozilla
because Netscape 6 does not support NS_InitXPCOM2(). Does this matter?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.