Using Python to add thumbnails to Explorer

C

c d saunter

Greetings All,
In Widows Explorer there is a thumbnail view, where you see images as thumbnails.
Applications such as MS Office and OpenOffice, when installed, cause their respective filetypes
to be previewed as thumbnails as well.

Thumbnails are stored in the Thumbs.db hidden file.

There my knowledge ends. I'm asuming that aplications install registry keys somewhere that
register an invocation that returns a thumbnail for a given file bit this is just a guess.

What I'd like to do is write some Python script that can be invoked to add thumbnails for
certian file types (my own custom types and things like the .FITS array format.)

Googling isn't going anywhere so I am hoping there are some wizards out there with poiters...

Specifically any information on how the thumbnail system works would be great!

Cheers,
Chris
 
R

Roger Upole

As you guessed, the icon locations are stored in the registry.
There's a key under HKEY_CLASSES_ROOT for each
registered file type, with a default value holding the class name.
Under the class name, there's a DefaultIcon key that gives
the path to the icon. Using python files an an example, you
have HKCR\.py with Default=Python.File, and under
HKCR\Python.File\DefaultIcon, you should have the
path to py.ico. You can use the _winreg module to create
your own entries.

hth
Roger
 
C

c d saunter

Hi Roger,
Thanks for the info - I was actually interested in custom
per file thumbnails rather than icons, but your message sentt me
pouring through seemingly relevent parts of the registry - however
what I need isn't there.

Turns out I need to use a .dll shell extension as per
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
shellcc/platform/shell/programmersguide/shell_int/shell_int_extending/
extensionhandlers/shell_ext.asp

Not so simple, and not (directly) a job for Python.

Thanks,
Chris
Roger Upole ([email protected]) wrote:
: As you guessed, the icon locations are stored in the registry.
: There's a key under HKEY_CLASSES_ROOT for each
: registered file type, with a default value holding the class name.
: Under the class name, there's a DefaultIcon key that gives
: the path to the icon. Using python files an an example, you
: have HKCR\.py with Default=Python.File, and under
: HKCR\Python.File\DefaultIcon, you should have the
: path to py.ico. You can use the _winreg module to create
: your own entries.

: hth
: Roger
 
R

Roger Upole

Sorry, I didn't realize you meant per-file.
However, Pythoncom supports both the interfaces
(IExtractIcon and IPersistFile) specified on the page
you referenced, so you ought to be able to implement
an icon handler with the Pywin32 extensions.

Roger
 
J

John J. Lee

Roger Upole said:
Sorry, I didn't realize you meant per-file.
However, Pythoncom supports both the interfaces
(IExtractIcon and IPersistFile) specified on the page
you referenced, so you ought to be able to implement
an icon handler with the Pywin32 extensions.

Or, if not, then you can do it with module ctypes.

http://starship.python.net/crew/theller/ctypes/


There's an O'Reilly book called something like "win32 shell
programming" that covers this stuff.


John
 
C

c d saunter

John J. Lee ([email protected]) wrote:


: Or, if not, then you can do it with module ctypes.

: http://starship.python.net/crew/theller/ctypes/

: There's an O'Reilly book called something like "win32 shell
: programming" that covers this stuff.

: John

Roger & John - thanks for the info. Unless I'm wrong (a distinct
posibility) this isn't an option, as all though COM is used as the
interface, it is used to talk to *in process* code loaded from a DLL - so
Python can only be used if the interpreter is invoked from within a custom
shell extension .dll, which is probably not the best idea for various
reasons.

Thanks,
Chris
 
R

Roger Upole

Not sure how ctypes works, but with Pywin32
Pythoncom24.dll is actually registered as the
shell extension dll, and it passes calls to methods
of a Python class you create that implements the
interface methods.

Roger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top