我正在重新访问我在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