使用DLL与PHP for Dummies [英] Using a DLL With PHP for Dummies

查看:175
本文介绍了使用DLL与PHP for Dummies的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要用PHP访问DLL的项目。服务器是一台Windows机器,Apache服务器是由XAMPP提供的。



我在网上看过多个答案,如





这是我如何在 HTA / Javascript



< object style =display:noneid =SOME_IDclassid =clsid:SOME_CLASS_IDcodebase =。 /somePath.dll\"></object>



有人有工作示例吗?



这是我迄今为止在PHP中尝试过的:

  $ obj =新COM('pathTo.dll'); 

有关DLL的信息:


  1. 使用Delphi编译

  2. 这是(当然)自制的

  3. 我收到以下错误当我尝试使用 regsvr32

$注册DLL时,DllRegister Server入口点未找到 b
$ b

可以在没有注册的情况下使用 regsvr32

解决方案

创建DLL文件时,需要使用模块定义文件。它将包含类似于此的内容:

 ; 
;包含从该DLL导出的函数列表
;

描述简单的COM对象

EXPORTS
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE

该定义允许regsvr32找到DllRegisterServer入口点。



您可以尝试的另一个选项是将/ n标志传递给regsvr32。


Regsvr32 [/ u] [/ n] [/ i [:cmdline]] dllname



/ u - 注销服务器



/ i - 调用DllInstall传递一个可选的[cmdline];当用于/ u调用dll卸载



/ n - 不要调用DllRegisterServer;此选项必须与/ i一起使用



/ s - 静音;显示没有消息框(添加Windows XP和Windows Vista)


最终,在尝试使用PHP工作DLL之前,您需要确保你的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

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:

  1. Compiled using Delphi
  2. It is (of course) home made
  3. I get the following error the DllRegister Server entry point was not found when I try to register the DLL with regsvr32

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