VB.NET如何实现隐藏、显示windows桌面图标功能

qingdaofeng 2017-09-30 12:06:03
在windows上单击鼠标右键时,选择“查看”,然后勾选“显示桌面图标”,此处可以控制桌面图标“集体”显示与隐藏,在VB.NET中该用哪个类库呢?具体怎样实现呢?
...全文
636 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
123工艺品 2017-10-24
  • 打赏
  • 举报
回复
https://jingyan.baidu.com/article/4b52d7028fe6cefc5d774b7e.html 利用注册表隐藏 HKEY_CURRENT_USER“——”Software“——”Microsoft“——”Windows“——”CurrentVersion“——”Policies” 找到“Explorer”文件夹。右键“Explorer”,新建一个项,重命名为“Advanced”。 右键“Advanced”,新建一个项,重命名为“HideIcons”。然后双击右侧的“默认”。 在弹出的窗口中,将“数值数据”改为1。单击确认退出注册表,再重启电脑即可。 ================ vb.net实现: Dim scoreKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("你要创建的项 ") 具体的代码没实践
wq1282 2017-10-23
  • 打赏
  • 举报
回复
非常用操作,这种东西,是没有一个公用方法实现的,只能是自己来做! 如上源码即可。
wq1282 2017-10-23
  • 打赏
  • 举报
回复
Imports System.Net.Sockets
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.Text

Module Module1

    <DllImport("User32.dll", EntryPoint:="FindWindow")>
    Private Function FindWindow(lpClassName As String, lpWindowName As String) As IntPtr
    End Function

    <DllImport("user32.dll", SetLastError:=True)>
    Public Function FindWindowEx(parentHandle As IntPtr, childAfter As IntPtr, className As String, windowTitle As String) As IntPtr
    End Function

    <DllImport("user32.dll", EntryPoint:="ShowWindow")>
    Public Function ShowWindow(hwnd As IntPtr, nCmdShow As Integer) As Integer
    End Function

    <DllImport("user32.dll")>
    Public Function IsWindowVisible(hwnd As IntPtr) As Boolean
    End Function

    Public Const SW_SHOW As Integer = 5
    Public Const SW_HIDE As Integer = 0

    ''' <summary>
    ''' 命令行程序入口位置
    ''' </summary>
    Public Sub Main()
        HideDeskTopIcon()
        Threading.Thread.Sleep(5000)
        ShowDeskTopIcon()
    End Sub

    ''' <summary>
    ''' 显示之前隐藏过的桌面图标
    ''' </summary>
    Private Sub ShowDeskTopIcon()
        GetDesktopHwnd()
        If hWndDeskop <> IntPtr.Zero Then
            If Not IsWindowVisible(hWndDeskop) Then
                ShowWindow(hWndDeskop, SW_SHOW)
            Else
                Debug.Print("已经显示啦")
            End If
        End If
    End Sub

    ''' <summary>
    ''' 隐藏桌面图标
    ''' </summary>
    Private Sub HideDeskTopIcon()
        GetDesktopHwnd()
        If hWndDeskop <> IntPtr.Zero Then
            If IsWindowVisible(hWndDeskop) Then
                ShowWindow(hWndDeskop, SW_HIDE)
            Else
                Debug.Print("已经隐藏啦")
            End If
        End If
    End Sub
    Private hWndDeskop As IntPtr = IntPtr.Zero

    ''' <summary>
    ''' 获取桌面图标句柄
    ''' </summary>
    ''' <returns></returns>
    Private Function GetDesktopHwnd() As IntPtr
        Dim hWndPm As IntPtr = IntPtr.Zero
        hWndPm = FindWindow(Nothing, "Program Manager")
        If hWndPm = IntPtr.Zero Then
            Debug.Print("无法找到桌面。" & "错误")
        Else
            Dim hWndPm2 As IntPtr = IntPtr.Zero
            hWndPm2 = FindWindowEx(hWndPm, IntPtr.Zero, Nothing, "")
            If hWndPm2 = IntPtr.Zero Then
                Debug.Print("无法找到窗口。" & "错误")
            Else
                hWndDeskop = FindWindowEx(hWndPm2, IntPtr.Zero, Nothing, "FolderView")
                If hWndDeskop = IntPtr.Zero Then
                    Debug.Print("无法找到窗口。" & "错误")
                End If
            End If
        End If
    End Function




End Module
qingdaofeng 2017-09-30
  • 打赏
  • 举报
回复
很想通过VB6.0的代码转换,但是还是很想用.net的类库实现

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