L
let_it_be
Unregistered / Unconfirmed
GUEST, unregistred user!
我将Word文件以流的形式读写 TBlodField,我下面的代码有错吗?
constructor TTemplet.createTmp(kind: String; Aowner: TComponent);
var
stream: TmemoryStream;
Field: TBlobField;
begin
inherited Create(self);
qry.SQL.Add('Select WordTemplet from WordTemplet where TempletName='+quotedstr(kind));
qry.Open;
Field:=TBlobField(qry.FieldByName('WordTemplet'));
if not Field.IsNull then
begin
oc.CreateObject('word.application',false);
stream:=TmemoryStream.Create;
try
Field.SaveToStream(stream);
oc.LoadFromStream(stream);
oc.DoVerb(1);
finally
stream.Free;
end;
end;
end;
还有,oc.CreateObject('word.application',false);是必须的吗?
CreateObject后,我发现Word还驻留在内存,我是动态建立的。
如果用 OC.CreateObjectFromFile('d:/saveAsDocument.doc',false);则不会有上面的问题;难道一定要转换为临时文件?
constructor TTemplet.createTmp(kind: String; Aowner: TComponent);
var
stream: TmemoryStream;
Field: TBlobField;
begin
inherited Create(self);
qry.SQL.Add('Select WordTemplet from WordTemplet where TempletName='+quotedstr(kind));
qry.Open;
Field:=TBlobField(qry.FieldByName('WordTemplet'));
if not Field.IsNull then
begin
oc.CreateObject('word.application',false);
stream:=TmemoryStream.Create;
try
Field.SaveToStream(stream);
oc.LoadFromStream(stream);
oc.DoVerb(1);
finally
stream.Free;
end;
end;
end;
还有,oc.CreateObject('word.application',false);是必须的吗?
CreateObject后,我发现Word还驻留在内存,我是动态建立的。
如果用 OC.CreateObjectFromFile('d:/saveAsDocument.doc',false);则不会有上面的问题;难道一定要转换为临时文件?