转换 C++ Delphi 函数:如何处理 void* 参数?
我正在使用下面的 C++ 示例在 Delphi 中编写 DLL:
USERDLL_API double process_message (const char* pmessage, const void* param)
{
if (pmessage==NULL) { return 0; }
if (param==NULL) { return 0; }
if (strcmp(pmessage,"state")==0)
{
current_state *state = (current_state*) param;
return process_state( (current_state*)param );
}
}
不幸的是,我对 C++ 和指针几乎一无所知。我应该使用什么来代替 char* (PChar?) 和 void*?
function process_message (const pmessage: PChar; const param: ???): Double; export;
begin
???
end;
exports process_message;
任何有关函数主体的帮助也将受到高度赞赏。我意识到这不是火箭科学,但如果有人愿意为我做这件事,我不会仅仅为了转换几行而学习 C++ 基础知识:-)
I'm writing a DLL in Delphi using the below C++ example:
USERDLL_API double process_message (const char* pmessage, const void* param)
{
if (pmessage==NULL) { return 0; }
if (param==NULL) { return 0; }
if (strcmp(pmessage,"state")==0)
{
current_state *state = (current_state*) param;
return process_state( (current_state*)param );
}
}
Unfortunately, I know next to nothing about C++ and pointers. What should I use instead of char* (PChar?) and void*?
function process_message (const pmessage: PChar; const param: ???): Double; export;
begin
???
end;
exports process_message;
Any help with the body of the function will be highly appreciated, too. I realize it's not rocket science, but I wouldn't learn the basics of C++ just to convert a couple of lines, if someone's kind enough to do that for me :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
RAD Studio 在线文档包含一个 Delphi 到 C++ 类型映射 表它可以帮助您将 C++ 代码翻译为 Delphi。
The RAD Studio online documentation includes a Delphi to C++ types mapping table which can help you to translate the C++ Code to Delphi.
未经测试,但应该有助于您入门。
Untested, but should help to get you started.
Pointer
数据类型与 Cvoid*
完全相同。Pointer
datatype is an exact equivalent of Cvoid*
.