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

WBOY
发布: 2016-07-13 17:28:02
原创
789 人浏览过

首先写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 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/531812.htmlTechArticle首先写ActiveX Dll: 新建一个VB6工程,ActiveX Dll将工程命名为P_test,类名为c_test ,类的文件内容如下: Option Explicit Private MyScriptingContext As Scr...
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!