Skip to content
Advertisement

Tag: ctypes

Python ctypes behaviour with variable types

I’m using a third party python library, that is using ctypes (it uses a dll). I’m not very familiar with ctypes. The lib offers a type definition and a structure definition as given in the minimum example below. I’m trying to assign the member variable myClassInst.MSGTYPE the value of the constant MYConst. Afterwards I want to check the value with

How do I copy a part of bytearray to c_void_p-referenced memory and vice versa?

In the Python application, I have a bytearray with some data. My python code is called by some external native library (DLL/so/dylib) (using ctypes and its callback functions). One of the callback functions includes a pointer to the unmanaged buffer, allocated in that external library. I need to copy a part of the bytearray into this unmanaged buffer or copy

Accessing C array in golang

I have two files, module.go and test.py. My goal is to speed up some calculations that is done in python, but have an issue accessing array of integers in go. module.go and simple test file in python: After compiling go module with go build -buildmode=c-shared -o gomodule.so module.go and fire up python file I got: I get that C array

Python – Difference Between Windows SystemParametersInfoW vs SystemParametersInfoA Function

I have a quick question that I cannot seem to clarify, despite my research on Stack Overflow and beyond. My questions involves the Windows SystemParametersInfo function with its variants SystemParametersInfoW (Unicode) and SystemParametersInfoA (ANSI) in relation to a Python 3.x script. In a Python script I am writing, I came across two different explanations into when to use these variants.

Accessing a structure element in Python

I’m having trouble accessing a structure element. Notice that I have read something into the structure using sscanf (to simulate my actual routine) but Python does not seem to realize that. So I added a statement to assign a value, then Python realizes there is something there. This only happens when I’m reading into a strcuture … as I have

Advertisement