[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2006-07-12
8
Medium Priority
?
350 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 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

650 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