Home > database >  PB call c # to write the EXE, how to acquire the string value returns to its execution procedures?
PB call c # to write the EXE, how to acquire the string value returns to its execution procedures?

Time:10-14

I didn't contact with PB, but do in the project involves: PB call c # to write the EXE, the c # EXE is written by our company, PB is another company, need to let the other side to call our EXE, XML input parameters specified in the call time, after performing the EXE, PB EXE need to get to his return values, XML format in the calling process, our company will have some business process form interaction,
Ask ace to help solve!
C # code EXE service execution procedures (ConsoleApp. EXE) of sample code is as follows:
The static void Main (string [] args)
{
String procName=System. Diagnostics. Process. GetCurrentProcess (). The ProcessName;
File. AppendAllText (" D: \ \ systemtool TXT ", procName + "\ n");
If ((System. Diagnostics. Process. GetProcessesByName (procName). GetUpperBound (0)==0)
{
File. AppendAllText (" D: \ \ systemtool TXT ", "Bussiness handle" + "\ n");
//receiving over XML format string parameter
String paramXML="";
if (! String. IsNullOrEmpty (args [0])
{
ParamXML=args [0];
File. AppendAllText (" D: \ \ systemtool TXT ", "XML Input parameters:" + paramXML + "\ n");
XmlDocument oXmlDoc=new XmlDocument ();
Try
{
OXmlDoc. LoadXml (paramXML);
XmlNode root=oXmlDoc. DocumentElement;
XmlNodeList nodes=root..childnodes;
Foreach (XmlNode node in nodes)
{
File. AppendAllText (" D: \ \ systemtool TXT ", node. The Name + "- & gt;" + node. The InnerText + "\ n \ n");
}

//call other business form code
.

}
The catch (Exception error)
{
File. AppendAllText (" D: \ \ systemtool TXT ", "the Exception error - & gt;" . + error Message + "\ n");
Throw new Exception (error Message);
}
The finally
{
OXmlDoc=null;
}
}
//the return value
String returnParam="& lt; Root> 1 & lt;/RetValue> ";

The Console. Write (returnParam);//returns the value written to the standard of the console output,
}

C # call EXE executable program sample, as follows:
The Process of p=new Process ();
P. tartInfo. UseShellExecute=false;
P. tartInfo. RedirectStandardOutput=true;
//external Console service routine physical path
P. tartInfo. FileName=@ "F: \ ConsoleApp exe";
P. tartInfo. CreateNoWindow=true;
//start parameter
P. tartInfo. The Arguments="& lt; Root> 0 ";
P. tart ();
P.W aitForExit ();
//the return value
String returnValue=(https://bbs.csdn.net/topics/p.StandardOutput.ReadToEnd);

Please help write a test through the source code, thank you very much, hurry!!

CodePudding user response:

You can change your c # program to function, to generate a DLL for the other PB call; Best parameters are converted to a string, if you have multiple return parameters, other parameters with ref
Specific steps may refer to:
http://blog.csdn.net/nocry115/article/details/52851722

CodePudding user response:

reference 1st floor nocry115 response:
can change your c # program to function, to generate a DLL call for the other PB; Best parameters are converted to a string, if you have multiple return parameters, other parameters with ref
Specific steps may refer to:
http://blog.csdn.net/nocry115/article/details/52851722


We design a exe by other system calls, may be a vb, may also make the pb, or c #, c + +,

CodePudding user response:

You can write a text file, call out to get the results from a text file

CodePudding user response:

reference zjl8008 reply: 3/f
can be written to a text file, call the it is ok to get the results from a text file


Can't write text or database

CodePudding user response:

Redirects the output to a file, try the following code

Run (" f: \ consoleapp exe '& lt; Root> 0 '& gt;> C: \ 111. TXT ")

Then pb in open c: \ 111. TXT for processing
  • Related