我试图定义一个新的IE搜索引擎,但每当我尝试安装该服务时都会遇到麻烦。
我浏览了以下example并且只更改了文件的名称
upload.xml:
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Web Search</ShortName>
<Description>Use Example.com to search the Web.</Description>
<Tags>example web</Tags>
<Contact>admin@example.com</Contact>
<Url type="application/rss+xml"
template="http://example.com/?q={searchTerms}&pw={startPage?}&format=rss"/>
</OpenSearchDescription>
home.html的
<html>
<header>
<link rel="search"
type="application/opensearchdescription+xml"
href="http://somesite.com/upload.xml"
title="Content search" />
</header>
</html>
链接有效且有效。
C ++:
ATL::CComPtr<IOpenServiceManager> spManager;
if (FAILED(hr = spManager.CoCreateInstance(CLSID_OpenServiceManager)))
return false;
//URL-OF-SERVICE: See http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_elements
ATL::CComPtr<IOpenService> spService;
if (FAILED(hr = spManager->InstallService(L"http://somesite.com/home.html", &spService)))
return 0;
if (FAILED(hr = spService->SetDefault(TRUE, nullptr)))
return 0;
return 1;
每次我尝试安装我得到的服务(hr = 0xc00ce556 / E_INVALIDARG)
答案 0 :(得分:0)
ActiveX / COM使用SysAllocString()
函数族中的BSTR
个字符串(由CComBSTR
类包装)。尝试通过WCHAR[]
使用它代替编译时L"..."
文字:
BSTR url = SysAllocString(L"http://somesite.com/home.html");
spManager->InstallService(url, &spService)
SysFreeString(url);
CComBSTR url(L"http://somesite.com/home.html");
spManager->InstallService((BSTR)url, &spService)