By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,957 Members | 2,038 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,957 IT Pros & Developers. It's quick & easy.

Using Python to add thumbnails to Explorer

P: n/a
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
Oct 26 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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 d saunter" <ch*****************@durham.ac.uk> wrote in message news:dj**********@heffalump.dur.ac.uk...
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



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Oct 26 '05 #2

P: n/a
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/de...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 (ru****@hotmail.com) 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


Oct 26 '05 #3

P: n/a
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
"c d saunter" <ch*****************@durham.ac.uk> wrote in message news:dj**********@heffalump.dur.ac.uk...
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/de...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 (ru****@hotmail.com) 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



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Oct 27 '05 #4

P: n/a
"Roger Upole" <ru****@hotmail.com> writes:
"c d saunter" <ch*****************@durham.ac.uk> wrote in message news:dj**********@heffalump.dur.ac.uk...

[...]
Turns out I need to use a .dll shell extension as per
http://msdn.microsoft.com/library/de...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.


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

Oct 30 '05 #5

P: n/a
John J. Lee (jj*@pobox.com) wrote:

: "Roger Upole" <ru****@hotmail.com> writes:

: 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
Nov 2 '05 #6

P: n/a
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

"c d saunter" <ch*****************@durham.ac.uk> wrote in message news:dk**********@heffalump.dur.ac.uk...
John J. Lee (jj*@pobox.com) wrote:

: "Roger Upole" <ru****@hotmail.com> writes:

: 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



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Nov 2 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.