将项目从 Delphi 3 移至 Delphi 2010

发布于 2024-08-06 16:39:14 字数 480 浏览 3 评论 0原文

我被要求重新打开一个我在 1998/99 年用 Delphi 3 编写的项目,此后该项目一直稳定运行。我在一台老化的 Windows 98 机器上有 Delphi 3 代码库,它的存在只是为了让这个项目保持活力。显然,我希望在进行任何重大修改之前将源代码库带入 21 世纪。

我高兴地注意到,Delphi 2010(我目前使用的是 2007)声称能够从 Delphi 2 导入项目。有人有从 Delphi 3 导入大型项目的经验吗?我认为这是一个轻松的过渡还是困难的过渡?

此外,原始项目还使用了第三方组件,包括 DBISAM、WPTools 和 TMS Planner。我注意到所有这些仍然可用于最新版本的 Delphi。假设我首先将新版本安装到 Delphi 2010 中,我是否可以期望应用程序中使用这些组件的部分也能被翻译?我知道自原始应用程序中使用的版本以来,至少 WPTools 已经更改了它的一些组件结构和接口,显然我将在那里进行一些重新编码,但是程序的这些部分的失败是否会阻止我的代码库正在升级吗?

I've been asked to re-open a project I wrote in 1998/99 in Delphi 3 and which has been running stably since then. I have the Delphi 3 code base on an aging Windows 98 machine which exists only to keep this project alive. Obviously, I'd like to bring the source code base into the 21st century before undertaking any major revisions.

