VB.NET中DLL画面加载

主画面:


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 True

    End 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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值