Jump to content
dmitrybv

programmatically determine the edition of RAD Studio 12.3

Recommended Posts

Hello,
How can I programmatically determine the edition of RAD Studio 12.3?
In the registry key Computer\HKEY_CURRENT_USER\Software\Embarcadero\BDS\23.0, there is no value named Edition.
I have the same question regarding RAD Studio 11.3 and 10.4.

Share this post


Link to post
4 minutes ago, Anders Melander said:

GetRTLVersion would be my guess.

The actual values appears to be undocumented though.

1. RTLVersion and RAD Studio Edition (Professional, Enterprise, Community Edition) are different concepts. 
2. RTLVersion for RAD Studio 12.3 cannot be called from an external program.

Share this post


Link to post
Just now, dmitrybv said:

1. RTLVersion and RAD Studio Edition (Professional, Enterprise, Community Edition) are different concepts. 
2. RTLVersion for RAD Studio 12.3 cannot be called from an external program.

Oh - You meant what version of RAD Studio is installed on the local system.

 

I think the InstalledUpdates registry key is the closest you can get. There's no guarantee that it's valid though since it's only informational.

Share this post


Link to post

I don't have an answer but the edition is in the license. And I don't think there is a public API to read it.

But if you run ddc32 with different small projects the messages can tell you something about this.

Share this post


Link to post

There is this small component I use for ages (CEVersionInfo) that takes the version info from the Delphi IDE. (Menu-Projects-Project Options-Version Info)

In the IDE I put the Delphi version name into the "Comments" field and in the program source you can use it just like: "myEdit.Text:=CEVersionInfo.Comments" 

 

I've searched the web for the component but only saw some sites where I didn't dare to click to..

I'm willing to publish the source because there is no copyright involved and it is quite small code.

 

It can take the following info fields:

  FCompanyname      :='<info not available>';
  FFileDescription  :='<info not available>';
  FFileVersion      :='<info not available>';
  FInternalname     :='<info not available>';
  FLegalCopyright   :='<info not available>';
  FLegalTradeMarks  :='<info not available>';
  FOriginalFilename :='<info not available>';
  FProductName      :='<info not available>';
  FProductVersion   :='<info not available>';
  FComments         :='<info not available>';
  FMajorVersion     :='<info not available>';
  FMinorVersion     :='<info not available>';
  FRelease          :='<info not available>';
  FBuild            :='<info not available>';

 

Share this post


Link to post

As this information might be useful I added TAEIDEVersion.Edition and TAEIDEVersion.ExecutableVersion to my installed version / instance detection component. Tested with TAEDelphiVersion, seems to return correct values.

Share this post


Link to post
8 hours ago, dmitrybv said:

How can I programmatically determine the edition of RAD Studio 12.3?

From within the IDE? Use IOTAVersionSKUInfoService. Example:

var
  LSKUInfoService: IOTAVersionSKUInfoService;
begin
  LSKUInfoService := BorlandIDEServices as IOTAVersionSKUInfoService;
  Label1.Caption := Format('SKU: %s (%d)', [LSKUInfoService.SKUName, LSKUInfoService.SKU]);
end;

Oddly, for SKU the docs say:

    /// <summary>
    /// Return SKU identifier, possible values are:
    ///
    ///   Professional = 2
    ///   Professional C/S = 3
    ///   Enterprise = 4
    ///   Architect = 5
    ///   CommunityEdition = 128
    /// </summary>

..but in my install of Delphi (Enterprise), it returns 52. The SKUName value appears to be correct for me, though

Share this post


Link to post

Actually I need to determine the edition of RAD Studio from an external program, from my installer program, in order to understand whether I can use dcc32.exe to compile the library source codes to generate packages for installation or not.
RAD Studio 12.3 Community Edition does not support compilation via dcc32.exe.
I am trying to understand how I can determine in advance in the LibInstaller program whether I can generate packages and install the library in the IDE or not.

Share this post


Link to post
24 minutes ago, dmitrybv said:

