Http://www.cnblogs.com/onechen/p/3627942.html
XE7 Source Download: [Original] Get the app's own version number (malicious across 4 platforms) Xe7.zip
XE6 Source Download: [Original] Get the app's own version number (malicious across 4 platforms) Xe6.zip
XE5 Source Download: [Original] Get the app's own version number (malicious across 4 platforms). zip
------------------------------------------------------------------------------//by [Guishan] a swastika qq:1467948783//http ://www.cnblogs.com/onechen///------------------------------------------------------------------------------ Unit main;interfaceuses system.sysutils, System.types, System.uitypes, system.classes, System.variants, {$ Ifdef mswindows} winapi.windows, {$ENDIF} {$IFDEF ANDROID} Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.JavaTypes, FMX. Helpers.android,
Androidapi.helpers,//XE7 need to introduce
{$ENDIF}
{$IFDEF IOS} FMX. Platform.ios, Iosapi.foundation, Macapi.objectivec, {$ENDIF} {$IFDEF MACOS} FMX. Platform.mac, Macapi.foundation, Macapi.objectivec, {$ENDIF} FMX. Types, FMX. Controls, FMX. Forms, FMX. Graphics, FMX. Dialogs, FMX. Layouts, FMX. Memo, FMX. Stdctrls;type TForm1 = Class (Tform) Toolbar1:ttoolbar; Label1:tlabel; Memo1:tmemo; Procedure Formcreate (Sender:tobject); Private {Private declarations} public {public declarations} End;var form1:tform1;implementation{$R *.fmx}{$I Fdef mswindows}procedure Getbuildinfo (Var V1, V2, V3, V4:word); var verinfosize, Vervaluesize, Dummy:dword; Verinfo:pointer; Vervalue:pvsfixedfileinfo;begin verinfosize: = GetFileVersionInfoSize (PChar (paramstr (0)), Dummy); If verinfosize > 0 THEN BEGIN GETMEM (Verinfo, verinfosize); Try if GetFileVersionInfo (PChar (paramstr (0)), 0, Verinfosize, verinfo) THEN BEGIN VerQueryValue (Ver Info, ' \ ', Pointer (Vervalue), vervaluesize); With vervalue^ do begin V1: = Dwfileversionms shr 16; V2: = Dwfileversionms and $FFFF; V3: = Dwfileversionls shr 16; V4: = Dwfileversionls and $FFFF; End End Finally Freemem (Verinfo, verinfosize); End End;end;function Getbuildinfoasstring:string;var V1, V2, V3, V4:word;begin getbuildinfo (V1, V2, V3, V4); Result: = IntToStr (V1) + '. ' + inttostr (V2) + '. ' + inttostr (V3) + '. ' + inttostr (V4); end; {$ENDIF}procedure tform1.formcreate (sender:tobject); {$IFDEF Mswindows}begin memo1.beginupdate; MEMO1.LINES.ADD (' os:windows '); MEMO1.LINES.ADD (' ver: ' + getbuildinfoasstring); Memo1.endupdate;end; {$ENDIF} {$IFDEF Android}var packageinfo:jpackageinfo; Packagename:jstring;begin memo1.beginupdate; MEMO1.LINES.ADD (' os:android '); Memo1.Lines.Add (' Applicationlabel: ' + getapplicationtitle); PackageName: = Sharedactivitycontext.getpackagename; MEMO1.LINES.ADD (' PackageName: ' + jstringtostring (packagename)); PackageInfo: = SharedActivityContext.getPackageManager.getPackageInfo (PackageName, 0); Memo1.Lines.Add (' versionname: ' + jstringtostring (packageinfo.versionname)); Memo1.endupdate;end; {$ENDIF} {$IF Defined (IOS) or Defined (MACOS)}var appnamekey:pointer; Appbundle:nsbundle; Nsappname:nsstring;begin memo1.beginupdate; MEMO1.LINES.ADD (' Os:ios '); Appbundle: = Tnsbundle.wrap (TNSBundle.OCClass.mainBundle); Appnamekey: = (nsstr (' Cfbundlename ') as Ilocalobject). Getobjectid; Nsappname: = Tnsstring.wrap (AppBundle.infoDictionary.objectForKey (Appnamekey)); Memo1.Lines.Add (' cfbundlename: ' + utf8tostring (nsappname.utf8string)); Appnamekey: = (nsstr (' Cfbundledisplayname ') as Ilocalobject). Getobjectid; Nsappname: = Tnsstring.wrap (AppBundle.infoDictionary.objectForKey (Appnamekey)); Memo1.Lines.Add (' cfbundledisplayname: ' + utf8tostring (nsappname.utf8string)); Appnamekey: = (nsstr (' CfbundleIdentifier ') as Ilocalobject). Getobjectid; Nsappname: = Tnsstring.wrap (AppBundle.infoDictionary.objectForKey (Appnamekey)); Memo1.Lines.Add (' cfbundleidentifier: ' + utf8tostring (nsappname.utf8string)); Appnamekey: = (nsstr (' cfbundleversion ') as Ilocalobject). Getobjectid; Nsappname: = Tnsstring.wrap (AppBundle.infoDictionary.objectForKey (Appnamekey)); Memo1.Lines.Add (' cfbundleversion: ' + utf8tostring (nsappname.utf8string)); Memo1.endupdate;end; {$ENDIF}end.
Get the APP's own version number (malicious across 4 platforms)