那也要有个什么DLL的, 或者用shell命令吧
以下选自: http://jinesc.6600.org/myweb/disp.asp?idd=96&room=1030
1. FTP传输工具
我们首先使用FTP传输工具,用VB5.0中SHELL 命令调用DOS批处理 文件来实现传输的需要。
Shell调用格式:
Shell(pathname[,windowstyle])
例子:Shell("c:\windows\upload.bat")
批处理文件upload.bat 的内容:
c:\windows\ftp hostname
username
password
send c:\zrh\upload.txt upload.txt
bye
该命令实现了文件"upload.txt"的传输要求。在使用完毕之后, 再调用命令把该文件删除。
例子:Shell("c:\windows\del_up.bat")
批处理文件del_up.bat 的内容:
c:\windows\ftp hostname
username
password
dele upload.txt
bye
这样,文件"upload.txt"被删除。
但是,另一个问题出现了。由于Shell 函数的运行机制是与其它 程序同步执行,也就是说,当调用Shell 函数的子程序还没有执行完毕 之前,Shell函数后面的语句已经执行。在大批量添加数据的过程中, 就会出现某个记录的文件还没有传到,而下一个插入语句(I nsert)已 经开始调用。这样,ODBC调用就会出现错误。
以下选自: http://jinesc.6600.org/myweb/disp.asp?idd=96&room=1030
1. FTP传输工具
我们首先使用FTP传输工具,用VB5.0中SHELL 命令调用DOS批处理 文件来实现传输的需要。
Shell调用格式:
Shell(pathname[,windowstyle])
例子:Shell("c:\windows\upload.bat")
批处理文件upload.bat 的内容:
c:\windows\ftp hostname
username
password
send c:\zrh\upload.txt upload.txt
bye
该命令实现了文件"upload.txt"的传输要求。在使用完毕之后, 再调用命令把该文件删除。
例子:Shell("c:\windows\del_up.bat")
批处理文件del_up.bat 的内容:
c:\windows\ftp hostname
username
password
dele upload.txt
bye
这样,文件"upload.txt"被删除。
但是,另一个问题出现了。由于Shell 函数的运行机制是与其它 程序同步执行,也就是说,当调用Shell 函数的子程序还没有执行完毕 之前,Shell函数后面的语句已经执行。在大批量添加数据的过程中, 就会出现某个记录的文件还没有传到,而下一个插入语句(I nsert)已 经开始调用。这样,ODBC调用就会出现错误。
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
Public Declare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal sURL As String, ByVal sHeaders As String, ByVal lHeadersLength As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
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 InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Public Const IF_FROM_CACHE = &H1000000
Public Const IF_MAKE_PERSISTENT = &H2000000
Public Const IF_NO_CACHE_WRITE = &H4000000
Private Const BUFFER_LEN = 256
Public Function GetUrlSource(sURL As String) As String
Dim sBuffer As String * BUFFER_LEN, iResult As Integer, sData As String
Dim hInternet As Long, hSession As Long, lReturn As Long
'get the handle of the current internet connection
hSession = InternetOpen("vb wininet", 1, vbNullString, vbNullString, 0)
'get the handle of the url
If hSession Then hInternet = InternetOpenUrl(hSession, sURL, vbNullString, 0, IF_NO_CACHE_WRITE, 0)
'if we have the handle, then start reading the web page
If hInternet Then
'get the first chunk & buffer it.
iResult = InternetReadFile(hInternet, sBuffer, BUFFER_LEN, lReturn)
sData = sBuffer
'if there's more data then keep reading it into the buffer
Do While lReturn <> 0
iResult = InternetReadFile(hInternet, sBuffer, BUFFER_LEN, lReturn)
sData = sData + Mid(sBuffer, 1, lReturn)
Loop
End If
'close the URL
iResult = InternetCloseHandle(hInternet)
GetUrlSource = sData
End Function
示例:
text1.text=GetUrlSource("http://dapha.net/bbs") 以上代码保存于: SourceCode Explorer(源代码数据库)
复制时间: 2003-1-5 23:07:08
软件版本: 1.0.815
软件作者: Shawls
个人主页: Http://Shawls.Yeah.Net
E-Mail: [email protected]
QQ: 9181729