创建 IWebBrowser2 控件
Creating an IWebBrowser2 control
我只想成功添加到我的window,却出乎意料的困难
我试过了
#include "windef.h"
#include "winbase.h"
#include "initguid.h"
#include "ole2.h"
#include "olectl.h"
#include "shobjidl.h"
#include "shlguid.h"
#include "exdispid.h"
#include <objidl.h>
#include "OleIdl.h"
#include "Objbase.h"
#include <exdisp.h>
#include <exdispid.h>
...
IWebBrowser2* pBrowser2;
HRESULT hr = CoCreateInstance(CLSID_InternetExplorer, NULL,
CLSCTX_ALL, IID_IWebBrowser2, (void**)&pBrowser2);
得到
error: 'CLSID_InternetExplorer' undeclared (first use in this function)
HRESULT hr = CoCreateInstance(CLSID_InternetExplorer,
我也试过了
CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_LOCAL_SERVER,
IID_IWebBrowser2, (void**)&pBrowser2);
这个至少可以编译,但是没有添加任何东西到 window:
hr = OleCreate(&CLSID_WebBrowser, &IID_IOleObject, 1/*OLERENDER_DRAW*/, 0,
&ClientSite, &Storage, (void**)&mpWebObject);
我尝试了所有可以在网上找到的 headers 和库(如您所见)。
这是我 link:
的库
gcc -lmingw32 -mwindows -luser32 -lgdiplus -lole32 -luuid -loleaut32 -lcomctl32 -lcomdlg32 -ladvapi32 -loleaut32 -lshdocvw -lmf -lmfuuid
谢谢!
显然 MinGW 不支持 IWebBrowser2。该代码在 Visual Studio.
中运行良好
首先包含这些头文件:
#include <windows.h>
#include <objbase.h>
#include <ExDisp.h>
#include <ExDispid.h>
然后这个:
IWebBrowser2* pBrowser2 = nullptr;
HRESULT hr;
hr = CoCreateInstance(__uuidof(WebBrowser), NULL, CLSCTX_INPROC, __uuidof(IWebBrowser2), (void**)pBrowser2);
__uuidof 宏的使用解决了与外部定义的 guid 的链接问题。
你可以试试MinGW-w64。
这是 MinGW 的一个分支,除了同时支持 32 位和 64 位构建之外,它还在更积极的开发中。特别是,改进了 Windows API headers.
我只想成功添加到我的window,却出乎意料的困难
我试过了
#include "windef.h"
#include "winbase.h"
#include "initguid.h"
#include "ole2.h"
#include "olectl.h"
#include "shobjidl.h"
#include "shlguid.h"
#include "exdispid.h"
#include <objidl.h>
#include "OleIdl.h"
#include "Objbase.h"
#include <exdisp.h>
#include <exdispid.h>
...
IWebBrowser2* pBrowser2;
HRESULT hr = CoCreateInstance(CLSID_InternetExplorer, NULL,
CLSCTX_ALL, IID_IWebBrowser2, (void**)&pBrowser2);
得到
error: 'CLSID_InternetExplorer' undeclared (first use in this function)
HRESULT hr = CoCreateInstance(CLSID_InternetExplorer,
我也试过了
CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_LOCAL_SERVER,
IID_IWebBrowser2, (void**)&pBrowser2);
这个至少可以编译,但是没有添加任何东西到 window:
hr = OleCreate(&CLSID_WebBrowser, &IID_IOleObject, 1/*OLERENDER_DRAW*/, 0,
&ClientSite, &Storage, (void**)&mpWebObject);
我尝试了所有可以在网上找到的 headers 和库(如您所见)。
这是我 link:
的库gcc -lmingw32 -mwindows -luser32 -lgdiplus -lole32 -luuid -loleaut32 -lcomctl32 -lcomdlg32 -ladvapi32 -loleaut32 -lshdocvw -lmf -lmfuuid
谢谢!
显然 MinGW 不支持 IWebBrowser2。该代码在 Visual Studio.
中运行良好首先包含这些头文件:
#include <windows.h>
#include <objbase.h>
#include <ExDisp.h>
#include <ExDispid.h>
然后这个:
IWebBrowser2* pBrowser2 = nullptr;
HRESULT hr;
hr = CoCreateInstance(__uuidof(WebBrowser), NULL, CLSCTX_INPROC, __uuidof(IWebBrowser2), (void**)pBrowser2);
__uuidof 宏的使用解决了与外部定义的 guid 的链接问题。
你可以试试MinGW-w64。
这是 MinGW 的一个分支,除了同时支持 32 位和 64 位构建之外,它还在更积极的开发中。特别是,改进了 Windows API headers.