我使用ATL编写了一个ActiveX控件,在一个网页中进行调用。我想在ActiveX中得到那个网页的URL,然后处理这个网页,但是如何在
ActiveX中得到网页的URL呢?
ActiveX中得到网页的URL呢?
解决方案 »
- 怎样把VC编写的的文件生成一个软件
- 急!龚建伟关于串口通信的程序 有问题,期望高手解决!
- 难啊太难了。-------真难,这日子没法过了。
- 新手问题: 请问"abc"和TEXT("abc")有什么区别?
- 我很急!但找不到出问题的原因,请高人指教.这是我另外开的帖再加100
- 新手请教:在ListCtrl的每一行前面加图标的详细过程是怎样的?以及如何实现动态修改图标?
- 较大的程序,如何控制各种界面控制消息呢?
- 怎样把int,long,UINT对象转换为CString
- 如何获取线程的cpu占用率
- 剪切bmp的一部分并转存成JPG文件的问题
- 请问下点击任务栏上的“显示桌面”时,我怎么才能捕捉到这个事件?
- vc6 和 vc7 的问题!急!先谢谢了!
http://expert.csdn.net/Expert/topic/2944/2944033.xml?temp=.1045801
{
SHDocVw::IShellWindowsPtr m_spSHWinds; CComPtr<IDispatch> spDispatch;
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDoc2;
CComPtr<IHTMLElement> pElement;
CComPtr<IHTMLElementCollection> pElementCol;
CComPtr<IHTMLFormElement> pFormElement;
CComPtr<IHTMLInputTextElement> pInputElement;
if(m_spSHWinds==NULL)
{
if(m_spSHWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows))!=S_OK)
{
AfxMessageBox("失败...",MB_ICONINFORMATION);
CoUninitialize();
}
}
if(m_spSHWinds)
{
int n=m_spSHWinds->GetCount();
for(int i=0;i<n;i++)
{
_variant_t v=(long)i;
IDispatchPtr spDisp=m_spSHWinds->Item(v);
SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);//生成一个IE窗口的智能指针
if(spBrowser)
{
//
VARIANT id,index;
if(SUCCEEDED(spBrowser->get_Document(&spDispatch)))
pDoc2 = spDispatch;
if(pDoc2!=NULL)
{
if(SUCCEEDED(pDoc2->get_forms(&pElementCol)))
{
long p=0;
if(SUCCEEDED(pElementCol->get_length(&p)))
if(p!=0)
{
for(long i=0;i<=(p-1);i++)
{
V_VT(&id)=VT_I4;
V_I4(&id)=i;
V_VT(&index)=VT_I4;
V_I4(&index)=0;
if(SUCCEEDED(pElementCol->item(id,index,&spDispatch)))
if(SUCCEEDED(spDispatch->QueryInterface(IID_IHTMLFormElement,(void**)&pFormElement)))
{
long q=0;
if(SUCCEEDED(pFormElement->get_length(&q)))
for(long j=0;j<=(q-1);j++)
{
V_VT(&id)=VT_I4;
V_I4(&id)=j;
V_VT(&index)=VT_I4;
V_I4(&index)=0;
if(SUCCEEDED(pFormElement->item(id,index,&spDispatch)))
if(SUCCEEDED(spDispatch->QueryInterface(IID_IHTMLInputTextElement,(void**)&pInputElement)))
{
CComBSTR value;
CComBSTR type;
pInputElement->get_type(&type);
CString strtype(type);
strtype.MakeUpper();
if(strtype.Find("TEXT")!=-1)
{
pInputElement->get_value(&value);
CString str(value);
if(!str.IsEmpty())
{
m_List.AddString(_bstr_t("文本信息:")+_bstr_t(value));
Log((LPCTSTR)(_bstr_t("文本信息:")+_bstr_t(value)));
//AfxMessageBox(_bstr_t("文本信息:")+_bstr_t(value)+_bstr_t("\n"),MB_ICONINFORMATION);
}
}
else if(strtype.Find("PASSWORD")!=-1)
{
pInputElement->get_value(&value);
CString str(value);
if(!str.IsEmpty())
{
m_List.AddString(_bstr_t("密码信息:")+_bstr_t(value));
Log((LPCTSTR)(_bstr_t("密码信息:")+_bstr_t(value)));
//AfxMessageBox(_bstr_t("密码信息:")+_bstr_t(value)+_bstr_t("\n"),MB_ICONINFORMATION);
}
}
}
}
}
}
}
}
}
//
_bstr_t bsName=spBrowser->GetLocationName();//窗口名称
//AfxMessageBox(bsName,MB_ICONINFORMATION);
spBrowser->AddRef();
void * pData=spBrowser;
//AfxMessageBox((DWORD)(pData),MB_ICONINFORMATION);
}
}
}
}