# Finding the file version of a win32 dll in Ruby

**URL:** <https://www.ruby-forum.com/t/finding-the-file-version-of-a-win32-dll-in-ruby/70878>\
**Category:** Ruby\
**Created:** [October 3, 2006, 4:59pm UTC](https://www.ruby-forum.com/t/finding-the-file-version-of-a-win32-dll-in-ruby/70878 "2006-10-03T16:59:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tankow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@tankow](https://www.ruby-forum.com/u/tankow)\
**Post date:** [October 3, 2006, 4:59pm UTC](https://www.ruby-forum.com/t/finding-the-file-version-of-a-win32-dll-in-ruby/70878/1 "2006-10-03T16:59:56Z")

</div>

Is there a way to determine the file version attribute in win32 using  
Ruby?  
I would like to report and compare file versions between 2 different  
windows  
computers using Ruby. I am mainly concerned with dll, ocx and exe file  
types.

Thanks for any help.  
Phil

---

<div class="post-metadata">

**Author:** ![tankow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@tankow](https://www.ruby-forum.com/u/tankow)\
**Post date:** [October 3, 2006, 5:23pm UTC](https://www.ruby-forum.com/t/finding-the-file-version-of-a-win32-dll-in-ruby/70878/2 "2006-10-03T17:23:58Z")

</div>

On 10/3/06, Jan S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On 10/3/06, Phil W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Is there a way to determine the file version attribute in win32 using Ruby?  
> > I would like to report and compare file versions between 2 different windows  
> > computers using Ruby. I am mainly concerned with dll, ocx and exe file  
> > types.
> > 
> > Thanks for any help.  
> > Phil

look at this thread as well:  
[http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/161050](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/161050)

this is the WINAPI funciton to call:

> **[Technical documentation](https://learn.microsoft.com/en-us/docs/)**

---

<div class="post-metadata">

**Author:** ![tankow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@tankow](https://www.ruby-forum.com/u/tankow)\
**Post date:** [October 3, 2006, 5:17pm UTC](https://www.ruby-forum.com/t/finding-the-file-version-of-a-win32-dll-in-ruby/70878/3 "2006-10-03T17:17:57Z")

</div>

On 10/3/06, Phil W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a way to determine the file version attribute in win32 using Ruby?  
> I would like to report and compare file versions between 2 different windows  
> computers using Ruby. I am mainly concerned with dll, ocx and exe file  
> types.
> 
> Thanks for any help.  
> Phil

I use filever.exe (download from [1] and/or win xp sp2 cd) and this:

module Win  
class Version  
class \<\< self  
# returns version as array i.e. [1, 2, 12312, 5] or  
# empty array  
def get\_version\_array(path)  
(get\_version(path) || ‘’).split(‘.’).collect {|i| i.to\_i}  
end

```
		# return version as string ('1.2.12312.5') or nil
		def get_version(path)
			ver = short(path)
			ver.empty? ? nil : ver[14..30].strip
		end

		def short(path)
			`filever /B /A "#{Path.to_win(path)}" 2>&1`
		end

		def full(path)
			`filever.exe /V "#{Path.to_win(path)}" 2>&1`
		end
	end
end

```

end

[1]  
[http://www.microsoft.com/downloads/details.aspx?FamilyId=49AE8576-9BB9-4126-9761-BA8011FABF38&displaylang=en](http://www.microsoft.com/downloads/details.aspx?FamilyId=49AE8576-9BB9-4126-9761-BA8011FABF38&displaylang=en)

---

<div class="post-metadata">

**Author:** ![tankow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@tankow](https://www.ruby-forum.com/u/tankow)\
**Post date:** [October 3, 2006, 6:22pm UTC](https://www.ruby-forum.com/t/finding-the-file-version-of-a-win32-dll-in-ruby/70878/4 "2006-10-03T18:22:09Z")

</div>

Thanks, I’ll take a look.
