2025-05-24

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

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *