当前位置: 首页>>代码示例>>Python>>正文


Python shell.SHGetSpecialFolderLocation方法代码示例

本文整理汇总了Python中win32com.shell.shell.SHGetSpecialFolderLocation方法的典型用法代码示例。如果您正苦于以下问题:Python shell.SHGetSpecialFolderLocation方法的具体用法?Python shell.SHGetSpecialFolderLocation怎么用?Python shell.SHGetSpecialFolderLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32com.shell.shell的用法示例。


在下文中一共展示了shell.SHGetSpecialFolderLocation方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: gui_webui_save_download

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderLocation [as 别名]
def gui_webui_save_download(self, d2save, path):
        try:
            if sys.platform == 'win32':
                from win32com.shell import shell
                pidl = shell.SHGetSpecialFolderLocation(0, 5)
                defaultpath = shell.SHGetPathFromIDList(pidl)
            else:
                defaultpath = os.path.expandvars('$HOME')
        except:
            defaultpath = ''

        filename = 'test.mkv'
        if globalConfig.get_mode() == 'client_wx':
            import wx
            dlg = wx.FileDialog(None, message='Save file', defaultDir=defaultpath, defaultFile=filename, wildcard='All files (*.*)|*.*', style=wx.SAVE)
            dlg.Raise()
            result = dlg.ShowModal()
            dlg.Destroy()
            if result == wx.ID_OK:
                path = dlg.GetPath()
                d2save.save_content(path) 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:23,代码来源:BackgroundProcess.py

示例2: win32_appdata

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderLocation [as 别名]
def win32_appdata():
    # try to use win32 api to get the AppData folder since python doesn't populate os.environ with unicode strings.

    try:
        import win32com.client

        objShell = win32com.client.Dispatch("WScript.Shell")
        return objShell.SpecialFolders("AppData")
    except Exception, e:
        print "Error while getting AppData folder using WScript.Shell.SpecialFolders: {0!r}".format(e)
        try:
            from win32com.shell import shell, shellcon

            return shell.SHGetPathFromIDListEx(
                shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_APPDATA)
            )
        except Exception, e:
            print "Error while getting AppData folder using SHGetSpecialFolderLocation: {0!r}".format(e)

            return os.environ['APPDATA'].decode(sys.getfilesystemencoding()) 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:22,代码来源:directories.py

示例3: json_recycle_bin

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderLocation [as 别名]
def json_recycle_bin(self):
        if self.destination == 'local':
            with open(self.output_dir + self.computer_name + '_recycle_bin' + self.rand_ext, 'wb') as output:
                json_writer = get_json_writer(output)
                header = ["COMPUTER_NAME", "TYPE", "NAME_1", "NAME_2"]
                idl = shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_BITBUCKET)
                desktop = shell.SHGetDesktopFolder()
                files = desktop.BindToObject(idl, None, shell.IID_IShellFolder)

                for bin_file in files:
                    write_to_json(header,
                                  [self.computer_name, 'recycle_bin',
                                   files.GetDisplayNameOf(bin_file, shellcon.SHGDN_NORMAL),
                                   files.GetDisplayNameOf(bin_file, shellcon.SHGDN_FORPARSING)], json_writer)
                close_json_writer(json_writer)
        record_sha256_logs(self.output_dir + self.computer_name + '_recycle_bin' + self.rand_ext,
                           self.output_dir + self.computer_name + '_sha256.log') 
开发者ID:SekoiaLab,项目名称:Fastir_Collector,代码行数:19,代码来源:fs.py

示例4: win32_appdata

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderLocation [as 别名]
def win32_appdata():
    # try to use win32 api to get the AppData folder since python doesn't populate os.environ with unicode strings.

    try:
        import win32com.client

        objShell = win32com.client.Dispatch("WScript.Shell")
        return objShell.SpecialFolders("AppData")
    except Exception as e:
        print "Error while getting AppData folder using WScript.Shell.SpecialFolders: {0!r}".format(e)
        try:
            from win32com.shell import shell, shellcon

            return shell.SHGetPathFromIDListEx(
                shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_APPDATA)
            )
        except Exception as e:
            print "Error while getting AppData folder using SHGetSpecialFolderLocation: {0!r}".format(e)

            return os.environ['APPDATA'].decode(sys.getfilesystemencoding()) 
开发者ID:Podshot,项目名称:MCEdit-Unified,代码行数:22,代码来源:directories.py

