using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Win32;namespace Wjb.ReadOrWriteIniAndReg
{
/// <summary>
/// HardDiskVal 的摘要说明。
/// 读取指定盘符的硬盘序列号
/// 功能:读取指定盘符的硬盘序列号
/// </summary>
public class HardDiskVal
{
[DllImport("kernel32.dll")]
private static extern int GetVolumeInformation( string lpRootPathName,
string lpVolumeNameBuffer,
int nVolumeNameSize,
ref int lpVolumeSerialNumber,
int lpMaximumComponentLength,
int lpFileSystemFlags,
string lpFileSystemNameBuffer,
int nFileSystemNameSize
);
/// <summary>
/// 获得盘符为drvID的硬盘序列号,缺省为C
/// </summary>
/// <param name="drvID"></param>
/// <returns></returns>
public string HDVal(string drvID)
{
const int MAX_FILENAME_LEN = 256;
int retVal = 0;
int a =0;
int b =0;
string str1 = null;
string str2 = null;
int i = GetVolumeInformation(
drvID + @":\",
str1,
MAX_FILENAME_LEN,
ref retVal,
a,
b,
str2,
MAX_FILENAME_LEN
);
return retVal.ToString();
}
public string HDVal()
{
const int MAX_FILENAME_LEN = 256;
int retVal = 0;
int a =0;
int b =0;
string str1 = null;
string str2 = null;
int i = GetVolumeInformation(
"c:\\",
str1,
MAX_FILENAME_LEN,
ref retVal,
a,
b,
str2,
MAX_FILENAME_LEN
);
return retVal.ToString();
}
}
}关于硬盘序列号的类
原创
©著作权归作者所有:来自51CTO博客作者biyusr216的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:C#模拟鼠标操作
下一篇:实现键盘和鼠标的模拟
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Linux shell获取CPU序列号和硬盘序列号
获取硬盘序列号和CPU序列号的Linux脚本
linux CPU序号 硬盘序列号 硬盘编号 CPU编号 -
esxcli 查询硬盘序列号 硬盘序列号查看
硬盘序列号查询工具正式版是款针对电脑中硬盘所打造的序列号查询工具。硬盘序列号查询工具可以帮助用户快速读取硬盘的真实序列号,方便与包装壳系列号对比辨别硬盘真伪。硬盘序列号查询工具支持win7、win8等主流操作系统。华军软件园提供硬盘序列号查询工具软件的下载服务,下载硬盘序列号查询工具软件其他版本,请到华军软件园! 硬盘序列号查询工具软件简介 &nb
esxcli 查询硬盘序列号 前端代码怎么获取电脑硬盘序列号 硬盘物理序列号修改工具 序列号 工具软件 -
BIOS里序列号修改方法 bios 硬盘序列号
通过系统接口来获取机器的硬盘信息是编程中常遇见的小问题。 一般情况下,我们常用GetLogicalDrives,GetDriveType这两个API来获取当前系统下,硬盘的逻辑分区信息,以及各个分区的硬件类型。 &nbs
BIOS里序列号修改方法 command function access api -
学Python总被劝退?一篇帮你豁然开朗!超丝滑超详细的Python的入门指南来了(知识点总结)
python是一种动态类的语言,变量的类型可以随时变化,随着赋值的内容的变化而变化。如抽屉可以用drawer来表示。
python 讯飞AI大学堂 AI大学堂训练营 智能体 人工智能
















