procedure ShowStatusExample; const cBuf = 1024; var s: String; hMain: HWND; hStatus: HWND; idProcess: DWORD; hProcess: THandle; pBuf: Pointer; n: cardinal; i: integer; cParts: integer; begin // Get main window handle hMain := FindWindowEx(0, 0, 'IEFrame', nil); if hMain = 0 then RaiseLastWin32Error; // Get process handle GetWindowThreadProcessID(hMain, @idProcess); hProcess := OpenProcess(PROCESS_ALL_ACCESS, False, idProcess); if hProcess = 0 then RaiseLastWin32Error; // Allocate buffer in process pBuf := VirtualAllocEx(hProcess, nil, cBuf, MEM_COMMIT, PAGE_READWRITE); if pBuf = nil then RaiseLastWin32Error; try // Show main window's text n := GetWindowTextLength(hMain); SetLength(s, n); GetWindowText(hMain, PChar(s), n); ShowMessage(s); // Get status bar handle hStatus := FindWindowEx(hMain, 0, 'msctls_statusbar32', nil); if hStatus = 0 then RaiseLastWin32Error; // Get number of parts in status bar cParts := SendMessage(hStatus, SB_GETPARTS, 0, 0); for i := 0 to cParts - 1 do begin // Get status bar text into buffer n := LoWord(SendMessage(hStatus, SB_GETTEXT, i, Integer(pBuf))); SetLength(s, n); // Read buffer if not ReadProcessMemory(hProcess, pBuf, PChar(s), n, n) then RaiseLastWin32Error; if s <> '' then ShowMessage(IntToStr(i) + ': ' + s); end; finally VirtualFreeEx(hProcess, pBuf, cBuf, MEM_RELEASE); end; end;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question