Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #58771

Re: pywin32 programming error on Win7 with shell.SHGetDesktopFolder, desktop.BindToObject, desktop.GetDisplayNameOf

Date 2013-11-08 09:47 +0000
From Tim Golden <mail@timgolden.me.uk>
Subject Re: pywin32 programming error on Win7 with shell.SHGetDesktopFolder, desktop.BindToObject, desktop.GetDisplayNameOf
References <1b6591af-904c-4a95-8a7b-ee0c63af75db@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.2200.1383904073.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 08/11/2013 03:30, iMath wrote:
> 
> When running the following code on WinXP , all is fine ,
> --------------------------------------------------------------
> from win32com.shell import shell
> 
> def launch_file_explorer(path, files):
> 
>     folder_pidl = shell.SHILCreateFromPath(path,0)[0]
>     desktop = shell.SHGetDesktopFolder()
>     shell_folder = desktop.BindToObject(folder_pidl, None,shell.IID_IShellFolder)
>     name_to_item_mapping = dict([(desktop.GetDisplayNameOf(item, 0), item) for item in shell_folder])
>     to_show = []
>     for file in files:
>         if file not in name_to_item_mapping:
>             raise Exception('File: "{}" not found in "{}"'.format(file, path))
>         to_show.append(name_to_item_mapping[file])
>     shell.SHOpenFolderAndSelectItems(folder_pidl, to_show, 0)
> import os
> 
> 
> p=r'E:\aa'
> print(os.listdir(p))
> launch_file_explorer(p, os.listdir(p))


Did you mean to call .GetDisplayNameOf against the desktop folder? I
would have thought you wanted shell_folder.GetDisplayNameOf(item, 0).

TJG

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

pywin32 programming error on Win7 with shell.SHGetDesktopFolder,desktop.BindToObject,desktop.GetDisplayNameOf iMath <redstone-cold@163.com> - 2013-11-07 19:30 -0800
  Re: pywin32 programming error on Win7 with shell.SHGetDesktopFolder,  desktop.BindToObject, desktop.GetDisplayNameOf Tim Golden <mail@timgolden.me.uk> - 2013-11-08 09:47 +0000
    Re: pywin32 programming error on Win7 with shell.SHGetDesktopFolder,  desktop.BindToObject, desktop.GetDisplayNameOf iMath <redstone-cold@163.com> - 2013-11-08 07:28 -0800
    Re: pywin32 programming error on Win7 with shell.SHGetDesktopFolder,  desktop.BindToObject, desktop.GetDisplayNameOf iMath <redstone-cold@163.com> - 2013-11-08 07:28 -0800
  Re: pywin32 programming error on Win7 with shell.SHGetDesktopFolder,  desktop.BindToObject, desktop.GetDisplayNameOf MRAB <python@mrabarnett.plus.com> - 2013-11-08 17:51 +0000
    Re: pywin32 programming error on Win7 with shell.SHGetDesktopFolder,  desktop.BindToObject, desktop.GetDisplayNameOf iMath <redstone-cold@163.com> - 2013-11-09 21:23 -0800
  Re: pywin32 programming error on Win7 with shell.SHGetDesktopFolder,desktop.BindToObject,desktop.GetDisplayNameOf iMath <redstone-cold@163.com> - 2013-11-10 04:39 -0800
  Re: pywin32 programming error on Win7 with shell.SHGetDesktopFolder,desktop.BindToObject,desktop.GetDisplayNameOf iMath <redstone-cold@163.com> - 2013-11-10 04:39 -0800

csiph-web