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;
    
  • 相关阅读:
    ggplot2绘图入门系列之二:图层控制与直方图
    机器学习与数据挖掘中的十大经典算法
    mysql使用存储过程执行定时任务
    使用hbase-shaded-client解决google包冲突问题
    vue 表单校验及气泡清除
    druid配置
    如何修改maven jar包源码
    jar包冲突最新解决方式
    Hive安装
    Hbase
  • 原文地址:https://www.cnblogs.com/del/p/1663860.html
Copyright © 2011-2022 走看看