OpenFileName.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4. using System.Runtime.InteropServices;
  5. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
  6. public class OpenFileName
  7. {
  8. public int structSize = 0;
  9. public IntPtr dlgOwner = IntPtr.Zero;
  10. public IntPtr instance = IntPtr.Zero;
  11. public String filter = null;
  12. public String customFilter = null;
  13. public int maxCustFilter = 0;
  14. public int filterIndex = 0;
  15. public String file = null;
  16. public int maxFile = 0;
  17. public String fileTitle = null;
  18. public int maxFileTitle = 0;
  19. public String initialDir = null;
  20. public String title = null;
  21. public int flags = 0;
  22. public short fileOffset = 0;
  23. public short fileExtension = 0;
  24. public String defExt = null;
  25. public IntPtr custData = IntPtr.Zero;
  26. public IntPtr hook = IntPtr.Zero;
  27. public String templateName = null;
  28. public IntPtr reservedPtr = IntPtr.Zero;
  29. public int reservedInt = 0;
  30. public int flagsEx = 0;
  31. }
  32. public class DllTest
  33. {
  34. [DllImport("Comdlg32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)] public static extern bool GetOpenFileName([In, Out] OpenFileName ofn); public static bool GetOpenFileName1([In, Out] OpenFileName ofn) { return GetOpenFileName(ofn); }
  35. [DllImport("Comdlg32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)] public static extern bool GetSaveFileName([In, Out] OpenFileName ofn); public static bool GetSaveFileName1([In, Out] OpenFileName ofn) { return GetSaveFileName(ofn); }
  36. }