Using a DLL With PHP for Dummies

血红的双手。 提交于 2019-11-28 05:59:59

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.

A DLL cannot be access from Linux/Apache server. Therefore the project was drop.

UserHelpNeeding02356

I had the same problem and i fixed some steps :

  1. open the command line in administrator right (windows + r + type 'cmd') write the PATH where you're your dll file:
    C:\Windows\system32\regsvr32 xwizards.dll(it's example)
    a window show up with "DLLRegisterServer success"
  2. check your phpinfo() if you're com_dotnet extension
  3. now write into your PHP code :

        try    {
      $dll = new COM('<theNameOfDllFile>.<NameOfTheClass>'); //without extension '.dll' for theNameOfDllFile
      $dll->Function(); 
      } catch(Exception $e){
        echo 'error: ' . $e->getMessage(), "\n";}
    

    Now if you know how manage the class and the function of you're dll it's going ok,however no error massage should show up on your screen


If i wasn't clear let me know and i'll do my best the next time :)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!