procedure TForm1.Button1Click(Sender: TObject);
var
MemSize: Integer;
Buffer: PChar;
MyFile: TFileStream;
Stream: TBlobStream;
begin
MyFile := TFileStream.Create('c:/temp.tmp', fmCreate);
with Query1 do
begin
Stream := TBlobStream.Create(FieldByName('Doc') as TBlobField, bmRead);
MemSize := Stream.Size;
Inc(MemSize);
{Make room for the buffer's null terminator.}
Buffer := AllocMem(MemSize);
{Allocate the memory.}
try
Stream.Read(Buffer^, MemSize);
MyFile.Write(Buffer^, MemSize);
finally
MyFile.Free;
Stream.Free;
end;
end;
if FileExists('c:/temp.DOC') then
DeleteFile('c:/temp.DOC');
if FileExists('c:/temp.tmp') then
begin
RenameFile('c:/temp.tmp', 'c:/temp.DOC');
Doc_ole.CreateObjectFromFile('c:/temp.DOC', False);
Doc_ole.Run;
end;
浠ヤ笂绋嬪簭涓轰粠鏁版嵁搴撲粠灏哤ORD鏂囨。鍙栧嚭锛屽苟鏀惧湪temp.doc鐨勪复鏃舵枃浠朵笂骞跺湪ToleContainer鏋勪欢涓?樉绀恒