首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

线程引发access violation的异常

2012-04-07 
线程引发access violation的错误Delphi(Pascal) code//连接FTP的procedure TFtpThread.ExecutebeginFreeO

线程引发access violation的错误

Delphi(Pascal) code
//连接FTP的procedure TFtpThread.Execute;begin  FreeOnTerminate := True;  if not FtpConnState then  begin    FtpConnState := ConnFtp(MainForm.FtpLibrary,UserName,PassWord);    SendMessage(MainForm.Handle,WM_CONNFTP,Integer(PChar(FtpConnState)),0);  end;end;//上传文件的procedure TUpLoadThread.Execute;begin  FreeOnTerminate := True;   if not FtpConnState then  begin    MainForm.FtpLibrary.RemotePath :='446\1.txt';    MainForm.FtpLibrary.LocalPath:='c:\1.txt';    MainForm.FtpLibrary.Upload;  end;end;

上面的FtpLibrary是一个主窗体上的OCX控件 如果在主线程中直接调用没问题 放在线程里就不行了就会报access violation at address in module 'MSVBVM60.DLL'错误



[解决办法]
在线程离创建FtpLibrary

热点排行