5

I am developing a Delphi documents management application, so somehow I am giving the user some functionality similar to windows explorer.

I would like to know if there is a way to get the preview used by windows explorer. For example windows explorer creates a small thumbnail for a pdf document for example, and displays it when the user chooses to view "big icons". Is there a way to retrieve that preview?

MyTImage := GiveMePreviewForFile('C:\Test\File.pdf');
UnDiUdin
  • 14,924
  • 39
  • 151
  • 249

2 Answers2

9

@user193655, using the IExtractImage interface is the way to go, this interface exposes methods that request a thumbnail image from a Shell folder

you can find a very complete sample in this site and the source code is here.

check this image

alt text

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • 5
    At the moment, the source code can still be downloaded from archive.org: https://web.archive.org/web/20060115070800/http://www.delphi3000.com/article/3806/IExtractImageDemo.zip – Marcus Adams Dec 03 '13 at 13:53
  • Note that the code above from Hans Gulo works, but is very slow, taking around 500 to 1000 ms :-( The slowness occurs when calling the Extract function on line 24 of ShObjIdlQuot.pas. – CaptureWiz Nov 02 '22 at 11:36
  • Both Hans and Microsoft mention that you can call Kill to abort the process, but it's not clear how to do that or whether you still get a result. – CaptureWiz Nov 02 '22 at 11:46
  • To use Hans Gulo's code in a thread, you must first initialize the COM engine by calling CoInitialize(), then free it by calling CoUninitialize(); – CaptureWiz Nov 15 '22 at 01:41
2

Take a look at the docs for IExtractImage. Basically you use IShellFolder with IExtractImage to get the picture you are looking for.

Keith Giddings
  • 251
  • 1
  • 3