MrBeatnik Posted November 4, 2014 Share Posted November 4, 2014 Hi all, Two questions! First, the example in help docs for _WinAPI_IsWritable doesn't appear to give the desired results for me. In Windows 7, with me as an administrator and UAC disabled, it tells me that all my local hard drives are not writable. Is this a bug, or am I using the example incorrectly somehow? Second, if it was working... it doesn't appear to be valid for network drives. Is there an equivalent function for network drives? Please correct me if I am wrong in any of my posts. I like learning from my mistakes too. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 4, 2014 Moderators Share Posted November 4, 2014 MrBeatnik,When I look inside the function it seems to me that the flag to detect if the disk is write-protected is working in the reverse sense - I will consult with the Devs and get back to you. Could you please test this modified function and see if it works for you - it does for me: #include <WinAPIFiles.au3> Local $aDrive = DriveGetDrive('ALL') If IsArray($aDrive) Then Local $sText For $i = 1 To $aDrive[0] If _WinAPI_IsWritable_Mod($aDrive[$i]) Then $sText = 'Writable' Else $sText = 'Not writable' EndIf If Not @error Then ConsoleWrite(StringUpper($aDrive[$i]) & ' => ' & $sText & @CRLF) EndIf Next EndIf Func _WinAPI_IsWritable_Mod($sDrive) Local $hFile = _WinAPI_CreateFileEx('\\.\' & $sDrive, $OPEN_EXISTING, 0, $FILE_SHARE_READWRITE) If @error Then Return SetError(@error + 20, @extended, False) Local Const $ERROR_WRITE_PROTECT = 19 ; The media is write protected Local $aRet = DllCall('kernel32.dll', 'bool', 'DeviceIoControl', 'handle', $hFile, 'dword', 0x00070024, 'ptr', 0, 'dword', 0, _ 'ptr', 0, 'dword', 0, 'dword*', 0, 'ptr', 0) If __CheckErrorCloseHandle($aRet, $hFile, 1) <> 10 And @extended = $ERROR_WRITE_PROTECT Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc ;==>_WinAPI_IsWritable_ModM23 MikahS 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 4, 2014 Moderators Share Posted November 4, 2014 MrBeatnik,It seems I was correct - the function will be changed for future releases. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now