我是从C ++转换为js-ctypes,并遇到了这个没有记录的功能。
fillchar
它也不在msdn上。关于它做什么的任何想法?
var aButton:TTBBUTTON;
//Check if there's another button after this one.
fillchar(aButton,sizeof(aButton),0);
rez:=CallWindowProc(OldWndProc,hToolbar,TB_GETBUTTON,ButtonIndex+1,integer(@aButton));
HaveBehind:=(rez<>0) and (not HasFlag(aButton.fsStyle,BTNS_DROPDOWN));
js-ctypes aButton
中的就是:
var aButton = new struct_TBButton();
var struct_TBButton;
if (ctypes.voidptr_t.size == 4 /* 32-bit */ ) {
struct_TBButton = ctypes.StructType('TBButton', [
{'iBitmap': ctypes.int},
{'idCommand': ctypes.int},
{'fbState': ctypes.unsigned_char},
{'fsStyle': ctypes.unsigned_char},
{'bReserved': ctypes.unsigned_char},
{'bReserved2': ctypes.unsigned_char},
{'dwData': ctypes.uintptr_t},
{'iString': ctypes.intptr_t}
]);
} else { /* 64-bit */
struct_TBButton = ctypes.StructType('TBButton', [
{'iBitmap': ctypes.int},
{'idCommand': ctypes.int},
{'fbState': ctypes.unsigned_char},
{'fsStyle': ctypes.unsigned_char},
{'bReserved': ctypes.unsigned_char},
{'bReserved2': ctypes.unsigned_char},
{'bReserved3': ctypes.unsigned_char},
{'bReserved4': ctypes.unsigned_char},
{'bReserved5': ctypes.unsigned_char},
{'bReserved6': ctypes.unsigned_char},
{'dwData': ctypes.uintptr_t},
{'iString': ctypes.intptr_t}
]);
}
答案 0 :(得分:1)
看起来像Delphi
代码。实际上,Delphi有一个FillChar
函数,它匹配样本的签名,也可以从上下文中理解。 FillChar
只是C memset
的另一种实现。
所以,考虑到FillChar
fillchar(aButton,sizeof(aButton),0);
相当于
memset(aButton, 0, sizeof(aButton));
// Or ZeroMemory(aButton, sizeof(aButton));
意味着它只将整个事物设置为0
个字节。
如memset has no DLL so how ctype it中所述,您可以跳过此新js-ctypes结构实例,因为js-ctypes会为您初始化内存。