[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

I can launch explorer.exe, how can I launch the SEARCH window?

Posted on 2006-07-12
8
Medium Priority
?
357 Views
Last Modified: 2010-05-18
Process.Start("explorer.exe",[path]) launchs an explorer window.

I would like to launch the "Search..." window from Microsoft.  I just don't know if it's a different executable the Explorer, or is it a reconfigured Explorer.

I want to launch the "Search..." program, pass multiple paths to it, and have it run a search.  But just finding the program it self would be sufficent at this point.
0
Comment
Question by:Tertioptus
  • 3
  • 3
  • 2
8 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 17090350
Here is a wrapper class for the Shell32 API, to show how to accomplish particular tasks:

//Add a COM reference to 'Micro$oft Shell Controls and Automation'.

using Shell32;

public class Shell
{

  private static Shell32.Shell shellInterface = new Shell32.Shell();

  public static void ControlPanelItem(string name)
  {
    shellInterface.ControlPanelItem(name);
  }

  public static void CascadeWindows()
  {
    shellInterface.CascadeWindows();
  }

  public static void EjectLaptop()
  {
    shellInterface.EjectPC();
  }

  public static void ExploreFolder(string folder)
  {
    shellInterface.Explore(folder);
  }

  public static void ShowDesktop()
  {
    shellInterface.MinimizeAll();
  }

  public static void OpenFolder(string folder)
  {
    shellInterface.Open(folder);
  }

  public static void RefreshMenu()
  {
    shellInterface.RefreshMenu();
  }

  public static void RestoreAll()
  {
    shellInterface.UndoMinimizeALL();
  }

  public static void ShowFindComputerDialog()
  {
    shellInterface.FindComputer();
  }

  public static void ShowFindFilesDialog()
  {
    shellInterface.FindFiles();
  }

  public static void ShowProperties()
  {
    shellInterface.TrayProperties();
  }

  public static void ShowRunDialog()
  {
    shellInterface.FileRun();
  }

  public static void ShowShutdownWindowsDialog()
  {
    shellInterface.ShutdownWindows();
  }

  public static void ShowSetTimeDialog()
  {
    shellInterface.SetTime();
  }
}

Notice the static methods, and the ShowFindFilesDialog method.

Bob
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 17090547
The following VB script opens search window:

Set wshshell = CreateObject("Shell.Application")
wshshell.findfiles

This function is described here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/objects/shell/findfiles.asp

Try to do the same in C#. However, function doesn't have parameters, and it is difficult to continue from this point.
The same can be done running explorer and sending F3 key to it.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 17090599
Did'nt refresh page before posting :(
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 96

Expert Comment

by:Bob Learned
ID: 17091054
No problem, my friend ;)

Bob
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 17091088
Hey Bob,

  Do you have any idea how I can pass a folder path to it?

BTW - Thanks for the quick solution
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17091634
You can't with that code, but I have added additional functionality to the wrapper class, that uses a call to ShellExecute, which can accomplish what you are looking for:

//Add a COM reference to 'Micro$oft Shell Controls and Automation'.

using System;
using Shell32;
using System.Runtime.InteropServices;

public class Shell
{

  private static Shell32.Shell shellInterface = new Shell32.Shell();

  public static void ControlPanelItem(string name)
  {
    shellInterface.ControlPanelItem(name);
  }

  public static void CascadeWindows()
  {
    shellInterface.CascadeWindows();
  }

  public static void EjectLaptop()
  {
    shellInterface.EjectPC();
  }

  public static void ExploreFolder(string folder)
  {
    shellInterface.Explore(folder);
  }

  public static void ShowDesktop()
  {
    shellInterface.MinimizeAll();
  }

  public static void OpenFolder(string folder)
  {
    shellInterface.Open(folder);
  }

  public static void RefreshMenu()
  {
    shellInterface.RefreshMenu();
  }

  public static void RestoreAll()
  {
    shellInterface.UndoMinimizeALL();
  }

  public static void ShowFindComputerDialog()
  {
    shellInterface.FindComputer();
  }

  public static void ShowFindFilesDialog()
  {
    shellInterface.FindFiles();
  }

  [DllImport("Shell32.dll", CharSet=CharSet.Ansi)]
    private static extern int ShellExecute(IntPtr hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);

  private const int SW_SHOWNORMAL = 1;
  private const int SW_SHOWMINIMIZED = 2;
  private const int SW_SHOWMAXIMIZED = 3;
  private const int SW_SHOW = 5;
  private const int SW_MINIMIZE = 6;
  private const int SW_SHOWMINNOACTIVE = 7;
  private const int SW_SHOWNA = 8;
  private const int SW_RESTORE = 9;
  private const int SW_SHOWDEFAULT = 10;

  /// <summary>
  /// Show the Find files dialog with a starting path set
  /// </summary>
  /// <param name="hwnd">The handle to a form</param>
  /// <param name="path">The path to the initial folder</param>
  /// <returns></returns>
  public static void ShowFindFilesDialog(IntPtr handle, string path)
  {
    ShellExecute(handle, "find", path, "", "", SW_SHOWNORMAL);
  }

  public static void ShowProperties()
  {
    shellInterface.TrayProperties();
  }

  public static void ShowRunDialog()
  {
    shellInterface.FileRun();
  }

  public static void ShowShutdownWindowsDialog()
  {
    shellInterface.ShutdownWindows();
  }

  public static void ShowSetTimeDialog()
  {
    shellInterface.SetTime();
  }
}

Look at the overloaded ShowFindFilesDialog method call.

Bob
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 17101855
U da Bob, maaaaaaan!!!!
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 17123103
ShowFindFilesDialog doesn't seem to allow multiple paths like: "c:\[path 1];c:\[path 2]".

Even though if I launch the Search program I could do a search on that same string.
Do you know why this is so?  Am I doing something wrong?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Integration Management Part 2
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question