[RESOLVED] read the contents of an online text file
How can i read the contents of an online text file without downloading the file?
I have a program updater that is basically 2 parts.
Part 1 downloads a text file (only contains 3 digits) and compares their contents to the users exe version #. Eg:
Textfile contents 10.8 Users exe App.major & App.Minor = 10.8 No update available. next version i upload exe version 10.9 and change the textfile to 10.9
Then users using 10.8 will see a new version is available. The problem is using the WinHttpRequest object requires Admin just to download the text file.
I want the users to be able to check the text file without having to be admin.
Then if a new version is available they would need to be admin as their exe gets replaced with a new version. I put out a new version about every 6 months
but don't want users to have to be admin just to check if a new version is available. In short: How can i check the online textfile with needing to be admin?
Re: read the contents of an online text file
use microsoft internet transfer controls 6.0
for example:
Code:
Text1.Text = Inet1.OpenURL("youtube.com")
Re: read the contents of an online text file
Quote:
Originally Posted by
Justa Lol
use microsoft internet transfer controls 6.0
for example:
Code:
Text1.Text = Inet1.OpenURL("youtube.com")
I would of thought he knows that lol
Re: read the contents of an online text file
Quote:
Originally Posted by
Justa Lol
use microsoft internet transfer controls 6.0
for example:
Code:
Text1.Text = Inet1.OpenURL("youtube.com")
Thanks i think that will will work. have tested it on xp as a standard user and it works. Will have to make a setup for vista to install the ocx before testing
Re: read the contents of an online text file
Quote:
Originally Posted by
Justa Lol
use microsoft internet transfer controls 6.0
for example:
Code:
Text1.Text = Inet1.OpenURL("youtube.com")
Works on vista as a standard user, Thanks
Re: read the contents of an online text file
Quote:
Originally Posted by
Bountyhuntr
I would of thought he knows that lol
well i have a problem sometimes... i forget what code i need then i start browsing and don't find it then i ask on the forum...
but... not everyone knows this code, and i agree he should know that.
Re: read the contents of an online text file
Quote:
Originally Posted by
Justa Lol
well i have a problem sometimes... i forget what code i need then i start browsing and don't find it then i ask on the forum...
but... not everyone knows this code, and i agree he should know that.
True, I would search for it and not post.
It is kind of basic, maybe not used inet before...
Re: [RESOLVED] read the contents of an online text file
Hi, better use apis to beat the OCX.
Code:
Option Explicit
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 Const INTERNET_OPEN_TYPE_DIRECT As Long = 1
Private Const INTERNET_OPEN_TYPE_PROXY As Long = 3
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000
Function GetCode(sUrl As String) As String
Dim hOpen As Long, hFile As Long, sBuffer As String, Ret As Long
If Not UCase(Mid(sUrl, 1, 7)) = "HTTP://" Then sUrl = "http://" & sUrl
sBuffer = Space(1000)
hOpen = InternetOpen("VB6", INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
hFile = InternetOpenUrl(hOpen, sUrl, vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal 0&)
Do
InternetReadFile hFile, sBuffer, 1000, Ret
GetCode = GetCode & Left(sBuffer, Ret)
If Ret = 0 Then Exit Do
Loop
InternetCloseHandle hFile
InternetCloseHandle hOpen
End Function
Private Sub Form_Load()
MsgBox GetCode("www.youtube.com")
End Sub
Saludos.