COM“获取属性”;有多个参数 [英] COM "get property" with multiple arguments

查看:87
本文介绍了COM“获取属性”;有多个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试致电 WindowsInstaller。

I'm trying to call WindowsInstaller.Installer.ProductsEx from python, and can't figure out how to make it work.

这是我想从python调用的vbscript版本:

Here's a vbscript version of what I want to call from python:

dim msi, products
set msi = CreateObject("WindowsInstaller.Installer")
set products = msi.ProductsEx("", "s-1-1-0", 7)

我认为我的问题是 ProductsEx 是一个带有3个参数的只读get属性,我不知道如何说服 win32com comtypes 这样称呼。

I think my issue is ProductsEx is a read-only get property that takes 3 arguments, and I don't know how to convince win32com or comtypes to call it that way.

我尝试过:

>>> import win32com.client
>>> msi = win32com.client.Dispatch('WindowsInstaller.Installer')
>>> products = msi.ProductsEx('', 's-1-1-0', 7)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<COMObject WindowsInstaller.Installer>", line 2, in ProductsEx
pywintypes.com_error: (-2147352573, 'Member not found.', None, None)

并使用 comtypes 类似:

>>> import comtypes.client
>>> msi = comtypes.client.CreateObject('WindowsInstaller.Installer')
>>> products = msi.ProductsEx['', 's-1-1-0', 7]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\comtypes\client\dynamic.py", line 46, in __getitem__
**dict(_invkind=comtypes.automation.DISPATCH_PROPERTYGET))
  File "C:\Python27\lib\site-packages\comtypes\automation.py", line 768, in Invoke
 args))
_ctypes.COMError: (-2147352571, 'Type mismatch.', ('TypeError: Parameter 1', (('', 's-1-1-0', 7),)))

我想我从 DISPATCH_PROPERTYGET 是我想要做的。在这两个库中,我都尝试了所有可能想到的语法:

I think I got closer in comtypes since DISPATCH_PROPERTYGET is what I want to do. In both libs I tried every syntax I could think of:


  • msi.ProductsEx(['','s -1-1-0',7])

  • msi.ProductsEx [['','s-1-1- 0',7]]

  • msi.ProductsEx [''] ['s-1-1-0'] [7 ]

  • 而不是''

  • 元组而不是列表

  • msi.ProductsEx(['', 's-1-1-0', 7])
  • msi.ProductsEx[['', 's-1-1-0', 7]]
  • msi.ProductsEx['']['s-1-1-0'][7]
  • None instead of ''
  • tuples instead of lists

如何调用具有多个COM的获取属性来自python的参数?

How do I call a COM "get" property with multiple arguments from python?

推荐答案

使用Get / Set

Use Get/Set

msi.GetProductsEx("", "s-1-1-0", 7)

这篇关于COM“获取属性”;有多个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