18,356
社区成员
发帖
与我相关
我的任务
分享
#define GET_WINHTTP_STRING(IWinHttpRequestPtr_Obj,CString_Obj){\
_variant_t varBody=IWinHttpRequestPtr_Obj->GetResponseBody();\
ULONG datalen=varBody.parray->rgsabound[0].cElements;\
char* pContent = (char*)varBody.parray->pvData;\
CString_Obj=pContent;}
CString GetMidSteByLAndR(CString strBuffer, CString strLeft, CString strRight)
{
CString strRet;
int iStart, iEnd;
if (strBuffer.Find(strLeft) != -1)
{
iStart = strBuffer.Find(strLeft);
iStart += strLeft.GetLength();
if (strBuffer.Find(strRight, iStart) != -1)
{
iEnd = strBuffer.Find(strRight, iStart);
strRet=strBuffer.Mid(iStart,iEnd-iStart);
return strRet;
}
}
return strRet;
}
BOOL CMyDialog_GN::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 在此添加额外的初始化
//获取父窗口指针,用来取得网站链接信息
CString strGetUrl;
Cfeifeicms网站应用Dlg* m_pPWnd = (Cfeifeicms网站应用Dlg*)GetParent();
strGetUrl = m_pPWnd->strUrl;
//判断链接是否有加斜杠
if (strGetUrl.Right(1) == _T("/"))
strGetUrl += _T("index.php?s=Admin-Admin-Config");
else
strGetUrl += _T("/index.php?s=Admin-Admin-Config");
//打开请求链接
HRESULT hr=m_pPWnd->m_pHttpReq->Open(_T("GET"),strGetUrl.AllocSysString());
if (FAILED(hr))
return FALSE;
hr = m_pPWnd->m_pHttpReq->Send();
if (FAILED(hr))
return FALSE;
//获取网页返回内容
_bstr_t bstrRes = m_pPWnd->m_pHttpReq->ResponseText;
CString strCntRes = bstrRes;
//调试用的对话框
SetDlgItemText(IDC_EDIT1, strCntRes);
//获取指定网页内容和显示到界面上
CString strWZMC= GetMidSteByLAndR(strCntRes,_T("id=\"site_name\" value=\""),_T("\""));
CString strWZYM= GetMidSteByLAndR(strCntRes, _T("id=\"site_url\" value=\""), _T("\""));
CString strAZLJ= GetMidSteByLAndR(strCntRes, _T("id=\"site_path\" value=\""), _T("\""));
CString strBNXX= GetMidSteByLAndR(strCntRes, _T("id=\"site_icp\" value=\""), _T("\""));
CString strZZYX= GetMidSteByLAndR(strCntRes, _T("id=\"site_email\" value=\""), _T("\""));
CString strZDGJZ= GetMidSteByLAndR(strCntRes, _T("id=\"site_keywords\" value=\""), _T("\""));
CString strZDMS = GetMidSteByLAndR(strCntRes, _T("id=\"site_description\" value=\""), _T("\""));
SetDlgItemText(IDC_EDIT_DLG_FUNCTION_WZMC, strWZMC);
SetDlgItemText(IDC_EDIT_DLG_FUNCTION_WZYM, strWZYM);
SetDlgItemText(IDC_EDIT_DLG_FUNCTION_AZLJ, strAZLJ);
SetDlgItemText(IDC_EDIT_DLG_FUNCTION_BNXX, strBNXX);
SetDlgItemText(IDC_EDIT_DLG_FUNCTION_ZZYX, strZZYX);
SetDlgItemText(IDC_EDIT_DLG_FUNCTION_ZDGJZ, strZDGJZ);
SetDlgItemText(IDC_EDIT_DLG_FUNCTION_ZDMS, strZDMS);
return TRUE;
// return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}