void CIE_TestDlg::OnBtnTest()
{
// TODO: Add your control notification handler code here
UpdateData();
CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded"); //网页的信息头
CString strFormData = "/Up.asp?state=77"; //提交的页面地址信息
CInternetSession InternetSession;
CHttpConnection *PHttpConnection = InternetSession.GetHttpConnection(IP或者站点, (INTERNET_PORT)80);
CHttpFile *pHttpFile = PHttpConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST, strFormData);
if(pHttpFile)
{
pHttpFile->AddRequestHeaders(strHeaders);
pHttpFile->SendRequest(NULL, 0, strFormData.GetBuffer(0), (DWORD)strFormData.GetLength());
//获取网页信息的第一种方法
//char szReceiveBuff[36000];
//int nLen = sizeof(szReceiveBuff);
//memset(szReceiveBuff, 0, nLen);
//pHttpFile->Read(szReceiveBuff, nLen);
//m_strShowInfo = strTemp + "/r/n/r/n" + szReceiveBuff;
// 获取网页信息的第二种方法
CString strTemp;
while(pHttpFile->ReadString(strTemp))
{
m_strShowInfo += strTemp + "/r/n";
}
}
//获取的信息写入文件中
// FILE* fp;
// fp = fopen("1.txt", "wb");
// fwrite(szReceiveBuff, strlen(szReceiveBuff), 1, fp);
// fclose(fp);
if (pHttpFile != NULL)
{
pHttpFile->Close();
delete pHttpFile;
pHttpFile = NULL;
}
if (PHttpConnection != NULL)
{
PHttpConnection->Close();
delete PHttpConnection;
PHttpConnection = NULL;
}
InternetSession.Close();
UpdateData(FALSE);
}
void CIE_TestDlg::OnBtnT()
{
// TODO: Add your control notification handler code here
UpdateData();
CString strFormData = _T("state=77"); //提交的页面地址信息
CString dbg;
dbg.Format( "http://%s/Up.asp?%s", IP或者站点, strFormData );
m_strShowInfo += dbg + "/r/n/r/n";
CInternetSession InternetSession;
CStdioFile* pFile = NULL;
pFile = InternetSession.OpenURL(dbg);
if(pFile)
{
CString strTemp;
while(pFile->ReadString(strTemp))
{
m_strShowInfo += strTemp + "/r/n";
}
pFile->Close();
delete pFile;
pFile = NULL;
}
UpdateData(FALSE);
}