解决VC6.0使用winhttp.h问题

21 篇文章 0 订阅

本文转自

一、解决错误(fatal error C1083: Cannot open include file: 'winhttp.h': No such file or directory)

      1、下载并安装SDK。

       这里不详细介绍了,可以去搜索一下或查看

       http://hi.baidu.com/hrsoft%5Fcn/blog/item/c020d909eb2489a52eddd488.html

       2、VC6中添加路径。

      

                                         (1)

                

                                 (2)

 

二、解决错误(

       error C2146: syntax error : missing ';' before identifier 'dwResult'

       error C2501: 'DWORD_PTR' : missing storage-class or type specifiers

       error C2501: 'dwResult' : missing storage-class or type specifiers

       error C2061: syntax error : identifier 'DWORD_PTR'

       

 

     再将刚添加的路径上移至最前就可以了!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以使用 Winhttp.dll 来下载图片。下面是一个使用 Winhttp.dll 下载图片的示例代码: ```cpp #include <Windows.h> #include <Winhttp.h> #include <iostream> #include <fstream> #pragma comment(lib, "Winhttp.lib") int main() { // 创建 WinHTTP 会话 HINTERNET hSession = WinHttpOpen(L"WinHTTP Example/1.0", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0); if (hSession) { // 打开连接 HINTERNET hConnect = WinHttpOpenRequest(hSession, L"GET", L"http://example.com/image.jpg", NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, 0); if (hConnect) { // 发送请求 if (WinHttpSendRequest(hConnect, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0)) { // 接收响应 if (WinHttpReceiveResponse(hConnect, NULL)) { // 创建文件并写入数据 std::ofstream file("image.jpg", std::ofstream::binary); if (file) { BYTE buffer[4096]; DWORD bytesRead; while (WinHttpReadData(hConnect, buffer, sizeof(buffer), &bytesRead) && bytesRead > 0) { file.write(reinterpret_cast<const char*>(buffer), bytesRead); } file.close(); std::cout << "图片下载成功!" << std::endl; } else { std::cerr << "无法创建文件!" << std::endl; } } else { std::cerr << "无法接收响应!" << std::endl; } } else { std::cerr << "无法发送请求!" << std::endl; } // 关闭连接 WinHttpCloseHandle(hConnect); } else { std::cerr << "无法打开连接!" << std::endl; } // 关闭会话 WinHttpCloseHandle(hSession); } else { std::cerr << "无法创建会话!" << std::endl; } return 0; } ``` 在上面的示例代码中,将 `http://example.com/image.jpg` 替换为你想要下载的图片的 URL。此代码将创建一个名为 "image.jpg" 的文件,并将下载的图片数据写入其中。你可以根据需要修改保存文件的路径和文件名。 请注意,此示例仅适用于 Windows 平台,并且需要链接 Winhttp.lib 库。如果你使用的是其他平台或开发环境,请相应地进行修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值