Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to I read the registry to determine what version of Excel is on the PC

Posted on 2009-05-12
6
Medium Priority
?
1,107 Views
Last Modified: 2013-11-23
I am unfamiliar with TRegistry and TRegIniFile
I want to determine the current version of Excel on the machine
Every effort simply returns a blank
I know it is un HKEYS_CLASSES_ROOT and under \Excel.Application\CurVer

procedure TForm1.Button1Click(Sender: TObject);
var
  Reg: TRegIniFile;
begin
  Reg := TRegIniFile.Create;
 
  Reg.RootKey := HKEY_CLASSES_ROOT;
 
//  if Reg.OpenKeyReadOnly('\Excel.Application\CurVer\') then
    ShowMessage(Reg.ReadString('Excel.Application','CurVer','Unknown'));
 
  Reg.Free
end;

Open in new window

0
Comment
Question by:bellfieldpark
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 8

Expert Comment

by:BdLm
ID: 24362894
what is not workin on your approach ?
0
 
LVL 6

Accepted Solution

by:
bokist earned 1000 total points
ID: 24362957
There are 2 possible solutions

1.  From registry :

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.Application
    CurVer   >    Excel.ApplicationExcel...some_number
   
2.  With ole object :

Add ComObj  to uses

Function ExcelVersion: string;
var
   XLS: Variant;
begin
  Result := '';
  try
      Xls := CreateOleObject('Excel.Application');
      Result := Excel.Version;
  except
  end;
end;
0
 
LVL 8

Assisted Solution

by:BdLm
BdLm earned 1000 total points
ID: 24363169

unit Unit_eval_excel_version;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Registry;
type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button2: TButton;
    ListBox1: TListBox;
    procedure Button2Click(Sender: TObject);
  private
    function GetStringFromRegistry: String;
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
 

function  TForm1.GetStringFromRegistry : String;
var     Reg  :   TRegIniFile;
        results : TStringList;
begin
   //  Load from registry
   Reg := TRegIniFile.Create;
   results :=TStringList.Create;;
   try
   // Reg.RootKey := HKEY_LOCAL_MACHINE;
   // Reg.RootKey := HKEY_CURRENT_USER;
   Reg.RootKey := HKEY_CLASSES_ROOT;
   Reg.OpenKey('Excel.Application', true);
   try
     Reg.ReadSectionValues('CurVer', Results);

      ListBox1.Items := results ;
   except
       result :='';
   end;
   Reg.CloseKey;
   finally
   Reg.Free;
   end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
    edit1.text :=  GetStringFromRegistry;
end;
end.

ee-registry.bmp
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Closing Comment

by:bellfieldpark
ID: 31618522
ComObj answer was easy (although Result := XLs.Version)
Registry answer also worked, and can be used for other Registry issues
0
 

Author Comment

by:bellfieldpark
ID: 24365974
Comobj code should say Result := XLs.Version
Then it will work
0
 
LVL 6

Expert Comment

by:bokist
ID: 24367803
sorry, it was a typo...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
Suggested Courses

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question