最近在一个老外的程序中看到一段代码,其中使用了System.Runtime.InteropServices.MarshalAs方法进行托管代码与非托管代码之间封装数据,感觉很新颖。特意记录下来,供大家参考

[DllExport("ExpTest", CallingConvention = CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.LPWStr)]
public static string ExpTest([MarshalAs(UnmanagedType.LPWStr)] ref string sText, out int length)
{
    MessageBox.Show(sText, "ExpTest");
    length = sText.Length;
    return sText;
}

 

相关文章:

  • 2021-11-12
  • 2021-07-27
  • 2022-12-23
  • 2021-11-18
  • 2022-02-25
猜你喜欢
  • 2022-12-23
  • 2021-06-27
  • 2022-01-20
  • 2021-09-09
  • 2021-07-05
  • 2021-09-13
相关资源
相似解决方案