很感谢2-5楼的出手相助,但遗憾的是都不能解决问题。我仔细分析和测试了一下,发现这个问题和一个从FTP服务器下载文件的程序有关,只要运行了这个程序,接下来就会出现这个令人头痛的问题。请大家帮我分析一下,应该怎么修改一下程序:
*从 ftp 上下载文件
*-=-=-=-=-=-=-=-=-=-=-=-=-=-
PARAMETERS
lpszRemoteFile,lpszNewFile
*!*
lpszRemoteFile = "红雨/日历控件.zip"
&& if it still exists
*!*
lpszNewFile
= "C:\back\日历控件test.zip"
* How to download a file from the FTP server using FtpGetFile
* 使用 FtpGetFile 从 FTP 上下载文件
*--------------------------------------------------------------
Clea
* lAccessType - some values
#Define INTERNET_INVALID_PORT_NUMBER
0
#Define INTERNET_OPEN_TYPE_DIRECT
1
#Define INTERNET_OPEN_TYPE_PROXY
3
#Define INTERNET_DEFAULT_FTP_PORT
21
* lFlags: only a few
#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
* registry access settings
#Define INTERNET_OPEN_TYPE_PRECONFIG
0
#Define FTP_TRANSFER_TYPE_ASCII
1
#Define FTP_TRANSFER_TYPE_BINARY
2
* type of service to access
#Define INTERNET_SERVICE_FTP
1
#Define INTERNET_SERVICE_GOPHER
2
#Define INTERNET_SERVICE_HTTP
3
* file attributes
#Define FILE_ATTRIBUTE_NORMAL
128
&& 0x00000080
Do decl
* you are free to choose any name, say "John Dow"
* server-side variable $AGENT is the target
sAgent = "hongyu"
sProxyName = Chr(0)
&& I have no proxy
sProxyBypass = Chr(0)
&& so there is nothing to bypass
lFlags = 0
&& no flags used
* initialize access to Inet functions
hOpen = InternetOpen (sAgent, INTERNET_OPEN_TYPE_DIRECT,;
sProxyName, sProxyBypass, lFlags)
If hOpen = 0
? "找不到库 WinInet.Dll 的入口"
Return
Else
*
? "Wininet 句柄: " + LTRIM(STR(hOpen))
Endif
* connection parameters - you better put your data
strHost = "***。**。**。**"
strUser = "******"
strPwd
= "******"
* connecting to the FTP
hFtpSession = InternetConnect (hOpen, strHost,;
INTERNET_INVALID_PORT_NUMBER,;
strUser, strPwd,;
INTERNET_SERVICE_FTP, 0, 0)
If hFtpSession = 0
* close access to Inet functions and exit
= InternetCloseHandle (hOpen)
? "FTP " + strHost + " 无效"
Return
Else
*? "连接到 " + strHost + " as: [" + strUser + ", *****]"
*? "FTP 连接句柄: " + LTRIM(STR(hFtpSession))
Endif
* downloading a file from the FTP
* no check whether the target file exists
*!*
lpszRemoteFile = "红雨/日历控件.zip"
&& if it still exists
*!*
lpszNewFile
= "C:\back\日历控件test.zip"
&& check the destination folder
fFailIfExists
= 0
&& do not stop if the target already exists
dwContext
= 0
lnResult = FtpGetFile (hFtpSession, lpszRemoteFile, lpszNewFile,;
fFailIfExists, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_ASCII,;
dwContext)
If lnResult # 1
? "下载文件失败!"
Endif
* close handles
= InternetCloseHandle (hFtpSession)
= InternetCloseHandle (hOpen)
Return
&& main
Procedure
decl
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
Endproc
***************************