#16 get opera version

Release 2.0.6
accepted
None
5
2013-07-10
2013-05-21
No

i have this piece of code to retrieve Opera version, but doesn't seems to work. works well for IE
Public Function GetOperaVersion$()
Dim sOperaPath$, sOperaVer$, sOperaFriendlyVer$
On Error GoTo Error:
sOperaPath = RegGetString(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\App Paths\Opera.exe", "")
If sOperaPath = "" Then GoTo EndOfFun:
If FileExists(sOperaPath) = False Then GoTo EndOfFun:

Dim hData&, lDataLen&, uBuf() As Byte, uVFFI As VS_FIXEDFILEINFO
lDataLen = GetFileVersionInfoSize(sOperaPath, ByVal 0)
If lDataLen = 0 Then
GoTo EndOfFun:
End If

ReDim uBuf(0 To lDataLen - 1)
'get handle to file props
GetFileVersionInfo sOperaPath, 0, lDataLen, uBuf(0)
VerQueryValue uBuf(0), "\", hData, lDataLen
CopyMemory uVFFI, ByVal hData, Len(uVFFI)
With uVFFI
sOperaVer = Format(.dwFileVersionMSh, "00") & "." &
Format(.dwFileVersionMSl, "00") & "." &

Format(.dwProductVersionLSh, "0000")

End With
If sOperaVer = "00.00.0000" Then GoTo EndOfFun:

EndOfFun:
If lDataLen > 0 And Left(sOperaFriendlyVer, 1) <> "0" Then
GetOperaVersion = "Opera v" & sOperaFriendlyVer & " (" & sOperaVer & ")"
Else
GetOperaVersion = "Unable to get Opera version!"
End If
Exit Function

Error:
ErrorMsg Err.Number, Err.Description, "GetOperaVersion"
End Function
if you have a better way to do just let me know

Discussion

  • clairestreb

    clairestreb - 2013-07-02

    Hi Loucif,

    This is what I did:
    - Downloaded HijackThis 2.0.6 beta source code
    - Installed Opera 15.0.1147.130 on my Windows 7 Home Premium 64-bit machine
    - Added Microsoft Scripting Runtime to the Project > References
    - Added a new GetOperaVersion function plus supporting code to modUtils.bas (see attached)
    - If you find it acceptable, you'll also need to add this to CreateLogFile() in frmMain:

    sLog = sLog & GetOperaVersion() & vbCrLf
    

    Hope that helps,
    Claire

     
  • Loucif Kharouni

    Loucif Kharouni - 2013-07-10
    • status: open --> accepted
     
  • Loucif Kharouni

    Loucif Kharouni - 2013-07-10

    perfect. tested. works.

     

Log in to post a comment.