PropertiesDialog.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace BulePointLilac.Methods
  4. {
  5. public static class PropertiesDialog
  6. {
  7. public static bool Show(string filePath)
  8. {
  9. SHELLEXECUTEINFO info = new SHELLEXECUTEINFO
  10. {
  11. lpVerb = "Properties",
  12. //lpParameters = "详细信息";//显示选项卡,此处有语言差异
  13. lpFile = filePath,
  14. nShow = SW_SHOW,
  15. fMask = SEE_MASK_INVOKEIDLIST,
  16. cbSize = CbSize
  17. };
  18. return ShellExecuteEx(ref info);
  19. }
  20. private const int SW_SHOW = 5;
  21. private const uint SEE_MASK_INVOKEIDLIST = 12;
  22. private static readonly int CbSize = Marshal.SizeOf(typeof(SHELLEXECUTEINFO));
  23. [DllImport("shell32.dll", CharSet = CharSet.Auto)]
  24. private static extern bool ShellExecuteEx(ref SHELLEXECUTEINFO lpExecInfo);
  25. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
  26. private struct SHELLEXECUTEINFO
  27. {
  28. public int cbSize;
  29. public uint fMask;
  30. public IntPtr hwnd;
  31. [MarshalAs(UnmanagedType.LPTStr)]
  32. public string lpVerb;
  33. [MarshalAs(UnmanagedType.LPTStr)]
  34. public string lpFile;
  35. [MarshalAs(UnmanagedType.LPTStr)]
  36. public string lpParameters;
  37. [MarshalAs(UnmanagedType.LPTStr)]
  38. public string lpDirectory;
  39. public int nShow;
  40. public IntPtr hInstApp;
  41. public IntPtr lpIDList;
  42. [MarshalAs(UnmanagedType.LPTStr)]
  43. public string lpClass;
  44. public IntPtr hkeyClass;
  45. public uint dwHotKey;
  46. public IntPtr hIcon;
  47. public IntPtr hProcess;
  48. }
  49. }
  50. }