需要创建一个已编译的delphi应用程序,可以制作单独的编译应用程序

发布于 2024-09-16 15:11:03 字数 458 浏览 9 评论 0原文

我需要制作一个应用程序,让用户选择一些选项,单击按钮,然后创建一个单独的编译应用程序。这可能吗?我使用的是delphi 7和2010。

感谢您的回复。这里有更多信息。

它必须是一个图形应用程序并创建一个图形应用程序。

我想要的是用户启动“应用程序 A”(我最初制作的),能够选择一些选项(我为保密表示歉意。我认为这是一个价值百万美元的想法,可能 3 个人可能会觉得有用:) 然后使用该程序创建“应用程序 B”。然后可以将“应用程序 B”分发给最终用户,并且“应用程序 B”是单个可执行文件,其中包括已编译的应用程序和配置数据。我不关心如何,但我需要“App B”成为单个可执行文件。

我什至不需要使用 Delphi 来完成最终编译的应用程序。如果我可以从 Delphi 调用某种“伪编译器”,它将把预编译的 exe 和单独的配置文件结合到单个可执行文件中。那也可以很好地工作。

感谢您的回复和帮助。

谢谢。

I need to make an app that will let users select some options, click a button, and a separate compiled app is created. Is this possible? I am using delphi 7 and 2010.

Thanks for the replies. Here is a little more info.

It would have to be a graphical app and create a graphical app.

What I want is the user to fire up 'App A' (I originally made), be able to select some options (I apologize for the secrecy. I think this is a million dollar idea that probably 3 people may find useful :) then use the program to create 'App B.' 'App B' can then be distributed to end users and 'App B' is a single executable that includes a compiled app plus the configuration data. I don't care how, but I need 'App B' to be a single executable.

I wouldn't even need to use Delphi for the final compiled app. If there is some sort of "pseudo-compiler" that I can call from Delphi that would marry a precompiled exe and a separate config file into a single executable. That would work just fine as well.

Thank you for the replies and help.

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

咋地 2024-09-23 15:11:03

我也曾经遇到过类似的情况。我必须使用我的 exe 生成一个 exe。由于复杂性和许可证问题,我不想编译源代码。

我们将父应用程序称为 P,将子应用程序称为 C。还假设 C 需要的任何选项都可以总结在配置文件(XML/INI 等)中。我最终做的是:

  1. 创建P和C。将C插入P的资源数据中。
  2. 当用户选择选项后单击按钮时,P将从其资源数据中提取C。
  3. 创建一个包含用户选择的选项的 XML 文件并将其插入到 C 的资源数据中。

因此,每当 C 运行时,它将使用填充其中的 XML 文件中给出的选项。它看起来复杂又老套,但可靠且简单。谷歌一下“delphi 在 exe 中嵌入资源”,你会发现上面有很多文章可以做。

I also faced a similar situation once. I had to produce an exe using my exe. I didn't want to go the compiling a source code because of complexity and license problems.

Lets call the parent app P and child app C. Also lets assume that whatever option C needs can be summed up in a config file (XML/INI etc). What I ended-up doing was:

  1. Create P and C. Inserted C in resource data of P.
  2. When user clicked the button after selecting options, P would extract C from its resource data.
  3. Created an XML file containing the options selected by user and inserted it in C's resource data.

So whenever C will run, it will use the options given in the XML file stuffed in it. It looks like complicated and hacky but is reliable and simple. Do a google on "delphi embedding resource in exe" and you will find plenty of articles to do above.

得不到的就毁灭 2024-09-23 15:11:03

这是可能的。您将需要目标计算机上有一个 Delphi 7(或兼容)编译器(至少是命令行)。您还需要已编译应用程序的所有源代码,其中包括所有第三方库(如果您使用任何第三方库)。

当您完成所有设置后,只需使用正确的参数和路径调用命令行编译器(DCC32.EXE)即可。

为此,您可以使用两种方法:

  • 调用 ShellExecute
  • 调用 CreateProcess

您将可以更好地控制 CreateProcess 的执行。如果您打算以这种方式使用编译器,您还必须注意法律问题和许可证。

It is possible. You will need a Delphi 7 (or compatible) compiler (command line at least) on the target machine. You will also need all the source code for the compiled application and that includes all the third party libraries if you use any.

When you have it all set just call the command line compiler (DCC32.EXE) with the proper parameters and paths.

You can use two approaches for this:

  • Call ShellExecute
  • Call CreateProcess

You will have more control over the execution with CreateProcess. Also you will have to watch out for legal issues and licences if you plan to use the compiler this way.

此刻的回忆 2024-09-23 15:11:03

鉴于 Delphi 编译器无法重新分发,如果用户没有 Delphi 副本,一种解决方案可能是使用脚本引擎(即 RemObjects PascalScript,但还有其他引擎),为其生成代码,然后嵌入该代码(即在资源内)在可执行文件中,该可执行文件将在启动时执行它。

Given that the Delphi compiler can't be redistributed, one solution if the user has not a copy of Delphi may be to use a script engine (i.e. RemObjects PascalScript, but there are others), generate code for it, and embed that code (i.e. within a resource) in an executable that will execute it when launched.

小兔几 2024-09-23 15:11:03

创建一个单独的存根可执行文件,它实现您需要的所有逻辑,并从其自己的本地资源读取其配置(查看 TResourceStream 类以帮助您在运行时加载资源)。

编译时,将该存根可执行文件作为 RCDATA 资源包含在主应用程序的资源中。

在运行时,主应用程序可以在需要时从其资源中提取存根可执行文件,将其保存到磁盘,并使用 Win32 API UpdateResource() 函数将必要的配置数据插入存根的资源中。

Create a separate stub executable that implements all the logic you need, and that reads its configuration from its own local resources (look at the TResourceStream class to help you load a resource at runtime).

Include that stub executable as an RCDATA resource in your main app's resources when it is compiled.

At runtime, the main app can extract the stub executable from its resources when needed, save it to disk, and insert the necessary configuration data into the stub's resources using the Win32 API UpdateResource() function.

沉睡月亮 2024-09-23 15:11:03

在不了解更多关于为什么您认为需要这样做的情况下,我认为您实际上不需要这样做。考虑到上述要求,我只需要有一个用 Delphi 编写的应用程序,它会查找配置数据(.ini 文件、注册表等)是否存在。如果没有,它会显示一个屏幕,“将让用户选择一些选项,单击按钮”。然后,这些选项将存储在 .ini 文件中,程序的其余部分将继续使用这些选项。

或者,我会使用一些 pascal 脚本,例如 TMS 提供的脚本。

如果您正在寻找一种方法来制作应用程序的自定义品牌版本,可以将 Inno Setup 与 ResHacker 步骤结合使用。即在Inno中收集需求,将.exe吐出到临时目录中,使用ResHacker修改.exe,将其复制到程序文件夹中。

Without knowing more about why you think you need to do this, I assume you don't actually need to do this. Given the stated requirements, I'd simply have one app, written in Delphi, that looks for the existence of configuration data (.ini file, registry, etc..) In the absence of this, it presents a screen that "will let users select some options, click a button". Then the options are stored in a .ini file, and the rest of the program proceeds, making use of those options.

Alternately, I'd use some pascal scripting, such as provided by TMS.

If you are looking for a way to crank out custom-branded versions of an app, maybe use Inno Setup with a ResHacker step. i.e. gather requirements in Inno, spit out your .exe into a temp directory, use ResHacker to modify the .exe, copy it into the program folder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文