File: System\Design\UnsafeNativeMethods.cs
Project: System.Design.dll (System.Design)
#region Assembly System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Design.dll
#endregion
 
using System.Runtime;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Security;
using System.Text;
 
namespace System.Design
{
    [SuppressUnmanagedCodeSecurity]
    internal class UnsafeNativeMethods
    {
        [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
        public UnsafeNativeMethods();
 
        public static IntPtr BeginPaint(IntPtr hWnd, ref PAINTSTRUCT lpPaint);
        public static IntPtr CallNextHookEx(HandleRef hhook, int code, IntPtr wparam, IntPtr lparam);
        public static int ClientToScreen(HandleRef hWnd, POINT pt);
        public static ILockBytes CreateILockBytesOnHGlobal(HandleRef hGlobal, bool fDeleteOnRelease);
        public static bool DestroyIcon(HandleRef hIcon);
        public static bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT lpPaint);
        public static IntPtr ExtractIcon(HandleRef hMod, string exeName, int index);
        public static IntPtr GetActiveWindow();
        public static IntPtr GetDC(HandleRef hWnd);
        public static IntPtr GetFocus();
        public static int GetMessageTime();
        public static IntPtr GetStockObject(int nIndex);
        public static IntPtr GetWindowLong(HandleRef hWnd, int nIndex);
        public static IntPtr GetWindowLong32(HandleRef hWnd, int nIndex);
        public static IntPtr GetWindowLongPtr64(HandleRef hWnd, int nIndex);
        public static int GetWindowText(HandleRef hWnd, StringBuilder lpString, int nMaxCount);
        public static int GetWindowThreadProcessId(HandleRef hWnd, out int lpdwProcessId);
        public static bool IsChild(HandleRef hWndParent, HandleRef hwnd);
        public static IntPtr LresultFromObject(ref Guid refiid, IntPtr wParam, IntPtr pAcc);
        public static int MsgWaitForMultipleObjectsEx(int nCount, IntPtr pHandles, int dwMilliseconds, int dwWakeMask, int dwFlags);
        public static void NotifyWinEvent(int winEvent, HandleRef hwnd, int objType, int objID);
        public static IntPtr PostMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam);
        public static int ReadClassStg(HandleRef pStg, ref Guid pclsid);
        public static int ReleaseDC(HandleRef hWnd, HandleRef hDC);
        public static IntPtr SendMessage(IntPtr hwnd, int msg, bool wparam, int lparam);
        public static IntPtr SetActiveWindow(HandleRef hWnd);
        public static IntPtr SetFocus(HandleRef hWnd);
        public static IntPtr SetWindowLong(HandleRef hWnd, int nIndex, HandleRef dwNewLong);
        public static IntPtr SetWindowLongPtr32(HandleRef hWnd, int nIndex, HandleRef dwNewLong);
        public static IntPtr SetWindowLongPtr64(HandleRef hWnd, int nIndex, HandleRef dwNewLong);
        public static IntPtr SetWindowsHookEx(int hookid, HookProc pfnhook, HandleRef hinst, int threadid);
        public static IStorage StgCreateDocfileOnILockBytes(ILockBytes iLockBytes, int grfMode, int reserved);
        public static bool UnhookWindowsHookEx(HandleRef hhook);
 
        [Flags]
        public enum BrowseInfos
        {
            ReturnOnlyFSDirs = 1,
            DontGoBelowDomain = 2,
            StatusText = 4,
            ReturnFSAncestors = 8,
            EditBox = 16,
            Validate = 32,
            NewDialogStyle = 64,
            UseNewUI = 80,
            AllowUrls = 128,
            BrowseForComputer = 4096,
            BrowseForPrinter = 8192,
            BrowseForEverything = 16384,
            ShowShares = 32768
        }
 
