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

# Thread: Get file version info

1. ## 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:
' Display version information for the file.Private Sub cmdGetInfo_Click()Dim version_information As VersionInformationTypeDim txt As String     txtResults.Text = ""     ' Get the version information.    version_information = VersionInformation(txtFileName.Text)     ' Display the version information.    With version_information        txt = .FileVersion & vbCrLf    End With     txtResults.Text = txtEnd SubPrivate Sub Form_Load()Dim file_name As String     file_name = App.Path    If Right\$(file_name, 1) <> "\" Then file_name = file_name & "\"    txtFileName.Text = file_name & "Project1.exe"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. VB Code:
Dim strDirectory as StringDim strFiles as String strDirectory = "C:\path\to\whatever\"strFiles = Dir(strDirectory & "*.*") Do Until strFiles = ""         'Your version info code...            strFiles = Dir()Loop

3. Thanks, that worked

4. Worship me.

5. ## Re: Get file version info

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

6. ## 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. ## 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:

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.

#### 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