I note happily that Delphi 2010 (I'm currently on 2007) claims to be able to import projects from Delphi 2 on. Does anyone have any experience importing large projects from Delphi 3? Can I expect this to be an easy transition, or a difficult one?

In addition the original project makes use of third party components including DBISAM, WPTools, and TMS Planner. I note that all of these are still available for the latest release of Delphi. Assuming I first install the new versions into Delphi 2010 can I expect the parts of my application that use these components to be translated as well? I know that at least WPTools has changed some of its component structures and interfaces since the version used in the original application and obviously I'll have some recoding to do there, but will the failure of those parts of the program prevent my code base from being upgraded at all?

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

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

发布评论

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

评论(7

冧九 2024-08-13 16:39:14

应该很有可能进行这种迁移,并且根据代码的编写方式,它可能会很痛苦,也可能不会很痛苦。不幸的是,在您开始迁移过程之前,很难说出具体是什么。

我要做的第一件事是确保所有 DFM 文件都转换为其文本表示形式。我相信在 Delphi 的更高版本中这被设置为默认值,但我记得 Delphi 3 使用了二进制格式。 delphi 3 bin 目录中应该有一个名为 DFMConvert 的实用程序文件或其他文件,它允许您将 DFM 转换为文本。您想要执行此操作的原因是为了确保在由于未加载组件而必须对 DFM 执行手动编辑时您可以读取源代码。您不仅会跳转 Delphi 的版本,还会跳转您使用的每个组件的版本,并且可能存在一些不兼容性,从而导致组件加载失败。我发现如果是这种情况并且您有一个“新”版本,则直接使用编辑 DFM 源并将测试表单及其上的组件与旧版本包含的内容进行比较。删除任何不合适的内容(或重命名),然后尝试再次加载表单。

正如 Frabricio 提到的,如果您使用变体,那么您将需要对您的使用条款进行细微调整。

好消息是,一旦纠正了组件/使用子句,您的代码本身应该可以正常工作。如果您直接进入 Delphi 2010,您唯一的其他问题将是 Unicode,并且编译器通过错误和警告向您指出所有这些问题,做得非常出色。

It should be very possible to do this migration, and depending on how your code is written, it may either be painful or painless. Unfortunately its not easy to say which until you start the migration process.

The first thing i would do would be to make sure that ALL DFM files are converted to their text representation. This I believe was set to default in later versions of Delphi but as I recall Delphi 3 used a binary format. There should be a utility file named DFMConvert or something in the delphi 3 bin directory which allows you to convert a DFM to text. The reason you will want to do this is to insure that you can read the source if you have to perform a hand edit of the DFM due to a component not loading. Not only are you jumping versions of Delphi, but you also are jumping versions of EVERY component you use and there may be a few incompatibilities that may cause a component to fail loading. I have found if this is the case and you have a "new" version, then use the edit the DFM source directly and compare a test form with the component on it against what your old version contains. Remove anything (or rename) that is out of place and then attempt to load the form again.

As Frabricio mentioned, if you use variants then you will need to make minor adjustments to your uses clause.

The good news is that your code itself should work fine once you get the components/uses clause corrected. If you go directly to Delphi 2010, your only other issue would be Unicode and the compiler does a fantastic job of pointing all of them out to you via errors and warnings.

娜些时光,永不杰束 2024-08-13 16:39:14

由于您有 D2007 并假设所有这些组件集也都带有 D2007 dcus,我将
建议您首先尝试在 D2007 上重新打开代码库。之后,转到 D2010,因为实际 VCL 的 Unicode 功能 - 这可能会产生一些迁移问题(我不会在这里讨论,因为它在网络上和 此处)。

我之所以这么说,是因为在 D5 和 D7 之间(未准确记录)发生了 rtl 的单元重组(随着 Variants.pas 单元的创建和许多 OTAPI 单元更改名称等)。所以这就是你出现的第一个问题。编辑:不仅变体被重新定位,而且许多 IDE 集成内容也被重新定位 - 以避免部署未经许可的代码。如果您有一些 OTAPI 代码(例如,允许在继承表单上发布属性的代码),则需要将其重新定位到包项目。

正如skramradt所说,你可能必须处理二进制 DFM 的事情……

之后,如果一切正常,就转到 Unicode 的事情。根据应用程序的不同,这可能很简单,也可能很困难。对于我的人来说,并不是很烦恼。但我知道还有其他人面临着比我更大的问题。

As you have D2007 and assuming all these component sets come with D2007 dcus as well, I'll
advise you to first try reopen the codebase on D2007. And after that, go to D2010 because of the Unicode feature of the actual VCL - which can create some migration problems (which I'll not discuss here because it's deeply discussed on the web and here on SO).

I'd say that because somewhere between D5 and D7 (don't record exactly) happened an unit reorganization of the rtl (with the creation of the Variants.pas unit and many OTAPI units changed names, etc). So that will be where your first problems arise. EDIT:Not only Variants got relocated, but much IDE integration stuff too - to avoid unlicensed code to get deployed. If you have some OTAPI code (for example, code that allows published properties on inherited forms), it'll need to be relocated to a package project.

As skramradt said, you may have to deal with the binary DFM thing....

After that, if all works, go to the Unicode thing. Depending on the app, it can be easy or not. For mine ones, not of great annoyance. But I know there are others facing greater problems with it than me.

梦行七里 2024-08-13 16:39:14

以下是我们关于升级到 Delphi 2010 的一些注意事项

  1. Delphi2010 中编译的可执行文件的字节数比 Delphi3 编译的可执行文件的字节数多大约 3 倍。
  2. 任何编译都会导致比 Delphi3 多出一大堆警告和提示。好的做法是删除所有提示和警告。
  3. 我发现几个损坏的 Pascal 文件在 Delphi3 中可以正常编译,但在 Delphi2010 中却不能。从视觉上看没有任何问题或差异。然而,编译错误清楚地表明错误行号错误。在我的示例中,问题与 CR/LF 有关,在我的 Delphi 中只有 CR。这是一个很难解决的问题,也是一个真正的浪费时间的问题。但是,可以在记事本或使用 WinHex.exe 中查看文本。我编写了一个名为 PARSER.EXE 的程序,它允许识别这些控制字符。一旦您知道控制字符在哪里,这是在记事本中编辑这些文件的最佳方法。
  4. AnsiString。 Delphi 2010 现在使用 AnsiStrings、MBCS 和 WideStrings (UniCode)。与使用 ASCII 字符串的 Delphi 3 相反。标准 Delphi 2010 实现使用字符串作为 Unicode,使用字符作为 16 位字符。现在需要确保许多 8 位 ASCII 字符串被定义为 AnsiStrings。显然,具有用 PChar 定义的接口的旧 dll 现在需要 PAnsiChar。
  5. 由于以下原因,Delphi 平台之间的代码不可互换。Delphi
  6. 2010 具有额外的函数和变量类型,例如 AnsiChar、AnsiStrings。
  7. 这些表单在版本之间不兼容,因为后面的 Delphi 版本有额外的属性。
  8. dcus 版本之间不兼容。
  9. 这些软件包在版本之间不兼容。 Delphi 2010 中没有 Crystal Reports,因此您可能需要单独购买。使用的任何其他软件包也可能需要付费升级。
  10. 许多函数,例如 Readfile、Writefile、GettickCount 现在都坚持参数为 DWORD,而 Delphi3 则更加宽容。其中一些功能与更高的磁盘容量相关。
  11. 弹出菜单。它们有一个名为 AUTOHOTKEY 的新属性。这应该设置为手动。如果将此设置为默认值,则标题将带有“&”插入以提供热键功能。
  12. 光标。使用游标的方法已更改。
  13. 看来 Delphi2010 增加了一大堆功能,但代价是使其更易于使用。也许 Delphi 3 拥有更好、更易于使用的界面。
  14. 帮助。也许比 Delphi 3 更好。但是在尝试查找帮助信息时似乎消失了几分钟。交互式帮助很麻烦。
  15. BorlandMM.dll 不适用于带有 Delphi 2010 应用程序的 Windows 2000。因此,如果您想使用此 dll,您可能必须升级大量 PC。

我有大约 100 个应用程序 dll 和 COM 服务器需要升级。调试工作大概需要 12 周左右。希望这有帮助。

Here are a few notes we made regarding upgrading to Delphi 2010

  1. The executables complied in Delphi2010 are about 3 times more bytes than those compiled by Delphi3.
  2. Any compilation will result in a whole heap more warnings and hints than Delphi3. Good practice is to remove all hints and warnings.
  3. I have found several corrupted Pascal file that compiles fine in Delphi3 but not in Delphi2010. Visually there appear no problems or difference. However compilation errors clearly indicate the error on the wrong line number. In my examples the issue was related to CR/LF, in my Delphi there was only a CR. A difficult problem to solve and a real time waster. However the text may be viewed in Notepad or using WinHex.exe. I have written a program called PARSER.EXE, which allows these control characters to be identified. This is the best way to edit these files in Notepad once you know where the control characters are.
  4. AnsiString. Delphi 2010 now uses AnsiStrings, MBCS and WideStrings, (UniCode). As opposed to Delphi 3 which used ASCII strings. The standard Delphi 2010 implementation uses strings as Unicode and Chars as 16 bit characters. It is now necessary to ensure that many 8 bit ASCII strings are defined as AnsiStrings. Obviously older dlls that had interfaces defined with PChars now require PAnsiChar.
  5. The code is not interchangeable between the Delphi platforms for the following reasons
  6. Delphi 2010 has extra functions and variable types such as AnsiChar, AnsiStrings.
  7. The forms are not compatible between versions because latter Delphi versions have extra properties.
  8. The dcus are not compatible between versions.
  9. The packages are not compatible between versions. There is no Crystal Reports in Delphi 2010 so you may need to purchase this separately. Any other packages that were used may also require upgrading, at cost.
  10. Many functions, such as Readfile, Writefile, GettickCount now insist on parameters as DWORDs, whereas Delphi3 was more tolerant. Some of these functions are associated with higher disk capacities.
  11. Popup Menus. These have a new property called AUTOHOTKEY. This should be set to manual. If this is set as default, the captions will have ‘&’ inserted to provide hot key functionality.
  12. Cursors. The method for using cursors has changed.
  13. It appears that Delphi2010 has a whole heap more features that have been added at the expense of making it simpler to use. Probably Delphi 3 had a better and more easy to use interface.
  14. Help. Maybe better than Delphi 3. But seems to disappear for some minutes trying to find help information. Interactive help is a nuisance.
  15. BorlandMM.dll does not work on Windows 2000 with Delphi 2010 Applications. So you may have to upgrade a load of PCs if you want to use this dll.

I have about 100 applications dlls and COM servers to upgrade. Probably about 12 weeks work with commissioning. Hope this helps.

|煩躁 2024-08-13 16:39:14

只是为了让您放心,我最近将我正在开发的软件从 Delphi 4 转换为 Delphi 2009 以获得 Unicode 功能,我遇到了很多问题,但它们都在几周内得到解决。

需要注意的一件事:如果您使用任何第 3 方软件包,请确保它们有可用的 Delphi 2010 版本,您可以在转换之前升级到该版本。 Delphi 2009 没问题,但我不会尝试在 D2010 中使用旧包。

Just to reassure you, I recently converted the software I am developing from Delphi 4 to Delphi 2009 to gain Unicode capabilities, and I had a number of issues, but they were all solvable within a couple of weeks.

One thing to note: If you use any 3rd party packages, make sure they have a Delphi 2010 version available that you can upgrade to before you convert. Delphi 2009 would be okay, but I would not try to use older packages in D2010.

§对你不离不弃 2024-08-13 16:39:14

关于将D3迁移到D2010我不能说太多,但我最近成功地将D6迁移到D2010。首先,我所做的就是确保您在 D3 中使用的所有第三方组件在 D2010 中也可用。重新编译从 D6 到 D2010 的任何定制组件。加载我的 D6 源代码并编译。处理所有 unicode 问题。一一处理所有编译器错误...全部在大约 3 天内完成(大约 30000 行代码)

I can't say much about migrating D3 to D2010, but I've recently migrated D6 to D2010 successfully. To begin with, what I did was to make sure that all third party components that you've used in D3 are also available in D2010. Recompile any custom built components from D6 to D2010. Loaded my D6 source code, and compile. Handle all unicode issues. Handle all the compiler errors one by one... all done in about 3 days (approx 30000 lines of code)

黑白记忆 2024-08-13 16:39:14

我有一个 Delphi 7 项目组,Delphi 2010 很容易升级。
不幸的是,在下次启动新创建的 Delphi 2010 项目组文件时,
加载项目后 IDE 就会崩溃并消失。没有显示异常,没有
错误消息。我的解决方法是始终使用 Delphi 7 文件并让 Delphi 2010
无需使用新创建的项目文件即可升级任何内容。

I have a Delphi 7 project group which Delphi 2010 readily upgraded.
Unfortunately, during the next start with the newly created Delphi 2010 project group files,
the IDE just crashes and vanishes after loading the project. No exceptions are shown, no
error messages. My workaround is using the Delphi 7 file all the time and let Delphi 2010
upgrade whatever it likes to without using the newly created project files.

多彩岁月 2024-08-13 16:39:14

我证实了其他人的说法:就您自己的代码而言,将 D3 应用程序转换为 D2010 通常很容易。

我看到两个困难:

  1. 您使用 String 作为通用缓冲区,存储字符以外的东西。
  2. 您的代码假设 sizeof(char) 为 1,即应使用 SizeOf() 时使用 Length(),反之亦然。

最困难的部分是第三方组件。

看起来您使用的所有组件在 D2010 中仍然存在,这是一个很好的点。但很可能他们的界面已经改变,当然需要一些代码更改。

I confirm what the others are saying: converting a D3 application to D2010 is usually easy as far as your own code is concerned.

I see two difficulties:

  1. You used String as general buffer, storing something else than characters.
  2. Your code assume that sizeof(char) is 1, that is use Length() when SizeOf() should be used or the reverse.

The most difficult part are the 3rd party components.

It looks like all components you are using still exists for D2010, that is a good point. But it is likely that their interface has been changed and of course will require some code changes.

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