-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPartitionMagic.pas
More file actions
314 lines (290 loc) · 9.73 KB
/
PartitionMagic.pas
File metadata and controls
314 lines (290 loc) · 9.73 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
unit PartitionMagic;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Inifiles, ComCtrls, param, Main, SoftSel;
type
TPartition = class(TForm)
List1: TListView;
Button1: TButton;
Button3: TButton;
Button4: TButton;
Image1: TImage;
Button5: TButton;
Button2: TButton;
ProgressBar1: TProgressBar;
Button6: TButton;
Button7: TButton;
Button8: TButton;
procedure Button1Click(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormActivate(Sender: TObject);
procedure DisplayParts;
procedure List1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button2Click(Sender: TObject);
procedure List1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Button6Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure Button7Click(Sender: TObject);
procedure List1DblClick(Sender: TObject);
procedure Button8Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Partition: TPartition;
Operation: shortstring='';
implementation
uses PartitionCreate, LoadOS;
{$R *.dfm}
procedure TPartition.Button1Click(Sender: TObject);
begin
Close;
end;
procedure TPartition.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = vk_escape) and (Button1.Enabled) then
button1.OnClick(self);
end;
procedure TPartition.FormActivate(Sender: TObject);
begin
a:=-1; b:=-1;
Button3.Visible:=false;
Button4.Visible:=false;
Button5.Visible:=false;
Button2.Visible:=false;
Button6.Visible:=false;
Button7.Visible:=false;
Button8.Visible:=false;
If Operation='' then
Button2.Visible:=true;
If Operation='PMagic' then begin
If (MainForm.Label54.Caption<>'fdisk') and (MainForm.Label54.Caption<>'Íåò') then begin
Button7.Visible:=true;
WriteDiskStructure(dir+'\Temp\PartitionList.tmp');
end
else
Application.MessageBox('Çäåñü âû ìîæåòå èçìåíÿòü ñòðóêòóðó ðàçäåëîâ âàøåãî æåñòêîãî äèñêà. Áóäüòå îñòîðîæíû! Âñå èçìåíåíèÿ, êîòîðûå âû äåëàåòå îòìåíèòü áóäåò íåâîçìîæíî!','Ïîìîùü!',MB_ICONINFORMATION);
Button3.Visible:=true;
Button4.Visible:=true;
Button5.Visible:=true;
Button8.Visible:=true;
end;
If Operation='Active' then
Button6.Visible:=true;
If Parts<>nil then
DisplayParts;
List1.OnClick(self);
end;
procedure TPartition.DisplayParts;
var
i, j: integer;
ExtSize: integer;
begin
List1.Items.Clear;
for i:=0 to Length(Parts)-1 do begin
List1.Items.Add;
j:=0;
List1.Items[List1.Items.Count-1].Indent:=(i+10)*10+j;
List1.Items[List1.Items.Count-1].Caption:=Parts[i,0].Labe1;
if Parts[i,0].FileSystem='' then
List1.Items[List1.Items.Count-1].SubItems.Add('*')
else
List1.Items[List1.Items.Count-1].SubItems.Add(Parts[i,0].FileSystem);
List1.Items[List1.Items.Count-1].SubItems.Add(IntToStr(Parts[i,0].Size)+' Ìá');
List1.Items[List1.Items.Count-1].SubItems.Add(IntToStr(Parts[i,0].Free)+' Ìá');
If Parts[i,0].Active then
List1.Items[List1.Items.Count-1].SubItems.Add('Àêòèâåí')
else
List1.Items[List1.Items.Count-1].SubItems.Add('Íåò');
if Parts[i,0].FileSystem='' then
List1.Items[List1.Items.Count-1].SubItems.Add('*')
else
List1.Items[List1.Items.Count-1].SubItems.Add('Îñíîâíîé');
If Length(Parts[i])>1 then begin
List1.Items.Add;
List1.Items[List1.Items.Count-1].Caption:='';
List1.Items[List1.Items.Count-1].SubItems.Add('*');
ExtSize:=0;
for j:=1 to Length(Parts[i])-1 do
ExtSize:=ExtSize+Parts[i,j].Size;
List1.Items[List1.Items.Count-1].SubItems.Add(IntToStr(ExtSize)+' Ìá');
List1.Items[List1.Items.Count-1].SubItems.Add(IntToStr(ExtSize)+' Ìá');
List1.Items[List1.Items.Count-1].SubItems.Add('*');
List1.Items[List1.Items.Count-1].SubItems.Add('Äîïîëíèòåëüíûé');
end;
for j:=1 to Length(Parts[i])-1 do begin
List1.Items.Add;
List1.Items[List1.Items.Count-1].Indent:=(i+10)*10+j;
List1.Items[List1.Items.Count-1].Caption:=Parts[i,j].Labe1;
If Parts[i][j].FileSystem<>'' then
List1.Items[List1.Items.Count-1].SubItems.Add(Parts[i,j].FileSystem)
else
List1.Items[List1.Items.Count-1].SubItems.Add('*');
List1.Items[List1.Items.Count-1].SubItems.Add(IntToStr(Parts[i][j].Size)+' Ìá');
List1.Items[List1.Items.Count-1].SubItems.Add(IntToStr(Parts[i][j].Free)+' Ìá');
List1.Items[List1.Items.Count-1].SubItems.Add('Íåò');
If Parts[i][j].FileSystem<>'' then
List1.Items[List1.Items.Count-1].SubItems.Add('Ëîãè÷åñêèé')
else
List1.Items[List1.Items.Count-1].SubItems.Add('*');
end;
If i<Length(Parts)-1 then begin
List1.Items.Add;
List1.Items[List1.Items.Count-1].Caption:='----------';
List1.Items[List1.Items.Count-1].SubItems.Add('----------');
List1.Items[List1.Items.Count-1].SubItems.Add('----------');
List1.Items[List1.Items.Count-1].SubItems.Add('----------');
List1.Items[List1.Items.Count-1].SubItems.Add('----------');
List1.Items[List1.Items.Count-1].SubItems.Add('----------');
end;
end;
end;
procedure TPartition.List1Click(Sender: TObject);
begin
Button4.Enabled:=false;
Button3.Enabled:=false;
Button5.Enabled:=false;
Button2.Enabled:=false;
Button6.Enabled:=false;
Button8.Enabled:=false;
If List1.Selected<>nil then begin
a:=-1; b:=-1;
If (List1.Selected.Indent<>0) and (List1.Selected.SubItems[4]<>'Äîïîëíèòåëüíûé') then begin
a:=List1.Selected.Indent div 10 - 10;
b:=List1.Selected.Indent mod 10;
end;
If List1.Selected.SubItems[4]='*' then
Button4.Enabled:=true
else
If (List1.Selected.Caption<>'----------') and (List1.Selected.SubItems[4]<>'Äîïîëíèòåëüíûé') then begin
Button3.Enabled:=true;
Button5.Enabled:=true;
Button2.Enabled:=true;
Button8.Enabled:=true;
if List1.Selected.SubItems[4]<>'Ëîãè÷åñêèé' then
Button6.Enabled:=true;
end;
end;
end;
procedure TPartition.Button3Click(Sender: TObject);
begin
WhatToDo:='Delete';
if CreatePart = nil then Application.CreateForm(TCreatePart, CreatePart);
CreatePart.ShowModal;
end;
procedure TPartition.Button4Click(Sender: TObject);
begin
WhatToDo:='Create';
if CreatePart = nil then Application.CreateForm(TCreatePart, CreatePart);
CreatePart.ShowModal;
end;
procedure TPartition.Button5Click(Sender: TObject);
begin
WhatToDo:='Format';
if CreatePart = nil then Application.CreateForm(TCreatePart, CreatePart);
CreatePart.ShowModal;
end;
procedure TPartition.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Operation:='';
end;
procedure TPartition.Button2Click(Sender: TObject);
var
CanInstall: boolean;
begin
If b=0 then begin
If not Parts[a,b].Active then
Application.MessageBox('Äàííûé ðàçäåë ÿâëÿåòñÿ ñêðûòûì. Äîñòóï ê íåìó íåâîçìîæåí!','Ïîìîùü!',MB_ICONSTOP)
else
begin
If dataprm='OS' then begin
CanInstall:=false;
while pos('|',osfs)<>0 do begin
If copy(osfs,1,pos('|',osfs)-1)=Parts[a,b].FileSystem then begin
CanInstall:=true;
Break;
end;
osfs:=copy(osfs,pos('|',osfs)+1,255);
end;
If osfs=Parts[a,b].FileSystem then
CanInstall:=true;
If not CanInstall then
Application.MessageBox(PChar(SoftSelect.ComboBox1.Items.Strings[SoftSelect.ComboBox1.ItemIndex]+' íå ìîæåò ðàáîòàòü ñ ôàéëîâîé ñèñòåìîé '+Parts[a,b].FileSystem+'!'),'Ïîìîùü!',MB_ICONSTOP)
else
Close;
end
else
Close;
end;
end
else
If dataprm='OS' then
Application.MessageBox('×òîáû èìåòü âîçìîæíîñòü çàãðóæàòü îïåðàöèîííóþ ñèñòåìó åå íåîáõîäèìî óñòàíîâèòü íà îñíîâíîé ðàçäåë æåñòêîãî äèñêà!','Ïîìîùü!',MB_ICONSTOP)
else
Close;
end;
procedure TPartition.List1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
If (Key=VK_Return) and (Button2.Visible) and (Button2.Enabled) then
Button2.OnClick(self);
end;
procedure TPartition.Button6Click(Sender: TObject);
var
i: integer;
begin
If not Parts[a,b].Active then begin
for i:=0 to Length(Parts)-1 do
Parts[i,0].Active:=False;
Parts[a,b].Active:=true;
MainForm.Label30.Caption:=Parts[a,b].Soft.OS;
os:=Parts[a,b].Soft.OSType;
ActivePartition:=a;
DisplayParts;
Loading.ShowModal;
end
else
Application.MessageBox('Äàííûé ðàçäåë óæå ÿâëÿåòñÿ àêòèâíûì!','Ïîìîùü!',MB_ICONINFORMATION);
end;
procedure TPartition.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
CanClose:=Button1.Enabled;
end;
procedure TPartition.Button7Click(Sender: TObject);
begin
If FileExists(dir+'\Temp\PartitionList.tmp') then begin
LoadDiskStructure(dir+'\Temp\PartitionList.tmp');
DisplayParts;
Partition.OnActivate(self);
end
else
Application.MessageBox('Ïðîèçîøëà îøèáêà ïðè âîññòàíîâëåíèè èñõîäíîé ñòðóêòóðû ðàçäåëîâ æåñòêîãî äèñêà. Íåâîçìîæíî îòìåíèòü èçìåíåíèÿ!','Ïîìîùü!',MB_ICONSTOP);
end;
procedure TPartition.List1DblClick(Sender: TObject);
begin
If (Operation = '') and (Button2.Enabled) then Button2.OnClick(self);
If (Operation = 'Active') and (Button6.Enabled) then Button6.OnClick(self);
end;
procedure TPartition.Button8Click(Sender: TObject);
var
s: shortstring;
begin
s:=InputBox('Ìåòêà','Ââåäèòå ìåòêó äëÿ ýòîãî ðàçäåëà',Parts[a,b].Labe1);
If length(s)<=11 then
Parts[a,b].Labe1:=s
else
Application.MessageBox('Èìÿ ìåòêè ðàçäåëà íå äîëæíî ïðåâûøàòü 11 ñèìâîëîâ.','Ïîìîùü!',MB_ICONSTOP);
DisplayParts;
end;
end.