using System; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using System.Text; namespace LEContextMenuHandler { internal class NativeMethods { /// /// Retrieve the names of dropped files that result from a successful drag- /// and-drop operation. /// /// /// Identifier of the structure that contains the file names of the dropped /// files. /// /// /// Index of the file to query. If the value of this parameter is 0xFFFFFFFF, /// DragQueryFile returns a count of the files dropped. /// /// /// The address of a buffer that receives the file name of a dropped file /// when the function returns. /// /// /// The size, in characters, of the pszFile buffer. /// /// A non-zero value indicates a successful call. [DllImport("shell32", CharSet = CharSet.Unicode)] public static extern uint DragQueryFile( IntPtr hDrop, uint iFile, StringBuilder pszFile, int cch); /// /// Free the specified storage medium. /// /// /// Reference of the storage medium that is to be freed. /// [DllImport("ole32.dll", CharSet = CharSet.Unicode)] public static extern void ReleaseStgMedium(ref STGMEDIUM pmedium); /// /// Insert a new menu item at the specified position in a menu. /// /// /// A handle to the menu in which the new menu item is inserted. /// /// /// The identifier or position of the menu item before which to insert the /// new item. The meaning of this parameter depends on the value of /// fByPosition. /// /// /// Controls the meaning of uItem. If this parameter is false, uItem is a /// menu item identifier. Otherwise, it is a menu item position. /// /// /// A reference of a MENUITEMINFO structure that contains information about /// the new menu item. /// /// /// If the function succeeds, the return value is true. /// [DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool InsertMenuItem( IntPtr hMenu, uint uItem, [MarshalAs(UnmanagedType.Bool)] bool fByPosition, ref MENUITEMINFO mii); [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)] public static extern IntPtr CreatePopupMenu(); /// /// The DeleteObject function deletes a logical pen, brush, font, bitmap, /// region, or palette, freeing all system resources associated with the /// object. After the object is deleted, the specified handle is no longer /// valid. /// /// /// A handle to a logical pen, brush, font, bitmap, region, or palette. /// /// /// If the function succeeds, the return value is true. /// [DllImport("gdi32.dll", CharSet = CharSet.Unicode, SetLastError = true)] public static extern bool DeleteObject(IntPtr hObject); public static int HighWord(int number) { return (number & 0x80000000) == 0x80000000 ? number >> 16 : (number >> 16) & 0xffff; } public static int LowWord(int number) { return number & 0xffff; } } }