关于使用firefox中Gecko的问题
我准备用firefox的库解析HTML,其中要使用到里面的Gecko模块。但是,在使用的时候老是无法创建 nsIHTMLContentSink 的对象。。
返回的错误信息是: NS_ERROR_FACTORY_NOT_REGISTERED
初步估计是在初始化的时候,没有将创建这个对象的工厂载入或者注册。
以下是我的代码:
#include <iostream>
#include "nsXPCOM.h"
#include "nsIComponentManager.h"
#include "nsComponentManagerUtils.h"
#include "nsParserCIID.h"
#include "nsIParser.h"
#include "nsIHTMLContentSink.h"
#include "nsContentCID.h"
#include "nsIDocument.h"
#include "nsIDOMHTMLDocument.h"
using namespace std;
// Class IID's
static NS_DEFINE_CID(kParserCID, NS_PARSER_CID);
static NS_DEFINE_CID(kLoggingSinkCID, NS_LOGGING_SINK_CID);
nsresult ParseData() {
nsresult result = NS_OK;
// Create a parser
nsCOMPtr<nsIParser> parser(do_CreateInstance(kParserCID, &result));
if (NS_FAILED(result)) {
printf("\nUnable to create a parser\n");
return result;
}
// Create a sink
nsCOMPtr<nsILoggingSink> sink(do_CreateInstance(kLoggingSinkCID, &result));
/**此处无法创建 nsILoggingSink 对象(nsIHTMLContentSink是其父类)*/
if (NS_FAILED(result)) {
printf("\nUnable to create a sink\n");
return result;
}
}
//---------------------------------------------------------------------
int main(int argc, char** argv)
{
nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
if (NS_FAILED(rv)) {
printf("NS_InitXPCOM2 failed\n");
return -1;
}
ParseData();
return 0;
} 无法创建 nsIHTMLContentSink ,肯定是默认链接有问题,你可以重装一下
或者修复一下firefox的库解析 他山界面开发框架 v22是一套基于Gecko v22 的开源收费跨平台界面解决方案。可使用xul, html(5), css(3), js 开发界面,支持js, c++互调,发行包大小13MB 。 他山界面开发框架 v22是一套基于Gecko v22 的开源收费跨平台界面解决方案。可使用xul, html(5), css(3), js 开发界面,支持js, c++互调,发行包大小13MB
页:
[1]