简体   繁体   English

如何确定创建 Delphi 项目的 Delphi 版本

[英]How do I determine the Delphi version which created a Delphi project

I am trying to automatically figure out which Delphi version (of Delphi 5 to XE2 installed on my computer) to use to open a given project without upgrading that project by mistake.我试图自动找出用于打开给定项目的 Delphi 版本(我的计算机上安装的 Delphi 5 到 XE2),而不会错误地升级该项目。

Up to Delphi 7 there is a .dof file in .ini format for each project.在 Delphi 7 之前,每个项目都有一个 .ini 格式的 .dof 文件。 Delphi 5 does not have any entry which might help, but starting from Delphi 6 there is a [FileVersion] section which contains the following values: Delphi 5 没有任何可能有帮助的条目,但从 Delphi 6 开始有一个 [FileVersion] 部分,其中包含以下值:

  • Delphi 5: N/A德尔福 5:不适用
  • Delphi 6: 6.0德尔福 6:6.0
  • Delphi 7: 7.0德尔福 7:7.0

So I guess that settles that, since older Delphi versions do not concern me.所以我想这就解决了,因为旧的 Delphi 版本与我无关。

For Delphi 2005 and 2006 there is a .bdsproj file in XML format containing a version entry: \\BorlandProject\\PersonalityInfo\\Option\\Option对于 Delphi 2005 和 2006,有一个 XML 格式的 .bdsproj 文件,其中包含一个版本条目:\\BorlandProject\\PersonalityInfo\\Option\\Option

In Delphi 2005 it looks like this:在 Delphi 2005 中,它看起来像这样:

<Option Name="Version" Type="String">1.0</Option>

In Delphi 2006 like this:在 Delphi 2006 中是这样的:

<Option Name="Version">1.0</Option>

So I could look whether the attribute "Type" exists and depending on that decide on Delphi 2005 or 2006. Could somebody please have a look at his Delphi 2005 and 2006 projects and verify this difference?所以我可以看看属性“Type”是否存在,并取决于它是在 Delphi 2005 还是 2006 上决定的。有人可以看看他的 Delphi 2005 和 2006 项目并验证这种差异吗? (Or do you maybe have got a better idea?) (或者你有更好的主意吗?)

edit: I just tried to verify this and found, that Delphi 2005 does not always add the Type-Attribute.编辑:我只是试图验证这一点,发现 Delphi 2005 并不总是添加类型属性。 So now I am stuck.所以现在我被困住了。

edit: Maybe the GUID stored there is unique to the Delphi version?编辑:也许存储在那里的 GUID 是 Delphi 版本独有的?

  • Delphi 2005: {87D03616-A4C7-4B5A-AF0F-0164EA60BC59}德尔福 2005:{87D03616-A4C7-4B5A-AF0F-0164EA60BC59}
  • Delphi 2006: {CFE1BEE6-6FDE-4241-8CA5-D38D14EAA768}德尔福 2006:{CFE1BEE6-6FDE-4241-8CA5-D38D14EAA768}

Somehow I doubt it, I am afraid that the GUID may represent different SKUs (Professional / Architect etc.).不知怎的,我对此表示怀疑,我担心 GUID 可能代表不同的 SKU(专业/架构师等)。 But maybe you could verify this?但也许你可以验证这一点?

Starting with Delphi 2007 there is a .dproj file in a different XML format.从 Delphi 2007 开始,有一个不同 XML 格式的 .dproj 文件。 The Delphi 2007 format does not contain any version entry I could find, but from Delphi 2009 on there seems to be the following entry: Delphi 2007 格式不包含我能找到的任何版本条目,但从 Delphi 2009 开始,似乎有以下条目:

\\project\\PropertyGroup\\ProjectVersion

These are the values I found in my .dproj files:这些是我在 .dproj 文件中找到的值:

  • Delphi 2007: N/A德尔福 2007:不适用
  • Delphi 2009: 12.0德尔福 2009:12.0
  • Delphi 2010: 12.0德尔福 2010:12.0
  • Delphi XE: 12.3德尔福 XE:12.3
  • Delphi XE2: 13.4德尔福 XE2:13.4

If these are correct, I could reliably determine Delphi 2007, XE and XE2.如果这些是正确的,我可以可靠地确定 Delphi 2007、XE 和 XE2。 But how do I distinguish between Delphi 2009 and 2010?但是我如何区分 Delphi 2009 和 2010 呢?

Also, these numbers look odd to me.此外,这些数字对我来说看起来很奇怪。 Does anybody know whether there are any differences between the various updates of Delphi, eg did the original Delphi XE2 release maybe start with 13.0 and with each update increment the number after the dot?有没有人知道Delphi 的各种更新之间是否有任何区别,例如原始Delphi XE2 版本是否可能从13.0 开始,并且每次更新都会增加点后的数字? But if that's the case, how did Delphi XE get 12.3?但如果是这样,Delphi XE 是如何得到 12.3 的呢?

(There is a similar question How can I tell what version of Delphi was used to create a project but the single answer there is quite limited.) (有一个类似的问题, 我如何知道使用哪个版本的 Delphi 创建一个项目,但那里的单一答案非常有限。)

