also gut, muss ich es eben machen...
So das hier funzt nur unter WinXP
Option Explicit
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 hWndParent As Long, ByVal hWndChildAfter As Long, ByVal lpClassName As _
String, ByVal lpWindowName As String)
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As _
Long, lpdwProcessId As Long) As Long
Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal _
hWnd&, ByVal wMsg&, ByVal wParam&, lParam As Any)
Private Type POINTAPI
X As Long
Y As Long
End Type
'''''''''''''LISTVIEW KONSTANTEN''''''''''''''''
Private Const LVM_FIRST = &H1000
Private Const LVM_GETITEMCOUNT = LVM_FIRST + 4
Private Const LVM_GETITEMPOSITION& = LVM_FIRST + 16
''''''''''WINDOWS NT/2K/XP Memory Zeugs'''''''''''''''''''
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As _
Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Const PROCESS_VM_OPERATION = &H8
Const PROCESS_VM_READ = &H10
Const PROCESS_VM_WRITE = &H20
Const PROCESS_ALL_ACCESS = 0
Private Declare Function VirtualAllocEx Lib "kernel32" (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 VirtualFreeEx Lib "kernel32" (ByVal hProcess As Long, _
lpAddress As Any, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As _
Long
Const MEM_COMMIT = &H1000
Const MEM_RESERVE = &H2000
Const MEM_DECOMMIT = &H4000
Const MEM_RELEASE = &H8000
Const MEM_FREE = &H10000
Const MEM_PRIVATE = &H20000
Const MEM_MAPPED = &H40000
Const MEM_TOP_DOWN = &H100000
Private Const PAGE_NOACCESS = &H1&
Private Const PAGE_READONLY = &H2&
Private Const PAGE_READWRITE = &H4&
Private Const PAGE_WRITECOPY = &H8&
Private Const PAGE_EXECUTE = &H10&
Private Const PAGE_EXECUTE_READ = &H20&
Private Const PAGE_EXECUTE_READWRITE = &H40&
Private Const PAGE_EXECUTE_WRITECOPY = &H80&
Private Const PAGE_GUARD = &H100&
Private Const PAGE_NOCACHE = &H200&
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As _
Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, _
lpNumberOfBytesWritten As Long) As Long
Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As _
Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, _
lpNumberOfBytesWritten As Long) As Long
Private pIcPos() As POINTAPI
Private Function GetIconPositions() As Variant
Dim pid As Long, tid As Long, lStyle As Long
Dim hProcess As Long, lpSysShared As Long, dwSize As Long
Dim lWritten As Long
Dim lCount As Long
Dim lHwnd As Long
Dim l As Long
lHwnd = FindWindow("Progman", vbNullString)
lHwnd = FindWindowEx(lHwnd, 0, "SHELLDLL_defVIEW", vbNullString)
lHwnd = FindWindowEx(lHwnd, 0, "SysListView32", vbNullString)
lCount = SendMessage(lHwnd, LVM_GETITEMCOUNT, 0, 0&)
ReDim pIcPos(lCount - 1)
tid = GetWindowThreadProcessId(lHwnd, pid)
dwSize = Len(pIcPos(0))
lpSysShared = GetMemSharedNT(pid, dwSize, hProcess)
WriteProcessMemory hProcess, ByVal lpSysShared, pIcPos(0), dwSize, _
lWritten
For l = 0 To lCount - 1
SendMessage lHwnd, LVM_GETITEMPOSITION, l, ByVal lpSysShared
ReadProcessMemory hProcess, ByVal lpSysShared, pIcPos(l), dwSize, _
lWritten
Next l
FreeMemSharedNT hProcess, lpSysShared, dwSize
End Function
Public Function GetMemSharedNT(ByVal pid As Long, ByVal memSize As Long, _
hProcess As Long) As Long
hProcess = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or _
PROCESS_VM_WRITE, False, pid)
GetMemSharedNT = VirtualAllocEx(ByVal hProcess, ByVal 0&, ByVal memSize, _
MEM_RESERVE Or MEM_COMMIT, PAGE_READWRITE)
End Function
Public Sub FreeMemSharedNT(ByVal hProcess As Long, ByVal MemAddress As Long, _
ByVal memSize As Long)
Call VirtualFreeEx(hProcess, ByVal MemAddress, memSize, MEM_RELEASE)
CloseHandle hProcess
End Sub
Private Sub Command1_Click()
Dim l As Long
GetIconPositions
For l = LBound(pIcPos) To UBound(pIcPos)
MsgBox "Icon Nr." & l + 1 & " X=" & pIcPos(l).X & " Y=" & pIcPos(l).Y
Next l
End Sub For VB Tools visit :: www.planetultra.de :: |