注册会员,创建你的web开发资料库,using system;
using system.runtime.interopservices;
namespace arli.commonprj {
#region how use this?
/*
string svol = getvol.getvolof("c");
*/
#endregion
public class getvol{
[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
);
public static string getvolof(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("x");
}
}
}