首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在VisualStudio6.0中使用WinHTTP

在VisualStudio6.0中使用WinHTTP
EN

Stack Overflow用户
提问于 2016-12-20 14:12:53
回答 2查看 1.3K关注 0票数 3

我正在维护一个用VisualStudio6.0编写的遗留应用程序。

我需要用调用WinHTTP API来替换部分代码。

我已经在VisualStudio6.0测试项目中创建了一个小演示,这样我就可以看到事情会如何发展。

当我构建代码时,我会得到以下错误(同样的代码在Visual 2013中完美地工作):

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

我添加了包含路径,如下所示:

我在库中添加了路径,如下所示:

在尝试编译之后,我得到了以下内容:

代码语言:javascript
运行
复制
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 C2065: '__in' : undeclared identifier
error C2143: syntax error : missing ')' before 'const'
warning C4229: anachronism used : modifiers on data are ignored
error C2491: 'WinHttpTimeFromSystemTime' : definition of dllimport data not allowed
error C2059: syntax error : ')'
error C2065: '__in_z' : undeclared identifier
error C2146: syntax error : missing ')' before identifier 'LPCWSTR'
warning C4229: anachronism used : modifiers on data are ignored
error C2491: 'WinHttpTimeToSystemTime' : definition of dllimport data not allowed
error C2059: syntax error : ')'
error C2065: '__in_ecount' : undeclared identifier
error C2065: 'dwUrlLength' : undeclared identifier
error C2146: syntax error : missing ')' before identifier 'LPCWSTR'
warning C4229: anachronism used : modifiers on data are ignored
error C2491: 'WinHttpCrackUrl' : definition of dllimport data not allowed
error C2059: syntax error : ')'
error C2146: syntax error : missing ')' before identifier 'LPURL_COMPONENTS'
warning C4229: anachronism used : modifiers on data are ignored
error C2491: 'WinHttpCreateUrl' : definition of dllimport data not allowed
error C2059: syntax error : ')'
error C2065: '__in_z_opt' : undeclared identifier
error C2146: syntax error : missing ')' before identifier 'LPCWSTR'
warning C4229: anachronism used : modifiers on data are ignored
error C2491: 'WinHttpOpen' : definition of dllimport data not allowed
error C2440: 'initializing' : cannot convert from 'int' to 'void *'
            Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
error C2059: syntax error : ')'
error C2061: syntax error : identifier '__out_bcount_part'
error C2061: syntax error : identifier '__in_bcount_opt'
error C2061: syntax error : identifier '__out_data_source'
error C2059: syntax error : 'return'
warning C4518: '__declspec(dllimport ) ' : storage-class or type specifier(s) unexpected here; ignored
error C2146: syntax error : missing ';' before identifier 'BOOL'
    workaround.h(426) : fatal error C1004: unexpected end of file found

在将新添加的路径移到顶部后,我只有一个错误:

c:\program files (x86)\microsoft sdks\windows\v7.1a\include\specstrings.h(11) : fatal error C1083: Cannot open include file: 'sal.h': No such file or directory

我已经将sal.hConcurrencySal.h复制/粘贴到as 98/Include中,并且有copy/粘贴目录CodeAnalysis。

现在我得到了以下错误:

代码语言:javascript
运行
复制
c:\program files (x86)\microsoft visual studio\vc98\include\sal.h(708) : warning C4068: unknown pragma
c:\program files (x86)\microsoft visual studio\vc98\include\sal.h(1472) : warning C4068: unknown pragma
c:\program files (x86)\microsoft visual studio\vc98\include\sal.h(2866) : warning C4005: '__useHeader' : macro redefinition
        c:\program files (x86)\microsoft sdks\windows\v7.1a\include\sal_supp.h(57) : see previous definition of '__useHeader'
c:\program files (x86)\microsoft visual studio\vc98\include\sal.h(2876) : warning C4005: '__on_failure' : macro redefinition
        c:\program files (x86)\microsoft sdks\windows\v7.1a\include\specstrings_supp.h(77) : see previous definition of '__on_failure'
c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winnt.h(3994) : warning C4035: 'ReadPMC' : no return value
c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winnt.h(4023) : warning C4035: 'ReadTimeStampCounter' : no return value
c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winnt.h(12804) : error C2144: syntax error : missing ';' before type 'int'
c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winnt.h(12804) : error C2501: '__inner_checkReturn' : missing storage-class or type specifiers
c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winnt.h(12804) : fatal error C1004: unexpected end of file found

现在我在谷歌上搜索这个问题的解决方案.

问题:

您能否向我解释如何在VisualC++6中设置一个项目,以便它可以使用WinHTTP API (当然,如果可能的话)?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-12-20 15:58:16

您不能在MSVC 6中使用WindowsV7.1SDK。此版本太新,不兼容这种旧版本的编译器。

您将需要使用一个与MSVC 6兼容的旧版本的SDK,最后一个兼容版本是2003年2月的版本。如果您有MSDN订阅,仍然可以下载。我不知道你能在网上找到它,否则,我看到的所有链接都死了。

如果您找不到这个版本的SDK,或者它不包括对WinHTTP v5.1的支持,那么您可能需要回到WinHTTP v5.0。这是一个单独的可再发行版(winhttp5.dll),Windows 4和IE5.01及更高版本都支持它。使用MSVC 6应该没有问题。不幸的是,这也是不受支持的,并且不再可供下载(从2004年10月起)。你得有一本旧的。

动态调用所需的函数是最后的,最后的选择。您需要手动编写声明(或者从最新的SDK标头中移植声明),然后使用LoadModuleGetProcAddress动态调用导出的函数。这是一项很忙的工作。也许首先要研究如何升级编译器工具链。确保不会更容易地更新到更新版本的MSVC。很可能是这样;向后兼容性比向前兼容性容易得多。

票数 3
EN

Stack Overflow用户

发布于 2016-12-21 11:59:55

在VC6.0中使用WinHTTP是完全可行的。您可以在SDK5.0中使用它,即

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41244337

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档