我做了一个线程,在线程里包含了一个窗体的.pas文件,然后我写了下面的代码:
procedure GetURL.Execute;
begin
FreeOnTerminate:=true;
// if (!Terminated) Then
Synchronize(UpdateInfoThead);
end;
procedure GetURL.UpdateInfoThead;
Begin
try
frmMain.Edit1.Text := ‘test’;
finally
//
end;
End;
调试时,出现下面的错误,Debugger Exception Notification
---------------------------
Project WebUpdate.exe raised exception class EAccessViolation with message 'Access violation at address 0047ADC1 in module 'WebUpdate.exe'. Read of address 0000031C'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
请各位给予帮助,谢谢
在frmMain的定义处添加:
var frmMain:TfrmMain=nil ;
将:
frmMain.Edit1.Text := ‘test’;
改成
if (frmmain<>nil) then
begin
frmMain.Edit1.Text := ‘test’; end else
begin
showmessage("nil") ;
end ;
GetURL.Create(False);行吗?