private void btnModules_Click(object sender, System.EventArgs e) { // Get the item that is currently selected in the combo box. { all of the modules // for that process are displayed to the user via the richTextBox on frmModules. int ProcID; Int32 ProcessListIndex = cboCurrentProcesses.SelectedIndex; ProcID = Convert.ToInt32(ProcessList[ProcessListIndex]); frmModules frmMod = new frmModules(); frmMod.ProcessID = ProcID; frmMod.Show(); }
private void frmMain_Closing(object sender, System.ComponentModel.CancelEventArgs e) { // Clean up the child form if it's there if (!(mfrmMod == null)) { try { mfrmMod.Owner = null; mfrmMod.ParentProcess = null; mfrmMod.Close(); mfrmMod.Dispose(); mfrmMod = null; } catch (Exception exp) { MessageBox.Show(exp.Message, exp.Source, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void mnuModules_Click(object sender, System.EventArgs e) { // Load the child form to display module information frmModules mfrmMod = null; try { ListView lv = this.lvProcesses; if (lv.SelectedItems.Count == 1) { string strProcessId = lv.SelectedItems[0].SubItems[1].Text; // Check to see if we got our fake 'total' process if (strProcessId == PID_NA) { return; } Process p; p = ((Process)(mcolProcesses[Convert.ToInt32(strProcessId)])); // Don't enumerate the idle process. // You will receive an access denied error. if (p.ProcessName == PROCESS_IDLE) { return; } // null to show if (p.ProcessName == PROCESS_SYSTEM) { return; } p.Refresh(); // Finally check to see if we can even // Get the module count. // if not, no point in going further. try { int i = p.Modules.Count; } catch { MessageBox.Show("Sorry, you are not authorized to read this information.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // if the form is not available, load it if (mfrmMod == null) { mfrmMod = new frmModules(); } // Pass the selected process mfrmMod.ParentProcess = p; // Get the module data mfrmMod.RefreshModules(); // Show the form mfrmMod.ShowDialog(this); } } catch (Exception exp) { MessageBox.Show(exp.Message, exp.Source, MessageBoxButtons.OK, MessageBoxIcon.Error); } }