HttpWebRequest和HttpWebResponse的C ++接口版本 [英] C++ interface version of HttpWebRequest and HttpWebResponse

查看:93
本文介绍了HttpWebRequest和HttpWebResponse的C ++接口版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想知道如何在ATL c ++项目中使用HttpWebRequest和HttpWebResponse .net framework类是C ++中为webrequest类公开的任何接口,目前我们还没有c#项目,因此我们正在寻找替代接口.

We are wondering how to use HttpWebRequest and HttpWebResponse .net framework Class in ATL c++ project is their any interface exposed for webrequest class in C++, currently we cannot have a c# project so we are looking for alternative interface.

任何帮助将不胜感激.拉玛南

Any help will be greatly appreciated. Ramanand.

推荐答案

您有以下选择:

1)将托管的HttpWebRequest代码写入C#文件,并将其编译为DLL.使用RegAsm.exe将其注册为COM对象.使用C/C ++应用程序中的COM对象.

1) Write your managed HttpWebRequest code into a C# file, and compile it as a DLL. Use RegAsm.exe to register it as a COM object. Use the COM object from the C/C++ application.

2)正如迈克尔在上面建议的那样,使用托管C ++编写代码,并与C/C ++代码的其他部分互操作/接口.

2) As Michael has suggested above, use Managed C++ to write the code, and interop/interface with other parts of your C/C++ code.

3)不要使用托管代码!使用特定于平台的库-例如, WinHTTP 来自Microsoft的经过了良好的测试,并且支持客户端和服务器端操作.您还可以使用 Wininet 这是什么由Internet Explorer使用,但是不建议在中间层方案中使用.

3) Dont use managed code! Use the platform specific libraries - for eg, WinHTTP from Microsoft is well tested, and supported for both client side and server side operations. You can also use Wininet which is what is used by Internet Explorer, however it is not recommended for use in Middle-tier scenarios.

因此,除非您真的需要由System.Net托管代码名称空间提供的某些东西在Wininet/WinHTTP中不可用,否则我不会选择托管代码.托管代码将带来内存和cpu开销,如果您要做的只是下载网页,则实际上并不需要这些开销.

So,unless you really need something that is offered by System.Net managed code namespace that is not available on Wininet/WinHTTP, I would not opt for managed code. Managed code will bring in memory and cpu overhead that is really not needed if all you are doing is downloading web pages.

这篇关于HttpWebRequest和HttpWebResponse的C ++接口版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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