分享
 
 
 

非常有用的操作Internet的API函数

王朝other·作者佚名  2008-05-31
窄屏简体版  字體: |||超大  

必须安装有Winnet.dll文件, 功能比WINSOCK强大. 但MSDN里的说明和例子都是C++的,连VB的都没有. 我自己试探出这么一些功能.

先贴出来供大家参考.

*所有函数假如运行失败,返回 0 成功返回1或者句柄.

*参数大部分是用默认的,参数具体内容,查帮助文件

1.检查INTERNET是否连通

DECLARE Integer InternetGetConnectedState IN "wininet.dll" Integer,Integer

InternetGetConnectedState(0,0)

2.自动拨号-使用默认的拨号连接 (IE的INTERNET连接设置里必须设置拨号连接, 另外还有个InternetDial函数,必须使用拨号连接名称)

DECLARE Integer InternetAutodial IN "wininet.dll" Integer,Integer

InternetAutodial (0,0)

3.自动中断拨号或者连接

DECLARE Integer InternetAutodialHangup IN "wininet.dll" Integer

InternetAutodialHangup(0)

4. 获得一个连接句柄

Declare Integer InternetOpen IN "wininet.dll" String, Integer, String, String, Integer

lnOpen= internetOpen("MyFTP",1,null,null,0)

5. 连接到FTP SERVER

Declare Integer InternetConnect in "wininet.dll" Integer,String,Integer,String, String, Integer, Integer, Integer

lnConn=InternetConnect(lnOpen, "ftp.microsoft.com",0 , "anonymous", "aaaaa@yahoo.com", 1, 0, 0)

6. 下载一个文件. 还有不少FTP或者HTTP的操作文件或页面的函数. 有爱好者自己去试

Declare Integer FtpGetFile in "wininet.dll" Integer, String, String, Integer, Integer,Integer,Integer

? FtpGetFile(lnConn,''/bussys/readme.txt'',''c:\Temp\msreadme.txt'',0,0,1,0)

7. 中断连接

Declare Integer InternetCloseHandle In "wininet.dll" Integer

InternetCloseHandle(lnConn)

下面是WININET.DLL里大部分的API函数,是用VB格式的声明:

Declare Function GetProcessHeap Lib "kernel32" () As Long

Declare Function HeapAlloc Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, ByVal dwBytes As Long) As Long

Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any) As Long

Declare Sub CopyMemory1 Lib "kernel32" Alias "RtlMoveMemory" ( _

hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)

Declare Sub CopyMemory2 Lib "kernel32" Alias "RtlMoveMemory" ( _

hpvDest As Long, hpvSource As Any, ByVal cbCopy As Long)

Public Const ERROR_NO_MORE_FILES = 18

Public Declare Function InternetFindNextFile Lib "wininet.dll" Alias "InternetFindNextFileA" _

(ByVal hFind As Long, lpvFindData As WIN32_FIND_DATA) As Long

Public Declare Function FtpFindFirstFile Lib "wininet.dll" Alias "FtpFindFirstFileA" _

(ByVal hFtpSession As Long, ByVal lpszSearchFile As String, _

lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long, ByVal dwContent As Long) As Long

Public Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" _

(ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _

ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Long, _

ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean

Public Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" _

(ByVal hFtpSession As Long, ByVal lpszLocalFile As String, _

ByVal lpszRemoteFile As String, _

ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean

Public Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" _

(ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean

Public Declare Function FtpGetCurrentDirectory Lib "wininet.dll" Alias "FtpGetCurrentDirectoryA" _

(ByVal hFtpSession As Long, ByVal lpszDirectory As String, ByRef lpdwCurrentDirectory As Long) As Boolean

'' Initializes an application''s use of the Win32 Internet functions

Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _

(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, _

ByVal sProxyBypass As String, ByVal lFlags As Long) As Long

'' Opens a HTTP session for a given site.

Public Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" _

(ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, _

ByVal sUsername As String, ByVal sPassWord As String, ByVal lService As Long, _

ByVal lFlags As Long, ByVal lContext As Long) As Long

Public Declare Function InternetGetLastResponseInfo Lib "wininet.dll" Alias "InternetGetLastResponseInfoA" ( _

lpdwError As Long, _

ByVal lpszBuffer As String, _

lpdwBufferLength As Long) As Boolean

'' Type of service to access.

'' Opens an HTTP request handle.

Public Declare Function HttpOpenRequest Lib "wininet.dll" Alias "HttpOpenRequestA" _

(ByVal hHttpSession As Long, ByVal sVerb As String, ByVal sObjectName As String, ByVal sVersion As String, _

ByVal sReferer As String, ByVal something As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long

'' Sends the specified request to the HTTP server.

Public Declare Function HttpSendRequest Lib "wininet.dll" Alias "HttpSendRequestA" (ByVal _

hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, ByVal sOptional As _

String, ByVal lOptionalLength As Long) As Integer

'' Queries for information about an HTTP request.

Public Declare Function HttpQueryInfo Lib "wininet.dll" Alias "HttpQueryInfoA" _

(ByVal hHttpRequest As Long, ByVal lInfoLevel As Long, ByRef sBuffer As Any, _

ByRef lBufferLength As Long, ByRef lIndex As Long) As Integer

'' InternetErrorDlg

Public Declare Function InternetErrorDlg Lib "wininet.dll" _

(ByVal hWnd As Long, ByVal hInternet As Long, ByVal dwError As Long, ByVal dwFlags As Long, ByVal lppvData As Long) As Long

Public Declare Function GetDesktopWindow Lib "user32.dll" () As Long

'' The possible values for the lInfoLevel parameter include:

'' Reads data from a handle opened by the HttpOpenRequest function.

Public Declare Function InternetReadFile Lib "wininet.dll" _

(ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, _

lNumberOfBytesRead As Long) As Integer

Public Declare Function HttpSendRequestEx Lib "wininet.dll" Alias "HttpSendRequestExA" _

(ByVal hHttpRequest As Long, lpBuffersIn As INTERNET_BUFFERS, ByVal lpBuffersOut As Long, _

ByVal dwFlags As Long, ByVal dwContext As Long) As Long

Public Declare Function HttpEndRequest Lib "wininet.dll" Alias "HttpEndRequestA" _

(ByVal hHttpRequest As Long, ByVal lpBuffersOut As Long, _

ByVal dwFlags As Long, ByVal dwContext As Long) As Long

Public Declare Function InternetWriteFile Lib "wininet.dll" _

(ByVal hFile As Long, ByVal sBuffer As String, _

ByVal lNumberOfBytesToRead As Long, _

lNumberOfBytesRead As Long) As Integer

Public Declare Function FtpOpenFile Lib "wininet.dll" Alias _

"FtpOpenFileA" (ByVal hFtpSession As Long, _

ByVal sFileName As String, ByVal lAccess As Long, _

ByVal lFlags As Long, ByVal lContext As Long) As Long

Public Declare Function FtpDeleteFile Lib "wininet.dll" _

Alias "FtpDeleteFileA" (ByVal hFtpSession As Long, _

ByVal lpszFileName As String) As Boolean

Public Declare Function InternetSetOption Lib "wininet.dll" Alias "InternetSetOptionA" _

(ByVal hInternet As Long, ByVal lOption As Long, ByRef sBuffer As Any, ByVal lBufferLength As Long) As Integer

Public Declare Function InternetSetOptionStr Lib "wininet.dll" Alias "InternetSetOptionA" _

(ByVal

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有