Ich versuche gerade auf ein SysListView32 (Fremdprogramm) zuzugreifen.
Ich habe nach langem Suchen folgendes gefunden und verstehe nicht wirklich viel.
mycsharp.de/wbb2/thread.php?postid=3760476
Gibt es irgendwo eine Sammlung der Deklarationen von Win32API_Methods?
edit.
Habe die Deklaration mal zusammengesucht
Wie ich die Funktion jetzt aber anwenden muss, fehlt mir noch
Ich habe nach langem Suchen folgendes gefunden und verstehe nicht wirklich viel.
mycsharp.de/wbb2/thread.php?postid=3760476
VB.NET-Quellcode
- Public Shared Function GetListItemText(ByVal hWnd As IntPtr, ByVal index As Integer, ByVal Optional column As Integer = 0) As String
- Dim bufferSize As Integer = 256
- Dim processId As UInteger = GetProcessId(hWnd)
- Dim hProcess As IntPtr = Win32API_Methods.OpenProcess(8 Or 16 Or 32, True, CInt(processId))
- Dim remoteBuffer As IntPtr = Win32API_Methods.VirtualAllocEx(hProcess, IntPtr.Zero, CUInt(bufferSize), &H1000, 4)
- Dim localBuffer As IntPtr = Marshal.AllocHGlobal(bufferSize)
- Dim lvi As Win32API_Structs.LVITEM = New Win32API_Structs.LVITEM()
- lvi.mask = 1
- lvi.cchTextMax = bufferSize - Marshal.SizeOf(lvi)
- lvi.iItem = index
- lvi.iSubItem = column
- lvi.pszText = IntPtr.Add(remoteBuffer, Marshal.SizeOf(lvi))
- Dim ptrLvi As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(lvi))
- Marshal.StructureToPtr(lvi, ptrLvi, False)
- Win32API_Methods.WriteProcessMemory(hProcess, remoteBuffer, ptrLvi, Marshal.SizeOf(lvi), IntPtr.Zero)
- Win32API_Methods.SendMessage(hWnd, &H1000 + 75, IntPtr.Zero, remoteBuffer)
- Win32API_Methods.ReadProcessMemory(hProcess, remoteBuffer, localBuffer, bufferSize, IntPtr.Zero)
- lvi.pszText = localBuffer + Marshal.SizeOf(lvi)
- Marshal.FreeHGlobal(localBuffer)
- Win32API_Methods.VirtualFreeEx(hProcess, remoteBuffer, 0, &H8000)
- Win32API_Methods.CloseHandle(hProcess)
- Return Marshal.PtrToStringAuto(lvi.pszText)
- End Function
Gibt es irgendwo eine Sammlung der Deklarationen von Win32API_Methods?
edit.
Habe die Deklaration mal zusammengesucht
VB.NET-Quellcode
- Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
- Declare Function VirtualAllocEx Lib "kernel32.dll" (ByVal hProcess As Int32, ByVal lpAddress As Int32, ByVal dwSize As Int32, ByVal flAllocationType As Int32, ByVal flProtect As Int32) As Int32
- Public Declare Function WriteProcessMemory Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
- Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
- Public Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
- Declare Function VirtualFreeEx Lib "kernel32.dll" (ByVal hProcess As Integer, lpAddress As Object, ByRef dwSize As Integer, ByVal dwFreeType As Integer) As Integer
- Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Integer) As Integer
- Friend Structure LVITEM
- Public mask As Integer
- Public iItem As Integer
- Public iSubItem As Integer
- Public state As Integer
- Public stateMask As Integer
- Public pszText As IntPtr
- Public cchTextMax As Integer
- Public iImage As Integer
- Public lParam As IntPtr
- Public iIndent As Integer
- Public iGroupId As Integer
- Public cColumns As Integer
- Public puColumns As IntPtr
- End Structure
Wie ich die Funktion jetzt aber anwenden muss, fehlt mir noch
In Arbeit...
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „vico255“ ()