Solved

searching registry

Posted on 2001-09-12
4
194 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 75 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

691 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