我在一篇文章看到一个API涵数的声明:private declare function InternetReadHTML Lib "Wininet.dll" alias "InternetReadFile"(Byval hFile as long,...) as integer但我不能在vb6的API Viewer找到相关的东东,请教要怎么才能找到这个API涵数的声明?谢谢!
解决方案 »
- VB连接数据库模块的问题?
- VB能否实现windows的搜索功能?
- vb commonDialog 对话框选中一个文件"双击"时,会循环弹出此对话框,只有选中文件,点击”打开“按钮才跳出
- 串口 难!
- 请问各位高手如何更好的利用这些需要注册的控件?
- VB程序中如何打开外部的chm文件
- 如何在webbrowser控件中运用Keypress事件,再线等候!!!
- 禁令>>>>>让他们不要乱动
- 为什么Data.Find "[mc] ='test' And [mytime] ='2222'"会出错?(高分)
- 关于打印的一个简单问题
- 一个表中有三个字段为主键,如何判断是否重复?
- 请问如何获得:计算机管理/共享文件夹/共享、会话、打开文件)等信息
Const INTERNET_FLAG_EXISTING_CONNECT = &H20000000Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
(ByVal lpszAgent As String, ByVal dwAccessType As Long, _
ByVal lpszProxyName As String, ByVal lpszProxyBypass As String, _
ByVal dwFlags As Long) As Long
Private Declare Function InternetOpenUrl Lib "wininet.dll" Alias _
"InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, _
ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, _
ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As _
Long) As Integer
Private Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As _
Long, ByVal lpBuffer As String, ByVal dwNumberOfBytesToRead As Long, _
lNumberOfBytesRead As Long) As Integer' Download a file from Internet and save it to a local file
'
' it works with HTTP and FTP, but you must explicitly include
' the protocol name in the URL, as in
' CopyURLToFile "http://www.vb2themax.com/default.asp", "C:\vb2themax.htm"Sub CopyURLToFile(ByVal URL As String, ByVal FileName As String)
Dim hInternetSession As Long
Dim hUrl As Long
Dim FileNum As Integer
Dim ok As Boolean
Dim NumberOfBytesRead As Long
Dim Buffer As String
Dim fileIsOpen As Boolean On Error GoTo ErrorHandler ' check obvious syntax errors
If Len(URL) = 0 Or Len(FileName) = 0 Then Err.Raise 5 ' open an Internet session, and retrieve its handle
hInternetSession = InternetOpen(App.EXEName, INTERNET_OPEN_TYPE_PRECONFIG, _
vbNullString, vbNullString, 0)
If hInternetSession = 0 Then Err.Raise vbObjectError + 1000, , _
"An error occurred calling InternetOpen function" ' open the file and retrieve its handle
hUrl = InternetOpenUrl(hInternetSession, URL, vbNullString, 0, _
INTERNET_FLAG_EXISTING_CONNECT, 0)
If hUrl = 0 Then Err.Raise vbObjectError + 1000, , _
"An error occurred calling InternetOpenUrl function" ' ensure that there is no local file
On Error Resume Next
Kill FileName On Error GoTo ErrorHandler
' open the local file
FileNum = FreeFile
Open FileName For Binary As FileNum
fileIsOpen = True ' prepare the receiving buffer
Buffer = Space(4096)
Do
' read a chunk of the file - returns True if no error
ok = InternetReadFile(hUrl, Buffer, Len(Buffer), NumberOfBytesRead) ' exit if error or no more data
If NumberOfBytesRead = 0 Or Not ok Then Exit Do
' save the data to the local file
Put #FileNum, , Left$(Buffer, NumberOfBytesRead)
Loop
' flow into the error handlerErrorHandler:
' close the local file, if necessary
If fileIsOpen Then Close #FileNum
' close internet handles, if necessary
If hUrl Then InternetCloseHandle hUrl
If hInternetSession Then InternetCloseHandle hInternetSession
' report the error to the client, if there is one
If Err Then Err.Raise Err.Number, , Err.Description
End Sub
private declare function InternetReadHTML Lib "Wininet.dll" alias "InternetReadFile"(Byval hFile as long,...) as integerInternetReadHTML 这个名字我可以随便定义
Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer参数:
?hFile
Valid handle returned from a previous call to InternetOpenUrl, FtpOpenFile, GopherOpenFile, or HttpOpenRequest.?lpBuffer
Address of a buffer that receives the data read.?dwNumberOfBytesToRead
Number of bytes to read.?lpNumberOfBytesRead
Address of a variable that receives the number of bytes read. The InternetReadFile function sets this value to zero before doing any work or error checking.
返回值:
Returns TRUE if successful or FALSE otherwise. To get extended error information, call GetLastError. An application can also use InternetGetLastResponseInfo when necessary. 示例:
Const scUserAgent = "API-Guide test program"
Const INTERNET_OPEN_TYPE_DIRECT = 1
Const INTERNET_OPEN_TYPE_PROXY = 3
Const INTERNET_FLAG_RELOAD = &H80000000
Const sURL = "http://www.microsoft.com/index.htm"
Private Declare Function InternetOpen Lib "wininet" 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 InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer
Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
Private Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: [email protected] Dim hOpen As Long, hFile As Long, sBuffer As String, Ret As Long
'Create a buffer for the file we're going to download
sBuffer = Space(1000)
'Create an internet connection
hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
'Open the url
hFile = InternetOpenUrl(hOpen, sURL, vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal 0&)
'Read the first 1000 bytes of the file
InternetReadFile hFile, sBuffer, 1000, Ret
'clean up
InternetCloseHandle hFile
InternetCloseHandle hOpen
'Show our file
MsgBox sBuffer
End Sub以上代码来自API-Guide