主题:新人想问个问题,望高手回答
我想写个更新检测的程序附加在主程序里
代码运行后自动下载http://www.***.com/456.txt文件
注:456.txt文件内容为:v1.0.0
然后读取其内容
我写的代码如下
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Sub Command1_Click()
Dim fname As String
fname = app.path & "\456.txt"
DownloadFile "http://www.***.com/456.txt", fname
Dim v2
Open fname For Input As #1
v2 = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1
End If
End Sub
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function
运行后会自动下载http://www.***.com/456.txt的文件,但是读取是错误,无法读取其中内容
错误为: 输入超出文件尾 实时错误62
请问高手是什么原因呢?
代码运行后自动下载http://www.***.com/456.txt文件
注:456.txt文件内容为:v1.0.0
然后读取其内容
我写的代码如下
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Sub Command1_Click()
Dim fname As String
fname = app.path & "\456.txt"
DownloadFile "http://www.***.com/456.txt", fname
Dim v2
Open fname For Input As #1
v2 = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1
End If
End Sub
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function
运行后会自动下载http://www.***.com/456.txt的文件,但是读取是错误,无法读取其中内容
错误为: 输入超出文件尾 实时错误62
请问高手是什么原因呢?