php4调用自编com组件

搞完了php4调用javabean,又想去试试调用com,开始以为很难,自己用vb6写了一个active dll在php4中调用,马上成功,比调用javabean方便多了,下面讲一下我的步骤。 下载的版本是从http://www.mm4.de/。 一:用vb6写activex dll 代码如下: 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 = 1 if num = 0 then get_number_attrib = 0 end function 具体方法如下:新建一个vb6工程,activex dll将工程命名为p_test,类名为c_test 类的文件内容如上。 编译生成p_test.dll文件 二:注册 提示符下运行:regsvr32 p_test.dll 三:编写php文件,test.php4代码如下: 运行php4文件将显示-1 可能遇到的问题是,编译工程时通不过,要将 microsoft active server pages object library 引用进来,具体实现“project->references”找到改库,并勾上 相比之下,php4调用com应该比php4调用javabean好哦,因为毕竟是ms系统嘛。大家也可以去自己编写调用数据库的控件,用php4调用,从某种程度上,和php调用javabean一样,可以说,实现了“隐藏源代码”。

http://www.bkjia.com/phpjc/532093.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/532093.htmltecharticle搞完了php4调用javabean,又想去试试调用com,开始以为很难,自己用vb6写了一个active dll在php4中调用,马上成功,比调用javabean方便多了,下面…

Posted in 未分类

发表评论