dll不支持mfc
想get传递一个参数给http://xxx/xxx.php?action=1,并取得返回值
该怎么做呢?从没接触过 :(
想get传递一个参数给http://xxx/xxx.php?action=1,并取得返回值
该怎么做呢?从没接触过 :(
解决方案 »
- 怎么程序中只有win32 Release版本,不能改成win32 debug版本,请问是什么原因?
- MFC多文档程序的文档之间怎么交互数据?
- 怎么打开文件夹
- 在VC中如何打开一个已有的word文档,并向word里面的表格填写特定的信息。
- 请问用CDC类怎样画出填充色是半透明的矩形?有颜色,但是可以看到图形下面的图形。
- 求助!hook如何获取菜单消息~~~
- 一个比较奇怪的小问题,困扰我一个晚上了!
- 求“购”一个最简单的C/S网络程序(收到发分)
- 是否病毒???
- 一个很急得问题,请各位大哥指教。万分感谢!
- 请问FTP客户端如何实现断点续传?(急啊)
- vc里如何实现 向某个地址如:http://www.test.com/test.asp提交数据?
#include<wininet.h>
#include<iostream.h>void main(int argc, char *argv[])
{
if (argc != 3)
{
cout << "Usage: progress <host> <object>" << endl;
return;
} HINTERNET hSession = InternetOpen("WinInet Progress Sample",
INTERNET_OPEN_TYPE_PRECONFIG,
NULL,
NULL,
0);
HINTERNET hConnection = InternetConnect(hSession,
argv[1], // Server
INTERNET_DEFAULT_HTTP_PORT,
NULL, // Username
NULL, // Password
INTERNET_SERVICE_HTTP,
0, // Synchronous
NULL); // No Context HINTERNET hRequest = HttpOpenRequest(hConnection,
"GET",
argv[2],
NULL, // Default HTTP Version
NULL, // No Referer
(const char**)"*/*\0", // Accept
// anything
0, // Flags
NULL); // No Context
HttpSendRequest(hRequest,
NULL, // No extra headers
0, // Header length
NULL, // No Body
0); // Body length DWORD dwContentLen;
DWORD dwBufLen = sizeof(dwContentLen);
if (HttpQueryInfo(hRequest,
HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER,
(LPVOID)&dwContentLen,
&dwBufLen,
0))
{
// You have a content length so you can calculate percent complete
char *pData = (char*)GlobalAlloc(GMEM_FIXED, dwContentLen + 1);
DWORD dwReadSize = dwContentLen / 10; // We will read 10% of data
// with each read. cout << "Download Progress:" << endl;
cout << " 0----------100%" << endl;
cout << " ";
cout.flush(); DWORD cReadCount;
DWORD dwBytesRead;
char *pCopyPtr = pData;
for (cReadCount = 0; cReadCount < 10; cReadCount++)
{
InternetReadFile(hRequest, pCopyPtr, dwReadSize, &dwBytesRead);
cout << "*";
cout.flush();
pCopyPtr = pCopyPtr + dwBytesRead;
}
// extra read to account for integer division round off
InternetReadFile(hRequest,
pCopyPtr,
dwContentLen - (pCopyPtr - pData),
&dwBytesRead);
// Null terminate data
pData[dwContentLen] = 0; // Display
cout << endl << "Download Complete" << endl;
cout << pData;
}
else
{
DWORD err = GetLastError();
// No content length...impossible to calculate % complete
// Just read until we are done.
char pData[100];
DWORD dwBytesRead = 1;
while (dwBytesRead)
{
InternetReadFile(hRequest, pData, 99, &dwBytesRead);
pData[dwBytesRead] = 0;
cout << pData;
}
}
}
多看看MSDN
wininet和mfc中的afxinet有什么区别?