Delphi 11兼容Windows XP  
官方Delphi 学习QQ群: 682628230(三千人)
频道

Delphi 11兼容Windows XP


正如您可能注意到的那样,Delphi 11 正式不再支持 Windows XP。您可以通过简单的设置使您的应用程序再次兼容 XP。

在 Project Options|Building|Delphi Compiler|Linking 中,将“Set OS Version fields in PE Headers”和“Set SubSystem Version fields in PE Headers”设置为“5.1”

————————————————

20210915110723622.png


除非您的应用程序使用 System.Threading.pas(TTask 等),否则您应该在 Windows XP 下运行它没有问题。但如果是这样,那么你必须调整这个单元文件。

线程对象实际上在其内部使用了新的 TThread.GetTickCount64 方法,该方法硬连接到 Windows API GetTickCount64,而 Windows XP API 中没有该方法。

从 Delphi 11 安装中的“source\rtl\common”文件夹中获取这个单元。在本单元的实现部分的开头声明新的本地函数,如下所示:


 


function _GetTickCount64: UInt64;

begin

if TOSVersion.Major<6 then

Result := TThread.GetTickCount

else

Result := TThread.GetTickCount64;

end;

and


replace all occurences of TThread.GetTickCount64 calls with _GetTickCount64.

For Win32 applications then copy this modified unit to \lib\win32\debug and \lib\win32\release folders in Delphi 11 installation and rename original System.Threading.dcu to e.g. _System.Threading.dcu.

Then build your project which uses System.Threading with Debug and Release configuration. New System.Threading.dcu should be created in mentioned folders. After this you should remove modified System.Threading.pas from these folders to prevent its recurrent compilation.

Now your Delphi 11 Win32 applications should run under Windows XP with no External Exception crash.


并将所有出现的 TThread.GetTickCount64 调用替换为 _GetTickCount64。对于 Win32 应用程序,然后将此修改后的单元复制到 Delphi 11 安装中的 \lib\win32\debug 和 \lib\win32\release 文件夹,并将原始 System.Threading.dcu 重命名为例如 _System.Threading.dcu。

然后构建您的项目,该项目使用 System.Threading 和 Debug 和 Release 配置。应在上述文件夹中创建新 System.Threading.dcu。在此之后,您应该从这些文件夹中删除修改后的 System.Threading.pas 以防止其重复编译。

现在您的 Delphi 11 Win32 应用程序应该可以在 Windows XP 下运行而不会出现外部异常崩溃。


以下来自2CC.COM 网友 bjlg (蓝天)


其实最好修改system.classes一个地方


class function TThread.GetTickCount64: UInt64;

{$IF Defined(MSWINDOWS)}

begin

   if(TOSVersion.Major<6 )then  

  Result := Winapi.Windows.GetTickCount;

  else  

  Result := Winapi.Windows.GetTickCount64;

end;

在dpr文件加进去:

{$SETPEOSVERSION 5.0}  

{$SETPESUBSYSVERSION 5.0}


————————————————

20210915110754628.jpg



推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.046952962875366 seconds