Convert62.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace IPADDemo.Util
  8. {
  9. public class Convert62
  10. {
  11. [DllImport("EUtils.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
  12. private static extern IntPtr EStrToHex(string context);
  13. [DllImport("EUtils.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
  14. private static extern IntPtr EHexToStr(string context);
  15. /// <summary>
  16. /// 16进制转字符串
  17. /// </summary>
  18. /// <param name="context"></param>
  19. /// <returns></returns>
  20. public static string eStrToHex(string context) {
  21. IntPtr intptr = EStrToHex(context);
  22. string str = "" + Marshal.PtrToStringAnsi(intptr).Substring(0,344);
  23. return str;
  24. }
  25. /// <summary>
  26. /// 字符串转16进制
  27. /// </summary>
  28. /// <param name="context"></param>
  29. /// <returns></returns>
  30. public static string eHexToStr(string context)
  31. {
  32. IntPtr intptr = EHexToStr(context);
  33. string str = "" + Marshal.PtrToStringAnsi(intptr).Substring(0,232);
  34. return str;
  35. }
  36. }
  37. }