Using Python to add thumbnails to Explorer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • c d saunter

    Using Python to add thumbnails to Explorer

    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
  • Roger Upole

    #2
    Re: Using Python to add thumbnails to Explorer

    As you guessed, the icon locations are stored in the registry.
    There's a key under HKEY_CLASSES_RO OT 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.Fil e\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" <christopher.sa unter@durham.ac .uk> wrote in message news:djocih$msn $1@heffalump.du r.ac.uk...[color=blue]
    > 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[/color]




    ----== 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 =---

    Comment

    • c d saunter

      #3
      Re: Using Python to add thumbnails to Explorer

      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

      shellcc/platform/shell/programmersguid e/shell_int/shell_int_exten ding/
      extensionhandle rs/shell_ext.asp

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

      Thanks,
      Chris
      Roger Upole (rupole@hotmail .com) wrote:
      : As you guessed, the icon locations are stored in the registry.
      : There's a key under HKEY_CLASSES_RO OT 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.Fil e\DefaultIcon, you should have the
      : path to py.ico. You can use the _winreg module to create
      : your own entries.

      : hth
      : Roger




      Comment

      • Roger Upole

        #4
        Re: Using Python to add thumbnails to Explorer

        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" <christopher.sa unter@durham.ac .uk> wrote in message news:djoqn3$s0d $1@heffalump.du r.ac.uk...[color=blue]
        > 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/programmersguid e/shell_int/shell_int_exten ding/
        > extensionhandle rs/shell_ext.asp
        >
        > Not so simple, and not (directly) a job for Python.
        >
        > Thanks,
        > Chris
        > Roger Upole (rupole@hotmail .com) wrote:
        > : As you guessed, the icon locations are stored in the registry.
        > : There's a key under HKEY_CLASSES_RO OT 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.Fil e\DefaultIcon, you should have the
        > : path to py.ico. You can use the _winreg module to create
        > : your own entries.
        >
        > : hth
        > : Roger
        >
        >
        >
        >[/color]




        ----== 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 =---

        Comment

        • John J. Lee

          #5
          Re: Using Python to add thumbnails to Explorer

          "Roger Upole" <rupole@hotmail .com> writes:[color=blue]
          > "c d saunter" <christopher.sa unter@durham.ac .uk> wrote in message news:djoqn3$s0d $1@heffalump.du r.ac.uk...[/color]
          [...][color=blue][color=green]
          > > Turns out I need to use a .dll shell extension as per
          > > http://msdn.microsoft.com/library/de...library/en-us/
          > > shellcc/platform/shell/programmersguid e/shell_int/shell_int_exten ding/
          > > extensionhandle rs/shell_ext.asp
          > >
          > > Not so simple, and not (directly) a job for Python.[/color]
          >
          > 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.[/color]

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




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


          John

          Comment

          • c d saunter

            #6
            Re: Using Python to add thumbnails to Explorer

            John J. Lee (jjl@pobox.com) wrote:

            : "Roger Upole" <rupole@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

            Comment

            • Roger Upole

              #7
              Re: Using Python to add thumbnails to Explorer

              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" <christopher.sa unter@durham.ac .uk> wrote in message news:dkabqu$osi $1@heffalump.du r.ac.uk...[color=blue]
              > John J. Lee (jjl@pobox.com) wrote:
              >
              > : "Roger Upole" <rupole@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[/color]




              ----== 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 =---

              Comment

              Working...