Python pythoncom 模块,IID_IPersistFile() 实例源码

我们从Python开源项目中,提取了以下26个代码示例,用于说明如何使用pythoncom.IID_IPersistFile()

项目:code    作者:ActiveState    | 项目源码 | 文件源码
def resolve_shortcut(filename):
    """resolve_shortcut("Notepad.lnk") => "C:\WINDOWS\system32\notepad.exe"

    Returns the path refered to by a windows shortcut (.lnk) file.
    """

    shell_link = pythoncom.CoCreateInstance(
        shell.CLSID_ShellLink, None,
        pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink)

    persistant_file = shell_link.QueryInterface(pythoncom.IID_IPersistFile)

    persistant_file.Load(filename)

    shell_link.Resolve(0, 0)
    linked_to_file = shell_link.GetPath(shell.SLGP_UNCPRIORITY)[0]
    return linked_to_file
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
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"
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
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"
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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"
项目:wahcade    作者:sairuk    | 项目源码 | 文件源码
def read_scexec(scfile):
    """ read shortcut and return executable path """
    if sys.platform != 'win32':
        return "Only available for windows platforms! returning"
    try:
        import pythoncom
        from win32com.shell import shell, shellcon
    except:
        return "pythoncom module not found! \n download from http://sourceforge.net/projects/pywin32/files/pywin32/"
    shortcut = pythoncom.CoCreateInstance (
      shell.CLSID_ShellLink,
      None,
      pythoncom.CLSCTX_INPROC_SERVER,
      shell.IID_IShellLink
    )
    shortcut.QueryInterface (pythoncom.IID_IPersistFile).Load (scfile, 0)
    cmd, _ = shortcut.GetPath (shell.SLGP_UNCPRIORITY)
    args = shortcut.GetArguments ()
    work_dir = shortcut.GetWorkingDirectory()    
    return "Executing " + cmd, cmd, args, work_dir, False, False
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def load( self, filename ):
        """Read a shortcut file from disk."""
        self._base.QueryInterface(pythoncom.IID_IPersistFile).Load(filename)
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def save( self, filename ):
        """Write the shortcut to disk.

        The file should be named something.lnk.
        """
        self._base.QueryInterface(pythoncom.IID_IPersistFile).Save(filename, 0)
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
def load( self, filename ):
        # Get an IPersist interface
        # which allows save/restore of object to/from files
        self._base.QueryInterface( pythoncom.IID_IPersistFile ).Load( filename )
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
def save( self, filename ):
        self._base.QueryInterface( pythoncom.IID_IPersistFile ).Save( filename, 0 )
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
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()
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
def load( self, filename ):
        # Get an IPersist interface
        # which allows save/restore of object to/from files
        self._base.QueryInterface( pythoncom.IID_IPersistFile ).Load( filename )
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
def save( self, filename ):
        self._base.QueryInterface( pythoncom.IID_IPersistFile ).Save( filename, 1 )
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def load( self, filename ):
        """Read a shortcut file from disk."""
        self._base.QueryInterface(pythoncom.IID_IPersistFile).Load(filename)
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def save( self, filename ):
        """Write the shortcut to disk.

        The file should be named something.lnk.
        """
        self._base.QueryInterface(pythoncom.IID_IPersistFile).Save(filename, 0)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def load( self, filename ):
        # Get an IPersist interface
        # which allows save/restore of object to/from files
        self._base.QueryInterface( pythoncom.IID_IPersistFile ).Load( filename )
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def save( self, filename ):
        self._base.QueryInterface( pythoncom.IID_IPersistFile ).Save( filename, 0 )
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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()
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def load( self, filename ):
        # Get an IPersist interface
        # which allows save/restore of object to/from files
        self._base.QueryInterface( pythoncom.IID_IPersistFile ).Load( filename )
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def save( self, filename ):
        self._base.QueryInterface( pythoncom.IID_IPersistFile ).Save( filename, 1 )
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def load( self, filename ):
        # Get an IPersist interface
        # which allows save/restore of object to/from files
        self._base.QueryInterface( pythoncom.IID_IPersistFile ).Load( filename )
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def save( self, filename ):
        self._base.QueryInterface( pythoncom.IID_IPersistFile ).Save( filename, 0 )
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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())
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def load( self, filename ):
        # Get an IPersist interface
        # which allows save/restore of object to/from files
        self._base.QueryInterface( pythoncom.IID_IPersistFile ).Load( filename )
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def save( self, filename ):
        self._base.QueryInterface( pythoncom.IID_IPersistFile ).Save( filename, 1 )
项目:zenchmarks    作者:squeaky-pl    | 项目源码 | 文件源码
def load( self, filename ):
        """Read a shortcut file from disk."""
        self._base.QueryInterface(pythoncom.IID_IPersistFile).Load(filename)
项目:zenchmarks    作者:squeaky-pl    | 项目源码 | 文件源码
def save( self, filename ):
        """Write the shortcut to disk.

        The file should be named something.lnk.
        """
        self._base.QueryInterface(pythoncom.IID_IPersistFile).Save(filename, 0)