Get the version of a Windows DLL

Share your advanced PureBasic knowledge/code with the community.
MrCoder
New User
New User
Posts: 8
Joined: Wed Dec 03, 2003 11:21 pm
Location: UK
Contact:

Get the version of a Windows DLL

Post by MrCoder »

Code updated for 5.20+

You can use this find the version of a Windows DLL.

Code: Select all

; Get the version of a Windows DLL.
; Made by Chris Way (03/05/2004)


dll.DllVersionInfo\cbSize = SizeOf(DllVersionInfo)
OpenLibrary(0,"Shell32.dll")   ; The DLL to get the version of
CallFunction(0,"DllGetVersion",@dll)

OpenConsole()

PrintN(Str(dll\dwMajorVersion))
PrintN(Str(dll\dwMinorVersion))
PrintN(Str(dll\dwBuildNumber))
PrintN(Str(dll\dwPlatformID))

Input()
CloseConsole()

See this MSDN page for more info.

I havent seen this around here so I hope it hasn't been posted before.
Hope its helpful.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

But only if the DLL contains a function called "DllGetVersion" - right? I assum most (all?) of the MS ones do?
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
MrCoder
New User
New User
Posts: 8
Joined: Wed Dec 03, 2003 11:21 pm
Location: UK
Contact:

Post by MrCoder »

Yeah, it says on MSDN that pretty much all of the MS ones do. Not sure how to add it too your own DLL's, I'll have a look.
From MSDN:
This function is not an application programming interface (API). It is exported by name from each DLL that implements it. Currently, most of the Windows Shell and common controls DLLs implement DllGetVersion. These include, but are not limited to, Shell32.dll, Comctl32.dll, Shdocvw.dll, and Shlwapi.dll.
Post Reply