C#使用C++的DLL产生的问题

来源:百度知道 编辑:UC知道 时间:2024/07/07 23:25:09
C++:
typedef struct
{
TCHAR guid[260];
} dev_node_s;

int get_dev_list(dev_node_s* *dev_list, int *num);

--------------------------------------------------------

C#:
[DllImport("gui_api.dll", EntryPoint = "get_dev_list", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public unsafe static extern IntPtr get_dev_list(这个参数在C#里咋定义?, int* num);

结构体:
public struct dev_node_s
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string guid;
}

unsafe
{
函数调用部分咋写?
}

调用C++的dll:
[DllImport(@"SuperVisor.dll")]
private extern static int InitSuperVisorDll(IntPtr Mainhwnd, IntPtr hwnd, string LedName, string LedIPaddress, UInt16 LedNetport, int LedWidth, int LedHeight);
然后就可以在下面的程序中调用InitSuperVisorDll了啊。

参看:http://www.cnblogs.com/gaoweipeng/archive/2009/04/05/1429704.html