define _UNICODE 这是最主要的,这样编译时会用 unicode 库。class CString 使用 TCHAR data 类型, 本身就支持 unicode.程序里用 宏 _T 转换普通字符串 到 unicode 程序里用 TCHAR 代替原来用的char.用LPTSTR 代替原来用的 char 用LPCTSTR 代替原来用的 const char*.
用CInternetSession打开url得到一个CHttpFile,用ReadString读取CHttpFile中的内容。
void CReadInternetDataDlg::OnRead() { CInternetSession c ; CHttpFile * p=NULL ; p=(CHttpFile*)c.OpenURL("http://127.0.0.1/web") ; //打开一个URL CString str ; CString info=""; while(p->ReadString(str)) //读取网页数据 info+=str ; (this->GetDlgItem(IDC_EDIT1))->SetWindowText(i...
BOOL bSuccess=fileGet->QueryInfo(HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,&dwStatus,&dwBuffLen); if( bSuccess&&dwStatus>=200&&dwStatus<300) { CStdioFile fileWrite; if(fileWrite.Open(strWriteName, CFile::modeWrite|CFile::modeCreate)) { while(fileGet->ReadString(strSentence)) { fileWrite...
pHttpFile->ReadString(str);char*pStr = str.GetBuffer(str.GetLength());//取得str对象的原始字符串intnBufferSize = MultiByteToWideChar(CP_UTF8,0, pStr, -1, NULL,0);//取得所需缓存的多少wchar_t *pBuffer = (wchar_t*)malloc(nBufferSize *sizeof(wchar_t));//申请缓存空间MultiByteToWideChar(CP...
p=(CHttpFile*)c.OpenURL("http://127.0.0.1/web") ; //打开一个URL CString str ; CString info=""; while(p->ReadString(str)) //读取网页数据 info+=str ; (this->GetDlgItem(IDC_EDIT1))->SetWindowText(info); } 分享到: java 通过 socket 实现 服务器和客户端 ... | 多线程(NSOperat...
if(dwStatusCode == HTTP_STATUS_OK) { CString szData,szAllData; while(cFile->ReadString(szData)) { szAllData += szData; szAllData += "/r/n"; } cFile->Close(); Sess.Close(); CString name = GetFileName(url,TRUE); CFile file(name, CFile::modeCreate | CFile::modeWrite); ...
= nullptr) { // 发送请求 if (pFile->SendRequest()) { CString strResponse; // 读取响应 while (pFile->ReadString(strResponse)) { // 处理响应数据 AfxMessageBox(strResponse); } } else { // 处理发送请求失败的情况 AfxMessageBox(_T("Failed to send request")); } // 关闭文件 pFile...
while(fileGet->ReadString(strSentence)) { fileWrite.WriteString(strSentence+"\n"); } fileWrite.Close(); AfxMessageBox("下载完毕"); } else { AfxMessageBox("本地文件"+strWriteName+"打开出错."); } } else { strSentence.Format("打开网页文件出错,错误码:%d", dwStatus); ...
while(fileGet->ReadString(strSentence)) 28 { 29 fileWrite.WriteString(strSentence+"\n"); 30 } 31 fileWrite.Close(); 32 AfxMessageBox("下载完毕"); 33 } 34 else 35 { 36 AfxMessageBox("本地文件"+strWriteName+"打开出错."); 37