DemoApp.cpp
上传用户:goldcmy89
上传日期:2017-12-03
资源大小:2246k
文件大小:1k
- // DemoApp.cpp : 定义控制台应用程序的入口点。
- //
- #include <stdio.h>
- #include "nsXPCOM.h"
- #include "nsComponentManagerUtils.h"
- #include "nsStringAPI.h"
- #include "IDemoDll.h"
- #define DEMODLL_CONTRACTID "@actia.com.cn/DemoDll;1"
- int main()
- {
- //Your component's contract ID goes here
- //static const char szContractId[] = "@actia.com.cn/DemoDll;1";
-
- // Initialize XPCOM and check for failure ...
- nsresult rv;
- rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
- if ( NS_FAILED(rv) )
- {
- printf("Calling NS_InitXPCOM returns [%x].n", rv);
- return -1;
- }
-
- // Create an instance of our component
- nsCOMPtr<IDemoDll> mysample = do_CreateInstance(DEMODLL_CONTRACTID, &rv);
- if ( NS_FAILED(rv) )
- {
- printf("Creating component instance of %s fails.n", DEMODLL_CONTRACTID);
- return -2;
- }
-
- // Do something useful with your component ...
-
- // (main body of code goes here)
- nsCString nsStr = NS_LITERAL_CSTRING("Frank Test.");
- nsCString nsOutStr;
- mysample->GetRecordFileName(nsOutStr);
- printf("1.get default name = %sn",nsOutStr);
- mysample->SetRecordFileName(nsStr);
- mysample->GetRecordFileName(nsOutStr);
- printf("2.get setting name = %sn",nsOutStr);
-
- // Released any interfaces.
- // Shutdown XPCOM
- NS_ShutdownXPCOM(nsnull);
- return 0;
- }