Code : Tout sélectionner
Procedure.s GetFileVersionInfo(File.s)
Protected iLibrary.l, iFunctionInfo.l, iFunctionSize.l, iFunctionQry.l, *HoldVersion.l, HoldResult.l, HoldBuffer.l, HoldEmpty.l
Protected HoldString.s, HoldReturn.s
Protected *HoldInfo.VS_FIXEDFILEINFO
iLibrary = OpenLibrary(#PB_Any, "version.dll")
If iLibrary
iFunctionInfo = GetFunction(iLibrary, "GetFileVersionInfoA")
iFunctionSize = GetFunction(iLibrary, "GetFileVersionInfoSizeA")
iFunctionQry = GetFunction(iLibrary, "VerQueryValueA")
If iFunctionInfo And iFunctionSize And iFunctionQry
HoldBuffer = CallFunctionFast(iFunctionSize, @File, @HoldEmpty)
HoldReturn = Space(HoldBuffer)
HoldResult = CallFunctionFast(iFunctionInfo, File, 0, HoldBuffer, @HoldReturn)
HoldResult = CallFunctionFast(iFunctionQry, @HoldReturn, "\", @HoldEmpty, @HoldBuffer)
*HoldInfo = AllocateMemory(SizeOf(VS_FIXEDFILEINFO))
CopyMemory(HoldEmpty, *HoldInfo, SizeOf(VS_FIXEDFILEINFO))
HoldString = Str(*HoldInfo\dwFileVersionMS >> 16 & $FFFF) + "." + Str(*HoldInfo\dwFileVersionMS & $FFFF) + "." + Str(*HoldInfo\dwFileVersionLS >> 16 & $FFFF) + "." + Str(*HoldInfo\dwFileVersionLS & $FFFF)
CloseLibrary(iLibrary)
FreeMemory(*HoldInfo)
HoldReturn = Space(0)
If HoldResult
ProcedureReturn HoldString
Else
ProcedureReturn ""
EndIf
EndIf
CloseLibrary(iLibrary)
EndIf
EndProcedure
ProcedureDLL.s GetRichEditVersion()
Protected path_system.s, dir.s
path_system= GetEnvironmentVariable("Path")
For i=1 To CountString(GetEnvironmentVariable("Path"),";")+1
dir = StringField(GetEnvironmentVariable("Path"),i,";")
If Right(dir,1)<>"\"
dir+"\"
EndIf
; MSFTEDIT.DLL (à partir de WXP SP1) -> richedit 4.1+
If FileSize(dir+"MSFTEDIT.DLL")>0
ProcedureReturn "4.1"
ElseIf FileSize(dir+"RICHED20.DLL")>0
version.s=GetFileVersionInfo(dir+"RICHED20.DLL")
; RICHED20.DLL 5.30 (à partir de W2K/ME) -> richedit 3.0
If Right(version,3)="5.3"
ProcedureReturn "3.0"
; RICHED20.DLL 5.0 (à partir de W98/NT4) -> richedit 2.0
ElseIf Right(version,3)="5.0"
ProcedureReturn "2.0"
EndIf
; RICHED32.DLL (à partir de W95) -> richedit 1.0
ElseIf FileSize(dir+"RICHED32.DLL")>0
ProcedureReturn "1.0"
EndIf
Next
EndProcedure
Debug GetRichEditVersion()