[英]Python win32com.client Dispatch and Create Shorcut Methods
I want to ask few questions about win32com.client
. 我想问几个关于
win32com.client
问题。
What does DisPatch
do? DisPatch
做什么? It returns COMObject wscript.shell
. 它返回
COMObject wscript.shell
。 What exactly is this? 这到底是什么?
shell = win32com.client.Dispatch("wscript.shell")
And why do we use it while creating shortcut. 以及为什么我们在创建快捷方式时使用它。
shortcutcut = shell.CreateShortcut('shortcut.lnk')
win32com.client.Dispatch
creates a ActiveX/COM object. win32com.client.Dispatch
创建一个ActiveX / COM对象。 The argument is the so-called program ID. 参数是所谓的程序ID。 Another example of program ID is "Excel.Application" which would be used to create an instance of Excel.
程序ID的另一个示例是“ Excel.Application”,它将用于创建Excel实例。 In your case you are creating a
wscript.shell
object. 在您的情况下,您正在创建
wscript.shell
对象。
The program ID is mapped to a DLL on the system by the registry. 程序ID由注册表映射到系统上的DLL。 The object is instantiated through a number of well-known export methods.
通过许多众所周知的导出方法实例化该对象。
Apparently, one of the methods of a wscript.shell object is CreateShortcut. 显然,wscript.shell对象的方法之一是CreateShortcut。 Why you are using a wscript.shell to do this, I can't say.
我不能说为什么要使用wscript.shell来执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.