protected override bool RunDialog(IntPtr hwndOwner)
        {
            bool flag;

            OPENFILENAME_I.WndProc proc = new OPENFILENAME_I.WndProc(this.HookProc);
            OPENFILENAME_I         ofn  = new OPENFILENAME_I();

            try
            {
                this._charBuffer = CharBuffer.CreateBuffer(0x2000);
                if (this._fileNames != null)
                {
                    this._charBuffer.PutString(this._fileNames[0]);
                }
                ofn.lStructSize     = Marshal.SizeOf(typeof(OPENFILENAME_I));
                ofn.hwndOwner       = hwndOwner;
                ofn.hInstance       = IntPtr.Zero;
                ofn.lpstrFilter     = MakeFilterString(this._filter, this.DereferenceLinks);
                ofn.nFilterIndex    = this._filterIndex;
                ofn.lpstrFile       = this._charBuffer.AllocCoTaskMem();
                ofn.nMaxFile        = this._charBuffer.Length;
                ofn.lpstrInitialDir = this._initialDirectory;
                ofn.lpstrTitle      = this._title;
                ofn.Flags           = this.Options | 0x880020;
                ofn.lpfnHook        = proc;
                ofn.FlagsEx         = 0x1000000;
                if ((this._defaultExtension != null) && this.AddExtension)
                {
                    ofn.lpstrDefExt = this._defaultExtension;
                }
                if (_fakeKey != null)
                {
                    ResetPlaces();
                }
                if (m_places != null)
                {
                    SetupFakeRegistryTree();
                }
                flag = this.RunFileDialog(ofn);
            }
            finally
            {
                this._charBuffer = null;
                if (ofn.lpstrFile != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(ofn.lpstrFile);
                }
                try
                {
                    if (m_places != null)
                    {
                        ResetPlaces();
                    }
                }
                catch
                {
                }
            }
            return(flag);
        }
Beispiel #2
0
 private static extern IntPtr IntCriticalSetWindowLongPtr(HandleRef hWnd, int nIndex, OPENFILENAME_I.WndProc dwNewLong);