ComponentInstaller.CopyFromComponent(IComponent) 方法

定義

當在派生類別中覆寫時,會從指定元件複製安裝時所需的所有屬性。

public:
 abstract void CopyFromComponent(System::ComponentModel::IComponent ^ component);
public abstract void CopyFromComponent(System.ComponentModel.IComponent component);
abstract member CopyFromComponent : System.ComponentModel.IComponent -> unit
Public MustOverride Sub CopyFromComponent (component As IComponent)

參數

component
IComponent

要複製的元件。

範例

以下範例定義了一個類別,該類別 MyInstallClass建立事件日誌,並將事件日誌元件的屬性複製到 EventLogInstaller。 它也會檢查 是否 ServiceInstaller 能執行與 EventLogInstaller相同的安裝方式。

EventLogInstaller^ myEventLogInstaller = gcnew EventLogInstaller;
// Create a source for the specified event log, on local computer.
EventLog::CreateEventSource( "MyEventSource", "MyEventLog", "." );
// Create an event log instance and associate it with the log .
EventLog^ myEventLog = gcnew EventLog( "MyEventLog",".","MyEventSource" );
// Copy the properties that are required at install time from
// the event log component to the installer.
myEventLogInstaller->CopyFromComponent( myEventLog );
EventLogInstaller myEventLogInstaller = new EventLogInstaller();
// Create a source for the specified event log, on local computer.
EventLog.CreateEventSource("MyEventSource","MyEventLog", ".");
// Create an event log instance and associate it with the log .
EventLog myEventLog = new EventLog("MyEventLog", ".", "MyEventSource");
// Copy the properties that are required at install time from
// the event log component to the installer.
myEventLogInstaller.CopyFromComponent(myEventLog);
Dim myEventLogInstaller As New EventLogInstaller()
' Create a source for the specified event log, on local computer.
EventLog.CreateEventSource("MyEventSource", "MyEventLog", ".")
' Create an event log instance and associate it with the log .
Dim myEventLog As New EventLog("MyEventLog", ".", "MyEventSource")
' Copy the properties that are required at install time from
' the event log component to the installer.
myEventLogInstaller.CopyFromComponent(myEventLog)

備註

安裝程式應該會從活著的元件中取得所有資訊,並儲存在安裝時使用。

適用於