I have a Windows dll called some.dll with the following function:
void some_func(TCHAR* input_string)
{
...
}
some_func expects a pointer to utf-16 encoded string.
Running this python code:
from ctypes import *
some_string = "disco duck"
param_to_some_func = c_wchar_p(some_string.encode('utf-16')) # here exception!
some_dll = ctypes.WinDLL(some.dll)
some_dll.some_func(param_to_some_func)
fails with exception "unicode string or integer address expected instead of bytes instance"
The documentation for ctypes and ctypes.wintypes is very thin, and I have not found a way to convert a python string to a Windows wide char and pass it to a function.