回复 2楼 吹水佬
在网上搜到一段代码,编译后没反应(需要修改的地方已按自己的修改了)。只是我是用win共享搭建的服务端,没有ftp服务器,请问是这个影响的吗?
#Define INTERNET_INVALID_PORT_NUMBER 0
#Define INTERNET_OPEN_TYPE_DIRECT 1
#Define INTERNET_OPEN_TYPE_PROXY 3
#Define INTERNET_DEFAULT_FTP_PORT 21
#Define INTERNET_FLAG_ASYNC 268435456
&& &H10000000
#Define INTERNET_FLAG_FROM_CACHE 16777216 && &H1000000
#Define INTERNET_FLAG_OFFLINE 16777216
#Define INTERNET_FLAG_CACHE_IF_NET_FAIL 65536
&& &H10000
#Define INTERNET_OPEN_TYPE_PRECONFIG 0
#Define FTP_TRANSFER_TYPE_ASCII 1
#Define FTP_TRANSFER_TYPE_BINARY 2
#Define INTERNET_SERVICE_FTP 1
#Define INTERNET_SERVICE_GOPHER
2
#Define INTERNET_SERVICE_HTTP
3
#Define FILE_ATTRIBUTE_NORMAL
128
&& 0x00000080
Declare INTEGER InternetOpen IN wininet;
STRING sAgent, INTEGER lAccessType, STRING sProxyName,;
STRING sProxyBypass, STRING
lFlags
Declare INTEGER InternetCloseHandle IN wininet INTEGER hInet
Declare INTEGER InternetConnect IN wininet;
INTEGER hInternetSession, STRING
sServerName,;
INTEGER nServerPort, STRING
sUsername,;
STRING
sPassword, INTEGER lService,;
INTEGER lFlags, INTEGER lContext
Declare INTEGER FtpGetFile IN wininet;
INTEGER hFtpSession, STRING
lpszRemoteFile,;
STRING
lpszNewFile, INTEGER fFailIfExists,;
INTEGER dwFlagsAndAttributes,;
INTEGER dwFlags, INTEGER dwContext
sAgent = "var1"
sProxyName = Chr(0)
sProxyBypass = Chr(0)
lFlags = 0
hOpen = InternetOpen (sAgent, INTERNET_OPEN_TYPE_DIRECT,;
sProxyName, sProxyBypass, lFlags)
If hOpen = 0
=MESSAGEBOX("找不到库 WinInet.Dll 的入口",16," 警告")
Return
Endif
*在此修改自己的FTP服务器数据
strHost = "ftp.
&&存放升级文件的FTP服务器地址
strUser = "user"
&&升级的FTP用户名
strPwd
= "1111"
&&FTP用户密码
hFtpSession = InternetConnect (hOpen, strHost,;
INTERNET_INVALID_PORT_NUMBER,;
strUser, strPwd,;
INTERNET_SERVICE_FTP, 0, 0)
If hFtpSession = 0
= InternetCloseHandle (hOpen)
=MESSAGEBOX("找不到指定的服务器",16,"警告")
Return
Endif
*以下设置FTP的路径和文件名
lpszRemoteFile = "/aaa.exe"
&& FTP上的路径和文件名
lpszNewFile = "./aaa.exe"
&& 下载到本地的路径和文件名,默认在同一目录中
fFailIfExists = 0
&& 如果此文件已经存在,直接进行覆盖,不提问
dwContext = 0
lnResult = FtpGetFile (hFtpSession, lpszRemoteFile, lpszNewFile,;
fFailIfExists, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_ASCII,;
dwContext)
= InternetCloseHandle (hFtpSession)
= InternetCloseHandle (hOpen)
If lnResult # 1
=MESSAGEBOX("升级失败!请检查用户名和密码是否正确。",16,"
警告")
ELSE
=MESSAGEBOX("升级成功!请退出升级程序。",64,"提示")
thisform.Release
&&升级成功可自动离开表单
Endif
Return