MyDll.cs 843 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using RGiesecke.DllExport;
  4. namespace Mydll
  5. {
  6. public class Mydll
  7. {
  8. [DllExport("MyDllFunc", CallingConvention=CallingConvention.StdCall)]
  9. public static void MyDllFunc(IntPtr hWnd, [MarshalAs(UnmanagedType.LPStr)] string text, [MarshalAs(UnmanagedType.LPStr)] string caption, int options)
  10. {
  11. MessageBox(hWnd, text, caption, options);
  12. }
  13. [DllExport("MyDllFuncW", CallingConvention=CallingConvention.StdCall)]
  14. public static void MyDllFuncW(IntPtr hWnd, string text, string caption, int options)
  15. {
  16. MessageBox(hWnd, text, caption, options);
  17. }
  18. [DllImport("user32.dll", CharSet=CharSet.Auto)]
  19. static extern int MessageBox(IntPtr hWnd, String text, String caption, int options);
  20. }
  21. }