how to get url and hostname and url text in one page
来源:互联网 发布:疯狂呼叫软件 编辑:程序博客网 时间:2024/05/21 08:53
STDMETHODIMP CIEHlprObj::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags,
DISPPARAMS* pDispParams, VARIANT* pvarResult,
EXCEPINFO* pExcepInfo, UINT* puArgErr)
{
try
{
if(dispidMember == DISPID_DOCUMENTCOMPLETE)
{
/
// m_spWebBrowser2->get_LocationURL(&bstrUrlName); ->
// MessageBox(NULL,"doc","xxxxxxx",MB_OK);
//get document and set document
// CComPtr<IHTMLElement> body;
int ncount=0;
CComPtr<IDispatch> spDispatch;
CComPtr<IHTMLElementCollection> pElementCol;
CComPtr<IHTMLAnchorElement> pLoct;
TCHAR HostName[2*MAX_PATH];
TCHAR HostDesc[2*MAX_PATH];
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDoc2;
HRESULT hRes= m_spWebBrowser2->get_Document(&spDispatch);
IHTMLElement* ptext;
pDoc2 = spDispatch;
if(pDoc2!=NULL)
{
if (SUCCEEDED(pDoc2->get_links(&pElementCol)))
{
// AfxMessageBox("IHTMLElementCollection");
long p=0;
if(SUCCEEDED(pElementCol->get_length(&p)))
if(p!=0)
{
for(long i=0;i<=(p-1);i++)
{
CComBSTR String;
_variant_t index = i;
if(SUCCEEDED(pElementCol->item( index, index, &spDispatch)))
if(SUCCEEDED(spDispatch->QueryInterface( IID_IHTMLAnchorElement,(void **) &pLoct)))
//获得链接
pLoct->get_href(&String);
ZeroMemory(HostName,2*MAX_PATH);
lstrcpy(HostName,_bstr_t(String));
//获得链接的域名
pLoct->get_hostname(&String);
ZeroMemory(HostName,2*MAX_PATH);
lstrcpy(HostName,_bstr_t(String));
if(lstrlen(HostName))
{
//获得链接对应的文字
pLoct->QueryInterface(&ptext);
ptext->get_innerText(&String);
ZeroMemory(HostDesc,2*MAX_PATH);
lstrcpy(HostDesc,_bstr_t(String));
// MessageBox(NULL,HostName,HostName,MB_OK);
}
}
}
}
}
}// if(dispidMember == DISPID_DOCUMENTCOMPLETE)
}
catch (...)
{
}
return S_FALSE;
}
DISPPARAMS* pDispParams, VARIANT* pvarResult,
EXCEPINFO* pExcepInfo, UINT* puArgErr)
{
try
{
if(dispidMember == DISPID_DOCUMENTCOMPLETE)
{
/
// m_spWebBrowser2->get_LocationURL(&bstrUrlName); ->
// MessageBox(NULL,"doc","xxxxxxx",MB_OK);
//get document and set document
// CComPtr<IHTMLElement> body;
int ncount=0;
CComPtr<IDispatch> spDispatch;
CComPtr<IHTMLElementCollection> pElementCol;
CComPtr<IHTMLAnchorElement> pLoct;
TCHAR HostName[2*MAX_PATH];
TCHAR HostDesc[2*MAX_PATH];
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDoc2;
HRESULT hRes= m_spWebBrowser2->get_Document(&spDispatch);
IHTMLElement* ptext;
pDoc2 = spDispatch;
if(pDoc2!=NULL)
{
if (SUCCEEDED(pDoc2->get_links(&pElementCol)))
{
// AfxMessageBox("IHTMLElementCollection");
long p=0;
if(SUCCEEDED(pElementCol->get_length(&p)))
if(p!=0)
{
for(long i=0;i<=(p-1);i++)
{
CComBSTR String;
_variant_t index = i;
if(SUCCEEDED(pElementCol->item( index, index, &spDispatch)))
if(SUCCEEDED(spDispatch->QueryInterface( IID_IHTMLAnchorElement,(void **) &pLoct)))
//获得链接
pLoct->get_href(&String);
ZeroMemory(HostName,2*MAX_PATH);
lstrcpy(HostName,_bstr_t(String));
//获得链接的域名
pLoct->get_hostname(&String);
ZeroMemory(HostName,2*MAX_PATH);
lstrcpy(HostName,_bstr_t(String));
if(lstrlen(HostName))
{
//获得链接对应的文字
pLoct->QueryInterface(&ptext);
ptext->get_innerText(&String);
ZeroMemory(HostDesc,2*MAX_PATH);
lstrcpy(HostDesc,_bstr_t(String));
// MessageBox(NULL,HostName,HostName,MB_OK);
}
}
}
}
}
}// if(dispidMember == DISPID_DOCUMENTCOMPLETE)
}
catch (...)
{
}
return S_FALSE;
}
- how to get url and hostname and url text in one page
- Android open url ,and get page
- How can I get a FlowDocument Hyperlink to launch browser and go to URL in a WPF app?
- PHP: How to Get the Current Page URL
- [JavaScript]How to parse the URL and get the different fragments easily?
- How to get url not reached error in Anodroid Phonegap
- how to blend VB and C# in one project
- get current url in current page
- magento get url and dir
- IE title changes to <afterHash> if the page has a url with '#' , and has flash/swf embedded in it
- Linux: Where to set hostname and how to get IP info, as well as how to set DNS
- How to schedule and get the report in SCOM2012
- How to get parameters from the URL?
- How to Drill Down to External url page. How to Pass url parameters
- How to define One-Many and One-One relationships
- How to add custom fields to Customer Registration and Account page in magento
- Oracle APEX Open a new window/tab page and navigate to a URL
- how to display different title in one master page
- ciscoDHCP配置
- 入门,屏蔽页面JS错误的代码
- [.NET 基于角色安全性验证] 之五:跨应用程序进行 Forms 身份验证
- how to test IEHelper.DLL
- Oracle存储过程的基本语法
- how to get url and hostname and url text in one page
- Oracle 存储过程 触发器用法
- [转] 疯狂代码:大型网站架构系列(未完待续)
- Java常用开源工具概述
- 一个VC读写刷卡器的例子
- 读取 配置文件
- 一个美国老网络工程师,给年轻工程师的忠告
- trac配置(stand-alone server)
- winform中轉Excel檔