[python-win32] How to set value with PyIPropertyStore

Peng Chen capaneus at gmail.com
Wed Nov 6 16:28:00 EST 2019


Hi Tim,
 Thanks for the reply. Sorry for the late. I just found your email today.
Yes I tried with this code:

from win32comext.propsys import propsys, pscon
VIDEO_DATE_ENCODED = pscon.PKEY_Media_DateEncoded
properties = propsys.SHGetPropertyStoreFromParsingName(file_name)
mDate = properties.GetValue(VIDEO_DATE_ENCODED).GetValue() # got the
datetime object
dateShifted = mDate + shift_time.timedelta_obj # shift date
properties.SetValue(VIDEO_DATE_ENCODED, dateShifted) # set value
properties.Commit()

and I got error message when executing to
properties.SetValue(VIDEO_DATE_ENCODED, dateShifted)

it reports:
Object must be a PyPROPVARIANT


On Tue, Oct 15, 2019 at 1:25 AM Tim Roberts <timr at probo.com> wrote:

> Peng Chen wrote:
> >
> > I'm working on a script to shift video media creation time.
> > ....
> > I can see there is a function
> > PyIPropertyStore.SetValue(key, value) and PyIPropertyStore.Commit()
> > to write the date back, but I'm not sure how to construct the value
> > because it requires PyPROPVARIANT type.
> > I can't figure out any where to import this type and doesn't know how
> > to construct it.
>
> PyPROPVARIANT is generally a return type.  In a case like this, I would
> expect that you would simply pass the datetime value, and the interface
> code would convert it into a variant.  Have you tried that?  Did you get
> an error?
>
> --
> Tim Roberts, timr at probo.com
> Providenza & Boekelheide, Inc.
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> https://mail.python.org/mailman/listinfo/python-win32
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20191106/98c63a87/attachment.html>


More information about the python-win32 mailing list