コード例 #1
0
        // Token: 0x0600020F RID: 527 RVA: 0x000050C0 File Offset: 0x000032C0
        private static string[] GetMultiselectFiles(NativeMethods.CharBuffer charBuffer)
        {
            string text  = charBuffer.GetString();
            string text2 = charBuffer.GetString();

            if (text2.Length == 0)
            {
                return(new string[]
                {
                    text
                });
            }
            if (!text.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal))
            {
                text += Path.DirectorySeparatorChar.ToString();
            }
            List <string> list = new List <string>();

            do
            {
                bool flag  = text2[0] == Path.DirectorySeparatorChar && text2[1] == Path.DirectorySeparatorChar;
                bool flag2 = text2.Length > 3 && text2[1] == Path.VolumeSeparatorChar && text2[2] == Path.DirectorySeparatorChar;
                if (!flag && !flag2)
                {
                    text2 = text + text2;
                }
                list.Add(text2);
                text2 = charBuffer.GetString();
            }while (!string.IsNullOrEmpty(text2));
            return(list.ToArray());
        }
コード例 #2
0
        protected override IntPtr HookProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam)
        {
            IntPtr result = IntPtr.Zero;

            if (msg == 78)
            {
                this._hwndFileDialog = UnsafeNativeMethods.GetParent(new HandleRef(this, hwnd));
                NativeMethods.OFNOTIFY ofnotify = (NativeMethods.OFNOTIFY)UnsafeNativeMethods.PtrToStructure(lParam, typeof(NativeMethods.OFNOTIFY));
                switch (ofnotify.hdr_code)
                {
                case -606:
                    if (this._ignoreSecondFileOkNotification)
                    {
                        if (this._fileOkNotificationCount != 0)
                        {
                            this._ignoreSecondFileOkNotification = false;
                            UnsafeNativeMethods.CriticalSetWindowLong(new HandleRef(this, hwnd), 0, NativeMethods.InvalidIntPtr);
                            result = NativeMethods.InvalidIntPtr;
                            break;
                        }
                        this._fileOkNotificationCount = 1;
                    }
                    if (!this.DoFileOk(ofnotify.lpOFN))
                    {
                        UnsafeNativeMethods.CriticalSetWindowLong(new HandleRef(this, hwnd), 0, NativeMethods.InvalidIntPtr);
                        result = NativeMethods.InvalidIntPtr;
                    }
                    break;

                case -604:
                    this._ignoreSecondFileOkNotification = true;
                    this._fileOkNotificationCount        = 0;
                    break;

                case -602:
                {
                    NativeMethods.OPENFILENAME_I openfilename_I = (NativeMethods.OPENFILENAME_I)UnsafeNativeMethods.PtrToStructure(ofnotify.lpOFN, typeof(NativeMethods.OPENFILENAME_I));
                    int num = (int)UnsafeNativeMethods.UnsafeSendMessage(this._hwndFileDialog, (WindowMessage)1124, IntPtr.Zero, IntPtr.Zero);
                    if (num > openfilename_I.nMaxFile)
                    {
                        int num2 = num + 2048;
                        NativeMethods.CharBuffer charBuffer = NativeMethods.CharBuffer.CreateBuffer(num2);
                        IntPtr lpstrFile = charBuffer.AllocCoTaskMem();
                        Marshal.FreeCoTaskMem(openfilename_I.lpstrFile);
                        openfilename_I.lpstrFile = lpstrFile;
                        openfilename_I.nMaxFile  = num2;
                        this._charBuffer         = charBuffer;
                        Marshal.StructureToPtr(openfilename_I, ofnotify.lpOFN, true);
                        Marshal.StructureToPtr(ofnotify, lParam, true);
                    }
                    break;
                }

                case -601:
                    base.MoveToScreenCenter(new HandleRef(this, this._hwndFileDialog));
                    break;
                }
            }
            else
            {
                result = base.HookProc(hwnd, msg, wParam, lParam);
            }
            return(result);
        }