用access向ftp服务器上传文件
时 间:2007-10-18 21:43:35
作 者:CHENZHIRONG ID:42 城市:广州
摘 要:转自:OFFICE中国
发帖作者:CHENZHIRONG.
用ACCESS向ftp服务器上传文件
正 文:
'声明:
Private 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
Private 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
Private 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
Private 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
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
'函数
Private Function UpLoadFile(ByVal LocateFile As String, ByVal RemoteFile As String) As Boolean
Dim lngINet As Long, lngINetConn As Long, blnRC As Boolean
'Me.lbMsg.Caption = "打开INTERNET句柄"
'Me.Repaint
lngINet = InternetOpen("FTP", 1, vbNullString, vbNullString, 0)
If lngINet = 0 Then Exit Function
'Me.lbMsg.Caption = "连接远程主机"
'Me.Repaint
lngINetConn = InternetConnect(lngINet, "IP地址", 端口, "用户", "密码", 1, 0, 0)
If lngINetConn = 0 Then Exit Function
'Me.lbMsg.Caption = "上传文件"
'Me.Repaint
blnRC = FtpPutFile(lngINetConn, LocateFile, RemoteFile, 1, 0)
If blnRC = False Then Exit Function
'Me.lbMsg.Caption = "上传成功"
'Me.Repaint
InternetCloseHandle lngINetConn
InternetCloseHandle lngINet
UpLoadFile = True
'Me.lbMsg.Caption = ""
End Function
Private Function DownLoadFile(ByVal RemoteFile As String, ByVal LocateFile As String) As Boolean
Dim lngINet As Long, lngINetConn As Long, blnRC As Boolean
'Me.lbMsg.Caption = "打开INTERNET句柄..."
'Me.Repaint
lngINet = InternetOpen("FTP", 1, vbNullString, vbNullString, 0)
If lngINet = 0 Then Exit Function
'Me.lbMsg.Caption = "连接远程主机..."
'Me.Repaint
lngINetConn = InternetConnect(lngINet, "IP地址", 端口, "帐号", "密码", 1, 0, 0)
If lngINetConn = 0 Then Exit Function
'Me.lbMsg.Caption = "正在下载文件..."
'Me.Repaint
blnRC = FtpGetFile(lngINetConn, RemoteFile, LocateFile, False, 0, 1, 0)
If blnRC = False Then Exit Function
'Me.lbMsg.Caption = "下载成功"
'Me.Repaint
InternetCloseHandle lngINetConn
InternetCloseHandle lngINet
DownLoadFile = True
End Function
Access软件网QQ交流群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- Access对子窗体数据进行批...(10.30)
- 最精简的组合框行来源数据快速输...(10.25)
- Access仿平台的多值选择器...(10.24)
- 【Access日期区间段查询】...(10.22)
- 【Access源码示例】VBA...(10.12)
- Access累乘示例,Acce...(10.09)
- 数值8.88,把整数8去掉,转...(10.08)
- 【Access自定义函数】一个...(09.30)
- 【Access选项卡示例】Ac...(09.09)
学习心得
最新文章
- Access快速开发平台企业版--...(11.18)
- 不会用多表联合查询,多表查询没结果...(11.16)
- 【案例分享】主键字段值含有不间断空...(11.16)
- Access快速开发平台--后台D...(11.14)
- 微软Access邀测新Monaco...(11.12)
- Access列表框左右互选、列表框...(11.11)
- 高效率在导入数据前删除记录(11.10)
- Access报价单转订单示例代码(11.08)
- Access系统自带的日期选择器不...(11.08)
- 分享一下Access工程中的acw...(11.07)