Results 1 to 8 of 8

Thread: [RESOLVED] read the contents of an online text file

  1. #1

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Resolved [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?
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  2. #2
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    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")

  3. #3
    Addicted Member
    Join Date
    Nov 2008
    Location
    UK
    Posts
    171

    Re: read the contents of an online text file

    Quote Originally Posted by Justa Lol View Post
    use microsoft internet transfer controls 6.0
    for example:

    Code:
    Text1.Text = Inet1.OpenURL("youtube.com")
    I would of thought he knows that lol

  4. #4

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: read the contents of an online text file

    Quote Originally Posted by Justa Lol View Post
    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
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  5. #5

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: read the contents of an online text file

    Quote Originally Posted by Justa Lol View Post
    use microsoft internet transfer controls 6.0
    for example:

    Code:
    Text1.Text = Inet1.OpenURL("youtube.com")
    Works on vista as a standard user, Thanks
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  6. #6
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    Re: read the contents of an online text file

    Quote Originally Posted by Bountyhuntr View Post
    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.

  7. #7
    Addicted Member
    Join Date
    Nov 2008
    Location
    UK
    Posts
    171

    Re: read the contents of an online text file

    Quote Originally Posted by Justa Lol View Post
    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...

  8. #8
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    441

    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.
    leandroascierto.com Visual Basic 6 projects

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width