你是说在链表中清除吗?我在
procedure TfrmMain.tcpServerDisconnect(AThread: TIdPeerThread);
var
Client : TSimpleClient;
sql :string;
sPhone:string;
Logofftime:string;
//index:integer;
begin
Client := Pointer(AThread.Data);
Clients.Delete(Client.ListLink);
lbClients.Items.Delete(lbClients.Items.IndexOf(Client.Name));
sPhone:=Client.Name;
Client.Free;
AThread.Data := nil;
这样清楚对吗?
终端链表与listbox对应,Client.ListLink是其索引。
procedure TfrmMain.tcpServerDisconnect(AThread: TIdPeerThread);
var
Client : TSimpleClient;
sql :string;
sPhone:string;
Logofftime:string;
//index:integer;
begin
Client := Pointer(AThread.Data);
Clients.Delete(Client.ListLink);
lbClients.Items.Delete(lbClients.Items.IndexOf(Client.Name));
sPhone:=Client.Name;
Client.Free;
AThread.Data := nil;
这样清楚对吗?
终端链表与listbox对应,Client.ListLink是其索引。
咋写的?
相信TSimpleClient的定义也差不多
我暂时没有看出什么问题
自己再仔细研究一下demo吧
代码:
{=================================
功能:处理已登录的终端重新登录
参数:gprsClient:登录的终端
返回值:无
==================================}
procedure TfrmMain.HandleClient(gprsClient: PClient);
var
cindex:integer;
Client:PClient;
begin
cindex := IsInClients(gprsClient.Name); //查找先前终端链表中的索引
if (cindex <> -1) then
begin
try
try
Client := Clients.LockList.Items[cindex];
TIdPeerThread(Client.Thread).Connection.Disconnect;
except
TIdPeerThread(Client.Thread).stop;
end;
finally
Clients.UnlockList;
end;
end;
end;function TfrmMain.IsInClients(sp: string): integer;
var
// Count : Integer;
oldClient:PClient;
i:integer;
begin
{ Loop through all the clients connected to the system and set their names }
try
with Clients.LockList do
begin
for i := 0 to Count-1 do
begin
oldClient:=Items[i];
if oldClient.Name=sp then
begin
result:=i;
exit;
end
end;
end;
finally
Clients.UnlockList;
end;
result:=-1;