using System;
using SystemIO;
using SystemRuntimeInteropServices;
using SystemText;
using MicrosoftWin;
namespace WjbReadOrWriteIniAndReg
{
/**////
/// 读取指定盘符的硬盘序列号
///
public class HardDiskVal
{
[DllImport(kerneldll)]
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 = ;
int retVal = ;
int a =;
int b =;
string str = null;
string str = null;
int i = GetVolumeInformation(
drvID + @:\
str
MAX_FILENAME_LEN
ref retVal
a
b
str
MAX_FILENAME_LEN
);
return retValToString();
}
public string HDVal()
{
const int MAX_FILENAME_LEN = ;
int retVal = ;
int a =;
int b =;
string str = null;
string str = null;
int i = GetVolumeInformation(
c:\\
str
MAX_FILENAME_LEN
ref retVal
a
b
str
MAX_FILENAME_LEN
);
return retValToString();
}
}