Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stub program compiled with VFP 9 service pack 2, causes C0000006 - fatal error

Status
Not open for further replies.

teering

Programmer
Nov 4, 2002
30
US
I have the following stub program exe which i originally compiled with vfp7 and the main called program compiled with vfp7.
No problems with the stub or main calling program with vfp7.
After updating to vfp9 with service pack 2 - compiling both programs with vfp9, the stub.exe crashes with the fatal error C0000006.
If i leave the stub.exe compiled with the vfp7 it does not crash when it calls the main program compiled with vfp9.
Does anyone know what would cause this error code with vfp9? And would it cause memory/crash problems to leave it compiled with
different versions?

Here is the stub program code:

LOCAL lcexecpath,lcfilename,lcskeleton,lnfilecount
LOCAL lcexe,ltlatest, lnI
LOCAL ARRAY lafiles(1)

* get the path to the executable directory
lcexecpath = JUSTPATH(SYS(16))
SET RESOURCE OFF
*make that the default
SET DEFAULT TO (lcexecpath)

* get the root name of the executable program
lcfilename = JUSTSTEM(SYS(16))

*build an array of all possible exe names
lcskeleton = lcfilename+"??.exe"
lnfilecount = ADIR(lafiles,lcskeleton)

*look for the most recent exe file
lcexe = ""
ltlatest = {}
FOR lnI = 1 TO lnfilecount
IF FDATE(lafiles(lnI,1),1) > ltlatest
ltlatest = FDATE(lafiles(lnI,1),1)
lcexe = lafiles(lnI,1)
ENDIF
ENDFOR

*launch the most recent exe file
IF NOT EMPTY(lcexe)
DO (lcexe)
ENDIF



Teresa Pickering
Professional Computer Services
 
You could avoid different version problems by using ShellExecute instead. Here is a portion of my stub app. You of course could modify it to suit your needs using the most recent version, but as you can see, it don't take much to use it:

Code:
PARAMETERS lcFileName
SET CONFIRM ON
SET BELL OFF
SET SAFETY OFF
SET EXCLUSIVE OFF
SET RESOURCE OFF

DECLARE INTEGER ShellExecute IN shell32.DLL ;
   INTEGER hndWin, ;
   STRING cAction, ;
   STRING cFileName, ;
   STRING cParams, ;
   STRING cDir, ;
   INTEGER nShowWin

*... run updated .exe
ShellExecute(0, "open", lcFileName, '', '', 9)

RETURN


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Hi Teresa,

Dave is right. The DO command runs the target EXE in the same environment as the program which calls it. That means it will use the same run time library as the caller, regardless of which version was used to build it. I accept that that does not explain the symptons you are seeing, but in general it is better to use ShellExecute() to launch a subsidiary program in cases like this.

Keep in mind that there is another key difference between DO and ShellExecute(). The former is synchronous, which means that the calling program will wait for the called program to finish. In this case, your stub will still be in memory, waiting for the called program to finish before it exits. By contrast, with ShellExecute(), the stub will continue to run at the same time as the called program.

In this case, it makes no difference, because your DO command is the last one in the stub. But by using ShellExecute, you open the possibility of the stub program doing some background housekeeping while the main program is being launched. For example, you could use it to delete any old versions of the main program that it finds.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top