Example #1
0
        private static IEnumerable <string> ReadFileNamesFromHGlobal(IntPtr hGlobal)
        {
            List <string> files     = new List <string>();
            int           fileCount = UnmanagedMethods.DragQueryFile(hGlobal, -1, null, 0);

            if (fileCount > 0)
            {
                for (int i = 0; i < fileCount; i++)
                {
                    int           pathLen = UnmanagedMethods.DragQueryFile(hGlobal, i, null, 0);
                    StringBuilder sb      = new StringBuilder(pathLen + 1);

                    if (UnmanagedMethods.DragQueryFile(hGlobal, i, sb, sb.Capacity) == pathLen)
                    {
                        files.Add(sb.ToString());
                    }
                }
            }
            return(files);
        }