Blob(Binary Large Object) 字段包括:
ftBlob, 
ftMemo, 
ftGraphic, 
ftFmtMemo, 
ftParadoxOle, 
ftDBaseOle, 
ftTypedBinary, 
ftCursor, 
ftFixedChar, 
ftWideString,
ftLargeint, 
ftADT, 
ftArray, 
ftReference, 
ftDataSet, 
ftOraBlob, 
ftOraClob, 
ftVariant, 
ftInterface, 
ftIDispatch, 
ftGuid, 
ftTimeStamp, 
ftFMTBcd, 
ftFixedWideChar, 
ftWideMemo

{ TBlobType = ftBlob..ftWideMemo }


示例:



uses IOUtils, MMSystem;

{ 建立包含 Blob 字段的数据集, 并载入 Windows\Media\*.wav }
procedure TForm1.FormCreate(Sender: TObject);
var
  MediaPath, Path: string;
begin
  with ClientDataSet1 do begin
    FieldDefs.Add('WavFileName', ftString, 32);
    FieldDefs.Add('WAV', ftBlob);
    CreateDataSet;
  end;

  MediaPath := GetEnvironmentVariable('SystemRoot') + '\Media\';
  for Path in TDirectory.GetFiles(MediaPath, '*.wav') do
  begin
    ClientDataSet1.Append;
    ClientDataSet1['WavFileName'] := ExtractFileName(Path);
    TBlobField(ClientDataSet1.FieldByName('WAV')).LoadFromFile(Path);
  end;
  ClientDataSet1.MergeChangeLog;
end;

{ 播放 }
procedure TForm1.Button1Click(Sender: TObject);
var
  BlobStream: TClientBlobStream;
  BlobField: TBlobField;
begin
  BlobField := ClientDataSet1.FieldByName('WAV') as TBlobField;
  BlobStream := TClientBlobStream.Create(BlobField, bmRead);
  Win32Check(PlaySound(BlobStream.Memory, 0, SND_SYNC or SND_MEMORY));
  BlobStream.Free;
end;

posted on 2010-02-04 17:59  万一  阅读(6660)  评论(0编辑  收藏  举报