?
Solved

searching registry

Posted on 2001-09-12
4
Medium Priority
?
196 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month11 days, 12 hours left to enroll

752 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