So here’s a quick post on calling dll’s in Windows using php. I have a dll that encrypts data in a certain format that we need for another process. So I need to pass the dll a string and it returns the encrypted string back.

I tried calling the dll using the COM class in code and was having issues until I realized I have to register the dll in windows first before I can call it using the COM class. To register a dll in windows you do the following in your command line:


Now that the dll is registered you can do the following to start accessing the dll:

span class=”st0″>’MyStuff.Functions’);

MyStuff is the dll name an/or id and Functions is the object inside the dll that we want to use. Now I call the method I need and pass the parameters:

span class=”st0″>’This needs to be encrypted.’

This is pretty much it. We instantiate the COM class with the dll and function I want. Then I call the method in the dll passing my text and it returns into my $encrypted_text var the encrypted text. I can now do my next process with the encrypted text like:


Tags: , , ,