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>
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>
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 refSpecific steps may refer to:
http://blog.csdn.net/nocry115/article/details/52851722
CodePudding user response: