如何在把IDTcpClient接收文件封装在DLL中??????我写一个接收文件线程封装在DLL中 可以发送字符 但IDTcpClient用ReadLn读字符 是就失败!!
线程在EXE 中使用就没问题 ,请问该如何解决????????
线程在EXE 中使用就没问题 ,请问该如何解决????????
解决方案 »
- Access violation at address 问题最后是 write address 00000000
- 怎么把一个对象和对象数组作为一个类的属性供类的内部过程或函数调用
- 关于Delphi的Unit:Printers的问题!
- 在delphi中怎样定义全局变量(对整个应用程序有效):定义在哪里?在那里初始化?
- delphi7里,查询姓名以某字开头的?
- 我写一个小程序,请问有BUG吗
- 关于DCOM的基本连接问题(求助)
- 500分求助
- dbgrid里怎样分类统计
- 最新Delphi网站建站公告,以后大家又多了一个学习Delphi的好地方!
- SPCOMM 接收称重仪串口数据,ReceiveData每6秒返回2048字节数据
- DLL返回PCHAR问题?
Classes, SysUtils,IdBaseComponent,
IdComponent, IdTCPConnection, IdTCPClient;type
TDemoThread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
end;implementation{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example, Synchronize(UpdateCaption); and UpdateCaption could look like, procedure TDemoThread.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }{ TDemoThread }procedure TDemoThread.Execute;
var
idTcp : TIdTCPClient;
s : string;
begin
idTcp := TIdTCPClient.Create(nil);
if Assigned(idTcp) then
try
idTcp.Host := 'www.163.com';
idTcp.Port := 80;
idTcp.Connect();
s := 's';
while (not Terminated) and idTcp.Connected and (s <> '') do
begin
idTcp.Write('GET / '#10#13#10#13);
s := idTcp.ReadLn;
s := idTcp.AllData;
end;
finally
FreeAndNil(idTcp);
end;
end;end.
Dll.dpr:library Dll;{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }uses
SysUtils,
Classes,
UnitDll in 'UnitDll.pas';{$R *.res}procedure StartThread; stdcall;
var
DemoThread : TDemoThread;
begin
DemoThread := TDemoThread.Create(false);
DemoThread.FreeOnTerminate := true;
end;exports
StartThread;
begin
end.
调用的 exe:procedure StartThread; external 'dll.dll' name 'StartThread';procedure TForm1.Button3Click(Sender: TObject);
begin
StartThread;
end;