SHARE
TWEET

Untitled

a guest Feb 19th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Procedure TForm1.Button1Click(Sender: TObject);
  2. type
  3.   PForm = ^TForm;
  4.   PClass = ^TClass;
  5. var
  6.   formPtr : PForm;
  7.   I: Integer;
  8.   msg : string;
  9.   windowHandle : HWND;
  10. begin
  11.   windowHandle := FindWindow('TForm1', 'FORMSSSSS');
  12.   formPtr := PForm(GetVCLObjectAddr(windowHandle) + 4);
  13.   if (not Assigned(formPtr)) then Exit;
  14.   for I := 0 to formPtr^.ControlCount - 1 do // Error
  15.   begin
  16.     msg := msg + formPtr^.Controls[i].Name;
  17.     if formPtr^.Controls[i].Name = 'StringGrid1' then
  18.     begin
  19.       msg := TStringGrid(formPtr^.Controls[i]).Cells[1, 1];
  20.     end;
  21.  
  22.   end;
  23.   ShowMessage(msg);
  24. end;
  25.  
  26.  
  27. function GetVCLObjectAddr(AHandle: HWND): DWORD;
  28. var
  29.   pid: DWORD;
  30. begin
  31.   pid := 0;
  32.   GetWindowThreadProcessId(AHandle, pid);
  33.   if (pid =0) then
  34.   begin
  35.     Result := 0;
  36.     Exit;
  37.   end;
  38.   Result := GetPropW(AHandle, PWideChar(WideString(Format('Delphi%.8X', [PID]))))
  39. end;
  40.    
  41. Procedure TForm1.Button1Click(Sender: TObject);
  42. var
  43.   formPtr : TForm;
  44.   I: Integer;
  45.   msg : string;
  46.   windowHandle : HWND;
  47. begin
  48.   windowHandle := FindWindow('TForm1', 'FORMSSSSS');
  49.   formPtr := TForm(GetVCLObjectAddr(windowHandle) + 4);
  50.   if (not Assigned(formPtr)) then Exit;
  51.   for I := 0 to formPtr.ControlCount - 1 do
  52.   begin
  53.     msg := msg + formPtr.Controls[i].Name;
  54.     if formPtr.Controls[i].Name = 'StringGrid1' then
  55.     begin
  56.       msg := TStringGrid(formPtr.Controls[i]).Cells[1, 1];
  57.     end;    
  58.   end;
  59.   ShowMessage(msg);
  60. end;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top