如何将一些外部可执行文件添加到 Borland C++生成器 2010 项目?
所以问题是如何向 c++ builder 2010 添加一些外部 .exe 文件?假设我在 Visual Basic 中制作了一些程序并拥有 exe 文件,因此不需要在 C++ 中制作相同的代码,我只想将该 exe 包含在我的项目中?是否可以使便携式应用程序成为一个 exe 文件,其中包含另一个 exe 文件(可能在资源路径中)? 如果它是另一个exe中的一个exe,如何在代码中调用它?我知道通过系统函数调用它,或者通过向 exe 指定方向来调用它,但是如果它与主 exe 位于同一地址,该怎么做?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不明白你到底想实现什么目标。如果您想使用给定程序的功能,您必须了解该程序的工作原理。
如果您想获取给定的可执行文件,并像调用 shell 脚本一样调用它,那么您需要启动给定的程序,并将其标准输入和标准输出重定向到管道。 MSDN 上提供了如何执行此操作的示例。如果您只想查看目标 EXE 中的 Visual Basic 类和方法(就像使用 Visual Basic .NET 所做的那样),那么您就不走运了,因为任意可执行文件不理解类或方法的概念。方法。
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.
使用
项目>; Resources
对话框将 VB .exe 文件添加到您的项目中并为其指定 ID。在运行时,您的 C++ 代码可以将该 ID 的资源数据提取到临时文件(例如使用TResourceStream
和TFileStream
),然后使用CreateProcess()
来运行它。使用完该文件后,请不要忘记将其删除。否则,将 VB 代码重新写入 DLL,然后 C++ 应用程序可以在需要时简单地调用 DLL 的导出函数。如果您想传送单个独立的 .exe(这通常不是 DLL 的使用方式),那么您将必须使用相同的资源方法,只需使用
LoadLibrary()
和GetProcAddress()
,而不是CreateProcess()
,动态访问 DLL 函数。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 withTResourceStream
andTFileStream
, and then useCreateProcess()
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()
andGetProcAddress()
, instead ofCreateProcess()
, to access the DLL functions dynamically.