Searches a path for a drive letter within the range of 'A' to 'Z' and returns the corresponding drive number
#include <WinAPIShPath.au3>
_WinAPI_PathGetDriveNumber ( $sFilePath )
$sFilePath | The path to be searched. |
Success: | The string that contains the drive letter (A:, B:, etc). |
Failure: | Empty string. |
Search PathGetDriveNumber in MSDN Library.
#include <WinAPIShPath.au3>
Local $aPath[5] = ['c:\path\file', 'c:\', 'c:', 'nodrive', StringFormat('d: %270s', '2')]
For $i = 0 To UBound($aPath) - 2
ConsoleWrite($aPath[$i] & ' => ' & _WinAPI_PathGetDriveNumber($aPath[$i]) & @CRLF)
Next
Local $iRet = _WinAPI_PathGetDriveNumber($aPath[UBound($aPath) - 1])
ConsoleWrite('TOO LONG STRING : @error = ' & @error & ' => "' & $iRet & '"' & @CRLF)