Reputation: 2873
I have an application compiled for Compact Framework which I need to find the version number for using Delphi 2006. I am using the code below.
function VersionNumber(ExeFile: string): string;
var
Size: Longint;
Dummy: Cardinal;
Buffer: Pointer;
FileInfo: Pointer;
begin
Size := GetFileVersionInfoSize(PChar(ExeFile), Dummy);
GetMem(Buffer, Size);
if (GetFileVersionInfo(PChar(ExeFile), Dummy, Size, Buffer)) then begin
//VerQueryValue(Buffer, '\\', FileInfo, Dummy);
//with PVSFixedFileInfo(FileInfo)^ do
//Result := IntToStr(dwFileVersionMS div $10000) + '.' +
// IntToStr(dwFileVersionMS mod $10000) + '.' +
// IntToStr(dwFileVersionLS div $10000) + ' (' +
// IntToStr(dwFileVersionLS mod $10000) + ')';
end
else begin
Result := 'No version info available.';
end;
FreeMem(Buffer, Size);
end;
If I view the file details using Windows 7 I cannot see the version number there either, so it's not surprising that I cannot get it from Delphi.
Just on the off chance someone knows a way to get the version number it would be greatly appreciated.
UPDATE
This code was written more then a decade ago by an ex staff member. Up until now, it has worked fine, but has never been tried on an executable compiled for Compact Framework.
The GetFileVersionInfo function is returning false, so I am getting 'No version info available.' result.
Upvotes: 0
Views: 229
Reputation: 5959
CF does not put C/C++ FileVersionInfo into exe or DLL files. The AssemblyInfo is something different from the FileVersionInfo resource you are looking for with your code sample.
ctacke has a usefull post about this at http://blog.opennetcf.com/2014/01/03/howto-add-the-win32-file-version-to-your-net-compact-framework-assemblies/ which can be found via Version information missing from .NET assembly (Compact Framework 3.5/VS2008), what graymatter already posted.
Upvotes: 1