手头一个项目,需要在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的下载资源里)。下载链接为: