主画面:
Public Function fnc_LoadDll(ByVal strDllPath As String, ByVal strObjectName As String, _
ByVal intMenuNo As Integer, ByVal intSelectNo As Integer, _ByVal intOperationMode As Integer, _
ByVal intTantoshaninshoshiyokubun As Integer, _
ByVal strTantosya As String) As Boolean
Dim objTemp As Object
Dim strTemp As String
Dim strDllFullPath As String
Dim intPos As Integer
Dim strProductName As String
Try
' DLL路径
If String.IsNullOrEmpty(strDllPath) = False Then
strDllPath = strDllPath.ToUpper()
intPos = InStrRev(strDllPath, "DLL")
If intPos = 0 Then
strTemp = strDllPath & ".DLL"
Else
strTemp = ""
End If
Else
Return False
End If
strDllFullPath = System.IO.Path.GetFullPath(".\\") & strTemp
If False = System.IO.File.Exists(strDllFullPath) Then
Return False
End If
strProductName = strDllPath
Dim objAssem As System.Reflection.Assembly = System.Reflection.Assembly.LoadFrom(strTemp)
intPos = InStrRev(strDllPath, "\\")
If intPos = 0 Then
strTemp = strDllPath & "." & strObjectName
Else
strTemp = strDllPath.Substring(intPos)
strTemp = strTemp & "." & strObjectName
End If
'指定类型对象取得
Dim objAssType As Type = objAssem.GetType(strTemp)
' 指定类型对象实例化
objTemp = Activator.CreateInstance(objAssType)
objTemp.pintMenuNo = intMenuNo
objTemp.pintSelectNo = intSelectNo
objTemp.pintOperationMode = intOperationMode
objTemp.pintTantoshaninshoshiyokubun = intTantoshaninshoshiyokubun
objTemp.pstrTantosya = strTantosya
objTemp.pstrProductName = strProductName
objTemp.ShowForm()
Catch ex As Exception
LogUtil.Fatal(Me, ex)
Return False
End Try
Return TrueEnd Function
子画面:
Public Sub ShowForm()
Try
Dim objT1 As Threading.Thread
objT1 = New Threading.Thread(AddressOf DisPlay)
objT1.SetApartmentState(Threading.ApartmentState.STA)
objT1.Start()
Catch ex As Exception
LogUtil.Fatal(Me, ex)
Throw ex
End Try
End Sub
Public Sub DisPlay()
Me.ShowDialog()
End Sub