使用私人元件修正現有的應用程式
從 Windows XP 開始,您可以建立私人元件,並將其提供給特定應用程式使用。 這項功能可用來修正與更新不相容的應用程式。 例如,升級作業系統之後,與最新版本MSVCRT.DLL不相容的應用程式。 在此情況下,您沒有取代系統版本的選項,因為MSVCRT.DLL是 Windows 受保護的檔案。 您不必重寫應用程式以使用新版本的 MSVCRT,而是可以建立 MSVCRT 的私人元件,並在您的應用程式資料夾中安裝此元件。 請注意,並非所有共用元件都是適合用於私人並存元件的候選項目,而且某些元件具有可安裝元件的授許可權制。 元件必須符合並存元件的準則。 詢問元件的發行者是否可以提供適當的元件。
私用元件的資訊清單和應用程式的資訊清單應該都安裝在與應用程式可執行檔相同的資料夾中。 當應用程式執行時,它會參考應用程式資訊清單,並將私用的 MSVCRT 版本載入應用程式。
在此範例中,私用元件會包含MSVCRT.DLL和MSVCIRT.DLL,如下列元件資訊清單所示:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32"
name="Microsoft.Windows.PrivateCPlusPlusRuntime"
version="6.0.0.0"
processorArchitecture="x86"/>
<file name="msvcrt.dll"/>
<file name="msvcirt.dll"/>
</assembly>
以下是可能的應用程式資訊清單範例。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="x86"
name="APPLICATION"
type="win32"
/>
<description>Description of Application</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.PrivateCPlusPlusRuntime"
version="6.0.0.0"
processorArchitecture="x86"/>
</dependentAssembly>
</dependency>
</assembly>