>백엔드 개발 >PHP 튜토리얼 >如何用PHP调用自己编写的COM组件?_PHP教程

如何用PHP调用自己编写的COM组件?_PHP教程

WBOY
WBOY원래의
2016-07-13 10:59:00942검색

首先写ActiveX Dll:
新建一个VB6工程,ActiveX Dll将工程命名为P_test,类名为c_test ,类的文件内容如下:

Option Explicit
Private MyscriptingContext As scriptingContext
Private MyApplication As Application
Private MyRequest As Request Private MyResponse As Response
Private MyServer As Server
Private MySession As Session Public

Sub OnStartPage(PassedscriptingContext As scriptingContext)
Set MyscriptingContext = PassedscriptingContext
Set MyApplication = MyscriptingContext.Application
Set MyRequest = MyscriptingContext.Request
Set MyResponse = MyscriptingContext.Response
Set MyServer = MyscriptingContext.Server
Set MySession = MyscriptingContext.Session
End Sub

Public Sub OnEndPage()
Set MyscriptingContext = Nothing
Set MyApplication = Nothing
Set MyRequest = Nothing
Set MyResponse = Nothing
Set MyServer = Nothing
Set MySession = Nothing
End Sub

Public Function Test_Number(num) As Variant
If num 0 Then Get_Number_Attrib = 1
If num = 0 Then Get_Number_Attrib = 0
End Function

编译生成p_test.dll文件

注册

提示符下运行:regsvr32 p_test.dll

编写php文件,test.php4代码如下:

$b=new COM("p_test.c_test");
$a=$b->Test_Number(-454);
echo $a;
?>

可能碰到的问题是,编译工程时通不过,要将Microsoft Active Server Pages Object Library引用进来,具体实现"Project->References"找到改库,并勾上 。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/631932.htmlTechArticle首先写ActiveX Dll: 新建一个VB6工程,ActiveX Dll将工程命名为P_test,类名为c_test ,类的文件内容如下: Option Explicit Private MyscriptingContext As scr...
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.