Re: Pythoncom PROPVARIANT

Mark Hammond <[email protected]> Tue, 26 Apr 2022 12:56:19 +1000
Newsgroups gmane.comp.python.windows
Message-ID <[email protected]>
On 26/04/2022 5:00 am, Nicholas Pfeiffer wrote:
> Hi there,
> 
> Where is the PROPVARIANT class located in the pythoncom library?
> The docs are not helpful about this:
> http://timgolden.me.uk/pywin32-docs/PyPROPVARIANT.html 
> <http://timgolden.me.uk/pywin32-docs/PyPROPVARIANT.html>
> 
> I've seen postings that use the propsys module but that one no longer 
> contains the PROPVARIANT class unfortunately.

It is implemented in that module - see 
https://github.com/mhammond/pywin32/blob/main/com/win32comext/propsys/src/PyPROPVARIANT.cpp. 


> I'm wondering if this class exists in a different package or if I can 
> somehow recreate it?
> 
> I need to write new properties to a file but using the WriteMultiple 
> method will only let me write Strings with a prop variable id of 8 and I 
> need them to show up as "Text" which has a prop variable id of 30.

30 == VT_LPSTR which isn't supported by pywin32 - but VT_LPWSTR (31) is 
- you can create such an object with something like:

 >>> from win32com.propsys import propsys
 >>> import pythoncom
 >>> propsys.PROPVARIANTType("foo", pythoncom.VT_LPWSTR)
<PyPROPVARIANT object at 0x000001FAB01737A0>

> The only way I understand how to do this is to wrap the values used in 
> the WriteMultiple method in a PROPVARIANT class call, but I haven't be 
> able to figure out where that class is called from.

Sorry, but I'm not familiar with using WriteMultiple and I suspect it 
will depends on what exactly is on the other end.

HTH,

Mark