Reputation: 374
How can I open "Windows Search Companion" or "Windows Basic Search" for a specific folder in an application using Visual Basic ?
I have found this article, but it's not what I'm looking for.
Upvotes: 4
Views: 2282
Reputation: 149277
Like this?
VBA/VB6 Code
Option Explicit
'~~> API declaration for the windows "Search Results" dialog
Private Declare Function ShellSearch& Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long)
Private Const SW_SHOWNORMAL = 1
Const drv As String = "C:\"
Sub Sample()
ShellSearch 0, "Find", drv, "", "", SW_SHOWNORMAL
End Sub
Tested in VBA
In Win XP
In Win 7
VB.NET (Tested on Visual Studio Ultimate 64 bit)
'~~> API declaration for the windows "Search Results" dialog
Private Declare Function ShellSearch Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Integer, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Integer) As Integer
Private Const SW_SHOWNORMAL = 1
Const drv As String = "C:\"
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
ShellSearch(0, "Find", drv, "", "", SW_SHOWNORMAL)
End Sub
Upvotes: 5