Union-within-structure syntax in ctypes

后端 未结 1 575
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 05:35

Quick question about ctypes syntax, as documentation for Unions isn\'t clear for a beginner like me.

Say I want to implement an INPUT structure (see here):



        
1条回答
  •  走了就别回头了
    2021-01-05 06:00

    Your Structure syntax isn't valid:

    AttributeError: '_fields_' must be a sequence of pairs
    

    I believe you want to use the anonymous attribute in your ctypes.Structure. It looks like the ctypes documentation creates a TYPEDESC structure (which is very similar in construction to the tagINPUT).

    Also note that you'll have to define DWORD as a base type for your platform.

    0 讨论(0)
提交回复
热议问题