Just in case anybody else needs this: I have just added a page to the Delphi Wiki which summarizes all answers and adds information for newer Delphi versions (currently up to Delphi 10.4.1).以防万一其他人需要这个:我刚刚在 Delphi Wiki 中添加了一个页面,该页面总结了所有答案并添加了更新的 Delphi 版本(目前最高为 Delphi 10.4.1)的信息。

I have now compared the .bdsproj files of Delphi 2005 and 2006 and there is no difference.我现在比较了 Delphi 2005 和 2006 的 .bdsproj 文件,没有区别。 Also, there is no difference between the .dproj files created by Delphi 2009 and 2010.此外,Delphi 2009 和 2010 创建的 .dproj 文件之间没有区别。

So the answer is:所以答案是:

  • if a .dproj file exists -> read \\project\\PropertyGroup\\ProjectVersion如果 .dproj 文件存在 -> 读取 \\project\\PropertyGroup\\ProjectVersion
    • empty -> Delphi 2007空 -> 德尔福 2007
    • 12.0 -> Delphi 2009 or 2010 12.0 -> 德尔福 2009 或 2010
    • 12.2 or 12.3 -> Delphi XE1 (according to Uwe Schuster) 12.2 或 12.3 -> Delphi XE1(根据 Uwe Schuster)
    • 13.4 -> Delphi XE2 13.4 -> 德尔福 XE2
  • if a .bdsproj file exists -> Delphi 2005 or 2006如果 .bdsproj 文件存在 -> Delphi 2005 或 2006
  • if a .dof file exists -> read [FileVersion]\\version如果 .dof 文件存在 -> 读取 [FileVersion]\\version
    • empty -> Delphi 5 (or possibly older)空 -> Delphi 5(或可能更旧)
    • 6.0 -> Delphi 6 6.0 -> 德尔福 6
    • 7.0 -> Delphi 7 7.0 -> 德尔福 7

Unfortunately this does not allow me to write a program that automatically starts the correct Delphi version for a given project.不幸的是,这不允许我编写一个程序来为给定的项目自动启动正确的 Delphi 版本。

Maybe I will let the program ask the user if there are two possibilities and store his answer in a .ini file so the next time the program knows which Delphi version to start.也许我会让程序询问用户是否有两种可能性并将他的答案存储在 .ini 文件中,以便程序下次知道要启动哪个 Delphi 版本。

btw: The reason I was looking into this is that I have several times accidentally opened Delphi 2007 projects with a later Delphi version which upgraded it and I had to reverse these changes by hand.顺便说一句:我正在研究这个的原因是我有几次不小心打开了 Delphi 2007 项目,后来的 Delphi 版本升级了它,我不得不手动撤销这些更改。 This has become so annoying that I wanted to prevent it by registering my own program as handler for .dpr files.这变得非常烦人,我想通过将我自己的程序注册为 .dpr 文件的处理程序来防止它。

The version numbers in the *PROJ files are not bound to releases or updates and not all versions hit the streets. *PROJ 文件中的版本号不受发布或更新的约束,并非所有版本都上市。

  • Delphi XE RTM used version 12.2 Delphi XE RTM 使用版本 12.2
  • Delphi XE Update #1 uses version 12.3 Delphi XE Update #1 使用版本 12.3
  • Delphi XE2 (RTM till Update #4) uses 13.4 Delphi XE2(RTM 直到更新 #4)使用 13.4

Just installed XE3 (RTM).刚刚安装了 XE3 (RTM)。 14.3 XE3 (C++ & Delphi) 14.3 XE3 (C++ & Delphi)

Today I find this topic googlin about Delphi edition (Standard, Professional, Enterprise).今天我发现这个关于 Delphi 版本(标准版、专业版、企业版)的主题谷歌搜索。

Anyway I checked some .dof files spread in mine machine and there is facts related to ancient delphi versions:无论如何,我检查了一些散布在我的机器中的 .dof 文件,并且有与古代 delphi 版本相关的事实:

if a .dof file exists -> read [Directories]/Packages如果 .dof 文件存在 -> 读取 [目录]/包

Delphi 3德尔福 3

[Directories]
OutputDir=
UnitOutputDir=
SearchPath=
Packages=VCLX30;VCL30;INETDB30;INET30;

Delphi 5德尔福 5

[Directories]
OutputDir=.
UnitOutputDir=.
PackageDLLOutputDir=.
PackageDCPOutputDir=.
SearchPath=
Packages=Vcl50;Inet50;Inetdb50;Vclx50;Indy50;

Additional info can be finded near end of dof file:附加信息可以在接近 dof 文件的末尾找到:

D3: D3:

[Excluded Packages]
C:\Program Files\Borland\Delphi 3\Bin\DCLDSS30.dpl=Delphi Decision Cube Components
C:\PROGRAM FILES\BORLAND\DELPHI 3\BIN\DCLTEE30.DPL=Delphi TeeChart Components

D5: D5:

[Excluded Packages]
$(DELPHI)\Bin\CorIde50.bpl=Borland Core IDE Package
$(DELPHI)\Bin\direct50.bpl=Borland Direct IDE Package

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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