回复 1# runsnake
这种基本只有循环解决了。能采取的技巧不多
#include <WinHttp.au3>
Local $sVer, $aVer, $sFileName, $sPartFileName, $iFlag = 0
$sVer = '2-0-3'
$sPartFileName = 'SirenOfShame'
$aVer = StringSplit($sVer, '-', 2)
For $i = $aVer[2] + 1 To 9
$sFileName = $sPartFileName & '-' & $aVer[0] & '-' & $aVer[1] & '-' & $i & '.msi'
If CheckNetFile($sFileName) Then
$iFlag = 1
ExitLoop
EndIf
Next
If $iFlag Then
MsgBox(0, 'Info', 'New Ver: ' & $sFileName)
Exit
Else
For $i = $aVer[1] + 1 To 9
For $j = 0 To 9
$sFileName = $sPartFileName & '-' & $aVer[0] & '-' & $i & '-' & $j & '.msi'
If CheckNetFile($sFileName) Then
$iFlag = 1
ExitLoop 2
EndIf
Next
Next
EndIf
If $iFlag Then
MsgBox(0, 'Info', 'New Ver: ' & $sFileName)
Exit
Else
For $i = $aVer[0] + 1 To $aVer[0] + 1
For $j = 0 To 9
For $k = 0 To 9
$sFileName = $sPartFileName & '-' & $i & '-' & $j & '-' & $k & '.msi'
If CheckNetFile($sFileName) Then
$iFlag = 1
ExitLoop 2
EndIf
Next
Next
Next
EndIf
If $iFlag Then
MsgBox(0, 'Info', 'New Ver: ' & $sFileName)
Else
MsgBox(0, 'Info', 'No new Version')
EndIf
Func CheckNetFile($sFileName)
ConsoleWrite($sFileName & @CRLF)
Local $hOpen, $hConnect, $hRequest, $sHeader, $iFlag
$hOpen = _WinHttpOpen()
$hConnect = _WinHttpConnect($hOpen, "siren-of-shame.googlecode.com")
$hRequest = _WinHttpOpenRequest($hConnect, Default, "files/" & $sFileName)
_WinHttpSendRequest($hRequest)
_WinHttpReceiveResponse($hRequest)
$sHeader = _WinHttpQueryHeaders($hRequest)
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)
$iFlag = StringRegExp($sHeader, "(?i)Last-Modified.*\nExpires")
Return $iFlag
EndFunc
|