public bool ShowDialog()
        {
            var credUiInfo = new CredUi.CredUiInfo();
            credUiInfo.pszCaptionText = "";
            credUiInfo.pszMessageText = "";

            var windowHandle = User32.GetActiveWindow();
            return PromptForCredentialsCredUIWin(windowHandle, true);
        }
Esempio n. 2
0
        public bool ShowDialog()
        {
            var credUiInfo = new CredUi.CredUiInfo();

            credUiInfo.pszCaptionText = "";
            credUiInfo.pszMessageText = "";

            var windowHandle = User32.GetActiveWindow();

            return(PromptForCredentialsCredUIWin(windowHandle, true));
        }
        private CredUi.CredUiInfo CreateCredUIInfo(IntPtr owner, bool downlevelText)
        {
            var info = new CredUi.CredUiInfo();

            info.cbSize     = Marshal.SizeOf(info);
            info.hwndParent = owner;

            if (downlevelText)
            {
                info.pszCaptionText = WindowTitle;
                switch (DownlevelTextMode)
                {
                case DownlevelTextMode.MainInstructionAndContent:
                    if (MainInstruction.Length == 0)
                    {
                        info.pszMessageText = Content;
                    }
                    else if (Content.Length == 0)
                    {
                        info.pszMessageText = MainInstruction;
                    }
                    else
                    {
                        info.pszMessageText = MainInstruction + Environment.NewLine + Environment.NewLine + Content;
                    }
                    break;

                case DownlevelTextMode.MainInstructionOnly:
                    info.pszMessageText = MainInstruction;
                    break;

                case DownlevelTextMode.ContentOnly:
                    info.pszMessageText = Content;
                    break;
                }
            }
            else
            {
                // Vista and later don't use the window title.
                info.pszMessageText = Content;
                info.pszCaptionText = MainInstruction;
            }

            return(info);
        }
        private CredUi.CredUiInfo CreateCredUIInfo(IntPtr owner, bool downlevelText)
        {
            var info = new CredUi.CredUiInfo();
            info.cbSize = Marshal.SizeOf(info);
            info.hwndParent = owner;

            if (downlevelText)
            {
                info.pszCaptionText = WindowTitle;
                switch (DownlevelTextMode)
                {
                    case DownlevelTextMode.MainInstructionAndContent:
                        if (MainInstruction.Length == 0)
                        {
                            info.pszMessageText = Content;
                        }
                        else if (Content.Length == 0)
                        {
                            info.pszMessageText = MainInstruction;
                        }
                        else
                        {
                            info.pszMessageText = MainInstruction + Environment.NewLine + Environment.NewLine + Content;
                        }
                        break;

                    case DownlevelTextMode.MainInstructionOnly:
                        info.pszMessageText = MainInstruction;
                        break;

                    case DownlevelTextMode.ContentOnly:
                        info.pszMessageText = Content;
                        break;
                }
            }
            else
            {
                // Vista and later don't use the window title.
                info.pszMessageText = Content;
                info.pszCaptionText = MainInstruction;
            }

            return info;
        }