Actually I need to determine the edition of RAD Studio from an external program, from my installer program, in order to understand whether I can use dcc32.exe to compile the library source codes to generate packages for installation or not.
RAD Studio 12.3 Community Edition does not support compilation via dcc32.exe.
I am trying to understand how I can determine in advance in the LibInstaller program whether I can generate packages and install the library in the IDE or not.

Does the executable dcc32.exe exist in that case? If not, there's your answer. If yes and it only outputs an error message or something, you could do exactly that: Call it and check for that error.

Share this post


Link to post

dcc32.exe is present in RAD Studio 12.3 Community Edition.
It runs without errors.
After running dcc32.exe %ERRORLEVEL% = 0.

Share this post


Link to post
1 minute ago, dmitrybv said:

dcc32.exe is present in RAD Studio 12.3 Community Edition.
It runs without errors.
After running dcc32.exe %ERRORLEVEL% = 0.

What error do you get when you compile something with dcc32.exe from the Community Edition.

Can't you catch this error and make you decision based on that?

Share this post


Link to post

dcc32.exe does not generate any error.

You can understand that something went wrong only at the end of the installation, when bpl packages are registered in the registry for IDE.

dcc32.exe does not create bpl packages and then it is already clear.

But I want to give the user information about the impossibility of installation before the installation process begins.

Share this post


Link to post
4 minutes ago, dmitrybv said:

dcc32.exe does not generate any error.

You can understand that something went wrong only at the end of the installation, when bpl packages are registered in the registry for IDE.

dcc32.exe does not create bpl packages and then it is already clear.

But I want to give the user information about the impossibility of installation before the installation process begins.

Why don't you use this:

10 hours ago, Kazantsev Alexey said:

 

Share this post


Link to post

It seems that the solution with "bds.exe /ProductInfo:SKU" is suitable, but it does not work in the classic function of outputting the results of the StdOutput work via CreatePipe.

 

Can you tell me how to correctly redirect the results passed to StdOutput to TMemo?

 

I am trying to use the following code, but TMemo remains empty.

 

At the same time, if you create a BdsGetSKU.Cmd file with the text
C:\RADStudio\23.0\bin\bds.exe /ProductInfo:SKU
and run it in cmd, the text "Enterprise" is output in cmd.

 

procedure RunConsoleAppAndCaptureOutput(const ACommandLine, AWorkingDir: string; AMemo: TMemo);
var
  SecurityAttr: TSecurityAttributes;
  ReadPipe, WritePipe: THandle;
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
  Buffer: array[0..255] of AnsiChar;
  BytesRead: DWORD;
  AppRunning: DWORD;
  Output: TStringStream;
  CommandLineMutable: array[0..1023] of Char;
begin
  AMemo.Clear;

  SecurityAttr.nLength := SizeOf(TSecurityAttributes);
  SecurityAttr.bInheritHandle := True;
  SecurityAttr.lpSecurityDescriptor := nil;

  if not CreatePipe(ReadPipe, WritePipe, @SecurityAttr, 0) then
  begin
    AMemo.Lines.Add('Failed to create channel.');
    Exit;
  end;

  FillChar(StartupInfo, SizeOf(StartupInfo), 0);
  StartupInfo.cb := SizeOf(StartupInfo);
  StartupInfo.hStdOutput := WritePipe;
  StartupInfo.hStdError := WritePipe;
  StartupInfo.dwFlags := STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW;
  StartupInfo.wShowWindow := SW_HIDE;

  StrPLCopy(CommandLineMutable, ACommandLine, Length(ACommandLine) + 1);

  if not CreateProcess(
    nil,
    CommandLineMutable,
    nil,
    nil,
    True,
    0,
    nil,
    PChar(AWorkingDir), // <- working directory
    StartupInfo,
    ProcessInfo
  ) then
  begin
    AMemo.Lines.Add('Failed to start process.');
    CloseHandle(ReadPipe);
    CloseHandle(WritePipe);
    Exit;
  end;

  CloseHandle(WritePipe);

  Output := TStringStream.Create;
  try
    repeat
      BytesRead := 0;
      if ReadFile(ReadPipe, Buffer, SizeOf(Buffer) - 1, BytesRead, nil) and (BytesRead > 0) then
      begin
        Buffer[BytesRead] := #0;
        Output.WriteString(String(AnsiString(Buffer)));
      end;

      GetExitCodeProcess(ProcessInfo.hProcess, AppRunning);
    until AppRunning <> STILL_ACTIVE;

    // Read the rest
    while ReadFile(ReadPipe, Buffer, SizeOf(Buffer) - 1, BytesRead, nil) and (BytesRead > 0) do
    begin
      Buffer[BytesRead] := #0;
      Output.WriteString(String(AnsiString(Buffer)));
    end;

    AMemo.Lines.Text := Output.DataString;
  finally
    Output.Free;
    CloseHandle(ReadPipe);
    CloseHandle(ProcessInfo.hProcess);
    CloseHandle(ProcessInfo.hThread);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
