我做了一个线程,在线程里包含了一个窗体的.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        
---------------------------  
请各位给予帮助,谢谢

解决方案 »

  1.   

    创建了,是包含的相关的文件里的一个窗体uses formMain;
      

  2.   

    formmain是别的线程里的吧,跨线程的内存调用,经常会出错
      

  3.   

    这样,
    在frmMain的定义处添加:
    var frmMain:TfrmMain=nil ;
    将:
      frmMain.Edit1.Text  :=  ‘test’;  
    改成
      if (frmmain<>nil) then
    begin
    frmMain.Edit1.Text  :=  ‘test’;  end else
    begin
      showmessage("nil") ;
    end ;
      

  4.   

    对了,我是这样调用的
    GetURL.Create(False);行吗?