Opened 3 years ago
Closed 3 years ago
#3850 closed Bug (Fixed)
_WinAPI_GetDriveNumber never returns -1 as partition number
Reported by: | AspirinJunkie | Owned by: | Jpm |
---|---|---|---|
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 Changed 3 years ago by Jpm
- Milestone set to 3.3.15.5
- Owner set to Jpm
- Resolution set to Fixed
- Status changed from new to closed
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Fixed by revision [12594] in version: 3.3.15.5