Miguel de Icaza在它的blog"C#'s Dynamic in Mono"中演示了在Mono上通过dymamic简化Pinvoke调用。

    dynamic d = new PInvoke("libc");
    d.printf("I have been clicked %d times", times);

在这种方式下,无需声明函数类型,非常直接。

在这个基础上,zhongzf进一步完善了这个方法,增加了返回值的支持,和refout属性参数的支持。

    dynamic user32 = new DynamicDllImport("user32.dll", callingConvention: CallingConvention.Winapi);
    user32.MessageBox(0, "Hello World", "Platform Invoke Sample", 0);

这个项目在google上开源的http://code.google.com/p/dynamicdllimport/,感兴趣的朋友可以看一下。

相关文章:

  • 2022-12-23
  • 2021-05-07
  • 2021-11-13
  • 2021-09-02
  • 2021-10-18
  • 2021-05-30
  • 2022-01-19
  • 2022-12-23
猜你喜欢
  • 2022-02-24
  • 2021-08-05
  • 2021-10-05
  • 2021-10-21
  • 2022-12-23
  • 2021-10-09
  • 2022-01-12
相关资源
相似解决方案