Create an NVO add the following local external function:
function long GetVolumeInformationA( ref string ls_RootPath, &
ref string ls_VolName, long ll_VolLen, ref string ls_volserial, &
long ll_maxcomplen, long ll_systemflags, &
ref string ls_SystemName,&
long ll_SystemLen ) Library 'kernel32'Then add a function called GetVolumeName which accepts a string and returns a string and add the following code:
// Call the API function to get the volumelabel from a drive letterLong ll_Max, ll_Flags, ll_Ret, ll_FileSys
Long ll_VolString ls_Vol
String ls_Drv, ls_FileSys, ls_Flags, ls_Serial
ls_Drv = as_Vol
ls_Vol = Space(32)
ls_FileSys = Space(32)
ls_Serial = Space(32)
ll_Vol = Len( ls_Vol )
ll_FileSys = Len( ls_Filesys )
ll_Ret = GetVolumeInformationA( ls_Drv, ls_Vol, ll_Vol, &
ls_Serial, ll_Max, ll_Flags, ls_FileSys, ll_FileSys )
IF (ll_Ret = 0) THEN
ls_Vol = ''
ELSE
ls_Vol = Trim( ls_Vol )
END IF
RETURN (ls_Vol)
Call the function passing the drive you want the volume name for. For example C:\
0 comments:
Post a Comment