首页
社区
课程
招聘
[求助]使用COM接口调用Navigate访问百度
发表于: 2019-4-7 21:37 2925

[求助]使用COM接口调用Navigate访问百度

2019-4-7 21:37
2925
先说结果,在CoCreateInstance函数返回0x80080005(服务器运行失败)
网上的一些解释并不能解决问题(诸如必须有GUI等)
源码在此:
#include <Ole2.h>
#include <ExDisp.h>
#include <iostream>

class __declspec(uuid("{D30C1661-CDAF-11D0-8A3E-00C04FC9E26E}")) riid;   // IWebBrowser2
class __declspec(uuid("{0002DF01-0000-0000-C000-000000000046}")) clsid;   // IE

INT testCOM(VOID) {
	OutputDebugString(L"Begin\r\n");

	OleInitialize(NULL);

	const CLSID cClsidIE = __uuidof(clsid);
	const IID cIidIWebBrowser2 = __uuidof(riid);
	LPVOID pFunc = 0;

	HRESULT hRes = CoCreateInstance(cClsidIE, NULL, CLSCTX::CLSCTX_LOCAL_SERVER, cIidIWebBrowser2, &pFunc);
	if (hRes != S_OK) {

		OutputDebugString(L"[Fail]CoCreateInstance\r\n");
		//return 0;
	}
	IWebBrowser2 *pBrowser = static_cast<IWebBrowser2 *>(pFunc);
	if (pBrowser) {
		VARIANT tmp;
		BSTR URL = SysAllocString(L"baidu.com");
		
		OutputDebugString(L"[DBG]pBrowser\r\n");

		pBrowser->Navigate(URL, &tmp, &tmp, &tmp, &tmp);
		SysFreeString(URL);

		hRes = pBrowser->put_Visible(VARIANT_TRUE);

		pBrowser->Release();
	}
	CoUninitialize();

	OutputDebugString(L"End\r\n");

	return 0;
}

[课程]Linux pwn 探索篇!

收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 1421
活跃值: (71)
能力值: ( LV4,RANK:40 )
在线值:
发帖
回帖
粉丝
2
经过更换操作系统的测试,发现在win7是可以弹出浏览器的,但是win10无法弹出,有没有大佬解释下为什么
2019-4-7 21:56
0
雪    币: 3
活跃值: (72)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
策略?
2019-4-8 10:26
0
游客
登录 | 注册 方可回帖
返回
//