任何想法fillchar正在做什么? [英] Any ideas what fillchar is doing?
问题描述
$ b $ p
fillchar
它也不在msdn上。任何想法在做什么?
var aButton:TTBBUTTON;
//检查这个之后是否有另一个按钮。
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位* /
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':
{'bReserved6':ctypes.unsigned_char},
{'dwData':ctypes.uintptr_t},
{'iString':ctypes.intptr_t}
]);
c> Delphi 代码。事实上,Delphi有一个 FillChar
函数匹配您的样本的签名,也将从上下文中有意义。 FillChar
只是C memset
的另一个实现。
因此,鉴于文档 FillChar
fillchar(aButton,sizeof( A按钮),0);
相当于
memset(aButton,0,sizeof(aButton));
//或者ZeroMemory(aButton,sizeof(aButton));
这意味着它只将整个事物设置为 0
字节。
正如中所讨论的,memset没有DLL,所以ctype ,你可以跳过这个新的js-ctypes结构实例,因为js-ctypes为你初始化了内存。
I'm converting from C++ to js-ctypes, and came across this function that is not documented by the guy.
fillchar
It's not on msdn either. Any ideas on what it's doing?
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));
in js-ctypes aButton
is this:
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}
]);
}
Looks like Delphi
code. Indeed, Delphi has a FillChar
function that matches the signature of your sample and also would make sense from the context. FillChar
is just another implementation of C memset
.
So, given the docs of FillChar
fillchar(aButton,sizeof(aButton),0);
is equivalent to
memset(aButton, 0, sizeof(aButton));
// Or ZeroMemory(aButton, sizeof(aButton));
meaning it only sets the whole thing to 0
bytes.
As discussed in memset has no DLL so how ctype it, you can skip this for new js-ctypes structure instances, as js-ctypes initializes the memory for you.
这篇关于任何想法fillchar正在做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!