Func CHECKNEWVERSION($APPVERSION, $FLAG = 0)
Local $APPNEWVERSION, $APPNEWVERSIONTMP
Local $INIFILE, $TMP, $TIMEOUT, $HDOWN, $WWW
Local $HWDVERSIONGUI, $VERSIONLABLE, $NEWVERSIONBUTTON, $NOTICEBUTTON, $CANCELBUTTON
$INIFILE = @ScriptDir & '\LiveCapture.ini'
#Region Language
Local $LANGINIFILE, $SECTIONNAME, $CNEWVERSION, $CUPDATENEWVERSION, $CNOCHECKNEWVERSION, $CCANCELUPDATE, $CNONEWVERSION, $CLATESTVERSION, $CERROR, $CNOACCESS
$LANGINIFILE = IniRead($INIFILE, 'LiveCapture', 'LanguageFile', '')
$SECTIONNAME = 'Update'
$CNEWVERSION = IniRead($LANGINIFILE, $SECTIONNAME, 'NewVersion', 'New Version')
$CUPDATENEWVERSION = IniRead($LANGINIFILE, $SECTIONNAME, 'UpdateNewVersion', 'Update new version')
$CNOCHECKNEWVERSION = IniRead($LANGINIFILE, $SECTIONNAME, 'NoCheckNewVersion', 'Don"t check new version')
$CCANCELUPDATE = IniRead($LANGINIFILE, $SECTIONNAME, 'CancelUpdate', 'CancelUpdate')
$CNONEWVERSION = IniRead($LANGINIFILE, $SECTIONNAME, 'NoNewVersion', 'No New Version')
$CLATESTVERSION = IniRead($LANGINIFILE, $SECTIONNAME, 'LatestVersion', 'You are using the latest version')
$CERROR = IniRead($LANGINIFILE, 'Common', 'Error', 'Error')
$CNOACCESS = IniRead($LANGINIFILE, $SECTIONNAME, 'NoAccess', 'Cann"t Access')
#EndRegion Language
$TMP = @TempDir & '\~LiveCatureCheckNewVersion.tmp'
$WWW = 'http://code.google.com/p/livecapture/downloads/list'
$HDOWN = InetGet($WWW, $TMP, 1, 1)
$TIMEOUT = TimerInit()
Do
If InetGetInfo($HDOWN, 4) Then ExitLoop
If TimerDiff($TIMEOUT) >= 3000 Then
ExitLoop
EndIf
Sleep(100)
Until InetGetInfo($HDOWN, 2)
InetClose($HDOWN)
$APPNEWVERSION = FileRead($TMP)
FileDelete($TMP)
If $APPNEWVERSION <> '' Then
$APPNEWVERSIONTMP = StringRegExp($APPNEWVERSION, 'LiveCapture\d\.\d\.\d\.zip', 3)
$APPNEWVERSION = StringRegExpReplace($APPNEWVERSIONTMP[0], '(LiveCapture)(\d\.\d\.\d)(\.zip)', '\2')
If $APPNEWVERSION > $APPVERSION Then
$HWDVERSIONGUI = GUICreate('', 280, 150, @DesktopWidth - 300, @DesktopHeight - 190, $WS_POPUP, -1, WinGetHandle(AutoItWinGetTitle()))
GUISetBkColor(14745599)
DllCall('user32.dll', 'int', 'AnimateWindow', 'hwnd', $HWDVERSIONGUI, 'int', 300, 'long', 524288)
GUICtrlCreateIcon(@ScriptDir & '\Resource\LiveCapture.ico', -1, 1, 10, 20, 20)
$VERSIONLABLE = GUICtrlCreateLabel('LiveCapture ' & $CNEWVERSION & ': ' & $APPNEWVERSION, 20, 13, 250, 20)
GUICtrlSetColor($VERSIONLABLE, 16711680)
GUICtrlSetBkColor($VERSIONLABLE, 29411)
GUICtrlSetFont($VERSIONLABLE, '', 400, 6)
$NEWVERSIONBUTTON = GUICtrlCreateButton($CUPDATENEWVERSION, 20, 45, 250, 20)
$NOTICEBUTTON = GUICtrlCreateButton($CNOCHECKNEWVERSION, 20, 80, 250, 20)
$CANCELBUTTON = GUICtrlCreateButton($CCANCELUPDATE, 20, 115, 250, 20)
GUISetState(@SW_SHOW, $HWDVERSIONGUI)
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $CANCELBUTTON
ExitLoop
Case $NEWVERSIONBUTTON
ShellExecute($WWW)
ExitLoop
Case $NOTICEBUTTON
IniWrite($INIFILE, 'LiveCapture', 'CheckAppUpdate', 0)
ExitLoop
EndSwitch
WEnd
DllCall('user32.dll', 'int', 'AnimateWindow', 'hwnd', $HWDVERSIONGUI, 'int', 500, 'long', 589824)
ElseIf $FLAG == 1 Then
MsgBox(0, 'Live Capture: ' & $CNONEWVERSION, $CLATESTVERSION & ': ' & $APPVERSION)
EndIf
Else
MsgBox(16, $CERROR & ' - Live Capture', $CNOACCESS & ': http://code.google.com/p/livecapture/downloads/list')
EndIf
EndFunc ;==>CHECKNEWVERSION