Getting file version

I want to get the version of a file
Here's what I have in the Global External Functions

Function long GetFileVersionInfoSize (string lptstrFilename, long 
lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeA"


and here's what I have in a button in  an empty window

long ll_dummy = 0, ll_size = 0
string ls_file = "C:\MyFile.EXE"

ll_size = GetFileVersionInfoSize (ls_file, ll_dummy)
messagebox(string(ll_size), "")



ll_size always = 0 no matter what.
When I try the same code in Microsoft Access, it works perfectly and gives 
me 2076

Win XP SP2
PowerBuilder Pro 10.2.1 Build 9671

all I want is to get the same result at both places so I can continue my 
coding to get the version. 


0
Stephen
8/22/2006 3:48:01 PM
sybase.powerbuilder.general 62418 articles. 19 followers. Follow

7 Replies
1611 Views

Similar Articles

[PageSpeed] 31

It looks like you're using the ANSI version of the function. Declare the 
Unicode version:

GetFileVersionInfoSizeW


Brad

Stephen wrote:
> I want to get the version of a file
> Here's what I have in the Global External Functions
> 
> Function long GetFileVersionInfoSize (string lptstrFilename, long 
> lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeA"
> 
> 
> and here's what I have in a button in  an empty window
> 
> long ll_dummy = 0, ll_size = 0
> string ls_file = "C:\MyFile.EXE"
> 
> ll_size = GetFileVersionInfoSize (ls_file, ll_dummy)
> messagebox(string(ll_size), "")
> 
> 
> 
> ll_size always = 0 no matter what.
> When I try the same code in Microsoft Access, it works perfectly and gives 
> me 2076
> 
> Win XP SP2
> PowerBuilder Pro 10.2.1 Build 9671
> 
> all I want is to get the same result at both places so I can continue my 
> coding to get the version. 
> 
> 
0
Brad
8/22/2006 3:54:01 PM
So should it look like that?

Function long GetFileVersionInfoSize (string lptstrFilename, long 
lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeW"

or like that

Function long GetFileVersionInfoSizeW (string lptstrFilename, long 
lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeA"



"Brad Wery [TeamSybase]" <bradweryatagricoreunited.com> wrote in message 
news:44eb2628$1@forums-2-dub...
> It looks like you're using the ANSI version of the function. Declare the 
> Unicode version:
>
> GetFileVersionInfoSizeW
>
>
> Brad
>
> Stephen wrote:
>> I want to get the version of a file
>> Here's what I have in the Global External Functions
>>
>> Function long GetFileVersionInfoSize (string lptstrFilename, long 
>> lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeA"
>>
>>
>> and here's what I have in a button in  an empty window
>>
>> long ll_dummy = 0, ll_size = 0
>> string ls_file = "C:\MyFile.EXE"
>>
>> ll_size = GetFileVersionInfoSize (ls_file, ll_dummy)
>> messagebox(string(ll_size), "")
>>
>>
>>
>> ll_size always = 0 no matter what.
>> When I try the same code in Microsoft Access, it works perfectly and 
>> gives me 2076
>>
>> Win XP SP2
>> PowerBuilder Pro 10.2.1 Build 9671
>>
>> all I want is to get the same result at both places so I can continue my 
>> coding to get the version. 


0
Stephen
8/22/2006 4:14:03 PM
You would use the first one:

Function long GetFileVersionInfoSize (string lptstrFilename, long
lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeW"



Stephen wrote:
> So should it look like that?
> 
> Function long GetFileVersionInfoSize (string lptstrFilename, long 
> lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeW"
> 
> or like that
> 
> Function long GetFileVersionInfoSizeW (string lptstrFilename, long 
> lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeA"
> 
> 
> 
0
Brad
8/22/2006 4:20:04 PM
I've tried that and I still get 0
I've done the same change in MS Access and it was now 0 too.
It seems that I need to use GetFileVersionInfoSizeA.
have you tried it?


"Brad Wery [TeamSybase]" <bradweryatagricoreunited.com> wrote in message 
news:44eb2c46$1@forums-2-dub...
> You would use the first one:
>
> Function long GetFileVersionInfoSize (string lptstrFilename, long
> lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeW"
>
>
>
> Stephen wrote:
>> So should it look like that?
>>
>> Function long GetFileVersionInfoSize (string lptstrFilename, long 
>> lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeW"
>>
>> or like that
>>
>> Function long GetFileVersionInfoSizeW (string lptstrFilename, long 
>> lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeA"
>>
>> 

0
Stephen
8/22/2006 4:26:01 PM
PB 10 is Unicode so you will want to use GetFileVersionInfoSizeW. A 
return of zero may be the correct return value. Here is what Microsoft's 
web site has to say about the function:

"The GetFileVersionInfoSize function determines whether the operating 
system can retrieve version information for a specified file. If version 
information is available, GetFileVersionInfoSize returns the size, in 
bytes, of that information."

Does the file you're accessing actually have a version number. I tried 
it on a dll and it returned the size in bytes. I tried it on an exe that 
did not have a version number and it returned 0.

If you hover your mouse over the file in Windows Explorer you should be 
able to see the version in the tooltip that pops up.

GetFileVersionInfoSizeA probably works in Access because it's an ANSI 
environment. If you want to use the ansi version in PB 10 you can 
declare it like this:

Function long GetFileVersionInfoSize (string lptstrFilename, long 
lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeA;ANSI"



Brad

Stephen wrote:
> I've tried that and I still get 0
> I've done the same change in MS Access and it was now 0 too.
> It seems that I need to use GetFileVersionInfoSizeA.
> have you tried it?
> 
> 
> "Brad Wery [TeamSybase]" <bradweryatagricoreunited.com> wrote in message 
> news:44eb2c46$1@forums-2-dub...
> 
>>You would use the first one:
>>
>>Function long GetFileVersionInfoSize (string lptstrFilename, long
>>lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeW"
>>
>>
>>
>>Stephen wrote:
>>
>>>So should it look like that?
>>>
>>>Function long GetFileVersionInfoSize (string lptstrFilename, long 
>>>lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeW"
>>>
>>>or like that
>>>
>>>Function long GetFileVersionInfoSizeW (string lptstrFilename, long 
>>>lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeA"
>>>
>>>
> 
> 
0
Brad
8/22/2006 4:39:57 PM
The file version is 2.0.3

The thing is that I find it bizarre that MS Access return 2076 when using 
that function for MyFile.exe and Powerbuilder returns 0.

I thought that in debug mode I could find where the problem is located and 
it seems to be with the GetFileVersionInfoSize function. Shouldn't it return 
the same value?




"Brad Wery [TeamSybase]" <bradweryatagricoreunited.com> wrote in message 
news:44eb30eb$1@forums-2-dub...
> PB 10 is Unicode so you will want to use GetFileVersionInfoSizeW. A return 
> of zero may be the correct return value. Here is what Microsoft's web site 
> has to say about the function:
>
> "The GetFileVersionInfoSize function determines whether the operating 
> system can retrieve version information for a specified file. If version 
> information is available, GetFileVersionInfoSize returns the size, in 
> bytes, of that information."
>
> Does the file you're accessing actually have a version number. I tried it 
> on a dll and it returned the size in bytes. I tried it on an exe that did 
> not have a version number and it returned 0.
>
> If you hover your mouse over the file in Windows Explorer you should be 
> able to see the version in the tooltip that pops up.
>
> GetFileVersionInfoSizeA probably works in Access because it's an ANSI 
> environment. If you want to use the ansi version in PB 10 you can declare 
> it like this:
>
> Function long GetFileVersionInfoSize (string lptstrFilename, long 
> lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeA;ANSI"
>
>
>
> Brad
>
> Stephen wrote:
>> I've tried that and I still get 0
>> I've done the same change in MS Access and it was now 0 too.
>> It seems that I need to use GetFileVersionInfoSizeA.
>> have you tried it?
>>
>>
>> "Brad Wery [TeamSybase]" <bradweryatagricoreunited.com> wrote in message 
>> news:44eb2c46$1@forums-2-dub...
>>
>>>You would use the first one:
>>>
>>>Function long GetFileVersionInfoSize (string lptstrFilename, long
>>>lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeW"
>>>
>>>
>>>
>>>Stephen wrote:
>>>
>>>>So should it look like that?
>>>>
>>>>Function long GetFileVersionInfoSize (string lptstrFilename, long 
>>>>lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeW"
>>>>
>>>>or like that
>>>>
>>>>Function long GetFileVersionInfoSizeW (string lptstrFilename, long 
>>>>lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeA"
>>>>
>>>>
>> 

0
Stephen
8/22/2006 5:13:48 PM
It should work. I have no problems using it here. What happens if you 
use it on a different file (e.g. a dll)?

Is MyFile.exe something you can send me? I could try it with what I have 
to see if it works or not.

Brad

Stephen wrote:
> The file version is 2.0.3
> 
> The thing is that I find it bizarre that MS Access return 2076 when using 
> that function for MyFile.exe and Powerbuilder returns 0.
> 
> I thought that in debug mode I could find where the problem is located and 
> it seems to be with the GetFileVersionInfoSize function. Shouldn't it return 
> the same value?
> 
> 
> 
> 
> "Brad Wery [TeamSybase]" <bradweryatagricoreunited.com> wrote in message 
> news:44eb30eb$1@forums-2-dub...
> 
>>PB 10 is Unicode so you will want to use GetFileVersionInfoSizeW. A return 
>>of zero may be the correct return value. Here is what Microsoft's web site 
>>has to say about the function:
>>
>>"The GetFileVersionInfoSize function determines whether the operating 
>>system can retrieve version information for a specified file. If version 
>>information is available, GetFileVersionInfoSize returns the size, in 
>>bytes, of that information."
>>
>>Does the file you're accessing actually have a version number. I tried it 
>>on a dll and it returned the size in bytes. I tried it on an exe that did 
>>not have a version number and it returned 0.
>>
>>If you hover your mouse over the file in Windows Explorer you should be 
>>able to see the version in the tooltip that pops up.
>>
>>GetFileVersionInfoSizeA probably works in Access because it's an ANSI 
>>environment. If you want to use the ansi version in PB 10 you can declare 
>>it like this:
>>
>>Function long GetFileVersionInfoSize (string lptstrFilename, long 
>>lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeA;ANSI"
>>
>>
>>
>>Brad
>>
>>Stephen wrote:
>>
>>>I've tried that and I still get 0
>>>I've done the same change in MS Access and it was now 0 too.
>>>It seems that I need to use GetFileVersionInfoSizeA.
>>>have you tried it?
>>>
>>>
>>>"Brad Wery [TeamSybase]" <bradweryatagricoreunited.com> wrote in message 
>>>news:44eb2c46$1@forums-2-dub...
>>>
>>>
>>>>You would use the first one:
>>>>
>>>>Function long GetFileVersionInfoSize (string lptstrFilename, long
>>>>lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeW"
>>>>
>>>>
>>>>
>>>>Stephen wrote:
>>>>
>>>>
>>>>>So should it look like that?
>>>>>
>>>>>Function long GetFileVersionInfoSize (string lptstrFilename, long 
>>>>>lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeW"
>>>>>
>>>>>or like that
>>>>>
>>>>>Function long GetFileVersionInfoSizeW (string lptstrFilename, long 
>>>>>lpdwHandle) Library "version.dll" Alias for "GetFileVersionInfoSizeA"
>>>>>
>>>>>
>>>
> 
0
Brad
8/22/2006 5:18:14 PM
Reply:

Similar Artilces:

Help on how to get Product Version and File Version on exe file
Hi All, Is there a way of getting the Product and File version of my pb application during runtime? Is there a pb function I can use or do I have to use an API function to do this? Currently using PB 9.0.1 Build 7171 Regards and Thanks, Willie ...

Get File Version from EXE File
hi folks how can i get the file version from a exe file. i need that information for a setup download website. best regards Philipp Use System.Diagnostics.FileVersionInfo.GetVersionInfo(path) to get the version info of a file.Hope this helps!Paul yes, thanks a lot :)...

Urgent: unable to get version information from powerbuilder 8 generated dll files
Hi, Wins2K/PB8 Version 8.0.1 Build 9056 After I built machine codes (DLLs) for my application, my codes (in attachment) could not get version information of those files. It failed after calling VerQueryValueA API. By the way, my local external functions are declared as followed: FUNCTION ulong GetFileVersionInfoSizeA( REF string lpFilename, REF ulong lpdwHandle ) LIBRARY "version.dll" FUNCTION boolean GetFileVersionInfoA( REF string lpFilename, REF ulong lpdwHandle, ulong dwLen, REF string lpData ) LIBRARY "version.dll" FUNCTION boolean VerQueryValueA(...

Urgent: unable to get version information from powerbuilder 8 generated dll files
begin 644 getversioninfo.txt M=6QO;F<)9'=(86YD;&4-"G5L;VYG"61W3&5N9W1H#0IS=')I;F<);'-?=F5R M<VEO;FME>7-;,3)=(#T@>R`B4')O9'5C=$YA;64B+"`B4')O9'5C=%9E<G-I M;VXB+"`F#0H)"0DB3W)I9VEN86Q&:6QE;F%M92(L(")&:6QE1&5S8W)I<'1I M;VXB+"`B1FEL959E<G-I;VXB+"`F#0H)"0DB0V]M<&%N>4YA;64B+"`B3&5G M86Q#;W!Y<FEG:'0B+"`B3&5G86Q4<F%D96UA<FMS(BP@)@T*"0D)(DEN=&5R M;F%L3F%M92(L(")0<FEV871E0G5I;&0B+"`B4W!E8VEA;$)U:6QD(BP@(D-O M;...

How to get file version?
I read in a <filename> but I don't know how get the file version out of the file. It seems Perl stat() doesn't work this way. Anybody knows what Perl function or module will work? Thanks, HL Ha Le wrote: > I read in a <filename> but I don't know how get the file version out of > the file. It seems Perl stat() doesn't work this way. Anybody knows what > Perl function or module will work? > what file version do you refer to? david Could you be more specific about what you mean by "version"? You mean for an executable...

How to get file version? #2
I read in a <filename> but I don't know how get the file version out of the file. It seems Perl stat() doesn't work this way. Anybody knows what Perl function or module will work? Thanks, HL On Sep 26, Le, Ha (OPB) said: >I read in a <filename> but I don't know how get the file version out of >the file. It seems Perl stat() doesn't work this way. Anybody knows >what Perl function or module will work? How are you defining a file version? -- Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/ RPI Acac...

How to get a file version of an exe
If I right click on a file and select properties, I get a window with a version tag that shows me the version of the file. How can I get that with code? I have been looking at the following window api call: BOOL GetFileVersionInfo(LPCSTR lptstrFilename, DWORD dwHandle, DWORD dwLen, LPVOID lpData ); Does anyone have some sample code that does this? I always get confused when trying to match arguments with windows api and I'm not sure how to use this if this is even the right way. Thanks > If I right click on a file and select properties, I get a > ...

Getting File Version
I'm sorry, I see it's been asked here a couple times but I need a different version number than the one the example on codexchange gets. Looking at the deployment window in PB I set the following just to see where everyone is pulling from. executable: product verison 1.2.3.4 file version: 4.3.2.1 used by installer product version: 9.6.3.5 file verison 7.4.1.8 Now using NSIS to build my installer, it pulls 7.4.1.8. Using the version10 project from codexchange, it pulls 1.2.3.4. I've tried this code: http://www.sybase.com/detail?id=1002724 and I get an array out...

How to get the version number of a file ?
Hello, I use a VB exe file with my PB Application. I wish to know the version number. Is is possible with API? I have tried to use the PFC but only the date is avalaible and returns "00/00/00". May someone help me ? Check the File version Information thread in powersoft.public.powerbuilder.general I haven't found the definitive answer yet, but this shows the general method (using various API calls), and hopefully someone will come up with a solution soon! Simon Olivier AIMOND wrote in message ... >Hello, > >I use a VB exe file with my PB ...

Versionning Powerbuilder Executable files
We are using Microsoft SMS tool for deploying our NT PB applications. We would like to get the version number when generating a new executable file. But when we try to get the product version, it is the powerbuilder product version that we get (For example version 6.5.00.444). Does anyone know how to put a real version numbre when compiling our applications ? Use VersionEdit from http://www.ecrane.com. FWIW, PB8 will allow you to specify your own version info in the project painter. -- pbm_hopethishelps, Roy Kiesler [TeamSybase] Sybase Developer Network (SDN) - http://sdn.syb...

Get executable file version
I am using PB 9. I generate an executable file and put the version 2.1.0.0 on all project versions' fields. How can I get this numbers on my application? Thiago Campos Pereira wrote: > I am using PB 9. > > I generate an executable file and put the version 2.1.0.0 on all project > versions' fields. How can I get this numbers on my application? > > http://eshop.sybase.com/detail/1,6904,44648,00.html -- Roy ...

How do I get the version of a file on the hard drive
How do I get the version of a file on the hard drive from within PowerBuilder. I cannot find a built in function or an example of an API call. Thanks, Scott Rupke scott@storertv.com Take a look at this thread. http://groups.google.com/groups?hl=en&threadm=896798178.3398.0.nnrp-07.c1ed0 e5f%40news.demon.co.uk&rnum=1&prev=/groups%3Fhl%3Den%26selm%3D896798178.3398 ..0.nnrp-07.c1ed0e5f%2540news.demon.co.uk (This link may span several lines and you may have to copy-and-paste them into your browser's URL) HTH -EGM Scott Rupke <scott@storertv.com...

regex to get version from file name
--089e01633aa82c2de204f2eb5814 Content-Type: text/plain; charset=ISO-8859-1 Hi all, From the below file names I only need the version number 1.2.4 without explicitly specifying it. check_mk-1.2.4.tar.gz check_mk-agent-1.2.4-1.noarch.rpm check_mk-agent-logwatch-1.2.4-1.noarch.rpm check_mk-agent-oracle-1.2.4-1.noarch.rpm mk-livestatus-1.2.4.tar.gz mkeventd-1.2.4.tar.gz What regex can I use to obtain only the string value 1.2.4 from the file names (or whatever future versions based on the 3 numbers separated by 3 dots, [0-9].[0-9].[0-9]? Thanks! Wernher --089e016...

RE: How do I get DLL file versions
This approach works >> use Win32::API; sub GetFileVersion { my $fn = shift @_; if (! $ref_GetFileVersionInfoSize) { $ref_GetFileVersionInfoSize = new Win32::API("Version", "GetFileVersionInfoSize", [P, P], I); if ( ! defined $ref_GetFileVersionInfoSize) { warn "Cannot import KERNEL fcn : GetFileVersionInfoSize : $!"; return undef; } } # OK, we've got a handle for GetFileVersionInfoSize; use it! my $z = 0; my $sz = $ref_GetFileVersionInfoSize->...

Web resources about - Getting file version - sybase.powerbuilder.general

San Bernardino Investigators Can’t Access NSA Phone Records
Authorities investigating the mass shooting in San Bernardino need Syed Farook and Tashfeen Malik ‘s phone records. Thanks to the USA Freedom ...

Alabama-Michigan St in CFP semifinal at familiar spot
Alabama and Michigan State are playing in the College Football Playoff semifinal at the Cotton Bowl in a stadium where both teams have already ...

At least 32 Islamic State fighters killed in strikes in Syria's Raqqa: monitor
At least 32 Islamic State fighters were killed and 40 more wounded in Syria's Raqqa province on Sunday, in a series of air strikes believed to ...

Arnold Schwarzenegger: Climate Change Hard On The Brain, Global Warming Fight Needs China And U.S. To ...
According to former California governor Arnold Schwarzenegger, climate change science is very difficult for the average brain to understand. ...

Star Wars planetary drinking glasses
Thinkgeek has extended its solar system drinking glasses with a new link of six 10oz Star Wars glasses that symbolize six of the Lucas mythos's ...


Ryan Gosling’s Scarecrow Sharpens ‘Saturday Night Live’ Parody Of ‘The Wiz Live!’
UPDATE, 9:30 AM: Adds full cast of The Wiz Live! parody, below. EARLIER: The cold opening — Taran Killam and Cecily Strong as Donald and Melania ...

Morgan Freeman’s Plane Crash Leaves Actor And SJ30 Jet Pilot, Jimmy Hobson, Unscathed
A private plane carrying actor Morgan Freeman and pilot Jimmy Hobson made an emergency crash landing in Tunica, Mississippi on Saturday. Fortunately, ...

‘Game of Thrones’ Trailer Sets Stage For A Game-Changing Season
The premiere of Game of Thrones Season 6 is more than four months away, but the hype surrounding the incredibly secretive production is already ...

Former US President Jimmy Carter Officially Announces He’s Cancer Free!
Former United States President, Jimmy Carter is having a great start to the week and made an announcement on Sunday that invites the world to ...

Resources last updated: 12/6/2015 6:21:02 PM