代码如下,编译没问题:
HRESULT hr;
hr = CoInitializeEx(NULL,COINIT_MULTITHREADED);
IHTMLDocument2 *pDoc = NULL;
hr = CoCreateInstance(CLSID_HTMLDocument,NULL,CLSCTX_INPROC_SERVER,IID_IHTMLDocument2,(LPVOID *) &pDoc);
if (pDoc)
{
IPersistStreamInit *pPersist = NULL;
hr = pDoc->QueryInterface(IID_IPersistStreamInit,(LPVOID *) &pPersist);
if (pPersist)
{
IMarkupServices *pMS = NULL;
pPersist->InitNew();
pPersist->Release();
hr = pDoc->QueryInterface(IID_IMarkupServices,(LPVOID *) &pMS);
if (pMS)
{
// Do works.
}
}
pDoc->Release();
}
CoUninitialize(); 如上代码,pDoc->QueryInterface(IID_IMarkupServices, (LPVOID *) &pMS)总是返回E_NOINTERFACE。
开发环境:
Windows XP SP3, IE7, VS2005 Professional.
HRESULT hr;
hr = CoInitializeEx(NULL,COINIT_MULTITHREADED);
IHTMLDocument2 *pDoc = NULL;
hr = CoCreateInstance(CLSID_HTMLDocument,NULL,CLSCTX_INPROC_SERVER,IID_IHTMLDocument2,(LPVOID *) &pDoc);
if (pDoc)
{
IPersistStreamInit *pPersist = NULL;
hr = pDoc->QueryInterface(IID_IPersistStreamInit,(LPVOID *) &pPersist);
if (pPersist)
{
IMarkupServices *pMS = NULL;
pPersist->InitNew();
pPersist->Release();
hr = pDoc->QueryInterface(IID_IMarkupServices,(LPVOID *) &pMS);
if (pMS)
{
// Do works.
}
}
pDoc->Release();
}
CoUninitialize(); 如上代码,pDoc->QueryInterface(IID_IMarkupServices, (LPVOID *) &pMS)总是返回E_NOINTERFACE。
开发环境:
Windows XP SP3, IE7, VS2005 Professional.
解决方案 »
- onPaint 函数里面 调用一个画图函数,导致界面不断地刷新
- 获取用USB to IDE 连接的存储设备的设备信息(厂商、序列号什么的)
- 上位机通过网口与记忆卡通信——困扰了一天的问题
- SOCKET获取CLIENT信息
- C++写COM组件,IClassFactory::LockServer()如何使用?
- 新手:读深入浅出,对message传递还是有一点不明白?
- 需要从字符串中截取定长字符的函数
- 一直找不到方向,大家给个建议好吗???
- error C2228: left of '.RecvCANMessage' must have class/struct/union type
- 高手们,关于透明窗体
- 开发一个工具
- 获得放置程序的路径
我只从IWebBrowser2* navigate一个url再获得的IHTMLDocument2*这么用过 注意下msdn这段话 可能问题在这里:
Typically, every window object has a corresponding document object that you can get by calling the QueryInterface method with the IID_IHTMLDocument or IID_IHTMLDocument2 interface identifiers. Windows that contain HTML documents always have valid document objects; windows that contain documents in other formats might not have valid document objects.In general, before you attempt to get the document object for a window that is not the current window, make sure that the source file associated with that window is an HTML document file or a file that can be represented as an HTML document, for example, a text file.
请大家帮助,谢谢。