如何在Visual Basic应用程序中打开“Windows搜索”?

4
我该如何使用Visual Basic打开特定文件夹中的“Windows搜索助手”或“Windows基本搜索”?

enter image description here

我找到了这篇文章,但它不是我要找的。

1
标签很混乱,你想要哪一个?vb.Net、Vb6还是VBA? - Akshay Joy
@AkshayJoy 所有版本,如果可能的话。 - Andriel
我不知道你期望的是什么,http://www.ehow.com/how_7536490_do-windows-search-vb.html。 - Akshay Joy
@SiddharthRout 太棒了!!像老板一样工作! - Andriel
@Andriel:同时添加了VB.NET的代码 :) - Siddharth Rout
显示剩余4条评论
1个回答

5

像这样?

VBA/VB6 代码

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

在VBA中进行测试

在Win XP中

enter image description here

在Win 7中

enter image description here

使用VB.NET (在Visual Studio Ultimate 64位上测试)

'~~> 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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接