Using normal win32 dlls from within php/phpdesktop

1,459 views
Skip to first unread message

Sreenadh OG

unread,
Jun 10, 2014, 12:23:57 AM6/10/14
to phpde...@googlegroups.com
Hi Czarek,
   Is there a way to instantiate and use normal win32 dlls from within php/phpdesktop?
Thanks and regards,
Sreenadh

Czarek Tomczak

unread,
Jun 10, 2014, 1:31:28 AM6/10/14
to phpde...@googlegroups.com
Explain what you're trying to do.

Sreenadh OG

unread,
Jun 10, 2014, 2:59:22 AM6/10/14
to phpde...@googlegroups.com
Hi Czarek,
   I want to use some useful functions present in a pure C++ dll (which contains some useful functions, a dll which cannot be registered using Regsvr32.exe), from within my application. From within VB6 or C# there is no difficulty in loading and using such dlls. But I don't see any way to using such dlls in php. So I was curious to know whether there is any workaround.
   Two major obstacles I face duing the use of PHP in windows desktop applications are -
   1. Absence of good enough ways to use generic win32 DLLs in PHP. (i.e. some powerful 3rdparty dlls usually written in C,C++ etc are available, but probably there is no way to use the functions present in them from within php). If there is a work around I would be happy to know.
   2. Absence of proper date handling functions to handle historic and prehistoric dates. There are few DLLs (written in languages like FASM etc: E.g. : http://mikhajduk.houa.org/EN/index.php?f=Calendar) which makes such date calculations possible. But I have no idea how to make use of such libraries from within PHP.
  I don't know how to solve such problems while using php/phpdesktop for desktop application development.
Thanks and regards,
Sreenadh

Czarek Tomczak

unread,
Jun 11, 2014, 3:17:52 AM6/11/14
to
If the DLL exposes COM interface then you can use the php_com extension, see:

If the COM DLL is registered in the system then you can use regular name like "WScript.Shell", if it's not then load the COM DLL using path:
$some = new COM("some.dll")

Another solution is to use create a PHP extension using the PHP-CPP library and C++. Creating php extensions with this library is very straightforward, take a look at the examples:

Using C/C++ you can load DLLs and expose the API you want to PHP:

Using the php_com extension you can use only functions from the DLL that have a COM interface. Using C/C++ along with the custom php extension you can call any functions from the DLL.

It should be possible to call dll functions using some COM library that exposes such functionality. Searched using google and found a few of such libraries, see:

1) Dynamic Wrapper - dynwrap


More examples: [1], [2], [3]

2) XNeat Scripting

Czarek Tomczak

unread,
Jun 11, 2014, 3:56:12 AM6/11/14
to phpde...@googlegroups.com
Edited previous post with two more solutions, COM libraries that can call any functions from a DLL file: Dynamic Wrapper and XNeat Core.

Sreenadh OG

unread,
Jun 12, 2014, 4:12:23 AM6/12/14
to phpde...@googlegroups.com
Hi Czarek,
   Thanks for the guidance. I will try in that direction.
Thanks and regards,
Sreenadh

Sreenadh OG

unread,
Jun 16, 2014, 2:17:18 AM6/16/14
to phpde...@googlegroups.com
Hi Czarek,
  Due to my ignorance and many other reasons, the above listed solutions did not work for me. I resolved the issue, by writing a console application in VB (which will interact with the DLLs and) which would be called by php using exec() function, so as to get the response. I am happy that the issue is resolved now. Thanks for your efforts and support.
Thanks and regards,
Sreenadh
Reply all
Reply to author
Forward
0 new messages