//キャプチャ開始 private void MainMenuStart_Click(object sender, EventArgs e) { Form2 dlg = new Form2();//デバイス選択ダイアログ //デバイス一覧の取得 var devList = WinPcap.GetDeviceList(); if (devList.Count <= 0) { MessageBox.Show("デバイスが見つかりません。", "ERROR"); return; } foreach (WinPcap.pcap_if dev in devList) { dlg.ListBox.Items.Add(dev.description); } dlg.ListBox.SelectedIndex = 0; if (DialogResult.OK == dlg.ShowDialog()) { int index = dlg.ListBox.SelectedIndex; if (WinPcap.Start(devList[index].name, dlg.Promiscuous)) { MainMenuStart.Enabled = false; MainMenuStop.Enabled = true; } } }
//キャプチャ停止 private void MainMenuStop_Click(object sender, EventArgs e) { if (WinPcap.Stop()) { MainMenuStart.Enabled = true; MainMenuStop.Enabled = false; } }