unit RegMacro;

interface

uses Windows, Messages, SysUtils, Classes, Registry;

procedure RegApplication(Firm, Title, Version: string);
procedure UnRegApplication(Firm, Title: string);
procedure UnRegFirm(Firm: string);
procedure RegUnInstall(Title, DisplayName, UnInstExe: string);
procedure UnRegUnInstall(Title: string);
procedure RegFileType(ftExt, ftName, ftTitle, ftApplication: string; ftIcon: Integer);
procedure UnRegFileType(ftExt, ftName: string);

implementation

{
Beispiel:

Firm:='Firma Mustermann';
Title:='Mein Programm';
Version:='1.0';

DisplayName:='Mein Programm (CD erforderlich)';
UnInstExe:='F:\UnInst.exe';
}

procedure RegApplication(Firm, Title, Version: string);
var reg : TRegistry;

begin

reg := TRegistry.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.OpenKey('\SOFTWARE\'+Firm+'\'+Title+'\'+Version, True);
reg.RootKey := HKEY_CURRENT_USER;
reg.OpenKey('\SOFTWARE\'+Firm+'\'+Title+'\'+Version+'\Options', True);
reg.Free;

end;

procedure UnRegApplication(Firm, Title: string);
var reg : TRegistry;

begin

// Löschen von Programmeinstellungen
reg := TRegistry.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.DeleteKey('\SOFTWARE\'+Firm+'\'+Title);
reg.RootKey := HKEY_CURRENT_USER;
reg.DeleteKey('\SOFTWARE\'+Firm+'\'+Title);
reg.free;

end;

procedure UnRegFirm(Firm: string);
var reg : TRegistry;

begin

// Löschen von Programmeinstellungen
reg := TRegistry.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.DeleteKey('\SOFTWARE\'+Firm);
reg.RootKey := HKEY_CURRENT_USER;
reg.DeleteKey('\SOFTWARE\'+Firm);
reg.free;

end;

procedure RegUnInstall(Title, DisplayName, UnInstExe: string);
var reg : TRegistry;

begin

reg := TRegistry.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\uninstall\'+Title, True);
reg.WriteString('DisplayName', DisplayName);
reg.WriteString('UninstallString', UnInstExe + ' /u');
reg.Free;

end;

procedure UnRegUnInstall(Title: string);
var reg : TRegistry;

begin

// Löschen der Uninstallinformationen
reg := TRegistry.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.DeleteKey('SOFTWARE\Microsoft\Windows\CurrentVersion\uninstall\'+ Title);
reg.free;

end;

procedure RegFileType(ftExt, ftName, ftTitle, ftApplication: string; ftIcon: Integer);
var reg: TRegistry;

begin
reg:=TRegistry.Create;
reg.RootKey:=HKEY_CLASSES_ROOT;

reg.OpenKey(ftExt, True);
reg.WriteString('', ftName);
reg.CloseKey;

reg.OpenKey(ftName, True);
reg.WriteString('', ftTitle);
reg.CloseKey;

reg.OpenKey(ftName+'\DefaultIcon', True);
reg.WriteString('', ftApplication+','+inttostr(ftIcon));
reg.CloseKey;

reg.OpenKey(ftName+'\Shell\Open\Command', True);
reg.WriteString('', ftApplication+' %1');
reg.CloseKey;

reg.OpenKey(ftName+'\Shell\Print\Command', True);
reg.WriteString('', ftApplication+' /p %1');
reg.CloseKey;

reg.Free;
end;

procedure UnRegFileType(ftExt, ftName: string);
var reg: TRegistry;

begin
reg:=TRegistry.Create;
reg.RootKey:=HKEY_CLASSES_ROOT;

reg.DeleteKey(ftExt);
reg.DeleteKey(ftName);

reg.Free;
end;

end.

Zurück zur Hauptseite