【发布时间】:2018-08-05 10:05:20
【问题描述】:
我只是想成功地将它添加到我的窗口中,并且它已经出乎意料地困难了。
我试过了
#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
谢谢!
【问题讨论】:
-
如果你使用 c - 你需要在链接器输入中包含
Uuid.Lib- 这里定义了CLSID_InternetExplorer和IID_IWebBrowser2。你也需要使用CoCreateInstance(&CLSID_InternetExplorer, NULL, CLSCTX_ALL, &IID_IWebBrowser2, (void**)&pBrowser2); -
但是您包含
-luuid- 您的版本中是否存在CLSID_InternetExplorer和IID_IWebBrowser2?这是来自 ms sdk 吗? -
@RbMm 我怀疑 MinGW 没有这些常量。如果你有 Visual Studio,也许你可以 std::cout 他们?
-
只需查看
uuid.lib- 是否存在CLSID_InternetExplorer和IID_IWebBrowser2。在 ms sdk 中 - 它存在。 -
你使用的是什么 GUI 工具包