Why am I getting an access violation when setting the value of IHTMLInputTextElement?

I get the following error:

Access violation at address 0050AA07 in the module "project1.exe". Reading address 00000000.

I am trying to autofill a form in TWebBrowser. This is just a "login" field on the form.

What does it mean? How to solve it?

procedure TForm1.Button2Click(Sender: TObject);
var
  doc: IHTMLDocument2;
  frm: IHTMLFormElement;
  fld: IHTMLInputTextElement;
begin
  doc := webbrowser1.Document as IHTMLDocument2;
  frm := doc.forms.item(0, EmptyParam) as IHTMLFormElement;
  fld := frm.item('login', EmptyParam) as IHTMLInputTextElement;
  fld.value := 'someone';
end;
+2
source share
1 answer

This means that you are looking for a pointer set to nil, and the code trying to commit this illegal act is $0050AA07in your process.

If you cannot solve this problem, then if you gave us the code, we could tell you why your pointer is set to nil.

+2
source

Source: https://habr.com/ru/post/1791835/


All Articles