LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to call GetFileVersionInfo in versio.dll from LV

I'm trying to use the Windows call GetFileVersionInfo in the version.dll file to get the version info of an executable. Either I get garbage back for the version info or LV crashes. I am able to call GetFileVersionInfoSize successfully. I know these calls can be tricky and I probably don't have the parameters right, but I'm at a loss for what to try next. I've included the VI I'm using.

0 Kudos
Message 1 of 5
(4,347 Views)
A few things...
 
1. The lpData returned by the GetFileVersionInfo is an opaque pointer (void*), meaning you should not try to associate anything other than an int32 with it. This is probably where you are getting your problems. Simply define the parameter as an int32 rather than a CStr and then pass the int32 into VerQueryValue.
 
2. VerQueryValue is going to be more problems because the output of that is a variety of different possible structures. Getting those mapped correctly into LV data types is a fraught exercise and in general I don't recommend it. It is generally much easier to create a C wrapper DLL that does the structure manipulations for you and returns the basic data types you need.
 
3. HOWEVER - what I really recommend that you do is drop the attempt to use the Win32 functions and use the .NET API instead (look at System.Diagnostics.FileVersionInfo). Due to the way .NET works, LV can provide automatic data conversions for the .NET APIs and all of these problems just go away.
0 Kudos
Message 2 of 5
(4,345 Views)
Brain,
 
Thanks. I thought about using .NET, but gave up when I couldn't find anything that looked like it had something to do with files. I found System.Diagnostics like you suggested but couldn't find System.Diagnostics.FileVersionInfo (the entries go from EventLogTraceListener to InstaneData). Could you give me some more details on how to find that path?
 
George
0 Kudos
Message 3 of 5
(4,341 Views)
My guess is that you are looking for it from the constructor node popup. However, this particular class does not have a public constructor, instead you need to use the static method GetVersionInfo. Drop down an invoke node and right click on the refnum input terminal to select the class.
0 Kudos
Message 4 of 5
(4,338 Views)

That did it. Thanks. Geeze that sure isn't obvious to the casual observer is it?

George

0 Kudos
Message 5 of 5
(4,335 Views)