Heim > php教程 > php手册 > php调用DLL(COM)注意事项

php调用DLL(COM)注意事项

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Freigeben: 2016-06-06 19:46:05
Original
2157 Leute haben es durchsucht

PHP调用DLL(COM)注意事项: 1、函数的参数中,最后一个参数函数是返回值,须是retval类型的。 2、向接口传字符串类型的参数时,不要用BSTR*类型的,而用BSTR,因为BSTR本身已经是指针了。 3、PHP中的数字0并不对应C/C++中的0或NULL,而是另有其值。 4、PHP中

PHP调用DLL(COM)注意事项:
1、函数的参数中,最后一个参数函数是返回值,须是retval类型的。
2、向接口传字符串类型的参数时,不要用BSTR*类型的,而用BSTR,因为BSTR本身已经是指针了。
3、PHP中的数字0并不对应C/C++中的0或NULL,而是另有其值。
4、PHP中的空字符串""并不对应C/C++中的NULL,最好用计算其长度是否为0来判断是否为空串。
5、向外输出的接口如果能放在一个类中,最好都放在一个类中。曾经在输出的接口函数中用了不是用来导出函数的类(但在ATL工程中),出现不可用的情况,不清楚是否和接口是否和不在同一个类中有关。
6、为字符串分配空间用::SysAllocString(),并用::SysFreeString(mem)释放。这一条不是必须的,只是看到网上好多例子都是用这对函数来分配和释放空间的。

 

本人刚接触PHP和COM,以上所说如若有不对之处,欢迎留言讨论。

 

至于如何制作可供PHP调用的DLL,网上有很多资源。下面一个连接:

http://www.360doc.com/content/10/0512/14/722458_27221569.shtml
 

Verwandte Etiketten:
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Aktuelle Ausgaben
PHP-Datenerfassung?
Aus 1970-01-01 08:00:00
0
0
0
PHP-Erweiterung intl
Aus 1970-01-01 08:00:00
0
0
0
Wie man PHP gut lernt
Aus 1970-01-01 08:00:00
0
0
0
Mehrere PHP-Versionen
Aus 1970-01-01 08:00:00
0
0
0
Beliebte Empfehlungen
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage