/*
DriveGet, Type, Type, %A_WinDir%
Type:
"REMOVABLE" (可移动)
"FIXED" (内置盘)
"NETWORK" (网络盘)
"CDROM" (光驱)
"RAMDISK" (内存盘)
*/
MsgBox, % "系统盘为:" (DriveIsSDD(A_WinDir)?"固态":"机械")
MsgBox % GetPhysicallyInstalledSystemMemory()
return
DriveIsSDD(vDrive){
local
if InStr(vDrive, ":\")
SplitPath, vDrive,,,,, vDrive
else if (StrLen(vDrive) = 1)
vDrive .= ":"
;FILE_SHARE_DELETE := 0x4 ;FILE_SHARE_WRITE := 0x2
;FILE_SHARE_READ := 0x1 ;OPEN_EXISTING := 3
hDev := DllCall("kernel32\CreateFile" (A_IsUnicode?"W":"A"), WStr,"\\.\" vDrive, UInt,0, UInt,0x7, Ptr,0, UInt,3, UInt,0, Ptr,0, Ptr)
if (hDev = -1) || (ErrorLevel != 0)
return
;StorageDeviceSeekPenaltyProperty := 7 ;PropertyStandardQuery := 0
VarSetCapacity(STORAGE_PROPERTY_QUERY, vSizeQ:=12, 0)
NumPut(7, &STORAGE_PROPERTY_QUERY, 0, "Int") ;PropertyId
VarSetCapacity(DEVICE_SEEK_PENALTY_DESCRIPTOR, vSizeD:=12, 0)
vBytesRet := 0
;IOCTL_STORAGE_QUERY_PROPERTY := 0x002D1400
if DllCall("kernel32\DeviceIoControl", Ptr,hDev, UInt,0x002D1400, Ptr,&STORAGE_PROPERTY_QUERY, UInt,vSizeQ, Ptr,&DEVICE_SEEK_PENALTY_DESCRIPTOR, UInt,vSizeD, UIntP,vBytesRet, Ptr,0)
{
DllCall("kernel32\CloseHandle", Ptr,hDev)
return !NumGet(DEVICE_SEEK_PENALTY_DESCRIPTOR, 8, "UChar") ;IncursSeekPenalty
}
;check:
;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\CloseHandle", Ptr,hDev)
return 0
}
GetPhysicallyInstalledSystemMemory(){ ;获取内存条内存大小
if !(DllCall("kernel32.dll\GetPhysicallyInstalledSystemMemory", "UInt64*", TotalMemory))
return DllCall("kernel32.dll\GetLastError")
return Floor(TotalMemory/1024**2)>0?Ceil(TotalMemory/1024**2) "G":Ceil(TotalMemory/1024) "K"
}
谢谢大佬