没有合适的资源?快使用搜索试试~ 我知道了~
获取系统UUID
3星 · 超过75%的资源 需积分: 31 67 下载量 36 浏览量
2016-05-06
16:01:54
上传
评论
收藏 2KB TXT 举报
温馨提示
试读
2页
获取系统不可更改的 UUID 比获取 CPU 硬盘 网卡 都要靠谱
资源推荐
资源详情
资源评论
/// <summary>
/// 获取系统 UUID
/// </summary>
/// <returns></returns>
public static string GetUuid()
{
var str = RunCmd("wmic csproduct list full");
return str.Split("UUID=")[1].Substring(0, 36);
}
public static string RunCmd(string cmd)
{
cmd = cmd.Trim().TrimEnd('&') + "&exit";//说明:不管命令是否成功均执行exit命令,否则当调用ReadToEnd()方法时,会处于假死状态
var output = string.Empty;
using (var p = new Process())
{
p.StartInfo.FileName = @"C:\Windows\System32\cmd.exe";
p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
p.StartInfo.RedirectStandardInput = true; //接受来自调用程序的输入信息
p.StartInfo.RedirectStandardOutput = true; //由调用程序获取输出信息
p.StartInfo.RedirectStandardError = true; //重定向标准错误输出
p.StartInfo.CreateNoWindow = true; //不显示程序窗口
p.Start();//启动程序
//向cmd窗口写入命令
p.StandardInput.WriteLine(cmd);
p.StandardInput.AutoFlush = true;
//获取cmd窗口的输出信息
/// 获取系统 UUID
/// </summary>
/// <returns></returns>
public static string GetUuid()
{
var str = RunCmd("wmic csproduct list full");
return str.Split("UUID=")[1].Substring(0, 36);
}
public static string RunCmd(string cmd)
{
cmd = cmd.Trim().TrimEnd('&') + "&exit";//说明:不管命令是否成功均执行exit命令,否则当调用ReadToEnd()方法时,会处于假死状态
var output = string.Empty;
using (var p = new Process())
{
p.StartInfo.FileName = @"C:\Windows\System32\cmd.exe";
p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
p.StartInfo.RedirectStandardInput = true; //接受来自调用程序的输入信息
p.StartInfo.RedirectStandardOutput = true; //由调用程序获取输出信息
p.StartInfo.RedirectStandardError = true; //重定向标准错误输出
p.StartInfo.CreateNoWindow = true; //不显示程序窗口
p.Start();//启动程序
//向cmd窗口写入命令
p.StandardInput.WriteLine(cmd);
p.StandardInput.AutoFlush = true;
//获取cmd窗口的输出信息
资源评论
- yyfather2017-08-26好像不能用. 我在WIN10下 运行 提示 命令语法不正确 . 其他系统没用过. XP 也不行.
- qq_259490312019-09-20对我有用,已经用上了
- 竹马恋青梅2018-07-25每次系统更新之后,或者不知道什么操作之后, 这个uuid就变了。
Johan.
- 粉丝: 96
- 资源: 121
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功