You are invited to Log in or Register a free Frihost Account!

# Integrating VC++ and PHP

bukaida
Hi
I have a program written in VC++. Is it possible to design any interface between them, like taking the input and displaying the output in php and the processing is done in the VC++ module? Please help. Do I need to convert the VC++ module to php?
hexkid
 bukaida wrote: I have a program written in VC++. Is it possible to design any interface between them, like taking the input and displaying the output in php and the processing is done in the VC++ module? Please help. Do I need to convert the VC++ module to php?

http://php.net/exec

Here's one way to do it
 Code:
bukaida
@Hexkid: Thanx man. Can I send an image like this? Actualy my OCR program is written in VC++ and The image is residing in anothe machine where the output is to be returned. Can I do it by the method mentioned by you? There is not much information about this in php manual.BTY I am using php4.4.0 with GD library support under apache 2.
hexkid
 bukaida wrote: @Hexkid: Thanx man. Can I send an image like this? Actualy my OCR program is written in VC++ and The image is residing in anothe machine where the output is to be returned. Can I do it by the method mentioned by you? There is not much information about this in php manual.BTY I am using php4.4.0 with GD library support under apache 2.

Well ... it depends. What are the inputs and outputs of your VC++ program?
Can you read and write to the other machine from your VC++ program?

Maybe this would work

YOURVC++PROGRAM --input=\\othermachine\path\to\image.tiff --output=\\othermachine\path\to\image.tiff.txt

and you'd use PHP to build the input and output parameters based on user input
bukaida
 Quote: Well ... it depends. What are the inputs and outputs of your VC++ program? Can you read and write to the other machine from your VC++ program?

Nope man, I have to scan the image in the local computer and ocr it there itself. Thats why I am trying to build the application so that the scanning part will be at the client's end and ocr will be at the remote server.The result will be returned to the client.Help me please.
hexkid
 bukaida wrote: I have to scan the image in the local computer and ocr it there itself. Thats why I am trying to build the application so that the scanning part will be at the client's end and ocr will be at the remote server.The result will be returned to the client.Help me please.

Use PHP to transfer the file from the client to the server (see Handling file uploads in the PHP manual).
After the file is transferred (and validated) use your VC++ program to generate the text output.
When you have the text output, send it to the client.

 Code: // part 1 // deal with file upload // ... // part 2 // generate text from image system('YOURVC++PROGRAM ' . $uploadedfilename . ' ' .$uploadedfilename . '.txt'); // ... // part 3 // send the text to the client echo '
';

Does YOURVC++PROGRAM work as expected on the server?

But, I think, the proper way to do what you want, is to do it all at the client side with no need to send files anywhere. The client scans the image and uses it with the OCR software that should be installed locally, on the client machine.
bukaida
The actual scenario is a bit complecated. The OCR software we are using requires huge amount of memory and processing power which a client machine cannot have.Moreover we want to provide it as a service rather than delivering the entire software to the client. It is a part of the e-Governance program, so they want to keep the main program with themselves.

BTW, does (YOURVC++PROGRAM ) means the exe file we are running?
I am trying to implement your suggessions. can inform you about the result and difficulties very shortly.
bukaida
@ hexkid: Man, it is not working. The VC++ program takes three arguments, Name of the image, Layout and output filename. I put all of them with a blankspace between them(as we do in stand alone system in command line mode) but it failed to generate the output.The image however is coming to the server.
hexkid
 bukaida wrote: The VC++ program takes three arguments, Name of the image, Layout and output filename.

If you go to the server yourself and try the command using the server keyboard, does the statement created by PHP work?

 Code: C:\VC\bin> YOURVC++PROGRAM "D:\USERDATA\INPUTFILE.TIFF" simple "D:\GENERATEDDATA\OUTPUTFILE.TXT"

Does the above create the output file?