--------------------------------------------------------------
                      VFP 9.0 FIX - THE MAXIMUM NUMBER OF RECENT DOCUMENTS
                                November 2020
                 --------------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9 (and vfp7, vfp8), we can set the maximum number of recent documents in the windows registry:
     HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\MaxRecentDocs,
     HKEY_CURRENT_USER\Software\Microsoft\VisualFoxPro\9.0\Options\RecentlyUsedFiles.

     In VFP Advanced 32-bit, we can set the maximum number of recent documents in the windows registry:
     HKEY_CURRENT_USER\Software\Microsoft\VisualFoxPro\10\Options\RecentlyUsedFiles.

     In VFP Advanced 64-bit, we can set the maximum number of recent documents in the windows registry:
     HKEY_CURRENT_USER\Software\Microsoft\VisualFoxPro64\10\Options\RecentlyUsedFiles.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun87e9f0 :: ; proc near
             push ebp                                                        ;0x0087e9f0 :        55
             mov ebp , esp                                                   ;0x0087e9f1 :        8bec
             sub esp , 0218h                                                 ;0x0087e9f3 :        81ec18020000
             mov eax ,  dword ptr [ Data937090 ]                             ;0x0087e9f9 :        a190709300
             mov  dword ptr [ ebp - 8 ] , eax                                ;0x0087ea04 :        8945f8
             mov  dword ptr [ ebp + 0FFFFFDE8h ] , 01h                       ;0x0087ea07 :        c785e8fdffff01000000
             push ebx                                                        ;0x0087e9fe :        53
             push esi                                                        ;0x0087e9ff :        56
             push edi                                                        ;0x0087ea00 :        57


     ;
     ;                 --------------------------------------------------------------
     ;                      VFP 9.0 FIX - THE MAXIMUM NUMBER OF RECENT DOCUMENTS
     ;                                November 2020
     ;                 --------------------------------------------------------------
     ;                                     CCB
     ;
     ; The maximum number of recent documents.
     ;
     ; 2020/11/9, by ccb
     ;

             push dword ptr [ ebp + 8 ]
             push offset vfpa_sys9039_valuename
             call Fun84f3ac
             test eax , eax
             jne Label87ea04
             push  dword ptr [ ebp + 12 ]
             call  atoi
             pop ecx
             cmp eax,00h
             jb Label87f318
             cmp eax,0FFh
             ja Label87f318
             mov dword ptr vfpa_sys9039_data,eax
             jmp Label87f318


     Label87ea04 ::
             push  dword ptr [ ebp + 8 ]                                     ;0x0087ea01 :        ff7508
             call Fun87e9aa                                                  ;0x0087ea11 :        e894ffffff
             push  dword ptr [ ebp + 12 ]                                    ;0x0087ea16 :        ff750c
             mov edi , eax                                                   ;0x0087ea19 :        8bf8
             call  atoi                                        ;0x0087ea1b :        ff15c0799100
             xor esi , esi                                                   ;0x0087ea21 :        33f6
             cmp eax , esi                                                   ;0x0087ea23 :        3bc6
             pop ecx                                                         ;0x0087ea25 :        59
             mov ecx , 08738h                                                ;0x0087ea26 :        b938870000
             setne bl                                                        ;0x0087ea2b :        0f95c3
             cmp edi , ecx                                                   ;0x0087ea2e :        3bf9
             mov  dword ptr [ ebp + 8 ] , eax                                ;0x0087ea30 :        894508
             jg Label87ef9d                                                  ;0x0087ea33 :        0f8f64050000
             je Label87ef3f                                                  ;0x0087ea39 :        0f8400050000
             add ecx , 0FFFFFFE5h                                            ;0x0087ea3f :        83c1e5
             cmp edi , ecx                                                   ;0x0087ea42 :        3bf9
             jg Label87ecbe                                                  ;0x0087ea44 :        0f8f74020000
             je Label87ec93                                                  ;0x0087ea4a :        0f8443020000
             mov ecx , 08710h                                                ;0x0087ea50 :        b910870000
             cmp edi , ecx                                                   ;0x0087ea55 :        3bf9
             jg Label87eb8a                                                  ;0x0087ea57 :        0f8f2d010000
             je Label87eb86                                                  ;0x0087ea5d :        0f8423010000
             add ecx , 0FFFFFFF9h                                            ;0x0087ea63 :        83c1f9
             cmp edi , ecx                                                   ;0x0087ea66 :        3bf9
             jg Label87eae7                                                  ;0x0087ea68 :        7f7d
             je Label87eadd                                                  ;0x0087ea6a :        7471
             sub edi , esi                                                   ;0x0087ea6c :        2bfe
             je Label87ead2                                                  ;0x0087ea6e :        7462
             sub edi , 08700h                                                ;0x0087ea70 :        81ef00870000
             je Label87eac7                                                  ;0x0087ea76 :        744f
             dec edi                                                         ;0x0087ea78 :        4f
             je Label87eaac                                                  ;0x0087ea79 :        7431
             dec edi                                                         ;0x0087ea7b :        4f
             je Label87ea9f                                                  ;0x0087ea7c :        7421
             dec edi                                                         ;0x0087ea7e :        4f
             je Label87ea95                                                  ;0x0087ea7f :        7414
             sub edi , 05h                                                   ;0x0087ea81 :        83ef05
             jne Label87f318                                                 ;0x0087ea84 :        0f858e080000
             mov  byte ptr [ Data94741e ] , bl                               ;0x0087ea8a :        881d1e749400
             jmp Label87f318                                                 ;0x0087ea90 :        e983080000


4. APPLIES TO:

     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_vfp9fix131.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix133.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix134.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix135.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix136.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix137.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix138.asp


6. OTHER:

     For reference only, there is no guarantees.

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