        [Guid("0000000A-0000-0000-C000-000000000046")]
        [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        public interface ILockBytes
        {
            void Flush();
            void LockRegion(long libOffset, long cb, int dwLockType);
            void ReadAt(long ulOffset, IntPtr pv, int cb, int[] pcbRead);
            void SetSize(long cb);
            void Stat(STATSTG pstatstg, int grfStatFlag);
            void UnlockRegion(long libOffset, long cb, int dwLockType);
            void WriteAt(long ulOffset, IntPtr pv, int cb, int[] pcbWritten);
        }
        [Guid("00000002-0000-0000-c000-000000000046")]
        [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        public interface IMalloc
        {
            IntPtr Alloc(int cb);
            int DidAlloc(IntPtr pv);
            void Free(IntPtr pv);
            int GetSize(IntPtr pv);
            void HeapMinimize();
            IntPtr Realloc(IntPtr pv, int cb);
        }
        [Guid("00020D03-0000-0000-C000-000000000046")]
        [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        public interface IRichEditOleCallback
        {
        }
        [Guid("00020D03-0000-0000-C000-000000000046")]
        [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        public interface IRichTextBoxOleCallback
        {
            int ContextSensitiveHelp(int fEnterMode);
            int DeleteObject(IntPtr lpoleobj);
            int GetClipboardData(CHARRANGE lpchrg, int reco, IntPtr lplpdataobj);
            int GetContextMenu(short seltype, IntPtr lpoleobj, CHARRANGE lpchrg, out IntPtr hmenu);
            int GetDragDropEffect(bool fDrag, int grfKeyState, ref int pdwEffect);
            int GetInPlaceContext(IntPtr lplpFrame, IntPtr lplpDoc, IntPtr lpFrameInfo);
            int GetNewStorage(out IStorage ret);
            int QueryAcceptData(IDataObject lpdataobj, IntPtr lpcfFormat, int reco, int fReally, IntPtr hMetaPict);
            int QueryInsertObject(ref Guid lpclsid, IntPtr lpstg, int cp);
            int ShowContainerUI(int fShow);
        }
        [Guid("0000000B-0000-0000-C000-000000000046")]
        [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        public interface IStorage
        {
            void Commit(int grfCommitFlags);
            void CopyTo(int ciidExclude, Guid[] pIIDExclude, IntPtr snbExclude, IStorage stgDest);
            IStorage CreateStorage(string pwcsName, int grfMode, int reserved1, int reserved2);
            IStream CreateStream(string pwcsName, int grfMode, int reserved1, int reserved2);
            void DestroyElement(string pwcsName);
            void EnumElements(int reserved1, IntPtr reserved2, int reserved3, out object ppVal);
            void MoveElementTo(string pwcsName, IStorage stgDest, string pwcsNewName, int grfFlags);
            IStorage OpenStorage(string pwcsName, IntPtr pstgPriority, int grfMode, IntPtr snbExclude, int reserved);
            IStream OpenStream(string pwcsName, IntPtr reserved1, int grfMode, int reserved2);
            void RenameElement(string pwcsOldName, string pwcsNewName);
            void Revert();
            void SetClass(ref Guid clsid);
            void SetElementTimes(string pwcsName, FILETIME pctime, FILETIME patime, FILETIME pmtime);
            void SetStateBits(int grfStateBits, int grfMask);
            void Stat(STATSTG pStatStg, int grfStatFlag);
        }
        [Guid("0000000C-0000-0000-C000-000000000046")]
        [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        [SuppressUnmanagedCodeSecurity]
        public interface IStream
        {
            IStream Clone();
            void Commit(int grfCommitFlags);
            long CopyTo(IStream pstm, long cb, long[] pcbRead);
            void LockRegion(long libOffset, long cb, int dwLockType);
            int Read(IntPtr buf, int len);
            void Revert();
            long Seek(long dlibMove, int dwOrigin);
            void SetSize(long libNewSize);
            void Stat(STATSTG pStatstg, int grfStatFlag);
            void UnlockRegion(long libOffset, long cb, int dwLockType);
            int Write(IntPtr buf, int len);
        }
 
        public struct PAINTSTRUCT
        {
            public bool fErase;
            public bool fIncUpdate;
            public bool fRestore;
            public IntPtr hdc;
            public int rcPaint_bottom;
            public int rcPaint_left;
            public int rcPaint_right;
            public int rcPaint_top;
            public int reserved1;
            public int reserved2;
            public int reserved3;
            public int reserved4;
            public int reserved5;
            public int reserved6;
            public int reserved7;
            public int reserved8;
        }
 
        public class BROWSEINFO
        {
            public IntPtr hwndOwner;
            public int iImage;
            public IntPtr lParam;
            public IntPtr lpfn;
            public string lpszTitle;
            public IntPtr pidlRoot;
            public IntPtr pszDisplayName;
            public int ulFlags;
 
            [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
            public BROWSEINFO();
        }
        public class Shell32
        {
            [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
            public Shell32();
 
            public static IntPtr SHBrowseForFolder(BROWSEINFO lpbi);
            public static int SHGetMalloc(IMalloc[] ppMalloc);
            public static bool SHGetPathFromIDList(IntPtr pidl, IntPtr pszPath);
            public static int SHGetSpecialFolderLocation(IntPtr hwnd, int csidl, ref IntPtr ppidl);
        }
 
        public delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam);
    }
}