刘继才

导航

 

  TDMSRequestBuffer=object
    Head:TDMSHead;
    Data:array[0..2047] of char;
    DataSize:Integer;
    procedure Init(Sys:TDMSSysType;Svr:TDMSSvrType);
    procedure EncodeRequest;
    function Size:integer;
  end;

 

目的,保存Data

 

function SaveDataToFile(AFileName: string; AData: Pointer; ALen: Integer): Boolean;
var
  stream: TMemoryStream;
begin
  Result := False;
  stream := TMemoryStream.Create;
  try
    try
      stream.Write(AData^,ALen);
      stream.SaveToFile(AFileName);
      Result := True;
    except
    end;
  finally
    stream.Free;
  end;
end;

调用方法

  SaveDataToFile('E:\1.txt',@RB.Data[0],RB.DataSize);

posted on 2015-04-13 10:41  刘继才  阅读(1065)  评论(0编辑  收藏  举报