GetVolumeName() and GetVolumeInfo() on Windows

Report any Hollywood bugs here
Post Reply
Flinx
Posts: 347
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

GetVolumeName() and GetVolumeInfo() on Windows

Post by Flinx »

On Windows, the functions GetVolumeName() and GetVolumeInfo() return the correct results for existing volumes, but for all non-existent volumes, the result is a random value or the previously returned value.
Without my p_PrintHex() function, the result looks different, so I left it in the first two loops. Without the GetVolumeInfo() call, the last name found is repeated.
I hope it's only a not initialized variable.

Code: Select all

Function p_PrintHex(st$)
	Local Debugstr$=""
	For Local i=0 To StrLen(st$, #ENCODING_RAW)-1
		Debugstr$=Debugstr$ ..FormatStr("%.2X", ByteVal(MidStr(st$,i,1, #ENCODING_RAW),#BYTE)).." "
	Next
	DebugPrint(Debugstr$)
EndFunction

Volumes=CreateList()
For i=65 To 72 ; A-H
	InsertItem(Volumes, Chr(i)..":")
Next	
InsertItem(Volumes, "df0:")

ForEach(Volumes,
	Function(a, b)
		n$=GetVolumeName(b)
		DebugPrint(b, n$)
		p_PrintHex(n$)
	EndFunction
       )

DebugPrint("\n--------------------\n")

ForEach(Volumes,
	Function(a, b)
		n$=GetVolumeName(b)
		DebugPrint(b, n$)
		p_PrintHex(n$)
		space = GetVolumeInfo(b,#FREESPACE)
		DebugPrint(space, "bytes are free on ",b)
	EndFunction
       )

DebugPrint("\n--------------------\n")

ForEach(Volumes,
	Function(a, b)
		n$=GetVolumeName(b)
		DebugPrint(b, n$)
	EndFunction
       )
Sleep(10000)
User avatar
airsoftsoftwair
Posts: 5848
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: GetVolumeName() and GetVolumeInfo() on Windows

Post by airsoftsoftwair »

Flinx wrote: Wed Dec 03, 2025 2:27 pm I hope it's only a not initialized variable.
Actually, this was because on Windows Hollywood wasn't checking if the drive name specified exists. Of course those functions should fail if the specified drive doesn't exist. Fixed this now, thanks for reporting!

Code: Select all

- Fix [Windows]: GetVolumeName() and GetVolumeInfo() didn't fail when the specified drive name didn't exist
Post Reply