I have a structure as below
class DEVINFO(Structure):
_fields_ = [("szDeviceName", c_char*MAX_PATH),
("pDevExtension", POINTER(DEVEXTENSION))]
In the above, DEVEXTENSION structure is as follows
class DEVEXTENSION(Structure):
_fields_ = [("szProductName",c_char*MAX_PATH),
("szManfName",c_char*MAX_PATH),
("szSerialNumber",c_char*32)]
My question is how would i access the members of “DEVEXTENSION” structure.
devInfo = DEVINFO()
devInfo.szDeviceName = "USB Flash 302"
print(devInfo.szDeviceName)
From the ctypes tutorial:
So,
devInfo.pDevExtensions.contents.szProductNamefor example, presuming thatDEVINFOwill produce an instance ofDEVEXTENSION– to me, it isn’t obvious it does here (but I’m not familiar with ctypes).Also note that PEP-8 recommends
CapWordsfor class names, andCAPSto be reserved for constants.