The question was made in stackoverflow.com (http://stackoverflow.com/questions/39252681/show-blob-content-into-olecontainer-delphi)
May be here with Delphians ... can solve....
In a table a BLOB column save multimedia data as spreadsheets, images, videos, music, docs., etc.,
My application wants show or reproduce contents:
Whe call the LoadFromStream method of OleContainer control raises Invalid stream format message.
Well... then put next code:
procedure TOleContainer.LoadAsDocument(const Stream: TStream); var DataHandle: HGLOBAL; Buffer: Pointer; begin DataHandle := GlobalAlloc(GMEM_MOVEABLE, Stream.Size); if DataHandle = 0 then OutOfMemoryError; try Buffer := GlobalLock(DataHandle); try Stream.Read(Buffer^, Stream.Size); finally GlobalUnlock(DataHandle); end; OleCheck(CreateILockBytesOnHGlobal(DataHandle, True, FLockBytes)); DataHandle := 0; OleCheck(StgOpenStorageOnILockBytes(FLockBytes, nil, STGM_READWRITE or STGM_SHARE_EXCLUSIVE, nil, 0, FStorage)); // <-------- HERE CRASHES OleCheck(OleLoad(FStorage, IOleObject, self, FOleObject)); FDrawAspect := DVASPECT_CONTENT; InitObject; FOleObject.SetExtent(DVASPECT_CONTENT, PixelsToHimetric(Point(ClientWidth, ClientHeight))); SetDrawAspect(False, 0); UpdateView; except if DataHandle <> 0 then GlobalFree(DataHandle); DestroyObject; raise; end; end;
When calling LoadAsDocument(Stream) raises "%1 already exists"
And Cann´t see the blob content.
How must do it?