當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。