次の方法で共有


InstallerCollection.Item プロパティ

指定したインデックスにあるインストーラを取得または設定します。

[C#] C# では、このプロパティは InstallerCollection クラスのインデクサになります。

Public Default Property Item( _
   ByVal index As Integer _) As Installer
[C#]
public Installer this[intindex] {get; set;}
[C++]
public: __property Installer* get_Item(intindex);public: __property void set_Item(intindex,   Installer*);
[JScript]
returnValue = InstallerCollectionObject.Item(index);InstallerCollectionObject.Item(index) = returnValue;またはreturnValue = InstallerCollectionObject(index);InstallerCollectionObject(index) = returnValue;

[JScript] JScript では、この型で定義されている既定のインデックス プロパティを使用することができます。しかし、独自のインデックス プロパティを明示的に定義することはできません。ただし、このクラスの expando 属性を指定すると、既定のインデックス プロパティが提供されます。提供されるインデックス プロパティの型は Object 型であり、インデックス型は String になります。

引数 [JScript]

  • index
    取得または設定するインストーラの 0 から始まるインデックス。

パラメータ [Visual Basic, C#, C++]

  • index
    取得または設定するインストーラの 0 から始まるインデックス。

プロパティ値

指定したインデックスにあるインストーラを表す Installer

解説

指定した InstallerInstallerCollection 内に配置されている場合、その InstallerParent プロパティには、そのコレクションを格納している Installer が設定されます。

使用例

[Visual Basic, C#, C++] MyAssembly1.exeMyAssembly2.exeAssemblyInstaller インスタンスを作成する例を次に示します。これらのインスタンスは、 TransactedInstaller に追加されます。インストールされるアセンブリすべての名前が、コンソールに表示されます。インストール プロセスによって、 MyAssembly1.exeMyAssembly2.exe の両方がインストールされます。

 
Dim myTransactedInstaller As New TransactedInstaller()
Dim myAssemblyInstaller As AssemblyInstaller
Dim myInstallContext As InstallContext

' Create a instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'.
myAssemblyInstaller = New AssemblyInstaller("MyAssembly1.exe", Nothing)

' Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Add(myAssemblyInstaller)

' Create a instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'.
myAssemblyInstaller = New AssemblyInstaller("MyAssembly2.exe", Nothing)

' Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.  
myTransactedInstaller.Installers.Add(myAssemblyInstaller)

'Print the assemblies to be installed.
Dim myInstallers As InstallerCollection = myTransactedInstaller.Installers
Console.WriteLine(ControlChars.Newline + "Printing all assemblies to be installed")
Dim i As Integer
For i = 0 To myInstallers.Count - 1
   If myInstallers(i).GetType().Equals(GetType(AssemblyInstaller)) Then
      Console.WriteLine("{0} {1}", i + 1, CType(myInstallers(i), AssemblyInstaller).Path)
   End If
Next i

[C#] 
TransactedInstaller myTransactedInstaller = new TransactedInstaller();
AssemblyInstaller myAssemblyInstaller;
InstallContext myInstallContext;

// Create a instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'.
myAssemblyInstaller = 
   new AssemblyInstaller("MyAssembly1.exe", null);

// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Add(myAssemblyInstaller);

// Create a instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'.
myAssemblyInstaller = 
   new AssemblyInstaller("MyAssembly2.exe", null);

// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.  
myTransactedInstaller.Installers.Add(myAssemblyInstaller);

//Print the assemblies to be installed.
InstallerCollection myInstallers = myTransactedInstaller.Installers;
Console.WriteLine("\nPrinting all assemblies to be installed");
for(int i = 0; i < myInstallers.Count; i++)
{
   if((myInstallers[i].GetType()).Equals(typeof(AssemblyInstaller)))
   {
      Console.WriteLine("{0} {1}", i + 1, 
         ((AssemblyInstaller)myInstallers[i]).Path);
   }
}

[C++] 
TransactedInstaller* myTransactedInstaller = new TransactedInstaller();
AssemblyInstaller* myAssemblyInstaller;
InstallContext* myInstallContext;

// Create a instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'.
myAssemblyInstaller = new AssemblyInstaller(S"MyAssembly1.exe", 0);

// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller->Installers->Add(myAssemblyInstaller);

// Create a instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'.
myAssemblyInstaller = new AssemblyInstaller(S"MyAssembly2.exe", 0);

// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller->Installers->Add(myAssemblyInstaller);

//Print the assemblies to be installed.
InstallerCollection* myInstallers = myTransactedInstaller->Installers;
Console::WriteLine(S"\nPrinting all assemblies to be installed");
for (int i = 0; i < myInstallers->Count; i++) {
    if (dynamic_cast<AssemblyInstaller*>(myInstallers->Item[i])) {
        Console::WriteLine(S"{0} {1}", __box(i + 1),
            __try_cast<AssemblyInstaller*>(myInstallers->Item[i])->Path);
    }
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

InstallerCollection クラス | InstallerCollection メンバ | System.Configuration.Install 名前空間 | Installer