W
OK. Verstehe ich aber nicht. In winapi.net habe ich jetzt Hilfe von -King- bekommen. So sieht's fertig aus:
DWORD pID;
TBBUTTON tbb;
HANDLE hProcess;
int button_count;
CHAR txt[1024];
// Fenster holen
HWND hEmule = FindWindow(NULL, "eMule v0.45b");
HWND hRB = FindWindowEx(hEmule, NULL, "ReBarWindow32", NULL);
HWND hTB = FindWindowEx(hRB, NULL, "ToolbarWindow32", NULL);
// Das Prozess-Handle holen
GetWindowThreadProcessId(hEmule, &pID);
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
// Die Anzahl aller TBButtons holen und Memory im Emule-Prozess reservieren
button_count = SendMessage(hTB, TB_BUTTONCOUNT, 0, 0);
LPTBBUTTON ptbb = (LPTBBUTTON)VirtualAllocEx(hProcess, NULL, sizeof(TBBUTTON), MEM_COMMIT, PAGE_READWRITE);
LPSTR ptxt = (LPSTR)VirtualAllocEx(hProcess, NULL, 1024, MEM_COMMIT, PAGE_READWRITE);
// Die Daten aus den Buttons auslesen und wenn nötig, Button drücken
for(int i=0; i < button_count; ++i)
{
SendMessage(hTB, TB_GETBUTTON, (WPARAM)i, (LPARAM)ptbb);
ReadProcessMemory(hProcess, (LPCVOID)ptbb, (LPVOID)&tbb, sizeof(TBBUTTON), NULL);
SendMessage(hTB, TB_GETBUTTONTEXT, (WPARAM)tbb.idCommand, (LPARAM)ptxt);
ReadProcessMemory(hProcess, (LPCVOID)ptxt, (LPVOID)txt, 1024, NULL);
if( lstrcmpi("T&rennen", txt) == 0 )
if( (tbb.fsStyle & TBSTYLE_SEP) == 0 )
SendMessage(hEmule, WM_COMMAND, MAKEWPARAM(tbb.idCommand, 0), (LPARAM)NULL);
}
// Speicher wieder freigeben
VirtualFreeEx(hProcess, ptxt, 0, MEM_RELEASE);
VirtualFreeEx(hProcess, ptbb, 0, MEM_RELEASE);
// Das Prozess-Handle wieder freigeben
CloseHandle(hProcess);