[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

searching registry

Posted on 2001-09-12
4
Medium Priority
?
198 Views
Last Modified: 2011-09-20
i want to search the registry for "winamp" and if its installed, display a message saying "winamp installed" or "winamp not installed"

can someone give me the code to do this?



thanks

ps, sorry to hear about the world trade centre, all my thoughs are with you all!!!

mark
0
Comment
Question by:marksmall
[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
4 Comments
 
LVL 21

Expert Comment

by:gemarti
ID: 6477350
{Create a new application. Add a listbox and a button.

Add this code. You can modify to compare for WinAmp}

unit unit1;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
 StdCtrls, Registry, Menus;

type
 TForm1 = class(TForm)
    ListBox1: TListBox;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;
 Reg : TRegistry;
 Val : TStringList;
 KeyName : String;
implementation

{$R *.DFM}

{var
 ValueName : String;}
{ valueName := ListBox1.Items.Text;
 if KeyName <> '' then
   begin
     Reg.OpenKey(KeyName,False);
     Edit1.Text := Reg.ReadString(ValueName);
   end;}

procedure TForm1.Button1Click(Sender: TObject);
var
 CompName : string;
 i:integer;
begin
 Val.Clear;
 KeyName := '\Software';
 Try
   Reg.RootKey := HKEY_LOCAL_MACHINE;
 Finally
       Reg.OpenKey(KeyName,FALSE);
       Reg.GetKeyNames(Val);
       for i := 0 to Val.Count - 1 do
       ListBox1.Items.Add(Val.Strings[i]);
 end;
end;

Initialization
begin
 Reg := TRegistry.Create;
 Val := TStringList.Create;
end;


Finalization
begin
 Val.Free;
 Reg.CloseKey;
 Reg.Free;
end;
end.
0
 

Author Comment

by:marksmall
ID: 6482141
I have the following code below which finds winamp.exe and if its there is displays its directory, but can someone modify this code so that if it cannot find winamp it displays a message eg  Label1.caption:=('Winamp NOT found');

thanx


private
  procedure ListFiles(D,Name,SearchName : String);

procedure TForm1.ListFiles(D,Name,SearchName : String);
var
    SR            : TSearchRec;
begin
  If D[Length(D)]<>'\' then
    D:=D+'\';
  If FindFirst(D+Name,faAnyFile,SR)=0then
    Repeat
      If (SR.Attr<>faDirectory) and (SR.Name[1]<>'.') then
        If AnsiUpperCase(SR.Name)=AnsiUpperCase(SearchName) then
          Label1.Caption:='Winamp installed on system in: ' + D+SR.Name;{If found then set label1.caption}
    Until (FindNext(SR)<>0);
  FindClose(SR);
  If FindFirst(D+'*.*',faDirectory,SR)=0 then
    begin
      Repeat
        If ((Sr.Attr and faDirectory)=faDirectory) and
            (SR.Name[1]<>'.') then
          ListFiles(D+SR.Name+'\',Name,SearchName);
      Until (FindNext(SR)<>0);
    end;
  FindClose(SR);
end;

procedure TForm1.Button11Click(Sender: TObject);
begin
ListFiles('c:\','*.*','winamp.exe');
0
 
LVL 21

Accepted Solution

by:
gemarti earned 300 total points
ID: 6484169

       If AnsiUpperCase(SR.Name)=AnsiUpperCase(SearchName) then
         Label1.Caption:='Winamp installed on system in: ' + D+SR.Name{If found then set label1.caption}
else
  Lable1.Caption := 'Winamp not installed!';



NOTE: you asked how to search the registry, not the file system.
0
 

Author Comment

by:marksmall
ID: 6628356
SORRY ABOUT DELAY, BEEN POORLY AND COULD GET ACCESS TO MY COMPUTER!
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

650 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