C#调用DLL之string转换成TCHAR

在C#调用DLL(c++编写的)时,经常会遇上参数为TCHAR,只需要在string前加上[MarshalAs(UnmanagedType.LPWStr)]即可。

例如:

public delegate int LMC1_INITIAL([MarshalAs(UnmanagedType.LPWStr)] string strEzCadPath,//ezcad的工作目录
                                            int bTestMode,//是否是测试模式
                                            IntPtr hOwenWnd);//父窗口

猜你喜欢

转载自blog.csdn.net/weixin_42116284/article/details/80735994