gpt4 book ai didi

python - win32com.client.Dispatch 类标签

转载 作者:可可西里 更新时间:2023-11-01 11:15:49 25 4
gpt4 key购买 nike

我正在尝试使用 python 连接到 COM 对象。

更具体地说,我正在使用 ASCOM 标准驱动程序连接到 MaxDome II,但不知道如何引用该驱动程序。

在此link作者使用“Celestron.Telescope”作为 win32com.client.Dispatch 实例化的参数。

我的问题是如何找到这个字符串。我知道这与安装在计算机上的已安装驱动程序有关,但我不知道如何找到具体的字符串。有没有办法使用 win32com.client 列出 COM 对象?

顺便说一句,在 64 位 Windows 7 专业版上运行。

谢谢

最佳答案

我认为不可能直接从 python 获取 COM 对象列表,但是您可以在 Powershell 中运行以下代码(实际上是从 python 内部运行):

Get-ChildItem HKLM:\Software\Classes -ErrorAction SilentlyContinue | Where-Object {
$_.PSChildName -match '^\w+\.\w+$' -and (Test-Path -Path "$($_.PSPath)\CLSID")
} | Select-Object -ExpandProperty PSChildName

这将输出系统中所有有效 COM 对象名称的列表,按字母顺序排序,语法通常为 MainProgram.SubFunction。

我机器上的一些输出:

Snippet of command output in Powershell

希望对您有所帮助!

关于python - win32com.client.Dispatch 类标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47602800/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com