调用c++ DLL 返回结构体问题
(1)我要调用c++ 写的Setting.dll中的FindConverter函数,其返回得到的设备信息。
(2)程序能编译过,但执行的时候说堆栈溢出,可能有死循环。我用c++调用很正常。因为没有setting.dll的代码,所以没办法改写。请高人指教。
//程序源码如下
namespace ResetModal
{
public class Win32
{
[StructLayout(LayoutKind.Sequential)]
public struct CONVINFO
{
public string strMac;
public string strIP;
public UInt16 devType;
};
[DllImport(@"E:\study\ResetModal\ResetModal\Setting.dll", CharSet = CharSet.Auto)]
public static extern int FindConverter( CONVINFO [] pConvInfo, int count,bool bEnableMsg,Int32 timeout);
[DllImport(@"E:\study\ResetModal\ResetModal\Setting.dll", CharSet = CharSet.Auto)]
public static extern bool ResetConverter(string strMAC,bool bEnableMsg,Int32 timeout);
}
class Program
{
static void Main(string[] args)
{
//
int count = 200;
Win32.CONVINFO [] _convInfo=new Win32.CONVINFO[200];
{
Win32.FindConverter( _convInfo, count, true, 3000);
Win32.ResetConverter(_convInfo[0].strMac, true, 1000);
}
}
}
}