private bool dialogShown = true; //set to false to enable the "BeforeShellCommand" functionality /// <summary> /// This shows how to capture the invocation command in order to /// process it explicitly, instead of letting shellbrowser do the /// default system task. You can of course also extend its functionality /// here, e.g. by adding logging capabilities. /// </summary> /// <param name="sender">Sender of the event.</param> /// <param name="e">The event args holding the affected paths and the possibility to cancel the operation.</param> private void shellListView1_BeforeShellCommand(object sender, BeforeShellCommandEventArgs e) { if (dialogShown) { return; } if ((e.Verb == ShellCommand.Default) || (e.Verb == ShellCommand.Open)) { DialogResult dialogResult = MessageBox.Show(String.Format("Do you want to open the file selected?{0}" + "(This message is shown only once as a demonstration of the 'BeforeShellCommand' event)", System.Environment.NewLine, e.Verb), "BeforeShellCommand", MessageBoxButtons.YesNo, MessageBoxIcon.Question); dialogShown = true; if (dialogResult == DialogResult.No) { //process the selected items on your own e.Cancel = true; } } }
private void searchResults_BeforeShellCommand(object sender, BeforeShellCommandEventArgs e) { System.Diagnostics.Debug.WriteLine(e.Verb); }