Danke für die Hilfe. Habe jetzt etwas rumprobiert und kann mit dem Code den Inhalt der Drag Listbox von Control Spy auslesen. Das Handle habe ich aus dem Control Viewer und gebe es Manuell ein. Wenn ich das gleiche jetzt z.B. bei einer Listbox von spyxx oder Pokerstars probiere werden mit bei spyxx nur Fragezeichen angezeigt und bei Pokerstars Garnichts.
Weiß einer von euch woran das liegt und wie ich dieses Problem lösen könnte?
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication6
{
class Program
{
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
public static extern int RegisterWindowMessage(string lpString);
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SendMessage", CharSet = System.Runtime.InteropServices.CharSet.Auto)] //
public static extern bool SendMessage(IntPtr hWnd, uint Msg, int wParam, StringBuilder lParam);
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr SendMessage(int hWnd, int Msg, int wparam,
int lparam);
const int LB_GETTEXT = 0x0189;
const int LB_GETTEXTLEN = 0x018A;
static void Main(string[] args)
{
IntPtr hWnd = new IntPtr(0x1F04FC);
StringBuilder title = new StringBuilder();
// Get the size of the string required to hold the window title.
Int32 size = SendMessage((int)hWnd, LB_GETTEXTLEN, 0, 0).ToInt32();
// If the return is 0, there is no title.
if (size > 0)
{
title = new StringBuilder(size + 1);
SendMessage(hWnd, (int)LB_GETTEXT, 0, title);
}
Console.WriteLine(title);
Console.ReadKey();
}
}
}