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;
    
  • 相关阅读:
    OCP-1Z0-053-200题-91题-667
    OCP-1Z0-053-200题-92题-668
    OCP-1Z0-053-200题-93题-669
    OCP-1Z0-053-200题-94题-670
    OCP-1Z0-053-200题-96题-671
    OCP-1Z0-053-200题-97题-227
    OCP-1Z0-053-200题-98题-242
    OCP-1Z0-053-200题-99题-10
    在Visual Studio 2010中配置VC++目录
    OCP-1Z0-053-200题-100题-69
  • 原文地址:https://www.cnblogs.com/del/p/1663860.html
Copyright © 2011-2022 走看看