StreamToPBlob

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
ikra
Üye
Mesajlar: 901
Kayıt: 28 Nis 2005 01:26
Konum: Simdilik Topragin Üstü

StreamToPBlob

Mesaj gönderen ikra »

selamu aleyküm...

asagida belirttigim kod ters calistirdigimda Blob dan stream a yaziyor fakat oldugu sekilde calistirdigimda, stream dan PBlob a yazmiyor. epey bi ugrastim. Internetten örnek kodlar buldum. örnekler hep ayni fakat sonuc sifir.

gözden kacirdigim bir nokta var mi? bir göz atabilir misiniz!

Kod: Tümünü seç

function StreamToPBlob(AStream: TStream; Blob: PBlob): PBlob;
  Var
    bytes_read, bufsize :Ushort;
    total_bytes_write :Long;
    buff :Pointer;
begin
  Result := Blob;
  
  if (not Assigned(Blob)) or (not Assigned(Blob^.BlobHandle)) then
    Exit;

  with Blob^ do begin
    bufsize := $8192;
    total_bytes_write := 0;
    bytes_read := 0;
    
    GetMem(buff,bufsize);

    try
      repeat
        try
          bytes_read := AStream.Read(buff^, bufsize);
        except
          on E:EINOutError do begin
            Exit;
          end
        end;
        
        PutSegment(BlobHandle, buff, bytes_read);
        Inc(total_bytes_write, bytes_read);
      until AStream.Size = total_bytes_write;
    finally
      FreeMem(buff);
    end;
  end;
end;
kıdemsiz üye
Cevapla