問題描述
我有一個項目需要使用 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.
這篇關于使用 DLL 和 PHP for Dummies的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!