Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Get Version number of my FMX application?



Permlink Replies: 7 - Last Post: Oct 1, 2016 5:44 PM Last Post By: steven chesser
steven chesser

Posts: 401
Registered: 4/13/09
Get Version number of my FMX application?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 29, 2016 9:45 PM
Using 10.1 Update 1

Using this code to get Android build version and it works pretty well.
Win32 version does not.
GetFileVersionInfoSize always fails.

My version number for Win32 is 1.0.0.2 (currently)
I also set the other attributes like CompanyName and such.

When I right click on my .exe non that shows?

Anyways, what I have currently.

uses
  {$IFDEF ANDROID}
  Androidapi.Helpers,
  Androidapi.JNI.App,
  Androidapi.JNI.GraphicsContentViewText,
  {$ENDIF}
  {$IFDEF WIN32}
  WINAPI.WINDOWS,
  {$ENDIF}
   .. ;
 
Function GetAppVersion : String;
   {$IFDEF ANDROID}
    Var
     PackageManager: JPackageManager;
     PackageInfo : JPackageInfo;
   begin
    PackageManager := SharedActivity.getPackageManager;
    PackageInfo := PackageManager.getPackageInfo(SharedActivityContext.getPackageName(), TJPackageManager.JavaClass.GET_ACTIVITIES);
    result := JStringToString(PackageInfo.versionName); 
   end;
  {$ENDIF}
  
  {$IFDEF WIN32}
var
  Exe: string;
  Size, Handle: DWORD;
  Buffer: TBytes;
  FixedPtr: PVSFixedFileInfo;
begin
  Exe := ParamStr(0);
  Size := GetFileVersionInfoSize(PChar(Exe), Handle);   //  <------- ALWAYS RETURNS 0
  if Size = 0 then
    RaiseLastOSError;
  SetLength(Buffer, Size);
  if not GetFileVersionInfo(PChar(Exe), Handle, Size, Buffer) then
    RaiseLastOSError;
  if not VerQueryValue(Buffer, '\', Pointer(FixedPtr), Size) then
    RaiseLastOSError;
  Result := Format('%d.%d.%d.%d',
    [LongRec(FixedPtr.dwFileVersionMS).Hi,  //major
     LongRec(FixedPtr.dwFileVersionMS).Lo,  //minor
     LongRec(FixedPtr.dwFileVersionLS).Hi,  //release
     LongRec(FixedPtr.dwFileVersionLS).Lo]) //build
end;
{$ENDIF}
 
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Get Version number of my FMX application? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 29, 2016 10:11 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

Win32 version does not.
GetFileVersionInfoSize always fails.

If that's the case, it may be that you don't have version info turned on in the project options for Win32 (make sure
you check both Debug and Release)

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
steven chesser

Posts: 401
Registered: 4/13/09
Re: Get Version number of my FMX application? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 30, 2016 7:46 AM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
steven chesser wrote:

Win32 version does not.
GetFileVersionInfoSize always fails.

If that's the case, it may be that you don't have version info turned on in the project options for Win32 (make sure
you check both Debug and Release)

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

Both are checked on...

Has to be checked on so can even modify those values.

But double checked that both Debug/Release have it on and they do.

Still windows right click and details shows no version # info.

Running the version number code of mine

System Error.  Code: 1813.
 
The specified resource type cannot be found in the image file.
steven chesser

Posts: 401
Registered: 4/13/09
Re: Get Version number of my FMX application? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 30, 2016 7:51 AM   in response to: steven chesser in response to: steven chesser
Got the bright idea to make a new FMX project.... and version #'s work.

Go back to my old project ive been working on... version # won't work.

Also noticed my icon for my .exe is not working now either.

Sigh... now to figure out wtf is broke ...
steven chesser

Posts: 401
Registered: 4/13/09
Re: Get Version number of my FMX application? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 30, 2016 7:28 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:
Got the bright idea to make a new FMX project.... and version #'s work.

Go back to my old project ive been working on... version # won't work.

Also noticed my icon for my .exe is not working now either.

Sigh... now to figure out wtf is broke ...

Messed with this off and on through out the day...

Still could not get working.

I assume its a problem in the .dproj file ? But what exactly I have no clue.
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Get Version number of my FMX application? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 1, 2016 3:07 AM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

Messed with this off and on through out the day...

Still could not get working.

I assume its a problem in the .dproj file ? But what exactly I have no clue.
And it isn't easily just to delete the old .dproj and .dpr and create a new project?
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Get Version number of my FMX application? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 1, 2016 4:13 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:

Also noticed my icon for my .exe is not working now either.

Sounds like it might be a problem with the .res file.

As per Cristian's message, you might want to recreate the .dpr and .dproj (by starting a new project, then add your
units), and make sure you delete the original .res file.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
steven chesser

Posts: 401
Registered: 4/13/09
Re: Get Version number of my FMX application? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 1, 2016 5:44 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
steven chesser wrote:

Also noticed my icon for my .exe is not working now either.

Sounds like it might be a problem with the .res file.

As per Cristian's message, you might want to recreate the .dpr and .dproj (by starting a new project, then add your
units), and make sure you delete the original .res file.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

That is what I'll be doing... I just wanted to see what was actually messed up for future blow ups and submit a QC report if its a bug in the IDE screwing it up.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02