国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#應用:讀取指定盤符的硬盤序列號

2023-05-18 12:33:16
字體:
來源:轉載
供稿:網友

using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Win32;

namespace Wjb.ReadOrWriteIniAndReg
{
/**////
/// 讀取指定盤符的硬盤序列號
///
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
);
/**////
/// 獲得盤符為drvID的硬盤序列號,缺省為C
///
///
///
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();
}
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 高陵县| 吉安县| 吉林市| 安仁县| 富顺县| 清镇市| 大安市| 竹山县| 麻江县| 康平县| 周口市| 阳朔县| 定陶县| 文昌市| 谷城县| 宁城县| 通渭县| 巩留县| 万州区| 荆州市| 神池县| 镇坪县| 博白县| 镇雄县| 会昌县| 南阳市| 黄石市| 革吉县| 克拉玛依市| 思茅市| 陆河县| 开江县| 佛山市| 新平| 桑日县| 兴安县| 弥渡县| 和静县| 昌江| 红桥区| 衡山县|