On 21/01/2021 10:00 pm, Olle Pontén wrote:
Hello!
I'm quite new to the pywin32 package (as in I have never interacted with
it before).
I'm currently trying to implement a python interface to a win32 bit program
that I can connect to using the ordinary win32com.client.Dispatch method.
This program controls an microscope camera and the only way to connect to
it is via this COM connection.
There is already an version of this software written in pascal by the
manufacturers
so I'm trying to create an expanded python version of this software.
I've managed to get the connection working and I can send commands that
do not
require any inputs and access the attributes of the interface/program.
The problem is that when I try to send commands to one of two exposed
methods that require input I get the
follow error:
s = win32com.client.VARIANT(pythoncom.VT_LPWSTR, 'On\0')
r = win32com.client.VARIANT(pythoncom.VT_LPWSTR, 'AL\0')
Response = AIPam.scriptCmd(r,s)
Traceback (most recent call last):
File "<ipython-input-38-c5635b52a462>", line 1, in <module>
Response = AIPam.scriptCmd(r,s)
File
"C:\Users\GWHLAB~2\AppData\Local\Temp\gen_py\3.8\E07C24C7-56CE-409F-AB60-DC7EDE9D9888x0x1x0.py",
line 37, in scriptCmd
return self._oleobj_.InvokeTypes(216, LCID, 1, (3, 0), ((31, 1),
(31, 1)),cmd
TypeError: The VARIANT type is unknown (0x0000001f)
If you look at
https://docs.microsoft.com/en-us/windows/win32/api/wtypes/ne-wtypes-varenum#remarks,
VT_LPWSTR is not valid in a VARIANT, so pywin32 doesn't let you create
them. Use VT_BSTR (or just pass a Python string) and see if that works -
if it doesn't you probably need to contact the vendor of the package.
HTH,
Mark
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32