Changes

Jump to: navigation, search

Discussion of Using XPCOM Components

349 bytes added, 15:02, 19 November 2008
nsCOMPtr
For example, we know that nsICookieManager2 inherits from nsICookieManager, so given an nsICookieManager we might wish to obtain a pointer to an nsICookieManager2 in order to get extra functionality:
nsCOMPtr<nsICookieManager2nsICookieManager> cookieMgr2 cookieManager = do_QueryInterfacedo_GetService(cookieMgrNS_COOKIEMANAGER_CONTRACTID); if (cookieManager2cookieManager)
{
nsCOMPtr<nsICookieManager2> cookieManager2 = do_QueryInterface(cookieMgr);
if (cookieManager2)
{
...
}
}
 
NOTE: it is more common (and advisable) to call the helper do_QueryInterface instead of using QueryInterface directly. See the [https://developer.mozilla.org/En/Using_nsCOMPtr/Reference_Manual nsCOMPtr Reference Manual].
=== Services ===

Navigation menu