Cと.Netを混在させると面倒だとは思いつつも・・・
↓このコードで出力した dummy1.txt, dummy2.txt を下のコードを使って読み込む。
System::Diagnostics::ProcessStartInfo^ userProcess
= gcnew System::Diagnostics::ProcessStartInfo;
// nslookup
userProcess->FileName = L"cmd.exe";
userProcess->Arguments =
L"/C nslookup google.co.jp > dummy1.txt";
System::Diagnostics::Process::Start(userProcess);
// ping
userProcess->FileName = L"cmd.exe";
userProcess->Arguments =
L"/C ping google.co.jp > dummy2.txt";
System::Diagnostics::Process::Start(userProcess);
char buf[256];
FILE *fp;
fp = fopen("dummy1.txt", "r");
while(fgets(buf, 256, fp)) {
this->textBox2->Text +=
System::Runtime::InteropServices::Marshal
::PtrToStringAnsi(IntPtr(buf));
}
fclose(fp);
fp = fopen("dummy2.txt", "r");
while(fgets(buf, 256, fp)) {
this->textBox2->Text +=
System::Runtime::InteropServices::Marshal
::PtrToStringAnsi(IntPtr(buf));
}
fclose(fp);