I have supposed some definitions as follows:
var CONFIG = {
is64bit: ctypes.voidptr_t.size == 4 ? false : true,
ifdef_UNICODE: true};
var TYPES = {
CHAR: ctypes.char,
WCHAR: ctypes.char16_t};
TYPES.LPSTR = TYPES.CHAR.ptr;
TYPES.LPWSTR = TYPES.WCHAR.ptr;
TYPES.LPTSTR = CONFIG.ifdef_UNICODE ? TYPES.LPWSTR : TYPES.LPSTR;
I have a string like: "OMNIKEY AG Smart Card Reader USB 0"
and I want to convert it to TYPES.LPTSTR.targetType.array format in which if it show by toString() it would be as follow:
ctypes.char16_t.array(36)(["O", "M", "N", "I", "K", "E", "Y", " ",
"A", "G", " ", "S", "m", "a", "r", "t", " ", "C", "a", "r", "d",
" ", "R", "e", "a", "d", "e", "r", " ", "U", "S", "B", " ", "0",
"\x00", "\x00"])
My system is 64 bit.
This will actually be done like this:
var st = "OMNIKEY AG Smart Card Reader USB 0"; var st_cArr = TYPES.LPTSTR.targetType.array(st.length+1)(st)I didst.length+1because by default you gt one null terminator, i did+1so you get the two null terminators of\x00