-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit_conf.pas
89 lines (61 loc) · 1.84 KB
/
unit_conf.pas
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
unit Unit_Conf;
{$mode ObjFPC}{$H+}
//Copyright (c) 2023 by Xelitan.com
//License: GNU GPL
//See the file LICENSE.txt, included in this distribution, for details.
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,Registry, ShlObj;
const
Formats: array[0..5] of String = ('.bmp', '.gif', '.jpg', '.jpeg', '.jpe', '.png');
APP_NAME = 'XelitanGUIPotrace';
type
{ TConfigDlg }
TConfigDlg = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
public
end;
var
ConfigDlg: TConfigDlg;
implementation
{$R *.lfm}
{ TConfigDlg }
procedure TConfigDlg.Button1Click(Sender: TObject);
var i: Integer;
begin
with TRegistry.Create do
try
RootKey := HKEY_CLASSES_ROOT;
for i:=0 to High(Formats) do begin
if OpenKey('\SystemFileAssociations\' + Formats[i] + '\shell\' + APP_NAME, true) then
WriteString('', 'Convert to SVG with Potrace');
if OpenKey('\SystemFileAssociations\' + Formats[i] + '\shell\' + APP_NAME + '\command', true) then
WriteString('', '"' + Application.ExeName + '" "%1"');
end;
finally
Free;
end;
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);
end;
procedure TConfigDlg.Button2Click(Sender: TObject);
var i: Integer;
begin
with TRegistry.Create do
try
RootKey := HKEY_CLASSES_ROOT;
for i:=0 to High(Formats) do begin
DeleteKey('\SystemFileAssociations\' + Formats[i] + '\shell\' + APP_NAME + '\command');
DeleteKey('\SystemFileAssociations\' + Formats[i] + '\shell\' + APP_NAME);
end;
finally
Free;
end;
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);
end;
end.