Quick Search for:  in language:    
EXE,function,will,retrieve,version,number,pro
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Visual Basic Stats

 Code: 3,014,970. lines
 Jobs: 119. postings

 How to support the site

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for Visual Basic.
Click here to see a screenshot of this code!MSChart Simple Example
By Sebastian Pereira on 7/2

(Screen Shot)

CString v1.5
By Ultimatum on 7/2


Tablature Pro
By Michael McMullen on 7/2


Click here to see a screenshot of this code!MSN Password Decryptor
By Muhammad Sufyan Ansari on 7/2

(Screen Shot)

Mp3 Paker
By Michael McMullen on 7/2


Suppress Run Time Script Errors
By Nuclear_1000G on 7/2


Click here to see a screenshot of this code!List Maker
By KBM-00 on 7/1

(Screen Shot)

Web Update Checker
By knormalnight on 7/1


A*Beginners API*
By Michael Nipper on 7/1


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Get Version Number for EXE, DLL or OCX files

Print
Email
 

Submitted on: 12/17/1999
By: Serge 
Level: Advanced
User Rating: By 10 Users
Compatibility:VB 5.0, VB 6.0

Users have accessed this code 6192 times.
 
 
     This function will retrieve the version number, product name, original program name (like if you right click on the EXE file and select properties, then select Version tab, it shows you all that information) etc
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

'**************************************
' Name: Get Version Number for EXE, DLL 
'     or OCX files
' Description:This function will retriev
'     e the version number, product name, orig
'     inal program name (like if you right cli
'     ck on the EXE file and select properties
'     , then select Version tab, it shows you 
'     all that information) etc
' By: Serge
'
' Returns:FileInfo structure
'
' Assumes:Label (named Label1 and make i
'     t wide enough, also increase the height 
'     of the label to have size of the form), 
'     Common Dilaog Box (CommonDialog1) and a 
'     Command Button (Command1)
'
'This code is copyrighted and has' limited warranties.Please see http://w
'     ww.Planet-Source-Code.com/vb/scripts/Sho
'     wCode.asp?txtCodeId=4976&lngWId;=1'for details.'**************************************

Public Function GetFileVersionInformation(ByRef pstrFieName As String, ByRef tFileInfo As FILEINFO) As VerisonReturnValue

Dim lBufferLen As Long, lDummy As Long Dim sBuffer() As Byte Dim lVerPointer As Long Dim lRet As Long Dim Lang_Charset_String As String Dim HexNumber As Long Dim i As Integer Dim strTemp As String 'Clear the Buffer tFileInfo tFileInfo.CompanyName = "" tFileInfo.FileDescription = "" tFileInfo.FileVersion = "" tFileInfo.InternalName = "" tFileInfo.LegalCopyright = "" tFileInfo.OriginalFileName = "" tFileInfo.ProductName = "" tFileInfo.ProductVersion = "" lBufferLen = GetFileVersionInfoSize(pstrFieName, lDummy) If lBufferLen < 1 Then GetFileVersionInformation = eNoVersion Exit Function End If
ReDim sBuffer(lBufferLen) lRet = GetFileVersionInfo(pstrFieName, 0&, lBufferLen, sBuffer(0)) If lRet = 0 Then GetFileVersionInformation = eNoVersion Exit Function End If
lRet = VerQueryValue(sBuffer(0), "\VarFileInfo\Translation", lVerPointer, lBufferLen) If lRet = 0 Then GetFileVersionInformation = eNoVersion Exit Function End If
Dim bytebuffer(255) As Byte MoveMemory bytebuffer(0), lVerPointer, lBufferLen HexNumber = bytebuffer(2) + bytebuffer(3) * &H100; + bytebuffer(0) * &H10000; + bytebuffer(1) * &H1000000; Lang_Charset_String = Hex(HexNumber) 'Pull it all apart: '04------= SUBLANG_ENGLISH_USA '--09----= LANG_ENGLISH ' ----04E4 = 1252 = Codepage for Windows ' :Multilingual Do While Len(Lang_Charset_String) < 8 Lang_Charset_String = "0" & Lang_Charset_String Loop
Dim strVersionInfo(7) As String strVersionInfo(0) = "CompanyName" strVersionInfo(1) = "FileDescription" strVersionInfo(2) = "FileVersion" strVersionInfo(3) = "InternalName" strVersionInfo(4) = "LegalCopyright" strVersionInfo(5) = "OriginalFileName" strVersionInfo(6) = "ProductName" strVersionInfo(7) = "ProductVersion" Dim buffer As String For i = 0 To 7 buffer = String(255, 0) strTemp = "\StringFileInfo\" & Lang_Charset_String _ & "\" & strVersionInfo(i) lRet = VerQueryValue(sBuffer(0), strTemp, _ lVerPointer, lBufferLen) If lRet = 0 Then GetFileVersionInformation = eNoVersion Exit Function End If
lstrcpy buffer, lVerPointer buffer = Mid$(buffer, 1, InStr(buffer, vbNullChar) - 1) Select Case i Case 0 tFileInfo.CompanyName = buffer Case 1 tFileInfo.FileDescription = buffer Case 2 tFileInfo.FileVersion = buffer Case 3 tFileInfo.InternalName = buffer Case 4 tFileInfo.LegalCopyright = buffer Case 5 tFileInfo.OriginalFileName = buffer Case 6 tFileInfo.ProductName = buffer Case 7 tFileInfo.ProductVersion = buffer End Select
Next i
GetFileVersionInformation = eOK End Function
'----------- Private Sub Command1_Click()
Dim strFile As String Dim udtFileInfo As FILEINFO On Error Resume Next With CommonDialog1 .Filter = "All Files (*.*)|*.*" .ShowOpen strFile = .FileName If Err.Number = cdlCancel Or strFile = "" Then Exit Sub End With
If GetFileVersionInformation(strFile, udtFileInfo) = eNoVersion Then MsgBox "No version available For this file", vbInformation Exit Sub End If
Label1 = "Company Name: " & udtFileInfo.CompanyName & vbCrLf Label1 = Label1 & "File Description:" & udtFileInfo.FileDescription & vbCrLf Label1 = Label1 & "File Version:" & udtFileInfo.FileVersion & vbCrLf Label1 = Label1 & "Internal Name: " & udtFileInfo.InternalName & vbCrLf Label1 = Label1 & "Legal Copyright: " & udtFileInfo.LegalCopyright & vbCrLf Label1 = Label1 & "Original FileName:" & udtFileInfo.OriginalFileName & vbCrLf Label1 = Label1 & "Product Name:" & udtFileInfo.ProductName & vbCrLf Label1 = Label1 & "Product Version: " & udtFileInfo.ProductVersion & vbCrLf End Sub


Other 2 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
12/17/1999 9:33:58 AM:don
This is a great code. I've been trying 
to achieve this for ages. Thank you 
very much.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/17/1999 3:58:57 PM:Alex
I agree. This is a great code. I've 
asked many people how to do that, but 
no one actually gave me the answer. 
You're great programmer Serge. Keep it 
up.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/2/2000 12:14:56 PM:The_Lung
If no one paid attention my code can 
manually read and write this info from 
executable type files with out the help 
of the 
api.
http://www.planet-source-code.co
m/vb/scripts/ShowCode.asp?txtCodeId=4224
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/27/2000 9:19:54 AM:Steven Lee
I think the codes are very useful but I 
won't place it in "advanced" category.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/4/2000 9:25:28 AM:Mug
Guys wake up!!! Have you ever heard 
about the MSDN library?????
Go there 
and you will find exact copy of the 
code above. Shame of you!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Visual Basic Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.