我正在创建一个Xaml/C#应用程序,我希望它能够通过登录提示弹出.
我想知道是否可以使用CredUIPromptForWindowsCredentials.
我已经查看过Windows安全登录表单了吗?和http://www.pinvoke.net/default.aspx/credui/creduipromptforwindowscredentials.html?diff=y但他们没有解释如何处理验证.
我真的想要一个小例子,如果用户输入username ="Bo"和密码="123",则其他成功显示错误消息并允许用户再次尝试.
该应用程序将安装在多台计算机上.
或者这根本不可能?
更新
灵感来自这个问题的答案在C#for Windows Vista/7中显示身份验证对话框
我修改了代码以按预期工作.
请注意,验证部分仅用于概念验证.
WindowsSecurityDialog.cs
public class WindowsSecurityDialog
{
public string CaptionText { get; set; }
public string MessageText { get; set; }
[DllImport("ole32.dll")]
public static extern void CoTaskMemFree(IntPtr ptr);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private struct CREDUI_INFO
{
public int cbSize;
public IntPtr hwndParent;
public string pszMessageText;
public string pszCaptionText;
public IntPtr hbmBanner;
}
[DllImport("credui.dll", …Run Code Online (Sandbox Code Playgroud) 我想访问网络共享文件.如何显示系统验证对话框,以便用户可以输入用户名和密码?
ps:通过UNC,在WinForm中.
我正在编写一个探索控件,我想在用户双击网络共享文件夹后显示该对话框.
如何在Windows WPF应用程序中显示Windows登录对话框?
