首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

雙擊實現隐藏任务栏“音量”图标,该如何解决

2012-01-30 
雙擊實現隐藏任务栏“音量”图标雙擊實現隐藏任务栏“音量”图标[解决办法]应该可以了:VB codePrivate Const W

雙擊實現隐藏任务栏“音量”图标
雙擊實現隐藏任务栏“音量”图标

[解决办法]
应该可以了:

VB code
Private Const WM_USER = &H400Private Const TB_BUTTONCOUNT = (WM_USER + 24)Private Const TB_HIDEBUTTON = (WM_USER + 4)Private Const TB_GETBUTTONTEXTA = (WM_USER + 45)Private Const TB_AUTOSIZE = (WM_USER + 33)Private Const MEM_COMMIT = &H1000&Private Const MEM_RESERVE = &H2000&Private Const MEM_RELEASE = &H8000&Private Const PAGE_READWRITE = &H4Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hwnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPrivate Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Declare Function VirtualAllocEx Lib "kernel32.dll" (ByVal hProcess As Long, lpAddress As Any, ByRef dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As LongPrivate Declare Function VirtualFreeEx Lib "kernel32.dll" (ByVal hProcess As Long, lpAddress As Any, ByRef dwSize As Long, ByVal dwFreeType As Long) As LongPrivate Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As LongPrivate Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As LongPrivate Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As LongPrivate Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As LongSub HideVolIcon()    '隐藏音量图标    Dim pIdExplorer As Long, hwnd2 As Long, hExplorer As Long, lpIconText As Long    Dim i As Integer    Dim BtnCount As Integer    Dim IconText As String    Dim lLen As Long, sBuff As String        hwnd2 = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)    hwnd2 = FindWindowEx(hwnd2, 0, "TrayNotifyWnd", vbNullString)    hwnd2 = FindWindowEx(hwnd2, 0, "SysPager", vbNullString)    hwnd2 = FindWindowEx(hwnd2, 0, "ToolbarWindow32", vbNullString)        GetWindowThreadProcessId hwnd2, pIdExplorer    hExplorer = OpenProcess(56, False, pIdExplorer)    lpIconText = VirtualAllocEx(ByVal hExplorer, ByVal 0&, Len(IconText), MEM_COMMIT Or MEM_RESERVE, PAGE_READWRITE)    BtnCount = SendMessage(hwnd2, TB_BUTTONCOUNT, 0, 0)    For i = 0 To BtnCount - 1        IconText = Space$(256)        lLen = SendMessage(hwnd2, TB_GETBUTTONTEXTA, i, ByVal lpIconText)        ReadProcessMemory hExplorer, ByVal lpIconText, ByVal IconText, Len(IconText), 0        If lLen <> -1 Then IconText = Left$(IconText, InStr(1, IconText, Chr$(0)) - 1)        If (IconText = "音量") Then SendMessage hwnd2, TB_HIDEBUTTON, i, ByVal -1&: Exit For    Next    VirtualFreeEx hExplorer, lpIconText, Len(IconText), MEM_RELEASE    CloseHandle hExplorerEnd Sub 

热点排行