трей 5. последняя битва. перевод с С++
#37558246
Ссылка:
Ссылка на сообщение:
Ссылка с названием темы:
Ссылка на профиль пользователя:
|
|
|
есть рабочий код на С++, удаляющий иконку чужого приложения из трея по всплывающей при наведении на иконку тексту http://forum.vingrad.ru/index.php?showtopic=219051&view=findpost&p=1569594 , есть примерный, не совсем точный перевод в vb6 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99.
Option Explicit
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpszText1 As String, ByVal lpszText2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function VirtualAllocEx Lib "kernel32.dll" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByVal lpBuffer As Long, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Const WM_USER As Long = &H400
Private Const TB_GETBUTTON = WM_USER + 23
Private Const TB_BUTTONCOUNT = WM_USER + 24
Private Const TB_GETBUTTONTEXT = WM_USER + 75
Private Const TB_DELETEBUTTON = WM_USER + 22
Private Const STANDARD_RIGHTS_REQUIRED As Long = &HF0000
Private Const SYNCHRONIZE As Long = &H100000
Private Const PROCESS_ALL_ACCESS As Long = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)
Private Const iBuffer_SIZE As Long = &H1000
Private Const MEM_COMMIT As Long = &H1000
Private Const PAGE_READWRITE As Long = &H4
Private Type TTBButton
iBitmap As Long
idCommand As Long
fsState As Byte
fsStyle As Byte
hReserved As Integer
dwData As Long
iString As Long
End Type
Public Sub DeleteToolBarButton(ByVal ButtonText As String)
Dim hOpProc As Long
Dim ProcID As Long, ThreadID As Long
Dim ToolBar As Long
Dim Window As Long
Dim ButtonsCount As Long
Dim I As Long
Dim iBuffer As String
Dim DButton As TTBButton
Dim RBytes As Long
Dim BTextLength As Long
Dim BText As String
Dim sBuff As String
ToolBar = FindWindow("Shell_TrayWnd", vbNullString)
ToolBar = FindWindowEx(ToolBar, 0, "TrayNotifyWnd", vbNullString)
ToolBar = FindWindowEx(ToolBar, 0, "SysPager", vbNullString)
ToolBar = FindWindowEx(ToolBar, 0, "ToolbarWindow32", vbNullString)
If ToolBar = 0 Then Exit Sub
'ПИД
ProcID = Shell("taskmgr.exe", vbMinimizedNoFocus)
ButtonsCount = SendMessage(ToolBar, TB_BUTTONCOUNT, ByVal 0&, ByVal 0&)
ThreadID = GetWindowThreadProcessId(ToolBar, ProcID)
hOpProc = OpenProcess(PROCESS_ALL_ACCESS, False, ProcID)
iBuffer = VirtualAllocEx(hOpProc, ByVal 0&, iBuffer_SIZE, MEM_COMMIT, PAGE_READWRITE)
For I = 0 To ButtonsCount
Call SendMessage(ToolBar, TB_GETBUTTON, I, iBuffer)
RBytes = 0
Call ReadProcessMemory(hOpProc, iBuffer, VarPtr(DButton), Len(DButton), RBytes)
Call ReadProcessMemory(hOpProc, DButton.dwData, VarPtr(Window), 4, RBytes)
If Window = 0 Then GoTo Continue
BTextLength = SendMessage(ToolBar, TB_GETBUTTONTEXT, DButton.idCommand, iBuffer)
If BTextLength > 0 Then
BText = Space(BTextLength)
Call ReadProcessMemory(hOpProc, iBuffer, StrPtr(BText), BTextLength, RBytes)
If BText = ButtonText Then
Call SendMessage(ToolBar, TB_DELETEBUTTON, I, 0)
Exit For
End If
End If
Continue:
Next
'Call VirtualFreeEx(hOpProc, iBuffer, 0, MEM_RELEASE) '<< Declare
Call CloseHandle(hOpProc)
End Sub
Private Sub Form_Load()
Call DeleteToolBarButton("Диспетчер задач Windows") 'здесь полюбэ ошибка, т.к. должно "быть Загрузка цп...."
End Sub
наверняка ошибка в какой-то строчке или букве, помогите плз исправить
|
|