设置IHTMLInputTextElement的值时为什么会出现访问冲突? [英] Why do I get an access violation when setting the value of an IHTMLInputTextElement?
问题描述
我收到以下错误:
模块 project1.exe中地址0050AA07的访问冲突。读取的地址为00000000。
Access Violation at address 0050AA07 in module "project1.exe". Read of address 00000000.
我试图在TWebBrowser中自动填写表格。这只是表单上称为登录的字段。
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;
推荐答案
这意味着您正在取消引用设置为 nil
和尝试执行此非法行为的代码位于您的进程中的 $ 0050AA07
。
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.
如果您不能从中解决问题,那么如果向我们展示代码,我们可以告诉您为什么将指针设置为 nil
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
.
这篇关于设置IHTMLInputTextElement的值时为什么会出现访问冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!