1. Tomas Beran
  2. PowerBuilder
  3. Monday, 28 March 2022 16:18 PM UTC

Hello

I want to show the version of my application in About box. Is there a more "PB-way" how to read these values from a project than C# FileVersionInfo.FileVersion()? I mean an environment variable, contextinformation etc.

Tomas Beran Accepted Answer Pending Moderation
  1. Friday, 1 April 2022 17:33 PM UTC
  2. PowerBuilder
  3. # 1

Hi

I've wrapped .NET FileVersionInfo class. If someone is interested in then there's the code:

C# source code for SnapDevelop is here.

Exported PB2021 object and compiled .NET Framework 2.0 DLL are attached. The DLL has no dependency.

using System;
using System.Diagnostics;

namespace eclipse
{
    namespace eclVersion
    {
        public class Version
        {
            private FileVersionInfo data;
            
            public void GetVersion(string filePath)
            {
                data = FileVersionInfo.GetVersionInfo(filePath);
            }
            public void GetVersion()
            {
                GetVersion(FullPath());
            }
            
            private String FullPath()
            {
                Process myProc = Process.GetCurrentProcess(); // Or whatever method you are using
                return myProc.MainModule.FileName;
            }
            public bool IsPreRelease { get { return data.IsPreRelease; } }
            public int ProductPrivatePart { get { return data.ProductPrivatePart; } }
            public string ProductName { get { return data.ProductName; } }
            public int ProductMinorPart { get { return data.ProductMinorPart; } }
            public int ProductMajorPart { get { return data.ProductMajorPart; } }
            public int ProductBuildPart { get { return data.ProductBuildPart; } }
            public string PrivateBuild { get { return data.PrivateBuild; } }
            public string OriginalFilename { get { return data.OriginalFilename; } }
            public string LegalTrademarks { get { return data.LegalTrademarks; } }
            public string LegalCopyright { get { return data.LegalCopyright; } }
            public string Language { get { return data.Language; } }
            public bool IsSpecialBuild { get { return data.IsSpecialBuild; } }
            public bool IsPrivateBuild { get { return data.IsPrivateBuild; } }
            public string ProductVersion { get { return data.ProductVersion; } }
            public string SpecialBuild { get { return data.SpecialBuild; } }
            public bool IsDebug { get { return data.IsDebug; } }
            public string InternalName { get { return data.InternalName; } }
            public string FileVersion { get { return data.FileVersion; } }
            public int FilePrivatePart { get { return data.FilePrivatePart; } }
            public string FileName { get { return data.FileName; } }
            public int FileMinorPart { get { return data.FileMinorPart; } }
            public int FileMajorPart { get { return data.FileMajorPart; } }
            public string FileDescription { get { return data.FileDescription; } }
            public int FileBuildPart { get { return data.FileBuildPart; } }
            public string CompanyName { get { return data.CompanyName; } }
            public string Comments { get { return data.Comments; } }
            public bool IsPatched { get { return data.IsPatched; } }
        }
        
    }
}
Attachments (1)
Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 28 March 2022 23:56 PM UTC
  2. PowerBuilder
  3. # 2

My OSVersion example returns information about the operating system version and it returns version info from an exe or dll.

https://www.topwizprogramming.com/freecode_osversion.html

 

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 28 March 2022 17:03 PM UTC
  2. PowerBuilder
  3. # 3

Hi Tomas;

  FWIW: That is how my Framework reads this information ... but it calls the MS-Windows API's directly for that to read the EXE (or DLL's) properties. No external DLL(s) needed.

For example: Form the IDE...

 

From an EXE ...

 

HTH

Regards ... Chris

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.