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;