首先写activex dll:
新建一个vb6工程,activex dll将工程命名为p_test,类名为c_test ,类的文件内容如下:
option explicitprivate myscriptingcontext as scriptingcontextprivate myapplication as applicationprivate myrequest as request private myresponse as responseprivate myserver as serverprivate mysession as session publicsub onstartpage(passedscriptingcontext as scriptingcontext)set myscriptingcontext = passedscriptingcontextset myapplication = myscriptingcontext.applicationset myrequest = myscriptingcontext.requestset myresponse = myscriptingcontext.responseset myserver = myscriptingcontext.serverset mysession = myscriptingcontext.sessionend subpublic sub onendpage()set myscriptingcontext = nothingset myapplication = nothingset myrequest = nothingset myresponse = nothingset myserver = nothingset mysession = nothingend subpublic function test_number(num) as variantif num 0 then get_number_attrib = 1if num = 0 then get_number_attrib = 0end function
编译生成p_test.dll文件
注册
提示符下运行:regsvr32 p_test.dll
编写php文件,test.php4代码如下:
test_number(-454);echo $a;?>
可能碰到的问题是,编译工程时通不过,要将microsoft active server pages object library引用进来,具体实现project->references找到改库,并勾上 。