1.在工程目錄下建立文本檔案并改名為 app.manifest
,添加如下内容(直接複制粘貼即可)
app.manifest
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清單選項
如果想要更改 Windows 使用者帳戶控制級别,請使用
以下節點之一替換 requestedExecutionLevel 節點。n
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
指定 requestedExecutionLevel 元素将禁用檔案和系統資料庫虛拟化。
如果你的應用程式需要此虛拟化來實作向後相容性,則删除此
元素。
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 設計此應用程式與其一起工作且已針對此應用程式進行測試的
Windows 版本的清單。取消評論适當的元素,
Windows 将自動選擇最相容的環境。 -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- 訓示該應用程式可以感覺 DPI 且 Windows 在 DPI 較高時将不會對其進行
自動縮放。Windows Presentation Foundation (WPF)應用程式自動感覺 DPI,無需
選擇加入。選擇加入此設定的 Windows 窗體應用程式(目标設定為 .NET Framework 4.6 )還應
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 設定設定為 "true"。-->
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
<!-- 啟用 Windows 公共控件和對話框的主題(Windows XP 和更高版本) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>
2. 在工程目錄下建立文本檔案并改名為 app.rc
,添加如下内容(直接複制粘貼即可)
app.rc
1 24 app.manifest
3. 在工程目錄下打開CMD運作
brcc32 app.rc -32 app.res
4. 在主窗體代碼中增加
{$R app.res}
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnLzQjNwMjNyITMwEDNwAjMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
重新編譯既可以啦
注意:需要用管理者重新打開delphi32.exe
win7以上系統圖示右下角有個盾牌則表示成功!