//  RunConsoleAppAndCaptureOutput(Edit1.Text, 'C:\RADStudio\23.0\bin', Memo1);
//  RunConsoleAppAndCaptureOutput('cmd /c dir', 'C:\Windows', Memo1);
  RunConsoleAppAndCaptureOutput('C:\RADStudio\23.0\bin\bds.exe /ProductInfo:SKU', 'C:\RADStudio\23.0\bin', Memo1);
//  RunConsoleAppAndCaptureOutput('C:\RADStudio\23.0\Projects\CommandLineInterpreter\BdsGetSKU.Cmd /ProductInfo:SKU', 'C:\RADStudio\23.0\bin', Memo1);
end;

 

Edited by dmitrybv

Share this post


Link to post

@dmitrybv I assume that in your real code, you retrieve the correct installation paths from registry?

 

Edit: Also, see this for executing shell commands:

 

Share this post


Link to post

Yes, in a real application I use the registry branch
Computer\HKEY_CURRENT_USER\Software\Embarcadero\BDS\23.0
to get the value for the App parameter that stores the path to bds.exe

 

I try to keep the demo code to a minimum so that it is clear what problem I am discussing here.

Edited by dmitrybv

Share this post


Link to post

Note that bds.exe /ProductInfo:SKU doesn't work in all version !! For me it prompts a popup dialog where I need to enter a license key (while I already have a licensed version installed).

So I wouldn't trust prameters to bds.exe unless you determined those parameters are correct for all versions.

 

You might have better luck just looking at the "Detail" properties of the bds.exe itself. Mine says "Product name: Professional" so I guess the community version would display "Community edition" or something.

 

(I wonder how the Jedi project does this. I think they use one or the other depending on the version.)

Share this post


Link to post

I tested RAD Studio 12.1 Community Edition.
For this edition, the "Detail" properties of the bds.exe contain the value “Personal”.
I don’t know what the value Personal means and whether it is related to the concept of Edition at all.

Share this post


Link to post

In terms of SKU, the Community Edition is in fact a Professional Edition. It is just the License restrictions that make it a CE.

Share this post


Link to post
2 minutes ago, Uwe Raabe said:

In terms of SKU, the Community Edition is in fact a Professional Edition. It is just the License restrictions that make it a CE.

Wat does "Personal" mean in the details then for the Community edition?

 

11 minutes ago, dmitrybv said:

I tested RAD Studio 12.1 Community Edition.
For this edition, the "Detail" properties of the bds.exe contain the value “Personal”.
I don’t know what the value Personal means and whether it is related to the concept of Edition at all.

 

Share this post


Link to post

What does the professional edition say in the "Detail" properties of the bds.exe? Also “Personal”? (or Professional)

Share this post


Link to post
2 minutes ago, Die Holländer said:

What does the professional edition say in the "Detail" properties of the bds.exe? Also “Personal”? (or Professional)

Delphi 10.2 Professional shows "Product name: Professional" and "Product version: 25.0". in the properties of bds.exe.

 

 

Edited by rvk

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×