Home > Backend Development > PHP Tutorial > php 调用 C++ dll,该怎么处理

php 调用 C++ dll,该怎么处理

WBOY
Release: 2016-06-13 11:46:02
Original
2155 people have browsed it

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

<br />extern "C" int __stdcall GameRegister(char* szSystemInfo, char *szRegCode, char *szLicense);<br />
Copy after login


PHP代码
<br /><?php<br />                $dw = new Com("DynamicWrapper");<br />				$dw->Register("EducationGameRegister.dll", "GameRegister", 'i=sss', "f=s", "r=u"); <br />				<br />				$reg_code = "";<br />				$ch = $dw->GameRegister("P2G9YFWGZW68G","2597367cea95b2cf0aace3bd5059c33e",&$reg_code);<br />				<br />				echo "Return Value:".$ch;<br />				echo "Register Code:".$reg_code;	<br />            ?><br />
Copy after login


运行时出现下面的错误: 
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);
這樣試試

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template