Modify

Opened 4 years ago

Closed 4 years ago

#3850 closed Bug (Fixed)

_WinAPI_GetDriveNumber never returns -1 as partition number

Reported by: AspirinJunkie Owned by: J-Paul Mesnage
Milestone: 3.3.15.5 Component: Standard UDFs
Version: 3.3.15.4 Severity: None
Keywords: Cc:

Description

The documentation for _WinAPI_GetDriveNumber says:

[2] - The partition number, or (-1) if device cannot be partitioned.

This is consistent with the description of the STORAGE_DEVICE_NUMBER structure.

However, the problem here is that the PartitionNumber part is of data type DWORD - i.e. an unsigned integer. A value of -1 is therefore simply not possible.
In C this is not a big problem, because DWORDs can also be tested for -1:

(DWORD)4294967295 == -1 // true

In AutoIt, however, 4294967295 is always returned in the case of -1 due to the conversion to Int64:

#include <WinAPIFiles.au3>

Local $aData = _WinAPI_GetDriveNumber('d:') ; a non partionable drive like a cd-drive
ConsoleWrite('Partition number: ' & $aData[2] & @CRLF)

Therefore, as a pragmatic solution, I suggest to change the structure definition as follows, deviating from the Win API documentation:

Local $tSDN = DllStructCreate('dword;dword;LONG')

Attachments (0)

Change History (1)

comment:1 by J-Paul Mesnage, 4 years ago

Milestone: 3.3.15.5
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed by revision [12594] in version: 3.3.15.5

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.