使用 DLL 和 PHP for Dummies
我有一个项目需要使用 PHP 访问 DLL.服务器为Windows机器,Apache服务器由XAMPP提供.
我在网上阅读了多个答案,例如
- 在 PHP 中使用 DLL?
- php 与 dll 通信?
- 通过php调用dll
- http://ca.php.net/manual/en/class.com.php
- http://ca2.php.net/manual/en/book.w32api.php
- http://www.talkphp.com/absolute-beginners/3340-php-how-load-com-dll-file.html
以下是我在 HTA
/Javascript
中调用 DLL 的方式:
<object style="display:none" id="SOME_ID" classid="clsid:SOME_CLASS_ID" codebase="./somePath.dll"></object>
>
有人有可行的例子吗?
这是我目前在 PHP 中尝试过的:
$obj = new COM('pathTo.dll');
关于 DLL 的信息:
- 使用 Delphi 编译
- 它(当然)是自制的
- 当我尝试使用
regsvr32
注册 DLL 时,出现以下错误
未找到 DllRegister 服务器入口点
不用regsvr32
注册就可以使用吗?
创建 DLL 文件时,需要使用 模块定义文件.它将包含类似的内容:
<代码>;;包含从这个 DLL 导出的函数列表;描述简单的 COM 对象"出口DllGetClassObject 私有DllCanUnloadNow 私人DllRegisterServer 私有DllUnregisterServer 私有
该定义允许 regsvr32 找到 DllRegisterServer 入口点.
您可以尝试的另一个选项是将/n 标志传递给 regsvr32.
<块引用>Regsvr32 [/u] [/n] [/i[:cmdline]] dllname
/u - 注销服务器
/i - 调用 DllInstall 并传递一个可选的 [cmdline];与/u 一起使用时调用 dll 卸载
/n - 不调用 DllRegisterServer;此选项必须与/i
一起使用/s – 静音;不显示消息框(随 Windows XP 和 Windows Vista 添加)
最终,在您尝试使 DLL 与 PHP 一起工作之前,您需要确保您的 DLL 能够正常工作.
I have a project that needs to access a DLL with PHP. The server is a Windows machine and the Apache server is provided by XAMPP.
I read multiple answers on the web like
- Use DLL in PHP?
- php communication with dll?
- calling dll through php
- http://ca.php.net/manual/en/class.com.php
- http://ca2.php.net/manual/en/book.w32api.php
- http://www.talkphp.com/absolute-beginners/3340-php-how-load-com-dll-file.html
Here is how I call the DLL in HTA
/ Javascript
:
<object style="display:none" id="SOME_ID" classid="clsid:SOME_CLASS_ID" codebase="./somePath.dll"></object>
Does someone have a working example?
Here is what I tried so far in PHP:
$obj = new COM('pathTo.dll');
Information on the DLL:
- Compiled using Delphi
- It is (of course) home made
- I get the following error
the DllRegister Server entry point was not found
when I try to register the DLL withregsvr32
Can it be used without registering it with regsvr32
?
When you create your DLL file, you need to use a module definition file. It will contain something similar to this:
;
;contains the list of functions that are being exported from this DLL
;
DESCRIPTION "Simple COM object"
EXPORTS
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
That definition allows regsvr32 to find the DllRegisterServer entry point.
Another option you can try is to pass the /n flag to regsvr32.
Regsvr32 [/u] [/n] [/i[:cmdline]] dllname
/u - Unregister server
/i - Call DllInstall passing it an optional [cmdline]; when used with /u calls dll uninstall
/n - do not call DllRegisterServer; this option must be used with /i
/s – Silent; display no message boxes (added with Windows XP and Windows Vista)
Ultimately, before you try to make a DLL work with PHP, you need to be sure your DLL works in general.
相关文章