본문 바로가기

카테고리 없음

[일반/컴포넌트] Outlook Express 설치여부 알아내기

반응형
First you will have to add Registry.pas to your unit's uses clause.
Next I made a procedure to check if Outlook Express exists and declared it in the TForm1 private area, you can just add it to the same TButton.OnClick event if you wish.
When using the registry, first you need to create an instance of TRegistry. Next you need to set the RootKey. Then you will open the key that you want to open. Notice that I added a back-slash to the beginning of the key name. Then you can manipulate the entries of the registry by using the available methods of TRegistry.
Notice that I checked for a backslash at the end of the key's path entry. This is becasue I am not sure if it is the same on all systems.
Example 1

{...}

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

{...}

procedure TForm1.Button1Click(Sender: TObject);
begin
  if OutExInstalled() then
    ShowMessage('Outlook Express is Installed')
  else
    ShowMessage('Outlook Express is not Installed');
end;

function TForm1.OutExInstalled:Boolean;
var
  Reg    : TRegistry;
  tmpStr : String;
begin
  Result := False;
  try
    Reg := TRegistry.Create;
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('SoftwareMicrosoftWindowsCurrentVersionApp Pathsmsimn.exe',
                   FALSE) then
    begin
      if Reg.ValueExists('Path') then
      begin
        tmpStr := Reg.ReadString('Path');
        if tmpStr[Length(tmpStr)] <> '' then
          tmpStr := tmpStr + '';
        Result := FileExists(tmpStr+'msimn.exe');
      end;
    end;
  finally
    Reg.Free;
  end;
end;
반응형