Skip to content Skip to sidebar Skip to footer

Com Object Variant Parameters In Comtypes (python)

I am trying to use comtypes 1.1.0 package to access COM object within python 2.7.6.1 and I have a basic problem to get correct data from COM object method due to return VARIANT typ

Solution 1:

I'm not a python expert, but handling VARIANTS as well.This "PSEUDO" code piece might help you

from ctypes import *
from comtypes import automation 

if __name__ == '__main__':

    ...

    bsVar = automation.VARIANT("dwt")
    vValue = automation.VARIANT(0) 
    tValue = automation.VARIANT(0)
    bsRetMsg = automation.VARIANT(0)

    ReadVariable(bsVar, addressof(vValue), addressof(tValue), addressof(bsRetMsg))

    ...

PS: Moving forward lerning how Python works, I think, but not tested, the following might work:

    ...
    vValue,tValue,bsRetMsg = ReadVariable(automation.VARIANT("dwt"))
    ...

Post a Comment for "Com Object Variant Parameters In Comtypes (python)"