Why do I get an access violation when setting the

2019-07-21 19:59发布

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条回答
Explosion°爆炸
2楼-- · 2019-07-21 20:20

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.

查看更多
登录 后发表回答