Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" _
(ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" _
(ByVal hLibModule As Long) As Long
Private Declare Function GetCORVersion Lib "mscoree" _
(ByVal pbuffer As Long, ByVal cchBuffer As Long, dwlength As Long) As Long
Private Function GetFrameworkVersion(ByRef Version As String) As Boolean
Dim vSize As Long
Dim vHandle As Long
vHandle = LoadLibrary("mscoree.dll")
If vHandle Then
vSize = 256
Version = Space(vSize)
If (GetCORVersion(StrPtr(Version), vSize, vSize) = 0) Then
Version = Left$(Version, vSize - 1)
GetFrameworkVersion = True
End If
FreeLibrary vHandle
End If
End Function
' // Exemple d'utilisation //
'Private Sub Command1_Click()
' Dim vVer As String
' If GetFrameworkVersion(vVer) Then
' MsgBox "Framework .NET " & vVer, vbInformation
' Else
' MsgBox "Framework .NET n'est pas installé", vbInformation
' End If
'End Sub