About the class of the hard disk serial number

zhaozj2021-02-16  46

Using system.io; using system.runtime.interopservices; using system.text; using microsoft.win32; namespace wjb.readorwriteiniandreg {////

/// HardDiskVal's summary description. /// Read the hard disk serial number of the specified drive letter /// function: Read the hard disk serial number of the specified disk letter ////

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

);

///

/// Get the hard disk serial number of the drive letter to DRVID, default is c

///

///

Param>

///

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 rettval,

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 rettval,

a,

b,

STR2,

Max_filename_len

);

Return RetVal.Tostring ();

}

}

}

转载请注明原文地址:https://www.9cbs.com/read-25210.html

New Post(0)