- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
procedure TForm1.WMDropFiles(var Msg: TMessage);
var
I, Amount, Size: Integer;
Filename: String;
Ctrl:TControl;
P:TPoint;
begin
if MessageBox(Handle, 'Внимание! Выбранные файлы будут БЕЗВОЗВРАТНО удалены. Продолжить?','Треш-угар', MB_ICONEXCLAMATION or MB_YESNO) <> ID_YES then Exit;
GetCursorPos(P);
Amount := DragQueryFile(Msg.WParam, $FFFFFFFF, @Filename[1], 255);
for i := 0 to (Amount - 1) do
begin
Size := DragQueryFile(Msg.WParam, i, nil, 0) + 1;
SetLength(FileName, Size+1);
DragQueryFile(Msg.WParam, I, @Filename[1], Size);
SetLength(FileName, StrLen(PChar(FileName)));
Ctrl:=FindDragTarget(P, False);
CleanFile(FileName);
end;
DragFinish(Msg.WParam);
end;
procedure TForm1.CleanFile(FileName:string);
var
hFile:THandle;
Size:DWORD;
BW:DWORD;
I:Integer;
P:Pointer;
NewName, Fname :string;
begin
trEmpty.SendToBack;
trFull.BringToFront;
hFile:=CreateFile(PChar(FileName), GENERIC_WRITE, FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0);
if hFile=INVALID_HANDLE_VALUE then
exit;
try
Size:=GetFileSize(hFile,nil);
P:=AllocMem(Size);
SetFilePointer(hFile, 0, nil, FILE_BEGIN);
//for I:=0 to Size=1 do
//begin
//end;
WriteFile(hFile, P^, Size, BW, nil);
CloseHandle(hFile);
finally
CloseHandle(hFile);
end;
FName:=ExtractFileName(FileName);
NewName:=StrUtilsEx.RandomStr([rtLowerCase, rtUpperCase], Length(FName));
NewName:=ExtractFilePath(FileName)+FName;
MoveFile(PChar(FileName), PChar(NewName));
DeleteFile(PChar(NewName));
trFull.SendToBack;
trEmpty.BringToFront;
end;
end.