IBrowser :: get_LocationURL的问题 [英] problem with IBrowser::get_LocationURL
本文介绍了IBrowser :: get_LocationURL的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!我的小应用程序有问题.我处理了IE的单击,并希望获得IE所在的URL.调用"get_LocationURL"函数后,变量"bufferScript"的长度为0.有人可以告诉我此小代码中的错误在哪里吗?在此先感谢.
Hi all! there is a problem in my small application. I handle a click on IE, and want to get the URL in which IE is. After calling "get_LocationURL" function the length of variable "bufferScript" is 0. Can somebody tell me where the bug is in this small code?? thanks in advance.
<br />
typedef HRESULT (WINAPI *AttachCtrl)(IUnknown*, HWND,IUnknown**);<br />
<br />
LRESULT CHookDlg::OnMouseLBDown( WPARAM, LPARAM lParam )<br />
{<br />
IWebBrowser2 *pIwb;<br />
OleInitialize( 0 );<br />
CoCreateInstance( CLSID_InternetExplorer, NULL, CLSCTX_SERVER,IID_IWebBrowser2, (void**)&pIwb );<br />
if( pIwb )<br />
{<br />
VARIANT vEmpty;<br />
VARIANT_BOOL bBusy = VARIANT_TRUE;<br />
VariantInit( &vEmpty );<br />
<br />
HINSTANCE hIEInstance = LoadLibrary( "atl.dll" );<br />
<br />
AttachCtrl AtlAxAttachControl = (AttachCtrl)GetProcAddress( hIEInstance, "AtlAxAttachControl" );<br />
<br />
AtlAxAttachControl( pIwb, ::GetForegroundWindow(), 0 );<br />
<br />
BSTR bufferScript;<br />
pIwb->get_LocationURL( &bufferScript );<br />
pIwb->get_Name( &bufferScript );<br />
pIwb->get_Path( &bufferScript );<br />
<br />
<br />
pIwb->Quit();<br />
pIwb->Release();<br />
<br />
FreeLibrary( hIEInstance );<br />
}<br />
<br />
return 0;<br />
}<br />
P.S.
在Pallini的答案"之后,我添加了代码行,并调用了2个函数:get_Name& get_Path.他们的结果还可以.因此,问题仅在get_LocationURL中.
P.S.
After Pallini''s "answer" I added to lines, with calling 2 functions: get_Name & get_Path. Their results is OK. So the problem only in get_LocationURL.
推荐答案
为什么不检查get_LocationURL
方法的返回值?
:)
Why don''t you checkget_LocationURL
method return value?
:)
这篇关于IBrowser :: get_LocationURL的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文