Python组件类型问题

Python组件类型问题,python,comtypes,Python,Comtypes,我有以下代码: import comtypes from comtypes.client import CreateObject certadmin = CreateObject("CertificateAuthority.Admin") certadmin._ICertAdmin2__com_GetArchivedKey('hostname\\simpleca', 35, 'CR_OUT_BASE64', comtypes.BSTR(' ')) 但是,我对数据类型存在问题,例如 Traceb

我有以下代码:

import comtypes
from comtypes.client import CreateObject
certadmin = CreateObject("CertificateAuthority.Admin")
certadmin._ICertAdmin2__com_GetArchivedKey('hostname\\simpleca', 35, 'CR_OUT_BASE64', comtypes.BSTR(' '))
但是,我对数据类型存在问题,例如

Traceback (most recent call last):
File "<input>", line 1, in <module>
ArgumentError: argument 3: <type 'exceptions.TypeError'>: wrong type
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
ArgumentError:参数3::类型错误

任何建议都将不胜感激。

胡乱猜测。该方法的第三个参数应该是一个数字。您正在传递字符串
CR\u OUT\u BASE64
。这可能会起作用:

certadmin._ICertAdmin2__com_GetArchivedKey('hostname\\simpleca', 35, 1, comtypes.BSTR(' '))

CR\u OUT\u BASE64
常量等于1。

很好,可以工作。知道如何使用GetArchivedKey方法使用证书序列号而不是请求ID来请求证书吗?