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


Python shell.SHGetSpecialFolderPath方法代码示例

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


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

示例1: testShellLink

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderPath [as 别名]
def testShellLink(self):
        desktop = str(shell.SHGetSpecialFolderPath(0, CSIDL_DESKTOP))
        num = 0
        shellLink = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink)
        persistFile = shellLink.QueryInterface(pythoncom.IID_IPersistFile)
        names = [os.path.join(desktop, n) for n in os.listdir(desktop)]
        programs = str(shell.SHGetSpecialFolderPath(0, CSIDL_PROGRAMS))
        names.extend([os.path.join(programs, n) for n in os.listdir(programs)])
        for name in names:
            try:
                persistFile.Load(name,STGM_READ)
            except pythoncom.com_error:
                continue
            # Resolve is slow - avoid it for our tests.
            #shellLink.Resolve(0, shell.SLR_ANY_MATCH | shell.SLR_NO_UI)
            fname, findData = shellLink.GetPath(0)
            unc = shellLink.GetPath(shell.SLGP_UNCPRIORITY)[0]
            num += 1
        if num == 0:
            # This isn't a fatal error, but is unlikely.
            print "Could not find any links on your desktop or programs dir, which is unusual" 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:testShell.py

示例2: setup_environment

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderPath [as 别名]
def setup_environment():
    """Define any extra environment variables for use in CleanerML and Winapp2.ini"""
    csidl_to_environ('commonappdata', shellcon.CSIDL_COMMON_APPDATA)
    csidl_to_environ('documents', shellcon.CSIDL_PERSONAL)
    # Windows XP does not define localappdata, but Windows Vista and 7 do
    csidl_to_environ('localappdata', shellcon.CSIDL_LOCAL_APPDATA)
    csidl_to_environ('music', shellcon.CSIDL_MYMUSIC)
    csidl_to_environ('pictures', shellcon.CSIDL_MYPICTURES)
    csidl_to_environ('video', shellcon.CSIDL_MYVIDEO)
    # LocalLowAppData does not have a CSIDL for use with
    # SHGetSpecialFolderPath. Instead, it is identified using
    # SHGetKnownFolderPath in Windows Vista and later
    try:
        path = get_known_folder_path('LocalAppDataLow')
    except:
        logger().error('exception identifying LocalAppDataLow')
    else:
        set_environ('LocalAppDataLow', path) 
开发者ID:turingsec,项目名称:marsnake,代码行数:20,代码来源:windows.py

示例3: get_special_folder_path

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderPath [as 别名]
def get_special_folder_path(path_name):
    """Return special folder path"""
    from win32com.shell import shell, shellcon

    for maybe in """
       CSIDL_COMMON_STARTMENU CSIDL_STARTMENU CSIDL_COMMON_APPDATA
       CSIDL_LOCAL_APPDATA CSIDL_APPDATA CSIDL_COMMON_DESKTOPDIRECTORY
       CSIDL_DESKTOPDIRECTORY CSIDL_COMMON_STARTUP CSIDL_STARTUP
       CSIDL_COMMON_PROGRAMS CSIDL_PROGRAMS CSIDL_PROGRAM_FILES_COMMON
       CSIDL_PROGRAM_FILES CSIDL_FONTS""".split():
        if maybe == path_name:
            csidl = getattr(shellcon, maybe)
            return shell.SHGetSpecialFolderPath(
                0, csidl, False
            )
    raise ValueError(
        "%s is an unknown path ID" % (path_name,)
    ) 
开发者ID:winpython,项目名称:winpython,代码行数:20,代码来源:utils.py

示例4: get_special_folder_path

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderPath [as 别名]
def get_special_folder_path(path_name):
        try:
            import pythoncom
        except ImportError:
            print("pywin32 is required to run this script manually",
                  file=sys.stderr)
            sys.exit(1)
        from win32com.shell import shell, shellcon

        path_names = ['CSIDL_COMMON_STARTMENU', 'CSIDL_STARTMENU',
                      'CSIDL_COMMON_APPDATA', 'CSIDL_LOCAL_APPDATA',
                      'CSIDL_APPDATA', 'CSIDL_COMMON_DESKTOPDIRECTORY',
                      'CSIDL_DESKTOPDIRECTORY', 'CSIDL_COMMON_STARTUP',
                      'CSIDL_STARTUP', 'CSIDL_COMMON_PROGRAMS',
                      'CSIDL_PROGRAMS', 'CSIDL_PROGRAM_FILES_COMMON',
                      'CSIDL_PROGRAM_FILES', 'CSIDL_FONTS']
        for maybe in path_names:
            if maybe == path_name:
                csidl = getattr(shellcon, maybe)
                return shell.SHGetSpecialFolderPath(0, csidl, False)
        raise ValueError("%s is an unknown path ID" % (path_name,)) 
开发者ID:SanPen,项目名称:GridCal,代码行数:23,代码来源:windows_post_install.py

示例5: DumpFavorites

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderPath [as 别名]
def DumpFavorites():
	favfold = str(shell.SHGetSpecialFolderPath(0, shellcon.CSIDL_FAVORITES))
	print "Your favourites are at", favfold
	os.path.walk(favfold, FavDumper, None) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:dump_link.py

示例6: csidl_to_environ

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderPath [as 别名]
def csidl_to_environ(varname, csidl):
    """Define an environment variable from a CSIDL for use in CleanerML and Winapp2.ini"""
    try:
        sppath = shell.SHGetSpecialFolderPath(None, csidl)
    except:
        logger().error('exception when getting special folder path for %s', varname)
        return

    # there is exception handling in set_environ()
    set_environ(varname, sppath) 
开发者ID:turingsec,项目名称:marsnake,代码行数:12,代码来源:windows.py

示例7: get_home_dir

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderPath [as 别名]
def get_home_dir():
            return shell.SHGetSpecialFolderPath(0, 40) 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:4,代码来源:osutils.py

示例8: get_appstate_dir

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderPath [as 别名]
def get_appstate_dir():
            return shell.SHGetSpecialFolderPath(0, 26) 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:4,代码来源:osutils.py

示例9: get_picture_dir

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderPath [as 别名]
def get_picture_dir():
            return shell.SHGetSpecialFolderPath(0, 39) 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:4,代码来源:osutils.py

示例10: get_desktop_dir

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderPath [as 别名]
def get_desktop_dir():
            return shell.SHGetSpecialFolderPath(0, 16) 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:4,代码来源:osutils.py

示例11: getpath

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import SHGetSpecialFolderPath [as 别名]
def getpath(csidl):
    return shell.SHGetSpecialFolderPath(None, csidl, 0) 
开发者ID:euske,项目名称:pyrexecd,代码行数:4,代码来源:__init__.py


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