我只想把它成功地添加到我的窗口,这是令人惊讶的困难。
我试过了
#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);这个至少会编译,但是窗口中没有添加任何内容:
hr = OleCreate(&CLSID_WebBrowser, &IID_IOleObject, 1/*OLERENDER_DRAW*/, 0,
&ClientSite, &Storage, (void**)&mpWebObject);我尝试了我可以在网络上找到的所有标题和库(如您所见)。
下面是我链接的库:
gcc -lmingw32 -mwindows -luser32 -lgdiplus -lole32 -luuid -loleaut32 -lcomctl32 -lcomdlg32 -ladvapi32 -loleaut32 -lshdocvw -lmf -lmfuuid谢谢!
发布于 2018-02-26 20:07:00
你可以试试MinGW-w64。
这是MinGW的一个分支,它除了支持32位和64位构建之外,还处于更积极的开发中。特别是改进了Windows报头。
发布于 2018-02-26 02:35:08
显然,MinGW不支持IWebBrowser2。代码在中运行良好。
发布于 2018-02-26 02:53:50
首先包括这些头文件:
#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宏的使用解决了外部定义guids的链接问题。
https://stackoverflow.com/questions/48980218
复制相似问题