c++ - How to properly use IOpenServiceManager::InstallService -
im trying define new ie search engine, getting trouble whenever try install service.
i walked through following example , changed name of files
upload.xml:
<opensearchdescription xmlns="http://a9.com/-/spec/opensearch/1.1/"> <shortname>web search</shortname> <description>use example.com search 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>
links valid , work.
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;
everytime try install service (hr = 0xc00ce556 / e_invalidarg)
activex/com uses bstr
strings sysallocstring()
family of functions (wrapped ccombstr
class). try using instead of compile-time wchar[]
literal via 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)
Comments
Post a Comment