任何想法fillchar正在做什么?

时间:2014-06-30 00:47:07

标签: firefox-addon jsctypes

我是从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}
    ]);
}

1 个答案:

答案 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会为您初始化内存。