Jump to content

My first Func -> GetCCleanerVersion


Recommended Posts

It functions as a pointer to download Ccleaner. Tell me what you think and if you have something to improve

Note: I do not speak English fluently

#include <Inet.au3>
;============================================================================================================
;RETURN VALUE:
; 0 - REAL VERSION (DEFAULT)
; 1 - VERSION TO "InetGet" - "InetGet("http://download.piriform.com/ccsetup" & GetCCleanerVersion(1) & ".exe")
;============================================================================================================
Func GetCCleanerVersion($CC_Version = 0)
$URL_CCleaner = "http://www.piriform.com/ccleaner/download"
FileDelete(@TempDir & "GetVersion_CCLEANER.txt")
FileWrite(@TempDir & "GetVersion_CCLEANER.txt", StringAddCR(_INetGetSource($URL_CCleaner)))
$CCLEANER_VERSION = StringTrimRight(StringTrimLeft(FileReadLine(@TempDir & "GetVersion_CCLEANER.txt", 226), 33), 5)
$FIX_CCLEANER_VERSION = StringTrimRight(StringReplace($CCLEANER_VERSION, ".", ""), 4)
If $CC_Version = 0 Then
Return $CCLEANER_VERSION
Else
Return $FIX_CCLEANER_VERSION
EndIf
EndFunc ;=> GetCCleanerVersion
;To test
MsgBox(0, "Real Version:", GetCCleanerVersion(0))
;To test
MsgBox(0, "Version to InetGet Func:", GetCCleanerVersion(1))
Link to comment
Share on other sites

I have this code that works well for me, if it can help you

#include <String.au3>
#NoTrayIcon
$Handle = FileOpen($CmdLine[1],0)
$RemoteVersion = ""
$Found = False
If ($Handle <> -1) Then
  While Not $Found
    $Line = FileReadLine($Handle)
    If (@error <> 0) Then
     MsgBox(0,"Problem","Cannot find the current version in the downloaded file!")
      ExitLoop
    Else
      $FoundString = StringRegExp($Line,"Download CCleaner \d+\.\d+\.\d+",1)
      If (Ubound($FoundString)) Then
        $RemoteVersionArray = StringRegExp($FoundString[0],"\d+\.\d+",1)
        $RemoteVersion = $RemoteVersionArray[0]
        $Found = True
      EndIf
    EndIf
  WEnd
  FileClose($Handle)
Else
  MsgBox(0,"File problem","Cannot open """ & $CmdLine[1] & """ for reading!",10)
EndIf

If ($Found) Then
  IniWrite($CmdLine[2],"Version","RemoteVersion",$RemoteVersion)
  IniWrite($CmdLine[2],"Version","RemoteVersionURL","[url="http://www.piriform.com/ccleaner/download/portable/downloadfile"]http://www.piriform.com/ccleaner/download/portable/downloadfile[/url]")
EndIf

it is called from a script Not au3

WebGet,http://filehippo.com/download_ccleaner/,%Temp%\DownloadPage.htm
If,ExistFile,%Temp%\DownloadPage.htm,Begin
  Echo,"Processing downloaded file to get current version..."
  ShellExecute,Hide,%Temp%\GetCCleanerCurrentVersion.exe,"%Temp%\DownloadPage.htm %Temp%\CCleanerVer.ini"
End
Else,Echo,"Could not check current version!"
// See if we have to do a full download
IniRead,%Temp%\CCleanerVer.ini,Version,LocalVersion,%LocalVer%
IniRead,%Temp%\CCleanerVer.ini,Version,RemoteVersion,%RemoteVer%
If,%LocalVer%,NotEqual,%RemoteVer%,Begin
  Echo,"** Newest CCleaner version is %RemoteVer% **"
  Run,%ScriptFile%,Download
End
Else,Echo,"** CCleaner version is %RemoteVer% **"

Posted Image

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...