给你代码:
var
memsize:integer;
buffer
char;
myfile:tfilestream;
stream:tblobstream;
filename:string;
begin
if opendialog1.Execute then
begin
filename:=opendialog1.FileName;
myfile:=tfilestream.Create(filename,fmopenread);
with table1 do
begin
open;
edit;
stream:=tblobstream.Create(fieldbyname('doc') as tblobfield,bmwrite);
memsize:=myfile.Size;
inc(memsize);
buffer:=allocmem(memsize);
try
stream.Seek(0,sofrombeginning);
myfile.Read(buffer^,memsize);
stream.Write(buffer^,memsize);
fieldbyname('name').AsString:=extractfilename(filename);
fieldbyname('size').AsInteger:=memsize-1;
finally
myfile.Free;
stream.Free;
end;
try
table1.Post;
except
showmessage('dddd');
halt;
end;
showmessage('ok');
ole1.CreateObjectFromFile(filename,false);
ole1.Run;
end;
end;
end;