示例5: ExplorePIDL

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderLocation [as 别名]
def ExplorePIDL():
    pidl = shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_DESKTOP)
    print "The desktop is at", shell.SHGetPathFromIDList(pidl)
    shell.ShellExecuteEx(fMask=shellcon.SEE_MASK_NOCLOSEPROCESS,
                         nShow=win32con.SW_NORMAL,
                         lpClass="folder", 
                         lpVerb="explore", 
                         lpIDList=pidl)
    print "Done!" 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:shellexecuteex.py

示例6: test_idlist_roundtrip

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderLocation [as 别名]
def test_idlist_roundtrip(self):
        pidl = shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_DESKTOP)
        item = shell.SHCreateItemFromIDList(pidl, shell.IID_IShellItem)
        pidl_back = shell.SHGetIDListFromObject(item)
        self.assertEqual(pidl, pidl_back) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:testShellItem.py

示例7: test_parsing_relative

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderLocation [as 别名]
def test_parsing_relative(self):
        desktop_pidl = shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_DESKTOP)
        desktop_item = shell.SHCreateItemFromIDList(desktop_pidl, shell.IID_IShellItem)

        sf = shell.SHGetDesktopFolder()
        flags = shellcon.SHCONTF_FOLDERS | shellcon.SHCONTF_NONFOLDERS
        children = sf.EnumObjects(0, flags)
        child_pidl = children.next()
        name_flags = shellcon.SHGDN_FORPARSING | shellcon.SHGDN_INFOLDER
        name = sf.GetDisplayNameOf(child_pidl, name_flags)

        item = shell.SHCreateItemFromRelativeName(desktop_item,  name, None,
                                                  shell.IID_IShellItem)
        # test the name we get from the item is the same as from the folder.
        self.assertEqual(name, item.GetDisplayName(name_flags)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:testShellItem.py

示例8: test_create_item_with_parent

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderLocation [as 别名]
def test_create_item_with_parent(self):
        desktop_pidl = shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_DESKTOP)
        desktop_item = shell.SHCreateItemFromIDList(desktop_pidl, shell.IID_IShellItem)

        sf = shell.SHGetDesktopFolder()
        flags = shellcon.SHCONTF_FOLDERS | shellcon.SHCONTF_NONFOLDERS
        children = sf.EnumObjects(0, flags)
        child_pidl = children.next()
        item1 = shell.SHCreateItemWithParent(desktop_pidl, None, child_pidl, shell.IID_IShellItem)
        item2 = shell.SHCreateItemWithParent(None, sf, child_pidl, shell.IID_IShellItem)
        self.assertShellItemsEqual(item1, item2) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:testShellItem.py

示例9: get_recycle_bin

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderLocation [as 别名]
def get_recycle_bin():
    """Yield a list of files in the recycle bin"""
    pidl = shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_BITBUCKET)
    desktop = shell.SHGetDesktopFolder()
    h = desktop.BindToObject(pidl, None, shell.IID_IShellFolder)
    for item in h:
        path = h.GetDisplayNameOf(item, shellcon.SHGDN_FORPARSING)
        if os.path.isdir(path):
            for child in file_op.children_in_directory(path, True):
                yield child
            yield path
        else:
            yield path 
开发者ID:turingsec,项目名称:marsnake,代码行数:15,代码来源:windows.py

示例10: csv_recycle_bin

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderLocation [as 别名]
def csv_recycle_bin(self):
        """Exports the filenames contained in the recycle bin"""
        with open(self.output_dir + self.computer_name + '_recycle_bin' + self.rand_ext, 'wb') as output:
            csv_writer = get_csv_writer(output)
            write_to_csv(("COMPUTER_NAME", "TYPE", "NAME_1", "NAME_2"), csv_writer)
            idl = shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_BITBUCKET)
            desktop = shell.SHGetDesktopFolder()
            files = desktop.BindToObject(idl, None, shell.IID_IShellFolder)

            for bin_file in files:
                write_to_csv(
                    [self.computer_name, 'recycle_bin', files.GetDisplayNameOf(bin_file, shellcon.SHGDN_NORMAL),
                     files.GetDisplayNameOf(bin_file, shellcon.SHGDN_FORPARSING)], csv_writer)
        record_sha256_logs(self.output_dir + self.computer_name + '_recycle_bin' + self.rand_ext,
                           self.output_dir + self.computer_name + '_sha256.log') 
开发者ID:SekoiaLab,项目名称:Fastir_Collector,代码行数:17,代码来源:fs.py


注:本文中的win32com.shell.shell.SHGetSpecialFolderLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。