【发布时间】:2015-04-17 01:39:35
【问题描述】:
我在 tthread 对象中运行我的代码时遇到问题。它应该通过 twebbrowser 中的所有链接,然后如果 url 包含“http://www.ebay.com/itm/”,则将其复制到备忘录中。该代码在 mainform 中完美运行,但在 tthread 对象中不起作用。
我的代码:
begin
count := 0;
loop := 0;
repeat
link := Webbrowser1.OleObject.Document.Links.Item(loop).href;
if AnsiContainsStr(link, 'http://www.ebay.com/itm/') then
begin
Form1.Memo1.Lines.Add(link);
end;
end;
loop := loop + 1;
count := count + 1;
until count = Webbrowser1.OleObject.Document.links.Length;
end;
我遇到的错误
模块 mshtml.dll 中地址 xxxxxx 的访问冲突
感谢您的阅读和所有回复。
【问题讨论】:
-
您不能只从线程更新主窗体控件。我建议您阅读 Delphi 中的多线程基础知识 (google.com/search?q=multithreading+in+Delphi),尤其是 Martin Harvey 教程 tabasco.torreingenieria.unam.mx/gch/Threads%20en%20delphi/…