import的方法调用dll和动态调用有什么区别?
原来静态调用:
#region struc declare const int MaxSensorCountPerChannel = 30;
const int MaxFreq = 150;
const int MaxChannelNum = 11;
[StructLayout(LayoutKind.Sequential)]
private struct SensorList
{
public int nSensorCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxSensorCountPerChannel)]
public float[] fWaveLengthVec;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxSensorCountPerChannel)]
public float[] fPowerDBVec;
}
[StructLayout(LayoutKind.Sequential)]
private struct PerChannel
{
public int nChNum;
public int nFreq;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxFreq)]
public SensorList[] tSensorListVec;
}
#endregion #region import dll
[DllImport("ReadData.dll")]
private static extern int SEN_Init(); [DllImport("ReadData.dll")]
private static extern void SEN_Close(); [DllImport("ReadData.dll")]
private static extern void SEN_ReadDSPData(IntPtr pp); [DllImport("ReadData.dll")]
private static extern bool SEN_IsConnected(); [DllImport("ReadData.dll")]
private static extern int SEN_SendParaData();如何改成动态调用?
原来静态调用:
#region struc declare const int MaxSensorCountPerChannel = 30;
const int MaxFreq = 150;
const int MaxChannelNum = 11;
[StructLayout(LayoutKind.Sequential)]
private struct SensorList
{
public int nSensorCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxSensorCountPerChannel)]
public float[] fWaveLengthVec;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxSensorCountPerChannel)]
public float[] fPowerDBVec;
}
[StructLayout(LayoutKind.Sequential)]
private struct PerChannel
{
public int nChNum;
public int nFreq;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxFreq)]
public SensorList[] tSensorListVec;
}
#endregion #region import dll
[DllImport("ReadData.dll")]
private static extern int SEN_Init(); [DllImport("ReadData.dll")]
private static extern void SEN_Close(); [DllImport("ReadData.dll")]
private static extern void SEN_ReadDSPData(IntPtr pp); [DllImport("ReadData.dll")]
private static extern bool SEN_IsConnected(); [DllImport("ReadData.dll")]
private static extern int SEN_SendParaData();如何改成动态调用?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货