Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Call VFP EXE and return value
Message
From
03/08/2020 02:07:34
 
General information
Forum:
C#
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01675453
Message ID:
01675502
Views:
56
It is possible, but may be more time consuming to implement. I have done this in the past, but it would be worth to do if you get more functionality than only a one liner.

One simple workaround is to write the result to a temporary file, which you access via naming convention (fixed name) or pass as a parameter. Often I would create an XML file and send the path as parameter to the process, while the process then writes the response to the same file or to another XML file.

You could create an XML file with the following structure to run code in a generic way:
<?xml version = "1.0" encoding="Windows-1252" standalone="yes"?>
<VFPData>
	<commands>
		<command>GetEnv("UserName")</command>
		<result></result>
	</commands>
</VFPData>
You send this file to the VFP exe and it runs the defined command, and fills the result which then can be accessed by the caller.

>Thank you. I doubt it.
>
>>Perhaps, you could use a COM DLL instead of an EXE and call that functions as a method. Like (in VFP, I don't know C#:
>>
>>
>>oVFP= CREATEOBJECT('myVfpComClass')   && Previously having registered "myVfpDll.dll"
>>lcUserName= oVFP.GetUserName()
>>
>>
>>
>>>Hi,
>>>
>>>I need to call a small VFP .EXE from a C#/.NET code. The VFP project has one .PRG with has just one line:
>>>
>>>RETURN (GetEnv("UserName")) 
>>>
>>>
>>>How do I call this .EXE from C# code?
>>>
>>>I called VFP EXE in my C# code before using the Proc syntax. Example:
>>>
>>>Process Proc = Process.Start(cVfpExeFullPath, "1");
>>>
>>>
>>>But before my VFP EXE didn't have to return anything. So, it was simple.
>>>
>>>Now I want the VFP EXE to return a value and capture this value in the C# code.
>>>
>>>How?
>>>
>>>TIA
Christian Isberner
Software Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform