插件
Public Sub LoadAddins()
Dim asm As Reflection.Assembly
Dim addin As InterfaceDll.Interface1
Dim tab As TabPage
For Each dll As String In Directory.GetFiles(My.Application.Info.DirectoryPath, "ClassDll*.dll")
asm = Assembly.LoadFile(dll)
For Each typ As Type In asm.GetTypes()
If typ.IsClass AndAlso typ.IsPublic AndAlso typ.GetInterface("Interface1") IsNot Nothing Then '根据此接口来调用DLL
addin = Activator.CreateInstance(typ)
If addin IsNot Nothing Then
tab = New TabPage
tab.Text = addin.FormCaption
tab.Name = addin.FormCaption
tab.Controls.Add(addin)
tab.Controls(0).Dock = DockStyle.Fill
TabControl1.TabPages.Add(tab)
End If
End If
Next
Next
End Sub
Dim asm As Reflection.Assembly
Dim addin As InterfaceDll.Interface1
Dim tab As TabPage
For Each dll As String In Directory.GetFiles(My.Application.Info.DirectoryPath, "ClassDll*.dll")
asm = Assembly.LoadFile(dll)
For Each typ As Type In asm.GetTypes()
If typ.IsClass AndAlso typ.IsPublic AndAlso typ.GetInterface("Interface1") IsNot Nothing Then '根据此接口来调用DLL
addin = Activator.CreateInstance(typ)
If addin IsNot Nothing Then
tab = New TabPage
tab.Text = addin.FormCaption
tab.Name = addin.FormCaption
tab.Controls.Add(addin)
tab.Controls(0).Dock = DockStyle.Fill
TabControl1.TabPages.Add(tab)
End If
End If
Next
Next
End Sub