Beispiel #1
0
        private static bool GetPrefferdDropEffect(IntPtr hwnd)
        {
            uint uFormat = PInvoke.RegisterClipboardFormat("Preferred DropEffect");
            bool flag    = false;

            if (PInvoke.OpenClipboard(hwnd))
            {
                try {
                    IntPtr clipboardData = PInvoke.GetClipboardData(uFormat);
                    if (!(clipboardData != IntPtr.Zero))
                    {
                        return(flag);
                    }
                    IntPtr source = PInvoke.GlobalLock(clipboardData);
                    try {
                        if (source != IntPtr.Zero)
                        {
                            byte[] destination = new byte[4];
                            Marshal.Copy(source, destination, 0, 4);
                            flag = (destination[0] & 2) != 0;
                        }
                    }
                    finally {
                        PInvoke.GlobalUnlock(clipboardData);
                    }
                }
                finally {
                    PInvoke.CloseClipboard();
                }
            }
            return(flag);
        }
Beispiel #2
0
        private static List <string> ClipboardGetFileDropList(IntPtr hwnd)
        {
            List <string> list = new List <string>();

            if (PInvoke.OpenClipboard(hwnd))
            {
                try {
                    IntPtr clipboardData = PInvoke.GetClipboardData(15);
                    if (!(clipboardData != IntPtr.Zero))
                    {
                        return(list);
                    }
                    IntPtr hDrop = PInvoke.GlobalLock(clipboardData);
                    if (!(hDrop != IntPtr.Zero))
                    {
                        return(list);
                    }
                    try {
                        uint num = PInvoke.DragQueryFile(hDrop, uint.MaxValue, null, 0);
                        if (num > 0)
                        {
                            for (uint i = 0; i < num; i++)
                            {
                                StringBuilder lpszFile = new StringBuilder(260);
                                PInvoke.DragQueryFile(hDrop, i, lpszFile, lpszFile.Capacity);
                                if (lpszFile.Length > 0)
                                {
                                    list.Add(lpszFile.ToString());
                                }
                            }
                        }
                        return(list);
                    }
                    finally {
                        PInvoke.GlobalUnlock(clipboardData);
                    }
                }
                finally {
                    PInvoke.CloseClipboard();
                }
            }
            return(list);
        }