PHP4 calls self-compiled COM components

Source: Internet
Author: User
Tags php file
After calling JavaBean in PHP4 and trying to call COM, I thought it was very difficult. I wrote an Active Dll using VB6 and called it in PHP4 immediately, it is much more convenient than calling javabean. The following describes my steps.
I. Use VB6 to write Activex Dll
The code is as follows:
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
The specific method is as follows: Create a VB6 project, ActiveX Dll name the project P_test, class name c_test
Class file content as above.

Compile and generate the p_test.dll file
II. Registration
Run: regsvr32 p_test.dll
3. Compile the php file. The test. php4 code is as follows:
<?
$ B = new COM ("p_test.c_test ");
$ A = $ B-> Test_Number (-454 );
Echo $;
?>
Running the php4 file will display-1
The possible problem is that when compiling the project
Microsoft Active Server Pages Object Library
Reference. Find and modify the library for "Project-> References" and check
In contrast, PHP4 calls com better than PHP4 calls javabean, because it is a Ms system after all. You can also compile the control for calling the database by yourself and call it with PHP4. To some extent, it is the same as calling the javabean with PHP, and it can be said that the "hidden Source Code" is implemented ".

If you are interested, please contact us.



Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.