Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8545187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:44:11+00:00 2026-06-11T12:44:11+00:00

I have an application in Delphi with a grid. I need to create another

  • 0

I have an application in Delphi with a grid.

I need to create another application, which should

a) read data from the grid and
b) write data into the grid,

i. e. emulate the actions of a human user.

In order to read data from the table, I use following code:

Procedure TForm1.Button1Click(Sender: TObject);
type
  PForm = ^TForm;
  PClass = ^TClass;
var
  formPtr : PForm;
  I: Integer;
  msg : string;
  windowHandle : HWND;
begin
  windowHandle := FindWindow('TForm1', 'FORMSSSSS');
  formPtr := PForm(GetVCLObjectAddr(windowHandle) + 4);
  if (not Assigned(formPtr)) then Exit;
  for I := 0 to formPtr^.ControlCount - 1 do // Error
  begin
    msg := msg + formPtr^.Controls[i].Name;
    if formPtr^.Controls[i].Name = 'StringGrid1' then
    begin
      msg := TStringGrid(formPtr^.Controls[i]).Cells[1, 1];
    end;

  end;
  ShowMessage(msg);
end;


function GetVCLObjectAddr(AHandle: HWND): DWORD;
var
  pid: DWORD;
begin
  pid := 0;
  GetWindowThreadProcessId(AHandle, pid);
  if (pid =0) then
  begin
    Result := 0;
    Exit;
  end;
  Result := GetPropW(AHandle, PWideChar(WideString(Format('Delphi%.8X', [PID]))))
end;

In the line with the “Error” comment, following problem occurs:

Project Project1.exe raised exception class EAccessViolation with message ‘Access
violation at address 0046C8C3 in module ‘Project1.exe’. Read of address 01262984′.

When I put a breakpoint on that line and inspect the value of the expression “formPtr^” in the “Watches” tab, I get “Inaccessible value” message.

How should the code be modified in order to be able to read data from the grid?

UPD:

If I change the code to the version given below, the memory problem disappears. But another problem arises – control count is equal to zero.

Procedure TForm1.Button1Click(Sender: TObject);
var
  formPtr : TForm;
  I: Integer;
  msg : string;
  windowHandle : HWND;
begin
  windowHandle := FindWindow('TForm1', 'FORMSSSSS');
  formPtr := TForm(GetVCLObjectAddr(windowHandle) + 4);
  if (not Assigned(formPtr)) then Exit;
  for I := 0 to formPtr.ControlCount - 1 do
  begin
    msg := msg + formPtr.Controls[i].Name;
    if formPtr.Controls[i].Name = 'StringGrid1' then
    begin
      msg := TStringGrid(formPtr.Controls[i]).Cells[1, 1];
    end;    
  end;
  ShowMessage(msg);
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:44:13+00:00Added an answer on June 11, 2026 at 12:44 pm

    That approach cannot work. Your two processes have isolated address spaces. An address, and therefore an object, is only meaningful in the context of the process that owns that address or object. You can only call methods on objects that reside in your process.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Delphi application which reads data from an excel spreadsheet using code
I have written an application in Delphi 2010 that imports data from one database
We have a delphi application which can also run as a sevice . We
I have an ISAPI Application in Delphi 6 that uses WebBroker. I need to
I have written a console application in Delphi that queries information from several locations.
I'm upgrading my application from Delphi 2007 to Delphi XE. I have my personal
I have a Delphi application database of which is in Oracle. Now there's a
we have a delphi application which contains a TXTextControl (v. 13.0). This application uses
I have a Delphi application which displays an image using a TImage. The location
I have a Delphi application using DevExpress cxGrid (which is connected to database). I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.