Click here to Skip to main content
15,880,854 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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.
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.
Posted
Updated 14-Jan-10 21:26pm
v4

1 solution

Why don't you check get_LocationURL method return value?
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900