Solved

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

Posted on 2006-07-12
8
345 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 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
Independent Software Vendors: 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

717 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