pds wrote:

> Hi,
>     I am new to XPCOM. I want to use the interface functions of
> nsICookieService.
> I am not sure where the CookieViewer is initiated first of all.
> 
> If I try to create a new instance of this interface using:
> 
> nsCOMPtr<nsICookieService> cookieservice = do_CreateInstance
> (COOKIESERVICE_ID);
> 
> I get a warning the first time I try do it, and I am unable to do it
> subsequently.


In general, "services" are accessed via the xpcom service API.  This API 
manages keeping track of the single instance of the component.

lxr.mozilla.org is your friend.  A quick search for nsICookieService 
yields a few good results.  The general pattern is:

NS_WITH_SERVICE(nsICookieService, cookieService, kCookieServiceCID, &rv);


eg: 
http://lxr.mozilla.org/seamonkey/source/modules/plugin/nglsrc/nsPluginHostImpl.cpp#4595

Mark.


Reply via email to