我正在重新訪問我在VB.Net中爲我的幫助臺團隊編寫的一個工具,並希望添加一些複選框以複製Windows用於顯示的相同功能隱藏的文件和文件夾/重新隱藏,以及受保護的操作系統文件。複製Windows取消隱藏文件夾和文件功能
我知道我可以通過編輯註冊表項並重新啓動explorer.exe來完成此操作,但是會關閉所有打開的資源管理器窗口,我不想那樣做。
有誰知道Windows如何通過簡單點擊一個複選框以及我如何能夠在VB.net中對其進行編碼來完成此操作?
對此的任何輸入都非常感謝。
編輯:所以它看起來像我發現作品刷新其可應用於Drarig的回答下面,但我無法將其轉換爲VB.net Windows資源管理器/文件瀏覽器的刷新方法最初的例子是在C#中。
'Original at http://stackoverflow.com/questions/2488727/refresh-windows-explorer-in-win7
Private Sub refreshExplorer(ByVal explorerType As String)
Dim CLSID_ShellApplication As Guid = Guid.Parse("13709620-C279-11CE-A49E-444553540000")
Dim shellApplicationType As Type = Type.GetTypeFromCLSID(CLSID_ShellApplication, True)
Dim shellApplication As Object = Activator.CreateInstance(shellApplicationType)
Dim windows As Object = shellApplicationType.InvokeMember("Windows", Reflection.BindingFlags.InvokeMethod, Nothing, shellApplication, New Object() {})
Dim windowsType As Type = windows.GetType()
Dim count As Object = windowsType.InvokeMember("Count", Reflection.BindingFlags.GetProperty, Nothing, windows, Nothing)
For i As Integer = 0 To CType(count, Integer)
Dim item As Object = windowsType.InvokeMember("Item", Reflection.BindingFlags.InvokeMethod, Nothing, windows, New Object() {i})
Dim itemType As Type = item.GetType()
'Only fresh Windows explorer Windows
Dim itemName As String = CType(itemType.InvokeMember("Name", Reflection.BindingFlags.GetProperty, Nothing, item, Nothing), String)
If itemName = explorerType Then
itemType.InvokeMember("Refresh", Reflection.BindingFlags.InvokeMethod, Nothing, item, Nothing)
End If
Next
End Sub
我正在一個例外對象引用不設置爲一個對象的實例當我設置ITEMTYPE爲Type = item.GetType()上方。我無法弄清楚哪個對象沒有被創建。當我單步執行代碼時,它看起來像windowsType包含一個對象windows。有沒有人有這個想法?一旦解決問題,我可以將它應用於下面的Drarig解決方案。
您可以使用此:http://www.askvg.com/create-simple-script-to-show隱藏文件和文件夾在Windows XP的Vista和7 /並運行它與vb.net,或在vb.net翻譯它。 – Drarig29
這真棒Drarig29,我昨晚發現這篇文章完全一樣。謝謝你的驗證,雖然:)我會更新此線程與答案,一旦我把它翻譯成VB.net。 – ganjeii
它也讓我感興趣,我可能會在代碼上工作併發布答案。 – Drarig29