Common HTTP and FTP WinInet APIs

两路半桥LLC谐振变换器软开关Simulink仿真(模拟谐振参数不同、分裂电容) 内容概要:本文介绍了“两路半桥LLC谐振变换器软开关Simulink仿真”资源包,重点在于基于Simulink平台对两路半桥LLC谐振变换器进行高精度建模与动态仿真,特别考虑了谐振参数不一致及分裂电容等非理想工况对系统性能的影响。该仿真模型不仅涵盖了主电路拓扑、软开关实现机制与谐振网络设计,还深入分析了不同参数配置下系统的启动特性、稳态效率、动态响应及软开关条件的满足情况。通过参数扫描与对比仿真,帮助用户掌握LLC变换器的关键设计要素与优化方法,具备较强的工程指导价值和科研教学意义。; 适合人群:电力电子、电气工程及其自动化等相关专业的高校师生,以及从事高频开关电源、新能源变换器、车载充电机等领域的研发工程师和技术人员。; 使用场景及目标:① 掌握两路并联半桥LLC谐振变换器的建模与仿真方法;② 理解软开关技术在提升变换器效率与降低EMI方面的关键作用;③ 分析谐振参数偏差与分裂电容结构对系统均流特性、增益曲线及软开关范围的影响;④ 支持科研项目中的拓扑验证、控制策略开发与故障工况分析; 阅读建议:建议结合Simulink仿真模型与配套说明文档进行学习,重点关注谐振腔参数设置、驱动时序设计及软开关波形观测;可通过调整谐振电感、电容值或引入参数失配,观察系统行为变化,深入理解LLC变换器的稳定边界与优化设计原则。 立即下载
 

This chapter covers most used WinInet APIs with sample code. I don't see any use of Gopher protocol these days, so I will skip that part for now.

WinInet HTTP APIs

Here is WinInet HTTP APIs hierarchy. To use an Http API, you have to go through the heirarchy. 



Before using any HTTP functions, you must be aware of InternetConnect funtion. Here is syntax for InternetConnect.

HINTERNET InternetConnect(IN HINTERNET hInternetSession, IN LPCSTR lpszServerName, IN INTERNET_PORT nServerPort, IN LPCSTR lpszUsername, IN LPCSTR lpszPassword, IN DWORD dwService, IN DWORD dwFlags, IN DWORD dwContext );

Where hInternetSession is handle retured by InternetOpen. Parameter lpszServerName is name of the server (a host name or host IP). The next parameter, nServerPort allows you to specify a port number. Here are default values for this parameter:

nServerPortValue Description
INTERNET_DEFAULT_FTP_PORTUses the default port for FTP server, port 21.
INTERNET_DEFAULT_GOPHER_PORTUses the default port for Gopher server, port 70.
INTERNET_DEFAULT_HTTP_PORTUses the default port for HTTP server, port 80.
INTERNET_DEFAULT_HTTPS_PORTUses the default port for FTP server or HTTPS, port 443.
INTERNET_DEFAULT_SOCKS_PORTUses the default port for Socks firewall servers, port 1080.
INTERNET_INVALID_PORT_NUMBERUses the default port for the service specified by dwService

Parameter lpszUsername and lpszPassword are UserID and passwords. Next parameter, dwService has three values:

dwServiceValue Description
INTERNET_SERVICE_FTPFTP service.
INTERNET_SERVICE_GOPHERGopher service.
INTERNET_SERVICE_HTTPHTTP service.

Here is an example:

