如何从 Delphi XE 编写的 EXE 文件启动 Delphi 7?

发布于 2024-11-07 12:28:32 字数 1078 浏览 1 评论 0原文

我正在做一些构建自动化,并希望从我使用 Delphi XE 编写的应用程序运行 Delphi 7 IDE。

我的 Delphi 7 IDE 处于:

'C:\Program Files\Borland\Delphi7\Bin\delphi32.exe'

尚未执行:

ShellExecute( Handle, 'Open', 'C:\Program Files\Borland\Delphi7\Bin\delphi32.exe', '', '', sw_ShowNormal );

最终进入 Delphi 7 IDE,但只是在出现大量丢失包错误之后。

做:

ShellExecute( Handle, 'Open', 'C:\windows\notepad.exe', '', '', sw_ShowNormal );

打开记事本工作文件。

我还有一个名为“Delphi7IDE.bat”的批处理文件,当我单击该批处理文件时,它会打开 Delphi 7,但是执行:

ShellExecute( Handle, 'Open', 'C:\sys\batch\Delphi7IDE.bat', '', '', sw_ShowNormal );

会产生与上面相同的错误。

我尝试使用 Delphi 7 菜单快捷方式中指定的directoy(即调用:

ShellExecute( Handle, 'Open', 'C:\Program Files\Borland\Delphi7\Bin\delphi32.exe', '', 'C:\Program Files\Borland\Delphi7\Projects\', sw_ShowNormal );"

但这会产生相同的错误(这是可以预料的,因为上面的批处理文件示例没有固定目录,并且单击时运行良好)

。有多个错误,但其中一个示例是 this one

我做错了什么?

I'm doing some build automation and would like to run the Delphi 7 IDE from an Application that I'm writing using Delphi XE.

My Delphi 7 IDE is at:

'C:\Program Files\Borland\Delphi7\Bin\delphi32.exe'

yet doing:

ShellExecute( Handle, 'Open', 'C:\Program Files\Borland\Delphi7\Bin\delphi32.exe', '', '', sw_ShowNormal );

eventually gets into the Delphi 7 IDE but only after lots of missing package errors.

Doing:

ShellExecute( Handle, 'Open', 'C:\windows\notepad.exe', '', '', sw_ShowNormal );

works file opening Notepad.

I also have a batch file called 'Delphi7IDE.bat' which opens Delphi 7 when I click the batch file, but doing:

ShellExecute( Handle, 'Open', 'C:\sys\batch\Delphi7IDE.bat', '', '', sw_ShowNormal );

produces the same errors as above.

I've tried using the directoy as specified in my Delphi 7 menu shortcut (i.e calling:

ShellExecute( Handle, 'Open', 'C:\Program Files\Borland\Delphi7\Bin\delphi32.exe', '', 'C:\Program Files\Borland\Delphi7\Projects\', sw_ShowNormal );"

but this gives the same error (and this is to be expected because the batch file example above has no fixed directory and runs fine when clicked).

There are multiple errors, but an exampler of one is this one

What am I doing wrong please?

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

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

发布评论

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

评论(3

偏闹i 2024-11-14 12:28:33

现在我想我明白了。 Delphi 7 已经很旧了。 Windows Vista(或7)是新的。 为了兼容性,您正在以管理员身份运行 delphi32.exe,不是吗? 也就是说,如果您右键单击 delphi32.exe (或快捷方式),您已在“兼容性”选项卡中选择“以管理员身份运行此程序”。如果您以管理员身份运行 delphi32.exe,则一切正常,但如果您不这样做,则会在启动过程中遇到所有这些错误。

现在,当您从 Delphi 应用程序中 ShellExecute delphi32.exe 时,delphi32.exe 继承您的权限德尔福应用程序。这很可能在没有任何提升权限的情况下运行,delphi32.exe 也是如此。

解决方案:右键单击您的 Delphi 应用程序(例如 Project1.exe),选择“兼容性”选项卡,然后单击“以管理员身份运行此程序”复选框。

Now I think I get it. Delphi 7 is old. Windows Vista (or 7) is new. You are running delphi32.exe as administrator, for compatibility, aren't you? That is, if you right-click delphi32.exe (or the short cut), you have selected "Run this program as an administrator" in the "Compatibility" tab. If you run delphi32.exe as an administrator, everything is fine, but if you don't, you get all these errors during startup.

And now, when you ShellExecute delphi32.exe from your Delphi application, delphi32.exe inherits the privileges of your Delphi application. This is most likely running without any elevated privileges, and so will delphi32.exe.

The solution: right-click your Delphi application (Project1.exe, say), select the "Compatibility" tab, and click the "Run this program as an administrator" checkbox.

亢潮 2024-11-14 12:28:33

您可能弄错了工作目录。右键单击“开始”菜单上的“Delphi 7”图标,然后按Ctrl+C 此快捷方式的工作目录。使用此字符串作为 ShellExecuteDirectory 参数。

我没有任何Delphi 7系统可供实验,但在我安装了Delphi 4的虚拟WIndows 95机器中,确实有一个指定的工作目录:

Windows 95 中的 Delphi 4 快捷方式属性

You probably get the working directory wrong. Right-click the "Delphi 7" icon on the Start Menu, and Ctrl+C the working directory of this shortcut. Use this string as the Directory parameter of ShellExecute.

I don't have any Delphi 7 system to experiment with, but in my virtual WIndows 95 machine, in which I have Delphi 4 installed, there is indeed a specified working directory:

Delphi 4 shortcut properties in Windows 95

梦里梦着梦中梦 2024-11-14 12:28:33

您可能对此感兴趣:http://msdn.microsoft .com/en-us/library/ms682431(v=vs.85).aspx 下面是一个有关如何使用该函数的 Delphi 示例:http://www.delphi3000.com/articles/article_4176.asp

This may interest you: http://msdn.microsoft.com/en-us/library/ms682431(v=vs.85).aspx And here's a Delphi example on how to use the function: http://www.delphi3000.com/articles/article_4176.asp

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