windows SDK help
The GetVolumeInformation function returns information about a file system and volume whose root directory is specified. BOOL GetVolumeInformation( LPCTSTR lpRootPathName, // address of root directory of the file system
LPTSTR lpVolumeNameBuffer, // address of name of the volume
DWORD nVolumeNameSize, // length of lpVolumeNameBuffer
LPDWORD lpVolumeSerialNumber, // address of volume serial number
LPDWORD lpMaximumComponentLength, // address of system's maximum filename length
LPDWORD lpFileSystemFlags, // address of file system flags
LPTSTR lpFileSystemNameBuffer, // address of name of file system
DWORD nFileSystemNameSize // length of lpFileSystemNameBuffer
);
用法?
strlabel:string;
serial_no:string;
strtype:stringGetVolumeInformation('c:\', strlabel,255, serial_no, 0, 0, strtype, 255);
试试?我没测试可能要对数据类型转换一下。
The GetVolumeInformation function returns information about a file system and volume whose root directory is specified. BOOL GetVolumeInformation( LPCTSTR lpRootPathName, // address of root directory of the file system
LPTSTR lpVolumeNameBuffer, // address of name of the volume
DWORD nVolumeNameSize, // length of lpVolumeNameBuffer
LPDWORD lpVolumeSerialNumber, // address of volume serial number
LPDWORD lpMaximumComponentLength, // address of system's maximum filename length
LPDWORD lpFileSystemFlags, // address of file system flags
LPTSTR lpFileSystemNameBuffer, // address of name of file system
DWORD nFileSystemNameSize // length of lpFileSystemNameBuffer
);
用法?
strlabel:string;
serial_no:string;
strtype:stringGetVolumeInformation('c:\', strlabel,255, serial_no, 0, 0, strtype, 255);
试试?我没测试可能要对数据类型转换一下。
解决方案 »
- 关于USB的难题?
- Delphi 合并Excel文件
- 删除一个无用的单元后,无法编译??
- 怎样根据需要加密的字符串和加密后的字符串得到加密算法?
- 怎样改变标题栏的图标和生成的.exe文件的图标?在线等!!!!!!!!!
- delphi7关闭后显示runtime error 217 at 00402818
- 有做过三层结构的进来谈谈
- 请教:为什么画的矩形打印出来长宽有差异,进来有分
- 我控制EXCEL列宽时使用ExcelWorksheet1.Columns[1].ColumnWidth := 10 ;为什么不可以?!!!还请各信大侠指点!!!
- 我在安装ORACLE8时提示要加大虚存,不知加C还是D?多大值?请告之详细步骤,谢谢!
- 有什么软件可以修复FAT表???SOS
- 请问选用哪本书?
TVolumeInformation = record
VolumeName : string;
VolumeSerialNumber,
MaximumComponentLength,
FileSystemFlags : integer;
FileSystemName : string;
end; function GetVolumeInformation (D : char; var V : TVolumeInformation) : boolean;
var
O : integer;
begin
O := SetErrorMode (SEM_FAILCRITICALERRORS);
try
with V do
begin
SetLength (VolumeName, MAX_PATH);
SetLength (FileSystemName, MAX_PATH);
VolumeSerialNumber := 0;
MaximumComponentLength := 0;
FileSystemFlags := 0;
Result := Windows.GetVolumeInformation (PChar (D+':\'), PChar (VolumeName), MAX_PATH,
@VolumeSerialNumber, MaximumComponentLength, FileSystemFlags,
PChar (FileSystemName), MAX_PATH);
RealizeLength (VolumeName);
RealizeLength (FileSystemName)
end
finally
SetErrorMode (O)
end
end;
var
TmpA,TmpE:Pchar;
TmpB,TmpC,TmpD,TmpF:DWord;
SerialNum:PDWord;
begin
TmpA:='';
TmpB:=0;
TmpC:=0;
TmpD:=FS_UNICODE_STORED_ON_DISK ;
TmpE:='';
TmpF:=0;
GetVolumeInformation(Pchar(DiskName+':\'),TmpA,TmpB,@SerialNum,TmpC,TmpD,TmpE,TmpF);
Result :=DWord( SerialNum );
if DWord(SerialNum)=0 then
Try
ChDir(DiskName+':\');
Result := 1;
except
end;
end;