Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ShellExecute Lost in Space?
Message
 
 
To
16/05/2011 14:54:36
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01510794
Message ID:
01510795
Views:
73
Have you verified what does lcFileName containt? Perhaps you need to pass the file name with the full path?
Also, you may want to examine the error code from ShellExecute - it provides the reason why the command fails.

>Any ideas why this ShellExecute call works fine when called as highlighted lines in the Command Window like this:
>
>
>lcHMISPath = 'C:\projects\csst\HMIS\'
>lcFileName = 'export.csv'
>RunAny(lcHMISPath + 'XML\CSST_HMIS.exe',,lcFileName)
>
>
>But fails when called with this code from a menu procedure within a running application, where the laFiles[lnIndex,1] value is "export.csv"?
>(CSST_HMIS.exe is an external procedure that is supposed to convert CSV to XML. It works fine in the first case, but simply pops up a DOS window and produces no output when called as shown below.)
>
>
>		FOR lnIndex = 1 TO ALEN(laFiles,1)
>			lcFileName = laFiles[lnIndex,1]
>			WAIT 'Processing ' + lcFilename NOWAIT 
>			 RunAny(lcHMISPath + 'XML\CSST_HMIS.exe',,lcFileName)
>
>			DOEVENTS 
>			Sleep(1000)
>		ENDFOR 
>
>
>Both call the same "RunAny" sub:
>
>
>*===================================================
>*
>FUNCTION RunAny
>*
>LPARAMETERS tcExecutableFileName,tcOperation,tcParms,tcWorkDir
>*
>IF EMPTY(tcExecutableFileName)
>	RETURN .F.
>ENDIF
>
>tcOperation = IIF(EMPTY(tcOperation),'open',tcOperation)
>tcParms = IIF(EMPTY(tcParms),'',tcParms)
>tcWorkDir = IIF(EMPTY(tcWorkDir),'',tcWorkDir)
>
>DECLARE INTEGER ShellExecute ;
>IN SHELL32.DLL ;
>INTEGER nWinHandle,;
>STRING cOperation,;
>STRING cFileName,;
>STRING cParameters,;
>STRING cDirectory,;
>INTEGER nShowWindow
>
>RETURN ShellExecute(0,tcOperation,tcExecutableFileName,tcParms,tcWorkDir,1)
>*
>*====================================================
>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform