當前位置: 首頁>>代碼示例>>Python>>正文


Python shell.IID_IShellLink方法代碼示例

本文整理匯總了Python中win32com.shell.shell.IID_IShellLink方法的典型用法代碼示例。如果您正苦於以下問題:Python shell.IID_IShellLink方法的具體用法?Python shell.IID_IShellLink怎麽用?Python shell.IID_IShellLink使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在win32com.shell.shell的用法示例。


在下文中一共展示了shell.IID_IShellLink方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testShellLink

# 需要導入模塊: from win32com.shell import shell [as 別名]
# 或者: from win32com.shell.shell import IID_IShellLink [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: __init__

# 需要導入模塊: from win32com.shell import shell [as 別名]
# 或者: from win32com.shell.shell import IID_IShellLink [as 別名]
def __init__(self, 
                 path=None,
                 arguments=None, 
                 description=None,
                 workingdir=None,
                 iconpath=None,
                 iconidx=0):
        self._base = pythoncom.CoCreateInstance(
            shell.CLSID_ShellLink, None,
            pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink
        )
        data = map(None, 
                   ['"%s"' % os.path.abspath(path), arguments, description,
                    os.path.abspath(workingdir), os.path.abspath(iconpath)], 
                   ("SetPath", "SetArguments", "SetDescription",
                   "SetWorkingDirectory") )
        for value, function in data:
            if value and function:
                # call function on each non-null value
                getattr(self, function)(value)
        if iconpath:
            self.SetIconLocation(iconpath, iconidx) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:24,代碼來源:shortcut.py

示例3: CreateShortCut

# 需要導入模塊: from win32com.shell import shell [as 別名]
# 或者: from win32com.shell.shell import IID_IShellLink [as 別名]
def CreateShortCut(Path, Target,Arguments = "", StartIn = "", Icon = ("",0), Description = ""):
    # Get the shell interface.
    sh = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, \
        pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink)

    # Get an IPersist interface
    persist = sh.QueryInterface(pythoncom.IID_IPersistFile)

    # Set the data
    sh.SetPath(Target)
    sh.SetDescription(Description)
    sh.SetArguments(Arguments)
    sh.SetWorkingDirectory(StartIn)
    sh.SetIconLocation(Icon[0],Icon[1])
#    sh.SetShowCmd( win32con.SW_SHOWMINIMIZED)

    # Save the link itself.
    persist.Save(Path, 1)
    print "Saved to", Path 
開發者ID:Lithium876,項目名稱:ConTroll_Remote_Access_Trojan,代碼行數:21,代碼來源:testcomext.py

示例4: Get

# 需要導入模塊: from win32com.shell import shell [as 別名]
# 或者: from win32com.shell.shell import IID_IShellLink [as 別名]
def Get(cls, filename):
        sh = pythoncom.CoCreateInstance(
            shell.CLSID_ShellLink,
            None,
            pythoncom.CLSCTX_INPROC_SERVER,
            shell.IID_IShellLink
        )
        persist = sh.QueryInterface(pythoncom.IID_IPersistFile).Load(filename)  # NOQA
        self = cls()
        self.path = filename
        self.target = sh.GetPath(shell.SLGP_SHORTPATH)[0]
        self.description = sh.GetDescription()
        self.arguments = sh.GetArguments()
        self.startIn = sh.GetWorkingDirectory()
        self.icons = sh.GetIconLocation()
        return self 
開發者ID:EventGhost,項目名稱:EventGhost,代碼行數:18,代碼來源:Shortcut.py

示例5: DumpLink

# 需要導入模塊: from win32com.shell import shell [as 別名]
# 或者: from win32com.shell.shell import IID_IShellLink [as 別名]
def DumpLink(fname):
	shellLink = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink)
	persistFile = shellLink.QueryInterface(pythoncom.IID_IPersistFile)
	persistFile.Load(fname,STGM_READ)
	shellLink.Resolve(0, shell.SLR_ANY_MATCH | shell.SLR_NO_UI)
	fname, findData = shellLink.GetPath(0)
	print "Filename:", fname, ", UNC=", shellLink.GetPath(shell.SLGP_UNCPRIORITY)[0]
	print "Description:", shellLink.GetDescription()
	print "Working Directory:", shellLink.GetWorkingDirectory()
	print "Icon:", shellLink.GetIconLocation() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:12,代碼來源:dump_link.py

示例6: __init__

# 需要導入模塊: from win32com.shell import shell [as 別名]
# 或者: from win32com.shell.shell import IID_IShellLink [as 別名]
def __init__( self ):
		self._base = pythoncom.CoCreateInstance(
			shell.CLSID_ShellLink, None,
			pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink
		) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:create_link.py

示例7: __init__

# 需要導入模塊: from win32com.shell import shell [as 別名]
# 或者: from win32com.shell.shell import IID_IShellLink [as 別名]
def __init__(self,
                 path=None,
                 arguments=None,
                 description=None,
                 workingdir=None,
                 iconpath=None,
                 iconidx=0):
        """
        @param path: Location of the target
        @param arguments: If path points to an executable, optional arguments
                      to pass
        @param description: Human-readable description of target
        @param workingdir: Directory from which target is launched
        @param iconpath: Filename that contains an icon for the shortcut
        @param iconidx: If iconpath is set, optional index of the icon desired
        """
        self._base = pythoncom.CoCreateInstance(
            shell.CLSID_ShellLink, None,
            pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink
        )
        if path is not None:
            self.SetPath(os.path.abspath(path))
        if arguments is not None:
            self.SetArguments(arguments)
        if description is not None:
            self.SetDescription(description)
        if workingdir is not None:
            self.SetWorkingDirectory(os.path.abspath(workingdir))
        if iconpath is not None:
            self.SetIconLocation(os.path.abspath(iconpath), iconidx) 
開發者ID:wistbean,項目名稱:learn_python3_spider,代碼行數:32,代碼來源:shortcut.py

示例8: create_shortcut

# 需要導入模塊: from win32com.shell import shell [as 別名]
# 或者: from win32com.shell.shell import IID_IShellLink [as 別名]
def create_shortcut(
    path,
    description,
    filename,
    arguments="",
    workdir="",
    iconpath="",
    iconindex=0,
):
    """Create Windows shortcut (.lnk file)"""
    import pythoncom
    from win32com.shell import shell

    ilink = pythoncom.CoCreateInstance(
        shell.CLSID_ShellLink,
        None,
        pythoncom.CLSCTX_INPROC_SERVER,
        shell.IID_IShellLink,
    )
    ilink.SetPath(path)
    ilink.SetDescription(description)
    if arguments:
        ilink.SetArguments(arguments)
    if workdir:
        ilink.SetWorkingDirectory(workdir)
    if iconpath or iconindex:
        ilink.SetIconLocation(iconpath, iconindex)
    # now save it.
    ipf = ilink.QueryInterface(pythoncom.IID_IPersistFile)
    if not filename.endswith('.lnk'):
        filename += '.lnk'
    ipf.Save(filename, 0)


# =============================================================================
# Misc.
# ============================================================================= 
開發者ID:winpython,項目名稱:winpython,代碼行數:39,代碼來源:utils.py

示例9: __init__

# 需要導入模塊: from win32com.shell import shell [as 別名]
# 或者: from win32com.shell.shell import IID_IShellLink [as 別名]
def __init__(self, lnkname):
        self.shortcut = pythoncom.CoCreateInstance(
            shell.CLSID_ShellLink, None,
            pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink)
        self.shortcut.QueryInterface(pythoncom.IID_IPersistFile).Load(lnkname) 
開發者ID:ActiveState,項目名稱:code,代碼行數:7,代碼來源:recipe-576437.py

示例10: Create

# 需要導入模塊: from win32com.shell import shell [as 別名]
# 或者: from win32com.shell.shell import IID_IShellLink [as 別名]
def Create(
        cls,
        path,
        target,
        arguments="",
        startIn="",
        icon=("", 0),
        description=""
    ):
        """Create a Windows shortcut:

        path - As what file should the shortcut be created?
        target - What command should the desktop use?
        arguments - What arguments should be supplied to the command?
        startIn - What folder should the command start in?
        icon - (filename, index) What icon should be used for the shortcut?
        description - What description should the shortcut be given?

        eg
        Shortcut.Create(
            path=os.path.join (desktop (), "PythonI.lnk"),
            target=r"c:\python\python.exe",
            icon=(r"c:\python\python.exe", 0),
            description="Python Interpreter"
        )
        """
        sh = pythoncom.CoCreateInstance(
            shell.CLSID_ShellLink,
            None,
            pythoncom.CLSCTX_INPROC_SERVER,
            shell.IID_IShellLink
        )
        sh.SetPath(target)
        sh.SetDescription(description)
        sh.SetArguments(arguments)
        sh.SetWorkingDirectory(startIn)
        sh.SetIconLocation(icon[0], icon[1])
        persist = sh.QueryInterface(pythoncom.IID_IPersistFile)
        persist.Save(path, 1) 
開發者ID:EventGhost,項目名稱:EventGhost,代碼行數:41,代碼來源:Shortcut.py

示例11: create_shortcut

# 需要導入模塊: from win32com.shell import shell [as 別名]
# 或者: from win32com.shell.shell import IID_IShellLink [as 別名]
def create_shortcut(path, description, filename,
                        arguments="", workdir="", iconpath="", iconindex=0):
        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  # analysis:ignore

        ilink = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None,
                                           pythoncom.CLSCTX_INPROC_SERVER,
                                           shell.IID_IShellLink)
        ilink.SetPath(path)
        ilink.SetDescription(description)
        if arguments:
            ilink.SetArguments(arguments)
        if workdir:
            ilink.SetWorkingDirectory(workdir)
        if iconpath or iconindex:
            ilink.SetIconLocation(iconpath, iconindex)
        # now save it.
        ipf = ilink.QueryInterface(pythoncom.IID_IPersistFile)
        ipf.Save(filename, 0)

    # Support the same list of "path names" as bdist_wininst. 
開發者ID:SanPen,項目名稱:GridCal,代碼行數:28,代碼來源:windows_post_install.py

示例12: set_shortcut

# 需要導入模塊: from win32com.shell import shell [as 別名]
# 或者: from win32com.shell.shell import IID_IShellLink [as 別名]
def set_shortcut(filename,lnkname,iconname):
    shortcut = pythoncom.CoCreateInstance(
    shell.CLSID_ShellLink, None,
    pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink)
    shortcut.SetPath(filename)
    shortcut.SetIconLocation(iconname,0)
    if os.path.splitext(lnkname)[-1] != '.lnk':
        lnkname += ".lnk"
    shortcut.QueryInterface(pythoncom.IID_IPersistFile).Save(lnkname,0)
    
#如果是遠程監聽某個電腦,可以將獲取到的信息通過郵件發出去 
開發者ID:Jackeriss,項目名稱:keyboard_recording_trojan,代碼行數:13,代碼來源:keyboard_recording_trojan.py


注:本文中的win32com.shell.shell.IID_IShellLink方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。