- UID
- 3702
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-4-8
- 最后登录
- 1970-1-1
|
发表于 2006-9-29 16:56:20
|
显示全部楼层
對於params的用法:
有其人提供下列
When you call mdlModify_elementSingle(), you pass it the filePos and
fileNum of an element, the address of your callback function
(elementFunc), and a void* to your parameters struct that is, in turn,
passed to your callback fuction.
If you want to pass any data, such as the filePos, to your callback you
should define a struct to hold those data:
// In your .h file
typedef struct dmitri_modifysingle_arg
{
ULong filePos;
int otherData;
} DMITRI_MODIFYSINGLE_ARG, *LP_DMITRI_MODIFYSINGLE_ARG;
// In your .mc file
void modifyElementFunc (void) { DMITRI_MODIFYSINGLE_ARG param; int fileNum = -1; ULong filePos = mdlElement_getFilePos (FILEPOS_CURRENT, &fileNum);
memset (¶m, 0x00, sizeof (param)); // Always initialise structs!
param.filePos = filePos; param.otherData = 99;
mdlModify_elementSingle (filePos, fileNum, MODIFY_REQUEST_NOHEADERS, MODIFY_ORIG, elementFunc, (void*)¶m, 0);
}
int elementFunc(MSElement* element, void* params, int fileNum, MSElementDescr* elmDscrP, MSElementDescr** newDscrPP)
{
LP_DMITRI_MODIFYSINGLE_ARG args = (LP_DMITRI_MODIFYSINGLE_ARG)param s;
ULong filePos = args->filePos;
} |
|