-----------------------------------------------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - DISPLAY THE RESOURCE FILE IS NOT VALID DIALOG BOX AT STARTUP
                                  January 2026
                 -----------------------------------------------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), if the resource file is not valid, for the following errors:
     File "name" does not exist (Error 1),
     File is in use by another user (Error 108),
     File access is denied (Error 1705),
     it will close the resource file (SET RESOURCE OFF),
     for other errors, it will display the dialog box "The resource file is not valid. Overwrite it with a new empty one?".

     In VFP Advanced IDE (it is the same as vfp9 IDE), if the resource file is not valid, for the following errors:
     File "name" does not exist (Error 1),
     File is in use by another user (Error 108),
     File access is denied (Error 1705),
     it will close the resource file (SET RESOURCE OFF),
     for other errors, it will display the dialog box "The resource file is not valid. Overwrite it with a new empty one?".

     In VFP Advanced Runtime and VFP Advanced Multi-threaded Runtime,
     if the resource file is not valid, it will close the resource file (SET RESOURCE OFF),
     it will not display the dialog box "The resource file is not valid. Overwrite it with a new empty one?".


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun40edc5 :: ; proc near
             push ebp                                                        ;0x0040edc5 :        55
             lea ebp ,  dword ptr [ esp + 0FFFFFDC8h ]                       ;0x0040edc6 :        8dac24c8fdffff
             sub esp , 02C8h                                                 ;0x0040edcd :        81ecc8020000
             mov eax ,  dword ptr [ Data937090 ]                             ;0x0040edd3 :        a190709300
             push ebx                                                        ;0x0040edd8 :        53
             push esi                                                        ;0x0040edd9 :        56
             mov  esi , dword ptr [ ebp + 0240h ]                            ;0x0040edda :        8bb540020000
             xor ebx , ebx                                                   ;0x0040ede0 :        33db
             push edi                                                        ;0x0040ede2 :        57
             xor edi , edi                                                   ;0x0040ede3 :        33ff
             inc ebx                                                         ;0x0040ede5 :        43
             cmp  dword ptr [ esi + 0A7Ch ] , edi                            ;0x0040ede6 :        39be7c0a0000
             mov  dword ptr [ ebp + 0234h ] , eax                            ;0x0040edec :        898534020000
             jne Label577dce                                                 ;0x0040edf2 :        0f85d68f1600
             mov ecx , 0203h                                                 ;0x0040edf8 :        b903020000
             call Fun42c583                                                  ;0x0040edfd :        e881d70100
             mov ecx , eax                                                   ;0x0040ee02 :        8bc8
             mov edx , 0100h                                                 ;0x0040ee04 :        ba00010000
             lea eax ,  dword ptr [ ebp + 40 ]                               ;0x0040ee09 :        8d4528
             call Fun42c33e                                                  ;0x0040ee0c :        e82dd50100
             cmp  dword ptr [ Data93ba20 ] , edi                             ;0x0040ee11 :        393d20ba9300
             jne Label577de0                                                 ;0x0040ee17 :        0f85c38f1600
             lea edi ,  dword ptr [ ebp + 40 ]                               ;0x0040ee1d :        8d7d28
             call Fun40ee8d                                                  ;0x0040ee20 :        e868000000
             mov  dword ptr [ Data93ba20 ] , ebx                             ;0x0040ee25 :        891d20ba9300
             mov  dword ptr [ ebp + 36 ] , ebx                               ;0x0040ee2b :        895d24
             xor edi , edi                                                   ;0x0040ee2e :        33ff

     Label40ee30 ::
             mov ecx , ebx                                                   ;0x0040ee30 :        8bcb
             call Fun42e42c                                                  ;0x0040ee32 :        e8f5f50100
             cmp  dword ptr [ esi + 0A5Ch ] , edi                            ;0x0040ee37 :        39be5c0a0000
             je Label40ee75                                                  ;0x0040ee3d :        7436
             lea edx ,  dword ptr [ ebp + 28 ]                               ;0x0040ee3f :        8d551c
             lea eax ,  dword ptr [ ebp - 60 ]                               ;0x0040ee42 :        8d45c4
             call Fun42c27f                                                  ;0x0040ee45 :        e835d40100
             push edi                                                        ;0x0040ee4a :        57
             push eax                                                        ;0x0040ee4b :        50
             call Fun42c2be                                                  ;0x0040ee4c :        e86dd40100
             mov esi , eax                                                   ;0x0040ee51 :        8bf0
             cmp esi , edi                                                   ;0x0040ee53 :        3bf7
             pop ecx                                                         ;0x0040ee55 :        59
             pop ecx                                                         ;0x0040ee56 :        59
             jne Label40ee61                                                 ;0x0040ee57 :        7508
             push  dword ptr [ ebp + 36 ]                                    ;0x0040ee59 :        ff7524
             call Fun41ef8b                                                  ;0x0040ee5c :        e82a010100

     Label40ee61 ::
             lea eax ,  dword ptr [ ebp + 28 ]                               ;0x0040ee61 :        8d451c
             push eax                                                        ;0x0040ee64 :        50
             lea eax ,  dword ptr [ ebp - 60 ]                               ;0x0040ee65 :        8d45c4
             call Fun42d200                                                  ;0x0040ee68 :        e893e30100
             cmp esi , edi                                                   ;0x0040ee6d :        3bf7
             jne Label577dec                                                 ;0x0040ee6f :        0f85778f1600

     Label40ee75 ::
             mov  ecx , dword ptr [ ebp + 0234h ]                            ;0x0040ee75 :        8b8d34020000
             call Fun42bf1d                                                  ;0x0040ee7b :        e89dd00100
             pop edi                                                         ;0x0040ee80 :        5f
             pop esi                                                         ;0x0040ee81 :        5e
             pop ebx                                                         ;0x0040ee82 :        5b
             add ebp , 0238h                                                 ;0x0040ee83 :        81c538020000
             leave                                                           ;0x0040ee89 :        c9
             ret 04h                                                         ;0x0040ee8a :        c20400

     Label577dce ::
             mov  dword ptr [ ebp + 36 ] , 02h                               ;0x00577dce :        c7452402000000
             mov  dword ptr [ esi + 0A5Ch ] , ebx                            ;0x00577dd5 :        899e5c0a0000
             jmp Label40ee30                                                 ;0x00577ddb :        e95070e9ff

     Label577de0 ::
             mov  dword ptr [ ebp + 36 ] , 02h                               ;0x00577de0 :        c7452402000000
             jmp Label40ee30                                                 ;0x00577de7 :        e94470e9ff

     Label577dec ::


     ;
     ;                 ------------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - DISPLAY THE RESOURCE FILE IS NOT VALID DIALOG BOX AT STARTUP
     ;                                September 2025
     ;                 ------------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; Display the resource file is not valid dialog box at startup.
     ;
     ; 2025/9/3, by ccb
     ;

             cmp dword ptr vfpa_sys9193_data,00h
             je Label577ea0


             mov ax ,  word ptr [ Data937770 ]                               ;0x00577dec :        66a170779300
             cmp ax , 02BEh                                                  ;0x00577df2 :        663dbe02
             je Label577ea0                                                  ;0x00577df6 :        0f84a4000000
             cmp ax , 02C1h                                                  ;0x00577dfc :        663dc102
             je Label577ea0                                                  ;0x00577e00 :        0f849a000000
             cmp  dword ptr [ ebp + 36 ] , 02h                               ;0x00577e06 :        837d2402
             jne Label577e16                                                 ;0x00577e0a :        750a
             cmp ax , 078h                                                   ;0x00577e0c :        663d7800
             je Label577ea0                                                  ;0x00577e10 :        0f848a000000

     Label577e16 ::
             push edi                                                        ;0x00577e16 :        57
             push edi                                                        ;0x00577e17 :        57
             mov ecx , 0207h                                                 ;0x00577e18 :        b907020000
             call Fun42c583                                                  ;0x00577e1d :        e86147ebff
             push eax                                                        ;0x00577e22 :        50
             call Fun6d9a04                                                  ;0x00577e23 :        e8dc1b1600
             test eax , eax                                                  ;0x00577e28 :        85c0
             je Label40ee75                                                  ;0x00577e2a :        0f844570e9ff
             mov edi , offset Data93ba24                                              ;0x00577e30 :        bf24ba9300
             call Fun546c56                                                  ;0x00577e35 :        e81ceefcff
             pushd 041h                                                      ;0x00577e3a :        6a41
             pop ecx                                                         ;0x00577e3c :        59
             mov esi , offset Data93ba24                                              ;0x00577e3d :        be24ba9300
             lea edi ,  dword ptr [ ebp + 0128h ]                            ;0x00577e42 :        8dbd28010000
             rep movsd                                                       ;0x00577e48 :        f3a5
             pushd offset Data919ec0                                                  ;0x00577e4a :        68c09e9100
             lea eax ,  dword ptr [ ebp + 0128h ]                            ;0x00577e4f :        8d8528010000
             push eax                                                        ;0x00577e55 :        50
             push eax                                                        ;0x00577e56 :        50
             movsb                                                           ;0x00577e57 :        a4
             call Fun42d3ac                                                  ;0x00577e58 :        e84f55ebff
             lea edi ,  dword ptr [ ebp + 0128h ]                            ;0x00577e5d :        8dbd28010000
             call Fun546c56                                                  ;0x00577e63 :        e8eeedfcff
             lea edx ,  dword ptr [ ebp + 32 ]                               ;0x00577e68 :        8d5520
             lea eax ,  dword ptr [ ebp + 0FFFFFF74h ]                       ;0x00577e6b :        8d8574ffffff
             call Fun42c27f                                                  ;0x00577e71 :        e80944ebff
             pushd 00h                                                       ;0x00577e76 :        6a00
             push eax                                                        ;0x00577e78 :        50
             call Fun42c2be                                                  ;0x00577e79 :        e84044ebff
             test eax , eax                                                  ;0x00577e7e :        85c0
             pop ecx                                                         ;0x00577e80 :        59
             pop ecx                                                         ;0x00577e81 :        59
             jne Label577e8c                                                 ;0x00577e82 :        7508
             push  dword ptr [ ebp + 36 ]                                    ;0x00577e84 :        ff7524
             call Fun41ef8b                                                  ;0x00577e87 :        e8ff70eaff

     Label577e8c ::
             lea eax ,  dword ptr [ ebp + 32 ]                               ;0x00577e8c :        8d4520
             push eax                                                        ;0x00577e8f :        50
             lea eax ,  dword ptr [ ebp + 0FFFFFF74h ]                       ;0x00577e90 :        8d8574ffffff
             call Fun42d200                                                  ;0x00577e96 :        e86553ebff
             jmp Label40ee75                                                 ;0x00577e9b :        e9d56fe9ff

     Label577ea0 ::
             mov  dword ptr [ Data93ba20 ] , edi                             ;0x00577ea0 :        893d20ba9300
             jmp Label40ee75                                                 ;0x00577ea6 :        e9ca6fe9ff


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_vfp9fix393.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix22.asp

     2, foxite.com:
     https://www.foxite.com/archives/the-resource-file-is-not-valid-error-0000280831.htm
     https://www.foxite.com/archives/foxuser-0000318958.htm
     https://www.foxite.com/archives/how-do-you-turn-off-this-message-0000401237.htm
     https://www.foxite.com/archives/please-help-0000047394.htm
     https://www.foxite.com/archives/error-message-pior-to-exe-file-0000034062.htm
     https://www.foxite.com/archives/how-to-get-rid-of-it-0000050038.htm
     https://www.foxite.com/archives/resource-file-is-not-valid-0000132538.htm
     https://www.foxite.com/archives/resource-file-not-valid-overwrite-with-new-one-0000042839.htm
     https://www.foxite.com/archives/server2008-0000245162.htm
     https://www.foxite.com/archives/source-file-is-not-valid-0000198844.htm
     https://www.foxite.com/archives/the-resource-file-0000398065.htm
     https://www.foxite.com/archives/the-resource-file-is-not-valid-0000032521.htm
     https://www.foxite.com/archives/the-resourece-is-not-valid-overwrite-it-0000107577.htm
     https://www.foxite.com/archives/vfp-running-under-windows-7-0000428306.htm
     https://www.foxite.com/archives/resource-file-is-invalid-0000109204.htm
     https://www.foxite.com/archives/running-exe-in-non-vfpproject-folder-0000426990.htm

     3, tek-tips.com:
     https://www.tek-tips.com/threads/the-resource-file-is-not-valid-overwrite-it-with-a-new-one.1813372/
     https://www.tek-tips.com/threads/how-to-deal-with-resource-file-is-not-valid.1467725/
     https://www.tek-tips.com/threads/resource-file-is-not-valid-overwrite-it-with-a-new-empty-one.309565/
     https://www.tek-tips.com/threads/what-are-the-possible-causes-for-resource-file-is-not-valid.911140/
     https://www.tek-tips.com/threads/the-resource-file-is-not-valid.1386109/
     https://www.tek-tips.com/threads/resource-file-is-not-valid.1308544/
     https://www.tek-tips.com/threads/invalid-resource-file.859792/

     4, narkive.com:
     https://microsoft.public.fox.helpwanted.narkive.com/gv349Hg0/the-resource-file-is-not-valid
     https://profox.leafe.narkive.com/NZrOndgI/vfp9-resource-file-not-valid
     https://microsoft.public.fox.helpwanted.narkive.com/Z005vVpt/overwrite-invalid-foxuser-file-with-a-new-empty-one
     https://microsoft.public.fox.programmer.exchange.narkive.com/YdJAUCds/meassage-appearing-before-my-exe-run


6. OTHER:

     For reference only, there is no guarantees.

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