为什么在设置 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屋!