--------------------------------------------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - THE NUMBER OF TIMES TO TRY AGAIN AFTER DELETE FILE FAILED
                                 January 2024
                 --------------------------------------------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), somtimes the DELETE FILE (or ERASE) command runs failed on Windows Vista or later.


2. CAUSE:

     There are some compatible problems when the DELETE FILE (or ERASE) command calls the DeleteFileA Windows API
     for the Windows Defender program or the antivirus programs.
     Now if the DELETE FILE (or ERASE) command calls the DeleteFileA Windows API failed,
     it will call the DeleteFileA Windows API many times again.

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun546c56 :: ; proc near


     ;
     ;                 ---------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - THE NUMBER OF TIMES TO TRY AGAIN AFTER DELETE FILE FAILED
     ;                                  March 2019
     ;                 ---------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; The number of times to try again after delete file failed.
     ;
     ; 2019/3/4, by ccb
     ;

     ;         push edi                                                        ;0x00546c56 :        57
     ;         call  DeleteFileA                                 ;0x00546c57 :        ff1584709100

             mov dword ptr vfpa_deletefile_deletefile_cnt,00h

     Label546c57 ::
             push edi
             call  DeleteFileA
             test eax , eax
             jne Label546c5d
             cmp dword ptr [ esp + 00 ] , offset Label51da7a ;; Fun51d979 .. ; proc near
             jne Label546c5d
             cmp dword ptr [ esp + 00 + (4+4CCh) ] , offset Label51d968 ;; Fun51d90e .. ; proc near
             jne Label546c5d
             mov ecx,dword ptr vfpa_sys9015_data
             inc dword ptr vfpa_deletefile_deletefile_cnt
             cmp dword ptr vfpa_deletefile_deletefile_cnt,ecx
             ja Label546c5d
             push dword ptr vfpa_sys9074_data
             call  Sleep
             jmp Label546c57


     Label546c5d ::
             test eax , eax                                                  ;0x00546c5d :        85c0
             je Label5471bd                                                  ;0x00546c5f :        0f8458050000
             xor eax , eax                                                   ;0x00546c65 :        33c0
             ret                                                             ;0x00546c67 :        c3


4. APPLIES TO:

     VFP 6.0.8167.0
     VFP 6.0.8961.0 (SP5)

     VFP 7.0.0.9262
     VFP 7.0.0.9465 (SP1)

     VFP 8.0.0.2521
     VFP 8.0.0.3117 (SP1)

     VFP 9.0.0.2412
     VFP 9.0.0.3504 (SP1)
     VFP 9.0.0.4611 (SP2)
     VFP 9.0.0.5015 (SP2)
     VFP 9.0.0.5411 (SP2)
     VFP 9.0.0.5721 (SP2)
     VFP 9.0.0.5815 (SP2)
     VFP 9.0.0.6303 (SP2)
     VFP 9.0.0.6602 (SP2)
     VFP 9.0.0.7423 (SP2)

     The bug has been fixed in VFP Advanced.


5. REFERENCE WEBSITES:

     1, baiyujia.com:
     http://www.baiyujia.com
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix69.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix65.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix66.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix67.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix68.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix71.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix72.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix73.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix74.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix84.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix85.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix107.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix108.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix109.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix110.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix143.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix144.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix145.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix146.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix147.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix148.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix149.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix150.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix203.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix261.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix262.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix269.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix270.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix278.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix279.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix348.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix349.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix350.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix351.asp

     2, microsoft.com:
     https://devblogs.microsoft.com/oldnewthing/20120907-00/?p=6663


6. OTHER:

     For reference only, there is no guarantees.

     Any questions or suggestions, please send me an email at ccb2000@163.com.