简体   繁体   中英

How do I add some external executable to a Borland C++ Builder 2010 project?

So the question is how to add to c++ builder 2010 some external .exe file? Let's say that i made some program in visual basic and have the exe file, so that does not need to make the same code in c++ i want to just include that exe in my project? Is it possible to make portable application one exe that have inside him self another exe file (maybe in resource path)? How to call it in code if it is one exe in other? I know to call it by system function, or other by putting direction to the exe, but how to do that if it is on same address as are main exe?

I don't understand exactly what you're trying to accomplish. If you want to use the functionality of a given program, you're going to have to know things about how that program works.

If you want to take a given executable, and call it as you would a shell script, then you would need to start the given program with it's standard input and standard output redirected to a pipe. An example of how to do that is available on MSDN . If you want to be able to just look at the Visual Basic classes and methods in the target EXE, as you could do with Visual Basic .NET, you are out of luck, as an arbitrary executable does not understand the concept of a class or method.

Use the Project > Resources dialog to add the VB .exe file to your project and give it an ID. At runtime, your C++ code can then extract the resource data for that ID to a temporary file, such as with TResourceStream and TFileStream , and then use CreateProcess() to run it. Don't forget to delete the file when you are done using it.

Otherwise, re-write the VB code into a DLL instead, and then the C++ app can simply call the DLL's exported functions when needed. If you want to ship a single self-contained .exe (which is generally not how DLLs are used), then you will have to use the same resource approach, just use LoadLibrary() and GetProcAddress() , instead of CreateProcess() , to access the DLL functions dynamically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM