首页  >  文章  >  后端开发  >  php 调用 C++ dll,该怎么解决

php 调用 C++ dll,该怎么解决

WBOY
WBOY原创
2016-06-13 10:51:17954浏览

php 调用 C++ dll
动态库中要调用的函数

C/C++ code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->extern "C" int __stdcall GameRegister(char* szSystemInfo, char *szRegCode, char *szLicense);


PHP代码
PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php $dw = new Com("DynamicWrapper");                $dw->Register("EducationGameRegister.dll", "GameRegister", 'i=sss', "f=s", "r=u");                                 $reg_code = "";                $ch = $dw->GameRegister("P2G9YFWGZW68G","2597367cea95b2cf0aace3bd5059c33e",&$reg_code);                                echo "Return Value:".$ch;                echo "Register Code:".$reg_code;                ?>


运行时出现下面的错误: 
Fatal error: Uncaught exception 'com_exception' with message 'Error [0x80070057] 参数不正确。 ' in D:\WAMP\WWW\index.php:11 Stack trace: #0 D:\WAMP\WWW\index.php(11): com->Register('EducationGameRe...', 'GameRegister', 'i=sss', 'f=s', 'r=l') #1 {main} thrown in D:\WAMP\WWW\index.php on line 11

初次接触PHP,大家帮我看一下,谢谢了!

------解决方案--------------------
原型要求参数是指针,而 com 是不能传递指针的
------解决方案--------------------
$ch = $dw->GameRegister("P2G9YFWGZW68G","2597367cea95b2cf0aace3bd5059c33e",$reg_code);
這樣試試
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn