欢迎光临
我们一直在努力

关于硬盘序列号的类-.NET教程,C#语言

建站超值云服务器,限时71元/月

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();

}

}

}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 关于硬盘序列号的类-.NET教程,C#语言
分享到: 更多 (0)

相关推荐

  • 暂无文章