这是我做的代码 它总是在SENDSTREAM时出错
报错如下:access violation at 0xff00ffff:read of address 0xff00ffff
我想知道如何用SENDSTREAM发送内存流
procedure TForm1.UDPDataReceived(Sender: TComponent;
NumberBytes: Integer; FromIP: String; Port: Integer);
var
buffer : array[0..4096] of char;
desk:tcanvas;
bitmap:tbitmap;
abit:tmemorystream;
tmpstr:string;
begin
buffer:='';
udp.readbuffer(buffer,numberbytes);
udp.RemoteHost:=fromip;
udp.RemotePort:=port;
edit1.Text:=fromip;
memo1.Lines.Add(buffer);
bitmap:=tbitmap.Create;
abit:=tmemorystream.Create;
desk:=tcanvas.Create; //以下代码为取得当前屏幕图象
desk.Handle:=getdc(hwnd_desktop);
with bitmap do
begin
width:=integer(screen.Width);
height:=integer(screen.Height);
canvas.CopyRect(canvas.cliprect,desk,desk.cliprect);
end;
abit.Position:=0;
bitmap.SaveToStream(abit);
abit.Position:=0;
udp.SendStream(abit); <-----出错
bitmap.free;
abit.free;
end;