/// <summary>
        /// 資格情報入力ダイアログの呼び出し
        /// </summary>
        /// <param name="caption">ダイアログのキャプション</param>
        /// <param name="message">ダイアログに表示するメッセージ</param>
        public static void CallCredentialDialog(string caption, string message)
        {
            var uiInfo = new PCREDUI_INFO();

            uiInfo.cbSize         = Marshal.SizeOf(uiInfo);
            uiInfo.pszCaptionText = caption;
            uiInfo.pszMessageText = message;

            uint   authPackage = 0;
            IntPtr outCredBuffer;
            uint   outCredSize;
            bool   fSave = false;

            if (CredUIPromptForWindowsCredentials(ref uiInfo, 0, ref authPackage, IntPtr.Zero, 0
                                                  , out outCredBuffer, out outCredSize, ref fSave, CREDUIWIN_FLAG.AUTHPACKAGE_ONLY) != 0)
            {
                Log.Instance.LogWrite(LogState.ERROR, GetErrorMessage());
                //throw new ApplicationException("資格入力ダイアログの呼び出しに失敗しました。");
            }

            var userName       = new StringBuilder(256);
            var userNameSize   = 256;
            var domainName     = new StringBuilder(256);
            var domainNameSize = 256;
            var password       = new StringBuilder(256);
            var passwordSize   = 256;

            // CredUnPackAuthenticationBufferのflagsにCREDUIWIN_GENERIC(0x1)を渡すとPasswordが平文で返ってくる
            // 暗号化しておきたい場合は0を渡す
            if (!CredUnPackAuthenticationBuffer(0, outCredBuffer, outCredSize, userName, ref userNameSize
                                                , domainName, ref domainNameSize, password, ref passwordSize))
            {
                Log.Instance.LogWrite(LogState.ERROR, GetErrorMessage());
                //throw new ApplicationException("資格入力ダイアログから情報を取得することに失敗しました。");
            }

            CoTaskMemFree(outCredBuffer);
        }
 private static extern uint CredUIPromptForWindowsCredentials(ref PCREDUI_INFO uiInfo, int authError, ref uint authPackage
                                                              , IntPtr InAuthBuffer, uint InAuthBufferSize, out IntPtr refOutAuthBuffer, out uint refOutAuthBufferSize
                                                              , ref bool fSave, CREDUIWIN_FLAG flags);