收藏 不显示删除回复显示所有回复显示星级回复显示得分回复 麻烦高手帮我运行下,我VS2008里面运行出错啊
// networ kDlg.cpp : 实现文件//
//#include "afxinet.h"
#include "stdafx.h"
#include "network.h"
#include "networkDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// 对话框数据
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// CnetworkDlg 对话框
CnetworkDlg::CnetworkDlg(CWnd* pParent /*=NULL*/)
: CDialog(CnetworkDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CnetworkDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CnetworkDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_BUTTON1, &CnetworkDlg::OnBnClickedButton1)
END_MESSAGE_MAP()
// CnetworkDlg 消息处理程序
BOOL CnetworkDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 将“关于...”菜单项添加到系统菜单中。
// IDM_ABOUTBOX 必须在系统命令范围内。
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
// TODO: 在此添加额外的初始化代码
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
void CnetworkDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// 如果向对话框添加最小化按钮,则需要下面的代码
// 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
// 这将由框架自动完成。
void CnetworkDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // 用于绘制的设备上下文
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 使图标在工作区矩形中居中
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// 绘制图标
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
//当用户拖动最小化窗口时系统调用此函数取得光标
//显示。
HCURSOR CnetworkDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CnetworkDlg::OnBnClickedButton1()
{
01.try
02. {
03.#define MAX_COUNT 1024
04. CInternetSession session(TEXT("session"));
05. INTERNET_PORT nPort = 80;
06. CHttpConnection* pHttpConnect = session.GetHttpConnection(TEXT("passport.), nPort);
07. if(pHttpConnect)
08. {
09. CHttpFile* pFile = pHttpConnect->OpenRequest(CHttpConnection::HTTP_VERB_POST, TEXT("/?ac=login"));
10. if(pFile)
11. {
12. // 这里是请求头信息,由抓包工具得到该信息
13. pFile->AddRequestHeaders(TEXT("POST /?ac=login HTTP/1.1"));
14. pFile->AddRequestHeaders(TEXT("Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"));
15. pFile->AddRequestHeaders(TEXT("Referer: http://passport.));
16. pFile->AddRequestHeaders(TEXT("Accept-Language: zh-cn"));
17. pFile->AddRequestHeaders(TEXT("User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; EasyBits GO v1.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)"));
18. pFile->AddRequestHeaders(TEXT("Content-Type: application/x-www-form-urlencoded"));
19. pFile->AddRequestHeaders(TEXT("Accept-Encoding: gzip, deflate"));
20. pFile->AddRequestHeaders(TEXT("Host: passport.));
21. pFile->AddRequestHeaders(TEXT("Connection: Keep-Alive"));
22. pFile->AddRequestHeaders(TEXT("Cache-Control: no-cache"));
23.// 这里是要提交的数据。说明一下: xxxx@xx.xxx指的是登陆的邮箱的地址,后面的XXXXXXX表示的是登陆的密码,使用的时候换成你自己的即可
24. TCHAR szRequest[MAX_COUNT] = TEXT("login%5Baccount%5D=xxxx@xx.xxx&login%5Bpasswd%5D=XXXXXXX&goto=http%3A%2F%2Fu.);
25. pFile->SendRequest(NULL, 0, szRequest, TEXTcslen(szRequest)+1);
26.
27. CString strStatus(TEXT(""));
28. if(pFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF, strStatus))
29. {
30. AfxMessageBox(strStatus);
31. }
32. pFile->Close();
33. delete pFile;
34. pFile = NULL;
35. }
36. }
37. pHttpConnect->Close();
38. delete pHttpConnect;
39. pHttpConnect =NULL; session.Close();
40. }
41. catch (CInternetException* e)
42. {
43. e->ReportError();
44. e->Delete();
45. }
}