如何在VC6.0中使用winhttp.h

手头一个项目,需要在VC6.0中,直接使用winhttp.h。但是,在工程中加入代码后,编译出错:

fatal error C1083: Cannot open include file: 'winhttp.h': No such file or directory

在网上找到资料,解决了此问题。现把解决过程贴出:

一、下载并安装SDK

最后一个支持VC6的SDK:Platform SDK February 2003:

http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm

上面的页面已经打不开了,不过下面的文件仍然能下载。链接如下:

http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.1.cab
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.2.cab
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.3.cab
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.4.cab
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.5.cab
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.6.cab
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.7.cab
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.8.cab
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.9.cab
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.10.cab
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.11.cab
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.12.cab
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.13.cab
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.bat
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/Extract.exe

处理过程:

1. 下载后全部放在一个文件夹中。如d:\temp

2. 进入命令行方式,转到d:\temp

3. 输入PSDK-FULL d:\sdk,注意后面要给出解压到的文件夹(如 d:\sdk)。然后用窗口方式进入d:\sdk中,找到Setup就可以安装了。

二、设置SDK项目路径

如下图所示,添加Include目录,Lib目录。




当然,我们可以不用下载完整的SDK,而是直接使用SDK提供的winhttp.h和winhttp.lib。

将SDK中的winhttp.h和winhttp.lib加入工程中,我们发现还是会产生编译错误:

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'
error C2061: syntax error : identifier 'DWORD_PTR'
error C2061: syntax error : identifier 'DWORD_PTR'

这是因为类型DWORD_PTR不识别。没关系,我们在winhttp.h中,把DWORD_PTR重定义为DWORD就可以了。为方便以后使用,我上传了一个可用的winhttp包(不知道怎么在博客中上传文件,只好放在CSDN的下载资源里)。下载链接为:

http://download.csdn.net/detail/zwz1984/5094712

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值