HINTERNET hConnection = InternetConnect( hSession, "
www.dotnetheaven.com", INTERNET_DEFAULT_HTTP_POST, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0 );

Here is a list of HTTP APIs:

HTTP APIsDescription
HttpOpenRequest Opens an HTTP request. You need to pass Internet connection as an input parameter to this function.
HTTPQueryInfo Queries information about a request.
InternetErrorDlg Displays predefined dialog for common Internet errors.
HttpAddRequestHeaders Adds HTTP request headers to the HTTP request handle.
HttpSendRequestSends actual request to the server. This request may be GET or POST.

HttpOpenRequest

This is the first HTTP function, which should be called after InternetConnect. To open an HTTP connection, InternetConnect must pass its third parameter value as INTERNET_DEFAULT_HTTP_PORT. This function sends a request to get or retrieve data depends on the method. Here is syntax:

HINTERNET HttpOpenRequest(IN HINTERNET hHttpSession,IN LPCSTR lpszVerb,    IN LPCSTR lpszObjectName,IN LPCSTR lpszVersion,IN LPCSTR lpszReferer,    IN LPCSTR FAR * lpszAcceptTypes,IN DWORD dwFlags,IN DWORD dwContext);

First line of every HTTP request is a combination of three elements: Method, URI, and Protocol Version. Three parameters lpszVerb, lpszObjectName, and lpszVersion of HttpOpenRequest make first line of HTTP request.

Parameters Description
hHttpSession Handle to the HTTP session returned by InternetConnect.
lpszVerb Address of string containing HTTP method. If you pass NULL, default method is GET.
lpszObjectName URI
lpszVersion Protocol version. If you pass NULL, default is HTTP/1.0.
lpszReferer 
lpszAcceptTypes 
dwFlags 
dwContext HTTP service.

Here is how to use this function:

HINTERNET hRequest = HttpOpenRequest( hConnection, "GET", "", NULL, NULL, INTERNET_FLAG_RELOAD, 0  );

We will see all the APIs in out example. For more details, you can see MSDN.

HttpSendRequest

Another important HTTP function is HttpSendRequest. This function actually sends a request to Http server. This request may be to post or to get data from the server. It depends on the HttpOpenRequest handle.

Syntax:

BOOL HttpSendRequest( IN HINTERNET hHttpRequest, IN LPCSTR lpszHeaders,    IN DWORD dwHeadersLength, IN LPVOID lpOptional, DWORD dwOptionalLength);

Parameters Description
hHttpRequest Handle of HttpOpenReqest
lpszHeaders NULL
dwHeaderLength 0
lpOptional NULL
dwOptionLength 0

Here is how to use this function:

HttpSendRequest( hData, NULL, 0, NULL, 0);

Example: Now let's see how to use all these functions in our example. This example shows how to download contents of a page using HTTP API functions.

HINTERNET hINet, hConnection, hData;
CHAR buffer[2048] ;
CString m_strContents ;
DWORD dwRead, dwFlags, dwStatus ;
hINet = InternetOpen("InetURL/1.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
if ( !hINet )
{
AfxMessageBox("InternetOpen Failed");
return;
}
try
{
hConnection = InternetConnect( hINet, "
www.dotnetheaven.com", 80, " "," ", INTERNET_SERVICE_HTTP, 0, 0 );
if ( !hConnection )
{
InternetCloseHandle(hINet);
return;
}
// Get datahData = HttpOpenRequest( hConnection, "GET", "/uicsa/index.htm", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0 );
if ( !hData )
{
InternetCloseHandle(hConnection);
InternetCloseHandle(hINet);
return;
}
HttpSendRequest( hData, NULL, 0, NULL, 0);
while( InternetReadFile( hData, buffer, 255, &dwRead ) )
{
if ( dwRead == 0 )
return;
buffer[dwRead] = 0;
m_strContents += buffer;
}
}
catch( CInternetException* e)
{
e->ReportError();
e->Delete();
}
InternetCloseHandle(hConnection);InternetCloseHandle(hINet);
InternetCloseHandle(hData);

HttpAddRequestHeaders

You can add, replace or remove headers to your HTTP request by using this function. Add, replace, or remove depends on dwModifiers parameter. Ok, here is the syntax:

BOOL HttpAddRequestHeaders( IN HINTERNET hHttpRequest, IN LPCSTR lpszHeaders,    IN DWORD dwHeadersLength,  IN DWORD dwModifiers);

Parameters Description
hHttpRequest Handle of http request.
lpszHeaders Header you want to add.
dwHeadersLengthLength of the header.
dwModifierswhat kind of request is it? Add, replace or remove.

Ok, here is an example:

char* chHead = "Accept: image/*/r/n" ; HttpAddRequestHeaders( hHttpHandle, chHead, -1, HTTP_ADDREQ_FLAG_ADD);

HttpQueryInfo

This function allows you to retrieve information about a give HTTP request. Here is the syntax:

BOOL HttpQueryInfo(IN HINTERNET hHttpRequest, IN DWORD dwInfoLevel,    IN LPVOID lpvBuffer,  IN LPDWORD lpdwBufferLength,IN OUT LPDWORD lpdwIndex);

ParametersDescription
hHttpRequest Handle of http request.
dwInfoLevelType of information you are interested in.
lpvBufferBuffer.
lpdwBufferLengthBuffer size
lpdwIndexIndex

Ok, here is an example:

CHAR chBuff[1024];DWORD dwLen 1024;BOOL bRet;bRet = HttpQueryInfo( hRequest, HTTP_QUERY_CUSTOM, chBuff, &dwLen, NULL);
 
WinInet FTP APIs

Here is a list of ftp functions. All FTP functions are easy to understand and use. There is nothing to explain. I have sample examples for most of the functions.

Function Description
FtpCreateDirectory Creates a new directory.
FtpDeleteFileDeletes a file.
FtpFindFirstFileSearches the specified directory of the given FTP session. File and directory entries are returned to the application in the WIN32_FIND_DATA structure.
FtpGetCurrentDirectory Retrieves the current directory for the specified FTP session.
FtpGetFileRetrieves a file from the FTP server and stores it under the specified file name, creating a new local file in the process.
FtpGetFileSizeRetrieves the file size of the requested FTP resource.
FtpOpenFileInitiates access to a remote file on an FTP server for reading or writing.
FtpPutFileStores a file on the FTP server.
FtpRemoveDirectoryRemoves the specified directory.
FtpRenameFileRenames a file.
FtpSetCurrentDirectoryChanges to a different working directory.

FtpCreateDirectory

This function creates a directory on the FTP server.

Syntax:

BOOL FtpCreateDirectory(IN HINTERNET hConnect, IN LPCTSTR lpszDirectory );

Sample:

if (!FtpCreateDirectory(g_hConnection, "NewDir"))
DoSomething();

FtpDeleteFile

This function deletes a file from the FTP server. Nothing to explain here :). Here is the syntax:

BOOL FtpDeleteFile( IN HINTERNET hConnect, IN LPCTSTR lpszFileName);

Sample:

if (!FtpDeleteFile(g_hConnection, strFileName))
DoSomething();

FtpFindFirstFile

This function finds a file on the FTP server and help InternetFindNextFile to find files on the server.

Syntax:

HINTERNET FtpFindFirstFile(IN HINTERNET hConnect,IN LPCTSTR lpszSearchFile,    OUT LPWIN32_FIND_DATA lpFindFileData, IN DWORD dwFlags, IN DWORD_PTR dwContext );

Sample:

CString strFileName = "mcb.asp";
WIN32_FIND_DATA FindFileData;
HINTERNET hFindFile=NULL;
m_RemoteList.ResetContent();
if (hFindFile)
InternetCloseHandle(hFindFile);
hFindFile = FtpFindFirstFile(g_hConnection, szFileName, &FindFileData, INTERNET_FLAG_RELOAD, 0);
if (hFindFile)
{
if ( (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY )
strFileName.Format("%s <DIR>", FindFileData.cFileName);
else
strFileName = FindFileData.cFileName;
m_RemoteList.AddString(strFileName);
while(InternetFindNextFile(hFindFile, &FindFileData))
{
if ( (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY )
strFileName.Format("%s <DIR>", FindFileData.cFileName);
else
strFileName = FindFileData.cFileName;
m_RemoteList.AddString(strFileName);
}
InternetCloseHandle(hFindFile);
}

FtpGetCurrentDirectory

This function returns the current active directory of the FTP server. All FTP function applies to current active directory. So this function is plays an important role.

Syntax:

BOOL FtpGetCurrentDirectory(IN HINTERNET hConnect,OUT LPTSTR lpszCurrentDirectory,    IN OUT LPDWORD lpdwCurrentDirectory);

Sample:

char szDir[255];
DWORD dwLen = 255;
//get the current remote directory
if (!FtpGetCurrentDirectory(g_hConnection, szDir, &dwLen))
DoSomething();

FtpGetFile

This function retrieves a file from the FTP server and stores on the local system. Here is the syntax:

BOOL FtpGetFile(IN HINTERNET hConnect, IN LPCTSTR lpszRemoteFile, IN LPCTSTR                lpszNewFile, IN BOOL fFailIfExists,IN DWORD dwFlagsAndAttributes,IN DWORD dwFlags,IN DWORD_PTR dwContext);
 
FtpGetFileSize

Retrieves the file size of the requested FTP resource.

Syntax:

DWORD FtpGetFileSize(IN HINTERNET hFile, OUT LPDWORD lpdwFileSizeHigh);
 
FtpOpenFile

Initiates access to a remote file on an FTP server for reading or writing.

Syntax:

HINTERNET FtpOpenFile (IN HINTERNET hConnect,IN LPCTSTR lpszFileName,IN DWORD dwAccess, IN DWORD dwFlags,IN DWORD_PTR dwContext);

FtpPutFile

Send a local file on the FTP server.

Syntax:

BOOL FtpPutFile(IN HINTERNET hConnect,IN LPCTSTR lpszLocalFile,IN LPCTSTR lpszNewRemoteFile, IN DWORD dwFlags,IN DWORD_PTR dwContext);
DWORD dwFlags;
if (m_lMode == MODE_ASCII) 
dwFlags = FTP_TRANSFER_TYPE_ASCII;
else  
dwFlags = FTP_TRANSFER_TYPE_BINARY;
BOOL bRet = FtpPutFile(g_hConnection, szLocalFile, szRemoteFile, dwFlags, 0);

FtpRemoveDirectory

Removes the specified directory on the FTP server.

Syntax:

BOOL FtpRemoveDirectory(IN HINTERNET hConnect,IN LPCTSTR lpszDirectory)
 
FtpRenameFile

Renames a file stored on the FTP server.

Syntax:

BOOL FtpRenameFile(IN HINTERNET hConnect,IN LPCTSTR lpszExisting,IN LPCTSTR lpszNew);

FtpSetCurrentDirectory Function

Change to a different working directory on the FTP server.

Syntax:

BOOL FtpSetCurrentDirectory(IN HINTERNET hConnect,IN LPCTSTR lpszDirectory);

Other chapters of this tutorial

ADS新手必看:ICCAP数据导入与导出CSV的完整流程(附常见问题解决) 本文为ADS新手详细讲解了如何将ICCAP测试数据导入ADS进行仿真分析,并导出为通用CSV格式的完整流程。内容涵盖文件格式解析、导入设置、数据验证、处理技巧及常见问题排查,重点解决了数据文件导入过程中的兼容性与单位映射等核心难点,帮助射频工程师高效连接测量与仿真环节。 阅读详情

相关推荐

基于MicroPython的ESP32与微信小程序MQTT通信实战

本文详细介绍了基于MicroPython的ESP32与微信小程序通过MQTT协议实现远程控制的完整实战方案。项目利用巴法云作为免费MQTT服务器,提供了从设备端编程、小程序开发到通信调试的全流程指南,帮助开发者快速构建低成本、易上手的物联网应用,如智能开关、传感器监控等。

week9的博客 634

FtpFindFirstFile()及InternetFindNextFile()对汉字编码的支持问题

首先说明情况。 ftp服务器是同事写的,运行在linux下,字符采用utf-8编码。 我写客户端,在windows下,自己的开发电脑是win74 64位简体中文版,ide采用vs2010,工程为ocx项目,支持MFC,unicode支持。 附加信息: 由于用到了字符编码的转换,为了简单,直接从网上找了相关的函数,参考网址: http://blog.youkuaiyun.com/feisy/a

jszj的专栏 3256

智能网联汽车云控系统核心解析:车云数据交互协议设计与实践

本文深入解析了智能网联汽车云控系统的核心——车云数据交互协议的设计与实践。文章围绕“说什么”、“怎么说”及异常处理三大核心问题,详细阐述了二进制与结构体数据类型定义、TCP/UDP双通道传输机制、通用报文格式以及典型交互流程(如GLOSA车速引导),并分享了时间同步、坐标系定义等关键实战经验与避坑指南,为构建高效、可靠、安全的车云“神经系统”提供专业指导。

alice7model的博客 122

用WinINet Api 开发FTP客户端 (二)

FTP WinApi 函数详解FTP 各函数间的关系 各FTP函数工作时需要用到InternetConnect创建的FTP会话句柄。而InternetConnect函数需要用到由InternetOpen创建的HINTERNET句柄。下面这个图可以表示他们间的关系。  而对那些在线操作的一些命令来说,他们的关系可以用下面这个图表示。例如用于枚举当前目录下文件的两个命令FtpFindFirstFile

洪虎专栏 1万+

Workbench下列车转向架随机振动疲劳分析

结果中添加功率谱响应工具(Response PSD Tool),可以查看几何体以及远程点上的功率谱密度,如下图11所示,这里查看几何体上某一硬点的加速度功率谱密度响应曲线,如下图12所示。结果中添加疲劳工具(Fatigue Tool),查看列车转向架的疲劳寿命情况,这里采用窄带的寿命假设理论,曝光时间为1s指明计算出的疲劳寿命的基本单位是秒,寿命结果如下图14所示,可以看到最大寿命为1e35s,最小寿命为2.3542e18s,注意单位制,可再次基础上将其转换为小时或天。频域上的统计计算,软件很快计算完成。

ansysxuexizhe的博客 2605

A-Level经济例题解析及练习Opportunity Cost

例题Question: Opportunity CostYou are selling your 1996 Mustang.&nbsp; You have already spent $1000 on repairs.&nbsp;At the last minute, the transmission dies.&nbsp; You can pay $600 to have it repaired, or sell the car “as is.”In each of the fol

Alevel3的博客 746

DELPHI 获取错误信息

try ....(需要执行的代码) except on e:exception do application.MessageBox(pchar(e.Message), '错误提示', 0); end;    转载于:https://www.cnblogs.com/Bung/archive/2011/08/15/2139384.html...

weixin_30384031的博客 329

白盒测试逻辑覆盖之谓词覆盖、子句覆盖、三类有效字句覆盖等知识点

本篇笔记会简化书本上的概念,用容易理解的方式来说明,有些例子打字麻烦,我会直接放图片! 目录 基础知识: 谓词覆盖predicate coverage 子句覆盖 clause coverage 组合覆盖 combinatorial coverage 有效字句覆盖Active Clause Coverage 广义有效子句覆盖(General Active Clause Coverage) 相关性有效子句覆盖(Correlated Active Clause Coverage) 限制性有效

weixin_46019681的博客 2666

获得ftp服务器上文件名和长度,怎么获得FTP服务器上目录下的所有文件名和子目录...

当前位置:我的异常网» Delphi»怎么获得FTP服务器上目录下的所有文件名和子目录怎么获得FTP服务器上目录下的所有文件名和子目录www.myexceptions.net网友分享于:2015-08-26浏览:560次如何获得FTP服务器上目录下的所有文件名和子目录我用的是indy 10 的tidftp控件,请问如何获得FTP服务器上目录下的所有文件名和子目录,先谢谢了---...

weixin_29745609的博客 784

从MIPS汇编到C语言:手把手教你用Mars模拟器理解指令集(附实战代码)

本文详细介绍了如何使用Mars模拟器从MIPS汇编过渡到C语言编程,通过实战代码解析ADD、LW、BEQ等指令集与C语言结构的对应关系。内容涵盖环境搭建、算术运算、内存访问、条件分支及函数调用等核心概念,帮助读者深入理解MIPS指令分类和计算机底层运行机制。

weixin_26821003的博客 361

【深度学习新浪潮】算力上太空:NVIDIA Space-1 Vera Rubin Module 深度技术解析

NVIDIA Space-1 Vera Rubin Module 不只是一款芯片模组,它是天地一体化 AI 的基础设施底座。它用成熟的 GPU 架构 + 航天级加固,把地面 AI 生态直接平移到太空。下一个 AI 创新战场,不在云端,而在轨道。在轨 LLM星上多模态实时处理卫星自主组网与分布式推理太空算力成为云计算的一级节点参考资料NVIDIA 官方博客:NVIDIA 推出太空计算,将 AI 送入太空轨道GTC 2026 黄仁勋主题演讲。

专注:太空算力、AI infra、异构调度、大模型成本工程 1128
上一篇: 修改EXE文件图标及资源的方法
下一篇: 感觉比较好的hips+av配置方案
iiprogram
博客等级 码龄25年 1068粉丝 1515原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值