1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
unit Unit1;
interface
uses
Windows, Forms, Registry, Buttons, StdCtrls, ShellAPI, jpeg, ExtCtrls, Dialogs, Classes,
Graphics, Controls, SysUtils;
type
TForm1 = class(TForm)
SpeedButton1: TSpeedButton;
Label1: TLabel;
Label2: TLabel;
Image1: TImage;
SpeedButton2: TSpeedButton;
Label4: TLabel;
Label3: TLabel;
Label5: TLabel;
Label6: TLabel;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
procedure SetCreateKey(SelectRootKey: HKEY; SelectKey: string; NewKey: string);
procedure SetWriteString(SelectRootKey: HKEY; SelectKey: string; NewValueName: string; Value: string);
function GetDeleteKey(SelectRootKey: HKEY; SelectKey: string; Key: string): Boolean;
procedure SpeedButton1Click(Sender: TObject);
procedure Label2Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.SetCreateKey(SelectRootKey: HKEY; SelectKey: string; NewKey: string);
begin
with TRegistry.Create do
begin
try
RootKey := SelectRootKey;
OpenKey(SelectKey, True);
if not KeyExists(NewKey) then
CreateKey(NewKey);
finally
Free;
end;
end;
end;
procedure TForm1.SetWriteString(SelectRootKey: HKEY; SelectKey: string; NewValueName: string; Value: string);
begin
with TRegistry.Create do
begin
try
RootKey := SelectRootKey;
OpenKey(SelectKey, True);
WriteString(NewValueName, Value);
finally
Free;
end;
end;
end;
function TForm1.GetDeleteKey(SelectRootKey: HKEY; SelectKey: string; Key: string): Boolean;
begin
with TRegistry.Create do
begin
try
RootKey := SelectRootKey;
OpenKey(SelectKey, True);
Result := DeleteKey(Key);
finally
Free;
end;
end;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
// Clé : HKCR\Directory\shell
// Etape 1 : Ajouter une clé, par exemple "MonApplication"
// Etape 2 : Ajouter une clé "Command"
// Etape 3 : Dans la clé Command à droite, cliquez sur (par valeur) et ajoutez la données de la valeur.
// Valeur : (par défaut)
// Compatibilités : 95, 98, Me, NT, 2K
// Type : REG_SZ
// Données de la valeur : calc %1
SetCreateKey(HKEY_CLASSES_ROOT,'Directory\shell', 'MonApplication');
SetCreateKey(HKEY_CLASSES_ROOT,'Directory\shell\MonApplication', 'Command');
SetWriteString(HKEY_CLASSES_ROOT,'Directory\shell\MonApplication\Command', '', 'calc %1');
MessageDlg('Votre configuration a été modifiée avec succès !', mtinformation, [mbOk], 0);
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
// Efface la valeur
GetDeleteKey(HKEY_CLASSES_ROOT, 'Directory\shell\MonApplication', 'Command');
GetDeleteKey(HKEY_CLASSES_ROOT, 'Directory\shell', 'MonApplication');
MessageDlg('Votre configuration d''origine a été rétablie avec succès !', mtinformation, [mbOk], 0)
end;
procedure TForm1.Label2Click(Sender: TObject);
begin
shellexecute(0,'open', 'http://www.dev-zone.com/faq/bdr/fqbdr_index.php', nil, nil, SW_SHOWMAXIMIZED );
end;
procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
// Clé : HKCR\exefile\shell
// Etape 1 : Ajouter une clé, par exemple "MonApplicationExe"
// Etape 2 : Ajouter une clé "Command"
// Etape 3 : Dans la clé Command à droite, cliquez sur (par valeur) et ajoutez la données de la valeur.
// Valeur : (par défaut)
// Compatibilités : 95, 98, Me, NT, 2K
// Type : REG_SZ
// Données de la valeur : calc %1
SetCreateKey(HKEY_CLASSES_ROOT,'exefile\shell', 'MonApplicationExe');
SetCreateKey(HKEY_CLASSES_ROOT,'exefile\shell\MonApplicationExe', 'Command');
SetWriteString(HKEY_CLASSES_ROOT,'exefile\shell\MonApplicationExe\Command', '', 'calc %1');
MessageDlg('Votre configuration a été modifiée avec succès !', mtinformation, [mbOk], 0);
end;
procedure TForm1.SpeedButton4Click(Sender: TObject);
begin
// Efface la valeur
GetDeleteKey(HKEY_CLASSES_ROOT, 'exefile\shell\MonApplicationExe', 'Command');
GetDeleteKey(HKEY_CLASSES_ROOT, 'exefile\shell', 'MonApplicationExe');
MessageDlg('Votre configuration d''origine a été rétablie avec succès !', mtinformation, [mbOk], 0)
end;
end. |
Partager