12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using System;
- using System.Runtime.InteropServices;
- using System.Security;
- namespace PicView.Native
- {
- //https://msdn.microsoft.com/en-us/library/ms182161.aspx
- [SuppressUnmanagedCodeSecurity]
- internal static class NativeMethods
- {
- [DllImport("shlwapi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
- internal static extern int StrCmpLogicalW(string x, string y);
- [DllImport("User32.dll")]
- internal static extern bool SetCursorPos(int x, int y);
- // Used to check for wallpaper support
- [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool SystemParametersInfo(uint uiAction, uint uiParam,
- string pvParam, uint fWinIni);
- // file properties
- //http://stackoverflow.com/a/1936957
- private const int SW_SHOW = 5;
- private const uint SEE_MASK_INVOKEIDLIST = 12;
- [DllImport("shell32.dll", CharSet = CharSet.Auto)]
- private static extern bool ShellExecuteEx(ref SHELLEXECUTEINFO lpExecInfo);
- internal static bool ShowFileProperties(string Filename)
- {
- var info = new SHELLEXECUTEINFO();
- info.cbSize = Marshal.SizeOf(info);
- info.lpVerb = "properties";
- info.lpParameters = "details";
- info.lpFile = Filename;
- info.nShow = SW_SHOW;
- info.fMask = SEE_MASK_INVOKEIDLIST;
- return ShellExecuteEx(ref info);
- }
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
- internal struct SHELLEXECUTEINFO
- {
- public int cbSize;
- public uint fMask;
- public IntPtr hwnd;
- [MarshalAs(UnmanagedType.LPTStr)]
- public string lpVerb;
- [MarshalAs(UnmanagedType.LPTStr)]
- public string lpFile;
- [MarshalAs(UnmanagedType.LPTStr)]
- public string lpParameters;
- [MarshalAs(UnmanagedType.LPTStr)]
- public readonly string lpDirectory;
- public int nShow;
- public IntPtr hInstApp;
- public IntPtr lpIDList;
- [MarshalAs(UnmanagedType.LPTStr)]
- public readonly string lpClass;
- public IntPtr hkeyClass;
- public readonly uint dwHotKey;
- public IntPtr hIcon;
- public IntPtr hProcess;
- }
- [DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = true)]
- public static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);
- /// <summary>
- /// Used to disable Screensaver and Power options.
- /// </summary>
- internal const uint ES_CONTINUOUS = 0x80000000;
- internal const uint ES_SYSTEM_REQUIRED = 0x00000001;
- internal const uint ES_DISPLAY_REQUIRED = 0x00000002;
- [DllImport("kernel32.dll", SetLastError = true)]
- public static extern uint SetThreadExecutionState([In] uint esFlags);
- }
- }
|