2013-04-16 79 views
4

如何在使用Visual Basic的應用程序中爲特定文件夾打開「Windows Search Companion」或「Windows Basic Search」?如何在Visual Basic應用程序中打開「Windows搜索」?

enter image description here

我發現this article,但它不是我要找的。

+1

標籤是混亂的,vb.Net,VB6,VBA,你要哪一個? –

+0

@AkshayJoy所有版本,如果可能的話。 – Andriel

+0

我不知道這是你所期待的http://www.ehow.com/how_7536490_do-windows-search-vb.html –

回答

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

​​

VB.NET(測試的Visual Studio旗艦版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 
+0

是的!它像一個魅力工作!謝謝! – Andriel

+0

知道的非常有用。謝謝。 –

+0

+ 1好作品... –

相關問題