Solved

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

Posted on 2009-05-12
6
1,076 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
  • 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 250 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 250 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
I'm a big fan of Windows' offline folder caching and have used it on my laptops for over a decade.  One thing I don't like about it, however, is how difficult Microsoft has made it for the cache to be moved out of the Windows folder.  Here's how to …
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…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now