zoukankan      html  css  js  c++  java
  • (FFOS Gecko)

    1. Using a service in C++

    nsCOMPtr<nsIServiceManager> servManager;
    nsresult rv = NS_GetServiceManager(getter_AddRefs(servManager));
    if (NS_FAILED(rv)) { // get ServiceManager error
      return -1;
    }
    
    // get real Service
    nsCOMPtr<nsICustomService> customService;
    rv = servMan->GetServiceByContractID("@mozilla.org/customservice",
                                         NS_GET_IID(nsICustomService),
                                         getter_AddRefs(customService));
    if (NS_FAILED(rv)) { // get CustomService error
      return -1;
    }
    
    // call a method of CustomService
    customService->callMethod(/*some parameters*/);

    2. Using a service in Javascript(XPConnect)

    customService = Components.classes["@mozilla.org/customservice;1"]
                     .getService();
    customService = customService.QueryInterface(Components.interfaces.nsICustomService);
    customService.callMethod();
  • 相关阅读:
    进程总结
    三大流程
    canvas简介
    时钟
    vim
    马拉车
    模拟退火
    洛谷P2055假期的宿舍
    洛谷P2320鬼谷子的钱袋.
    洛谷P2278操作系统
  • 原文地址:https://www.cnblogs.com/code-4-fun/p/4661738.html
Copyright © 2011-2022 走看看