Terenz Posted January 9, 2024 Posted January 9, 2024 (edited) expandcollapse popupMsgBox(64, "DriveIsSDD Test", "Is SSD: " & DriveIsSDD("C:")) Func DriveIsSDD($vDrive) Local $hDev, $vSizeQ, $vSizeD, $vBytesRet, $STORAGE_PROPERTY_QUERY, $DEVICE_SEEK_PENALTY_DESCRIPTOR If StringInStr($vDrive, ":\") Then $vDrive = StringRegExpReplace($vDrive, "(.*):.*", "$1") ElseIf StringLen($vDrive) = 1 Then $vDrive &= ":" EndIf ; FILE_SHARE_DELETE := 0x4 ; FILE_SHARE_WRITE := 0x2 ; FILE_SHARE_READ := 0x1 ; OPEN_EXISTING := 3 $hDev = DllCall("kernel32.dll", "dword", "CreateFileW", "wstr", "\\.\\" & $vDrive, "uint", 0, "uint", 0x7, "ptr", 0, "uint", 3, "uint", 0, "ptr", 0, "ptr", 0) If Not IsArray($hDev) Or $hDev[0] = -1 Or @error Then Return EndIf ; StorageDeviceSeekPenaltyProperty := 7 ; PropertyStandardQuery := 0 $vSizeQ = 12 $STORAGE_PROPERTY_QUERY = DllStructCreate("int PropertyId;int QueryType;byte AdditionalParameters[1]") DllStructSetData($STORAGE_PROPERTY_QUERY, "PropertyId", 7) DllStructSetData($STORAGE_PROPERTY_QUERY, "QueryType", 0) $vSizeD = 12 $DEVICE_SEEK_PENALTY_DESCRIPTOR = DllStructCreate("int Version;int Size;byte IncursSeekPenalty") $vBytesRet = 0 ; IOCTL_STORAGE_QUERY_PROPERTY := 0x002D1400 If DllCall("kernel32.dll","bool","DeviceIoControl", "ptr", $hDev[0], "uint", 0x002D1400, "ptr", DllStructGetPtr($STORAGE_PROPERTY_QUERY), "uint", $vSizeQ, "ptr", DllStructGetPtr($DEVICE_SEEK_PENALTY_DESCRIPTOR), "uint", $vSizeD, "uint*", $vBytesRet, "ptr", 0) Then DllCall("kernel32.dll", "int", "CloseHandle", "ptr", $hDev[0]) Return Not DllStructGetData($DEVICE_SEEK_PENALTY_DESCRIPTOR, "IncursSeekPenalty") EndIf ; IOCTL_ATA_PASS_THROUGH := 0x0004D02C ; ATA_PASS_THROUGH_EX ; IDENTIFY_DEVICE_DATA - NominalMediaRotationRate ; Sending ATA commands directly to device in Windows? - Stack Overflow ; https://stackoverflow.com/questions/5070987/sending-ata-commands-directly-to-device-in-windows DllCall("kernel32.dll", "int", "CloseHandle", "ptr", $hDev[0]) Return 0 EndFunc Probably there are many mistakes. Someone want to check it out? Thanks! 😀 Edited January 9, 2024 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength
KaFu Posted January 9, 2024 Posted January 9, 2024 Any reason why you don't use DriveGetType("c:\",2) ? OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Terenz Posted January 9, 2024 Author Posted January 9, 2024 On external disk not work in my case, so i have see a different approach on stackoverflow and i want to try it out. But with DllCall i have some difficuties 😅 Nothing is so strong as gentleness. Nothing is so gentle as real strength
Solution Nine Posted January 9, 2024 Solution Posted January 9, 2024 (edited) Here my take on it : #include <WinAPIFiles.au3> #include <WinAPIHObj.au3> IsSSD("D:") Func IsSSD($sDriveLetter) Local Const $tagSTORAGE_PROPERTY_QUERY = 'int PropertyId; int QueryType; byte AdditionalParameters[1];' Local Const $tagDEVICE_SEEK_PENALTY_DESCRIPTOR = 'dword Version;dword Size;byte IncursSeekPenalty;' $sDriveLetter = StringRegExpReplace($sDriveLetter, "([[:alpha:]]:).*", "$1") If @error Then Return SetError(1) Local $hDevice = _WinAPI_CreateFile('\\.\' & $sDriveLetter, 2, 0, 6, 0, 0) If Not $hDevice Then Return SetError(2) Local $tSTORAGE_PROPERTY_QUERY = DllStructCreate($tagSTORAGE_PROPERTY_QUERY) $tSTORAGE_PROPERTY_QUERY.PropertyId = 7 Local $tDEVICE_SEEK_PENALTY_DESCRIPTOR = DllStructCreate($tagDEVICE_SEEK_PENALTY_DESCRIPTOR) Local $iRes = _WinAPI_DeviceIoControl($hDevice, $IOCTL_STORAGE_QUERY_PROPERTY, _ DllStructGetPtr($tSTORAGE_PROPERTY_QUERY), DllStructGetSize($tSTORAGE_PROPERTY_QUERY), _ DllStructGetPtr($tDEVICE_SEEK_PENALTY_DESCRIPTOR), DllStructGetSize($tDEVICE_SEEK_PENALTY_DESCRIPTOR)) _WinAPI_CloseHandle($hDevice) If Not $iRes then Return SetError(3) ConsoleWrite($sDriveLetter & " is SSD " & Not $tDEVICE_SEEK_PENALTY_DESCRIPTOR.IncursSeekPenalty & @CRLF) EndFunc ;==>GetDiskSerial Edited January 9, 2024 by Nine KaFu 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Terenz Posted January 9, 2024 Author Posted January 9, 2024 Work fine! Thanks, i'll study it (and i don't have find on Google _WinAPI_DeviceIoControl lol, didn't know it already exist). Thanks again! Nothing is so strong as gentleness. Nothing is so gentle as real strength
Nine Posted January 10, 2024 Posted January 10, 2024 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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