Please help in converting small section of C++ program in C# progr

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

// this is the code for calling fortran executable
PROCESS_INFORMATION ProcessInfo;
STARTUPINFO StartupInfo = { 0 };
memset((LPVOID)&StartupInfo,0,sizeof(STARTUPINFO));
StartupInfo.cb = sizeof(STARTUPINFO);
if (CreateProcess ( NULL, "main.exe", NULL, NULL, FALSE,
0, NULL, NULL, &StartupInfo, &ProcessInfo) )
{
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);

}
else
{
}
// executable calling code end
 
Sohan,

You will want to take a look at the Process class in the
System.Diagnostics namespace, as well as the ProcessStartInfo class.
Finally, you want to call the WaitForExit method to wait for the process to
complete.
 
Nicholas,

Thank you for your answer. Actually I have not written a C# program in a
last little while. Will it be possible for you to write few lines of code
that accomplishes the same thing as my C++ program does?

Actually, I am mostly a Fortran programmer but rarely I am expected to do
some C++ (now it will be C#) programming to accomplish some mix language task.

(e-mail address removed)

Nicholas Paldino said:
Sohan,

You will want to take a look at the Process class in the
System.Diagnostics namespace, as well as the ProcessStartInfo class.
Finally, you want to call the WaitForExit method to wait for the process to
complete.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

SohanC said:
// this is the code for calling fortran executable
PROCESS_INFORMATION ProcessInfo;
STARTUPINFO StartupInfo = { 0 };
memset((LPVOID)&StartupInfo,0,sizeof(STARTUPINFO));
StartupInfo.cb = sizeof(STARTUPINFO);
if (CreateProcess ( NULL, "main.exe", NULL, NULL, FALSE,
0, NULL, NULL, &StartupInfo, &ProcessInfo) )
{
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);

}
else
{
}
// executable calling code end
 
Back
Top