Jump to content
Sign in to follow this  
marabunta

FileGetVersion

Recommended Posts

marabunta
Hello,

I just did as I understood this:https://www.autoitscript.com/autoit3/docs/functions/FileGetVersion.htm
I am wrong, but the examplanation is also bad.

#Include <WinAPI.au3>
#include <MsgBoxConstants.au3>

$Path='C:\test.dll'


ConsoleWrite(_FileInUse($Path) & @CR)

Func _FileInUse($sFile)

    Local $hFile = _WinAPI_CreateFile($sFile, 2, 2, 0)

    If $hFile Then
        _WinAPI_CloseHandle($hFile)
        Return 0
    EndIf

    Local $Error = _WinAPI_GetLastError()

    Switch $Error
        Case 32 ; ERROR_SHARING_VIOLATION
            Return 1
        Case Else
            Return SetError($Error, 0, 0)
    EndSwitch
EndFunc   ;==>_FileIsUses

Func GetFileVersion()
    ; Retrieve the file version of the AutoIt executable.
    Local $sFileVersion = FileGetVersion($Path, $FV_PRODUCTNAME ("ProductName"))

    ; Display the file version. This should be equal to @AutoItVersion.
    MsgBox($MB_SYSTEMMODAL, "", $sFileVersion)
EndFunc   ;==>Example

GetFileVersion()



Result:


>Running:(3.3.14.0):C:\autoit3.exe "C:\test\fileinuse.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
0
"C:\test\fileinuse.au3" (30) : ==> Variable cannot be accessed in this manner.:
Local $sFileVersion = FileGetVersion($Path, $FV_PRODUCTNAME ("ProductName"))
Local $sFileVersion = FileGetVersion($Path, $FV_PRODUCTNAME ^ ERROR
->21:24:15 AutoIt3.exe ended.rc:1
+>21:24:15 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 0.4797

 

Share this post


Link to post
Share on other sites
Jos

The stuff between brackets is an explanation so the function should be:

FileGetVersion($Path, $FV_PRODUCTNAME)

-or-

FileGetVersion($Path, "ProductName")

Jos
 

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  

×