程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> 如何用PHP調用自己編寫的COM組件

如何用PHP調用自己編寫的COM組件

編輯:關於PHP編程

首先寫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 = 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"找到改庫,並勾上 。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved