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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call C++ exe in Foxpro

Status
Not open for further replies.

takyan

Programmer
Oct 16, 2002
84
HK
Hi,

How can I call a C++ Exe from Foxpro? It is not possible to use RUN command. And how can I pass a parameter to that EXE??

Thx a lot.

Yan
 
takyan,

The procedure below is modified from a solution I got off Mike Lewis's website.


Code:
PROCEDURE StartProgram
	lparameters pcExeName, pcParameters, pnWindowStat, pcStartupDirectory
	LOCAL cAction, nPcount
	* first parameter required, other - optional
	nPcount = PCOUNT()
	IF nPcount<4
		  pcStartupDirectory = &quot;&quot;
		IF nPcount<3
			  	pnWindowStat = 1
			IF nPcount<2
				  	pcParameters = &quot;&quot;
			endif		
		endif		
	endif		

	DECLARE INTEGER ShellExecute IN shell32.dll ; 
	  INTEGER hndWin, ; 
	  STRING cAction, ; 
	  STRING cFileName, ; 
	  STRING cParams, ;  
	  STRING cDir, ; 
	  INTEGER nShowWin
	cAction = &quot;open&quot; 
	ShellExecute(0,cAction,pcExeName,pcParameters,pcStartupDirectory,pnWindowStat)
	
*!*	hndWin The handle of the program's parent window. In VFP, you will usually set this to 0. 
*!*	cAction The action which is to be performed (see below). 
*!*	pcExeName The file (or other 'object') on which the action is to be performed (see below). 
*!*	pcParameters If the file is an executable program, these are the parameters (if any) which are passed to it in the command line. 
*!*	pcStartupDirectory If the file is an executable program, this is the program's default or start-up directory. 
*!*	pnWindowStat The program's initial window state (1 = normal, 2 = minimised, 3 = maximised). 

ENDPROC

Slighthaze = NULL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top