简体   繁体   中英

Python win32com.client Dispatch and Create Shorcut Methods

I want to ask few questions about win32com.client .

  1. What does DisPatch do? It returns COMObject wscript.shell . What exactly is this?

     shell = win32com.client.Dispatch("wscript.shell") 
  2. And why do we use it while creating shortcut.

     shortcutcut = shell.CreateShortcut('shortcut.lnk') 

win32com.client.Dispatch creates a ActiveX/COM object. The argument is the so-called program ID. Another example of program ID is "Excel.Application" which would be used to create an instance of Excel. In your case you are creating a wscript.shell object.

The program ID is mapped to a DLL on the system by the registry. The object is instantiated through a number of well-known export methods.

Apparently, one of the methods of a wscript.shell object is CreateShortcut. Why you are using a wscript.shell to do this, I can't say.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM