Why do I get an access violation when setting the value of an IHTMLInputTextElement?

796 views Asked by At

I get the following error:

Access Violation at address 0050AA07 in module "project1.exe". Read of address 00000000.

I'm trying to auto fill a form in TWebBrowser. It's just a field called 'login' on a form.

What does it mean? How do I 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;
1

There are 1 answers

15
David Heffernan On BEST ANSWER

It means you are dereferencing a pointer that is set to nil and the code that is attempting this illegal act is located at $0050AA07 in your process.

If you can't solve it from this, then if showed us the code we could tell you why your pointer is set to nil.