WPF Password

获取 PasswordBox 中密码的代码如下:

// 使用一个IntPtr类型值来存储加密字符串的起始点 
IntPtr p = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(this.passwordBoxPassword.SecurePassword); 
       
// 使用.NET内部算法把IntPtr指向处的字符集合转换成字符串 
string password = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(p); 

 

posted @   microsoft-zhcn  阅读(195)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· NetPad:一个.NET开源、跨平台的C#编辑器
· PowerShell开发游戏 · 打蜜蜂
点击右上角即可分享
微信分享提示