需要设置php.ini文件,找到这行com.allow_dcom=true,把com组件支持启用
其实调用 OCX或者什么什么的控件文件包含进来
include("D:\wwwroot\Authen\Authen.ocx");
然后用COM函数调用它 其中参数是以 文件名.类名的形式调用的 这点由为重要
$word = new COM("Authen.CAuthenCtrl") or die("Unable to instanciate Word");
就这么简单 就可以完成PHP调用控件的工作了 ~~~呵呵 ~~~
偶是用MFC做的ActiveX控件, 生成了一个Authen.PHP里面引用首先 include("Authen.ocx的物理路径"); $myCom = new COM("Authen.CAuthenCtrl") or die("Unable to instanciate Word"); Authen是文件名 CAuthenCtrl是类名
来源:http://blog.chinaunix/uid-22414998-id-113455.html
从手册找到的 // 启动 word $word = new COM("word.application") or die("Unable to instanciate Word"); print "Loaded Word, version {$word->Version}\n"; //将其置前 $word->Visible = 1; //打开一个空文档 $word->Documents->Add(); //随便做些事情 $word->Selection->TypeText("This is a test..."); $word->Documents[1]->SaveAs("Useless test.doc"); //关闭 word $word->Quit(); //释放对象 $word->Release(); $word = null;