zoukankan      html  css  js  c++  java
  • TClientDataSet[20]: 使用 Blob 字段


    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;
    
  • 相关阅读:
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    codevs 2977 二叉堆练习1x
    codevs 2010 求后序遍历x
    二叉树的序遍历x(内含结构体与非结构体版x)
    医院设置x
    求后序遍历x
    [LightOJ1017]Brush (III)(dp)
  • 原文地址:https://www.cnblogs.com/del/p/1663860.html
Copyright © 2011-2022 走看看