欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

在程序中壓縮sql server2000的數(shù)據(jù)庫備份文件的代碼

 更新時(shí)間:2007年03月18日 00:00:00   作者:  
怎樣壓縮sql server2000的數(shù)據(jù)庫備份文件,像rar一樣?小弟有一7m的sql server2000
數(shù)據(jù)庫備份文件,在程序中怎樣壓縮啊?
復(fù)制代碼 代碼如下:

procedure TForm1.Button2Click(Sender: TObject); 
var 
  SHExecInfo: SHELLEXECUTEINFO; 
begin 
 SHExecInfo.cbSize := sizeof(SHELLEXECUTEINFO); 
  SHExecInfo.fMask := SEE_MASK_NOCLOSEPROCESS; 
  SHExecInfo.Wnd := Handle; 
  SHExecInfo.lpVerb := nil; 
  SHExecInfo.lpFile := 'WinRAR.exe'; 
  SHExecInfo.lpParameters := 'a e:\qwqw.rar e:\qwqw'; 
  SHExecInfo.lpDirectory := nil; 
  SHExecInfo.nShow := SW_SHOW; 
  SHExecInfo.hInstApp := Handle; 
  ShellExecuteEx(@SHExecInfo); 
  WaitForSingleObject(SHExecInfo.hProcess, INFINITE); 
  CloseHandle(SHExecInfo.hProcess); 
  ShellExecute(application.MainForm.Handle,'open','winrar.exe',PChar('a e:\zqzq.rar e:\zqzq'),'',SW_show); 
ShowMessage('壓縮完畢!'); }   

這是一段壓縮圖片的代碼,壓縮文件原理相同,只需稍做改動(dòng)即可。
復(fù)制代碼 代碼如下:

var 
  mss: TMemoryStream; 
  zip: TDeCompressionStream; 
  zip1: TCompressionStream; 
  fs : TFileStream; 
  fBuf: Array[0..16383] of Byte; 
  flen: Integer; 
  //從數(shù)據(jù)庫中取出圖片 
  //...寫出SQL語句以取得有圖片的記錄,此處從略 
  mss := TMemoryStream.Create; 
  fs := TFileStream.Create('filename.jpg',fmCreate or fmOpenWrite); 
  try 
    TBlobField(Que.FieldByName('pic')).SaveToStream(mss); 
    zip := TDeCompressionStream.Create(fs); 
    try 
      flen := zip.Read(fbuf, SizeOf(fBuf)); 
      while flen > 0 do begin 
        fs.Write(fbuf, flen); 
        flen := zip.Read(fbuf, SizeOf(fBuf)); 
      end; 
    finally 
      FreeAndNil(zip); 
    end; 
  finally 
    mss.Free; 
    fs.Free; 
  end; 
  //將文件filename.jpg中的圖片保存到數(shù)據(jù)庫 
  //...寫出SQL語句,打開Que,并定位到要保存圖片的記錄,此處從略 
  fs := TFileStream.Create('filename.jpg',fmOpenRead); 
  mss := TMemoryStream.Create; 
  try 
    zip1 := TCompressionStream.Create(clDefault,mss); 
    try 
      flen := fs.Read(fbuf, SizeOf(fBuf)); 
      while flen > 0 do begin 
        zip1.Write(fbuf, flen); 
        flen := fs.Read(fbuf, SizeOf(fBuf)); 
      end; 
      //保存到數(shù)據(jù)庫 
     TBlobField(Que.FieldByName('pic')).LoadFromStream(mss); 
      Que.UpdateBatch(); 
      //... 
    finally 
      zip1.Free; 
    end; 
  finally 
    fs.Free; 
    mss.Free; 
  end;   

相關(guān)文章

最新評(píng)論