PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Get file version info-VBForums
Results 1 to 7 of 7

Thread: Get file version info

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Location
    TX
    Posts
    12

    Get file version info

    I am using VB 6
    I need a program to get file version information of all files in a specified folder and print each file version on a seperate line...

    I have a pre-written API to get all the version info data.
    Then using the pre-written module the program does this:

    VB Code:
    1. ' Display version information for the file.
    2. Private Sub cmdGetInfo_Click()
    3. Dim version_information As VersionInformationType
    4. Dim txt As String
    5.  
    6.     txtResults.Text = ""
    7.  
    8.     ' Get the version information.
    9.     version_information = VersionInformation(txtFileName.Text)
    10.  
    11.     ' Display the version information.
    12.     With version_information
    13.         txt = .FileVersion & vbCrLf
    14.     End With
    15.  
    16.     txtResults.Text = txt
    17. End Sub
    18. Private Sub Form_Load()
    19. Dim file_name As String
    20.  
    21.     file_name = App.Path
    22.     If Right$(file_name, 1) <> "\" Then file_name = file_name & "\"
    23.     txtFileName.Text = file_name & "Project1.exe"
    24. End Sub

    It works great but only gets the file info version of one specified file.
    What is the code to go through all the files in a folder and print each file version on a seperate line?

  2. #2
    ASP.NET Moderator mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174
    VB Code:
    1. Dim strDirectory as String
    2. Dim strFiles as String
    3.  
    4. strDirectory = "C:\path\to\whatever\"
    5. strFiles = Dir(strDirectory & "*.*")
    6.  
    7. Do Until strFiles = ""
    8.  
    9.         'Your version info code...        
    10.     strFiles = Dir()
    11. Loop

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Location
    TX
    Posts
    12
    Thanks, that worked

  4. #4
    ASP.NET Moderator mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174


    Worship me.

  5. #5
    Junior Member
    Join Date
    Jul 2013
    Posts
    27

    Re: Get file version info

    What other code was used to make the code in Post #1 work. I need that code.

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,922

    Re: Get file version info

    Considering the age of the thread it is best to begin a new one stating your question, possibly linking back to this very old thread.

    The problem is defining what you mean by "version" which can mean very different things for different kinds of files. There is no version attribute stored as part of the directory entry of a file. Some kinds of files do hold such a value internally, but when present it is stored differently for each type and so a different retrieval process is required.

    The Windows Shell ("Explorer") knows how to extract such information for a few well-known MIME types, which is how it can display it for some files. It sounds like you are really asking how to obtain version info, which means we'd need to know what types of files you are asking about. There isn't any universal way to get this however.

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,922

    Re: Get file version info

    Based on your question in this other thread you also dug up from the grave you are after what the Shell calls the "File Version" extended property. More specifically the version info that compilers and linkers record within PE files (EXE, DLL, etc.).

    You can get this via the Shell's automation interfaces fairly easily, as well as by low-level API calls as illustrated in that other thread. However neither of these is "fast" since they both rely on reading data from the file to get it.

    Here is an example created by extending an earlier demo I wrote to retrieve some image file extended properties:

    Name:  sshot.png
Views: 97
Size:  15.9 KB

    So now you have two possible approaches. Applying either of them is just a matter of some very simple additional programming. Your post in the other thread is a bit disappointing in this regard. We don't do free custom programming here, but we're happy to help with questions.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width