vb.net与matlab的混合编程

首先,使用deploytool工具或者命令行将matlab的m文件编译成类,结果产生动态链接库.dll文件和一些c#代码的类.

       第二步,将这些dll文件导入进去,并使用一些win32api函数,因为此m文件会产生figure窗口,这些api函数将此figure窗口嵌入到vb程序窗体里面.

      代码:

Imports System
Imports System.Runtime.InteropServices
Imports MathWorks.MATLAB.NET.Arrays
Imports MathWorks.MATLAB.NET.Utility
Imports SinImage.SinImage

Public Class SinForm
    Dim img As New SinImage.SinImage
    Dim FigureHwnd As IntPtr = IntPtr.Zero
    Public Declare Function SetParent Lib "user32" Alias "SetParent" _
    (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
    Public Declare Function GetWindowLong Lib "User32.Dll" Alias "GetWindowLongA" _
    (ByVal hWnd As System.IntPtr, ByVal nIndex As Integer) As Integer
    Public Declare Function SetWindowLong

你可能感兴趣的:(数学与计算)