为什么在设置 IHTMLInputTextElement 的值时会出现访问冲突?
我收到以下错误:
模块“project1.exe”中地址 0050AA07 处存在访问冲突。读取地址 00000000。
我正在尝试在 TWebBrowser 中自动填写表格。它只是表单上一个名为“登录”的字段。
这是什么意思?我该如何解决?
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;
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这意味着您正在取消引用设置为
nil
的指针,并且尝试此非法行为的代码位于进程中的$0050AA07
处。如果您无法从此解决问题,那么如果向我们展示代码,我们可以告诉您为什么指针设置为
nil
。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
.