var
I: Integer;
lFileName: string;
lOle: TOleContainer;
lStream: TMemoryStream;
begin
if OpenDialogAccessorie.Execute then
begin
lFileName := OpenDialogAccessorie.FileName;
I := Pos('\',lFileName);
while I<>0 do
begin
lFileName := Copy(lFileName,I+1,Length(lFileName)-I+1);
I := Pos('\',lFileName);
end;
lOle := TOleContainer.Create(self);
try
lOle.Parent := Self;
lOle.CreateObjectFromFile(OpenDialogAccessorie.FileName, False);
try
lStream := TMemoryStream.Create;
lOle.SaveToStream(lStream);
with DataSetBrokerAccessorie.DataSet do
begin
Append;
TBlobField(FieldByName('Accessories')).LoadFromStream(lStream);
FieldByName('Number').AsInteger := RecordCount + 1;
FieldByName('Name').AsString := lFileName;
Post;
ApplyUpdates;
end;
finally
lStream.Free;
end;
finally
lOle.free;
end;
end;
结贴吧 |