在visual studio 6.0中使用winhttp [英] Use winhttp in visual studio 6.0

查看:114
本文介绍了在visual studio 6.0中使用winhttp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在维护一个用Visual Studio C ++ 6.0编写的遗留应用程序。



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



我在Visual Studio 6.0测试项目中创建了一个小型演示,所以我可以看看情况如何。



当我构建代码我得到以下错误(相同的代码在Visual Studio 2013中完美运行):



致命错误C1083:无法打开包含文件:'winhttp.h':没有这样的文件或目录



我添加了包含路径,就像在这个 [ ^ ]图片。



我添加了库的路径,例如这个 [ ^ ]图片。



尝试编译后我明白了:

I am maintaining a legacy app written in Visual Studio C++ 6.0.

I need to replace portion of the code with calls to WinHTTP API.

I have created small demo in Visual Studio 6.0 test project so I can see how would things go.

When I build the code I get the following error ( the same code works flawlessly in Visual Studio 2013 ) :

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

I have added the Include path, like in this[^] image.

I have added the path to library, like in this[^] image.

After trying to compile I get this:

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'
fatal error C1004: unexpected end of file found



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



c:\ program files( x86)\ microsoft sdks\windows\v7.1a\include\specstrings.h(11):致命错误C1083:无法打开包含文件:'sal.h':没有这样的文件或目录



我有复制/粘贴 sal.h ConcurrencySal.h 进入VC98 / Include,并有复制/粘贴目录 CodeAnalysis



现在我收到以下错误:


After moving the newly added paths to the top, I have got only one error:

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

I have copy/pasted sal.h and ConcurrencySal.h into VC98/Include, and have copy/pasted directory CodeAnalysis as well.

Now I get following errors:

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



问题:



你能解释一下如何设置一个Visual C ++ 6中的项目,所以它可以使用WinHTTP API(当然,如果可能的话)?



我尝试过:



在我正在谷歌搜索解决这个问题...


QUESTION:

Can you explain to me how to set up a project in Visual C++ 6 so it can use WinHTTP API (of course, if it is possible at all) ?

What I have tried:

At the moment I am Googling for a solution to this problem...

推荐答案

您正在尝试使用Windows SDK版本7.1A与Visual Studio 6.这不会工作。



支持Visual Studio 6的最后一个SDK是Microsoft Platform SDK 2003年2月(版本5.2.3790.0)(来源: Microsoft Windows SDK - Wikipedia [ ^ ])。请注意,您必须安装完整的SDK才能包含WinHttp标头和库文件。



所以你有三个选择:

You are trying to use the Windows SDK version 7.1A with Visual Studio 6. This won't work.

The last SDK that supports Visual Studio 6 is the Microsoft Platform SDK February 2003 (version 5.2.3790.0) (source: Microsoft Windows SDK - Wikipedia[^]). Note that you have to install the full SDK to have the WinHttp header and library file included.

So you have three options:


  1. 使用较新的Visual Studio版本构建应用程序的端口
  2. 使用WinINet API而不是WinHTTP API
  3. 安装用于Visual Studio 6的完整PSDK 2003年2月以上


因为winhttp是一个高级API,所以必须包括首先是标准的Windows标题 。这将解决代码中的大多数问题。

正确的方法是使用大括号:

Because winhttp is a high level API you MUST include the standard windows header at first . That will solve the most problems in your code.
the correct way is with braces:
#include <windows.h> 
#include <winhttp.h> 



在最后一个位置设置sdk搜索路径以避免冲突。并且您必须在链接器选项卡上包含winhttp.lib文件。



另请参阅winhttp示例



你最好使用一些永不版本在Visual Studio中,我更喜欢VS 2005或VS 2010。


Set the sdk search path at the last position to avoid collisions. And you must include the winhttp.lib file on the linker tabs.

Take also a look at the winhttp examples from Microsoft.

You better use some never version of Visual Studio, I prefer the VS 2005 or VS 2010.


这篇关于在visual studio 6.0中使用winhttp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