Bonsoir à toutes et à tous, avec cette fonction, je n'arrive pas à éffacer un fichier alors que manuellement c'est possible.
Utilisation :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 Function DelTree(DirName : string): Boolean; var SHFileOpStruct : TSHFileOpStruct; DirBuf : array [0..255] of char; begin try Fillchar(SHFileOpStruct,Sizeof(SHFileOpStruct),0) ; FillChar(DirBuf, Sizeof(DirBuf), 0 ) ; StrPCopy(DirBuf, DirName) ; with SHFileOpStruct do begin Wnd := 0; pFrom := @DirBuf; wFunc := FO_DELETE; //fFlags := FOF_ALLOWUNDO; //Evite la poubelle fFlags := fFlags or FOF_NOCONFIRMATION; fFlags := fFlags or FOF_SILENT; end; Result := (SHFileOperation(SHFileOpStruct) = 0) ; except Result := False; end; end;
Merci de l'aide éventuelle,
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 procedure TForm1.ResetClick(Sender: TObject); begin wd := Path[CSIDL_SYSTEM] ; //GetWinFolder_V1($0025); Dossier := '\oobe\info\BACKGROUNDS'; S := '\Backup' ; if FileExists(wd + Dossier + '\BackgroundDefault.Jpg') then DelTree(wd + Dossier + '\BackgroundDefault.Jpg') else showmessage('Le logon par défaut est ok'); end;
@+,
Cincap
Partager