1

Say I had a PHP page with a calculator interface, but I want to transfer the sum to Windows Calculator.exe and then get a reply from the application back to my PHP page, how do you go about doing this?

I understand that the sum could easily be done in PHP and it would be pointless using another application, but I just wondered how it would be done and will be helpful to know for my next project. I couldn't find any relevent exisiting questions but the search criteria for this isn't easy!

Thanks

closed as too broad by gnat, user40980, Bart van Ingen Schenau, GlenH7, Dynamic Jul 8 '14 at 21:32

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

4

Applications can communicate using an Application Programming Interface (API). When writing a program, the developer can choose to expose certain functions to allow other programs to interact with them. By only exposing certain functions, and in a certain way, the developer allows people to use his application in a safe way without accidentally (or intentionally) doing destructive things.

An API may be exposed in several ways, depending on the languages involved. In a .NET environment, for instance another .NET program could add a reference to an API dll created for this purpose. Another example is a web service API which can be communicated with using HTTP requests. If the API uses a common cross language technique such as JSON or XML to input and output data, a program in any language may be able to communicate with it.

  • +1. Not forget to mention the Windows Calculator has no officially documented API, AFAIK. Only way to communicate with it is to use the Windows messaging system through Win32 API, send the calculator some key stroke events, including "Ctrl-C" at the end and grab the result from the clipboard. – Doc Brown Jul 6 '14 at 8:34
0

In addition to what @razethestray said, applications can also talk to each other by means of so-called RPC interfaces, which stands for Remote Procedure Calls.

However, RPC itself is a broad term. Actually there are plenty of ways how an RPC could be implemented. For example, Microsoft's DCOM relies heavily on RPC. On the other hand, a SOAP (web) server call is considered an RPC as well. the one thing that they all have in common is, that a client calls a piece of code in a remote (server) process through a well-defined API to achive something.

As you can imagine, it is a good idea and highly recommended to use existing frameworks for such a task, simply to hide and manage the complexity that comes with the infrastructure needed for this. Those frameworks and in some cases built-in IDE support (e.g. for SOAP) make an RPC essentially look like a normal function/method call. In fact, behind the scenes there may be happen a lot, especially when the other process is on a remote machine.


PS: That's a quite sophisticated topic for starters.

Not the answer you're looking for? Browse other questions tagged or ask your own question.