本文整理匯總了Python中pythoncom.IID_IPersistFile方法的典型用法代碼示例。如果您正苦於以下問題:Python pythoncom.IID_IPersistFile方法的具體用法?Python pythoncom.IID_IPersistFile怎麽用?Python pythoncom.IID_IPersistFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pythoncom
的用法示例。
在下文中一共展示了pythoncom.IID_IPersistFile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: CreateShortCut
# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import IID_IPersistFile [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
示例2: Get
# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import IID_IPersistFile [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
示例3: DumpLink
# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import IID_IPersistFile [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()
示例4: load
# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import IID_IPersistFile [as 別名]
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 )
示例5: save
# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import IID_IPersistFile [as 別名]
def save( self, filename ):
self._base.QueryInterface( pythoncom.IID_IPersistFile ).Save( filename, 1 )
示例6: save
# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import IID_IPersistFile [as 別名]
def save( self, filename ):
self._base.QueryInterface( pythoncom.IID_IPersistFile ).Save( filename, 0 )
示例7: load
# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import IID_IPersistFile [as 別名]
def load( self, filename ):
"""Read a shortcut file from disk."""
self._base.QueryInterface(pythoncom.IID_IPersistFile).Load(filename)
示例8: save
# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import IID_IPersistFile [as 別名]
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)
示例9: load
# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import IID_IPersistFile [as 別名]
def load(self, filename):
"""
Read a shortcut file from disk.
"""
self._base.QueryInterface(pythoncom.IID_IPersistFile).Load(
os.path.abspath(filename))
示例10: save
# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import IID_IPersistFile [as 別名]
def save(self, filename):
"""
Write the shortcut to disk.
The file should be named something.lnk.
"""
self._base.QueryInterface(pythoncom.IID_IPersistFile).Save(
os.path.abspath(filename), 0)
示例11: create_shortcut
# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import IID_IPersistFile [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.
# =============================================================================
示例12: __init__
# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import IID_IPersistFile [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)
示例13: Create
# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import IID_IPersistFile [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)
示例14: set_shortcut
# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import IID_IPersistFile [as 別名]
def set_shortcut():
startup_path = shell.SHGetPathFromIDList(shell.SHGetSpecialFolderLocation(0,shellcon.CSIDL_STARTUP))
shortcut = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, \
shell.IID_IShellLink)
shortcut.SetPath(os.getcwd()+'\\Email My PC Launcher.exe')
shortcut.SetWorkingDirectory(os.getcwd())
shortcut.SetIconLocation(os.getcwd()+'\\ui\\images\\Icon.ico',0)
shortcut.QueryInterface(pythoncom.IID_IPersistFile).Save(startup_path+'\\Emai My PC.lnk',0)
#刪除開機啟動快捷方式
示例15: create_shortcut
# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import IID_IPersistFile [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.