$sFile = 'My File'
$sOld_Comments = FileGetVersion($sFile, 'Comments')
ConsoleWrite('Old Comments: ' & $sOld_Comments & @CRLF)
_FileSetVersion($sFile, 'Comments', 'My New Comments')
ConsoleWrite('New Comments: ' & FileGetVersion($sFile, 'Comments') & @CRLF)
_FileSetVersion($sFile, 'Comments', $sOld_Comments)
Func _FileSetVersion($hFileName, $sStringName = "FileVersion", $sStringText = @AutoItVersion)
Local $iResourceSize, $hFileOpen, $bFileRead, $bSearch, $bReplace, $bHex, $NewResSize, $iPos
Local $aStrSplit, $iResFieldSize, $bBinStrName, $sBinStrText, $sFileGetInfo, $iValue, $iCont
Local $bHeader = "34000000560053005f00560045005200530049004f004e005f0049004e0046004f"
Local $bEndHeader = "5400720061006e0073006c006100740069006f006e0000000000"
If Not FileExists($hFileName) Then Return SetError(1, 0, 0)
$hFileOpen = FileOpen($hFileName, 16)
$bFileRead = FileRead($hFileOpen)
FileClose($hFileOpen)
If FileGetVersion($hFileName) = "0.0.0.0" Then Return SetError(1, 0, 0)
$hFileOpen = FileOpen($hFileName, 18)
If $hFileOpen = -1 Then Return SetError(1, 0, 0)
FileWrite($hFileOpen, $bFileRead)
FileClose($hFileOpen)
Return SetError(0, 0, 1)
EndFunc
Func __NullEntryPoint($sString)
Local $iLen = StringLen($sString), $bNullString = ""
For $i = 1 To $iLen
$bNullString &= StringMid($sString, $i, 1)
If $i = $iLen Then ExitLoop
$bNullString &= Chr("00")
Next
Return $bNullString
EndFunc
Func __NullRepeat($sString, $iValue, $vChar = 0)
Local $sRepeat = ""
$iValue = $iValue - StringLen($sString)
If $iValue > 0 Then
For $i = 1 To $iValue
$sRepeat &= Chr($vChar)
Next
EndIf
Return $sString & $sRepeat
EndFunc
Func __Binary($sExpression)
Return StringTrimLeft(Binary($sExpression), 2)
EndFunc