dallas page
Попробуй:
Код: Drive.IsSSD = function (sDriveLetter)
assert(type(luacom) == 'table')
sDriveLetter = String.Upper(String.Left(sDriveLetter, 1));
nDriveNumber = -1;
Ret = false;
local objWMIService = luacom.GetObject("winmgmts:\\\\.\\root\\CIMV2");
local objColItems = objWMIService:ExecQuery("SELECT * FROM Win32_LogicalDiskToPartition", "WQL", 48);
if (objColItems) then
local oEnum = luacom.GetEnumerator(objColItems);
local objItem = oEnum:Next();
while (objItem) do
if sDriveLetter == string.match(objItem:Dependent(), 'Win32_LogicalDisk.DeviceID="(.):"') then
nDriveNumber = tonumber(string.match(objItem:Antecedent(), 'Disk #(.), Partition'));
break;
end
objItem = oEnum:Next();
end
end
if (nDriveNumber ~= -1) then
objColItems = objWMIService:ExecQuery('SELECT * FROM Win32_DiskDrive', "WQL", 48);
if (objColItems) then
oEnum = luacom.GetEnumerator(objColItems);
objItem = oEnum:Next();
while (objItem) do
if (objItem:DeviceID() == "\\\\.\\PHYSICALDRIVE"..nDriveNumber) then
Ret = (String.Find(objItem:PNPDeviceID(), "SSD") ~= -1) and true or false;
end
objItem = oEnum:Next();
end
end
end
return Ret;
end
local IsSSD = Drive.IsSSD('C:');
Dialog.Message("",tostring(IsSSD));
Попробуй:
Код: Drive.IsSSD = function (sDriveLetter)
assert(type(luacom) == 'table')
sDriveLetter = String.Upper(String.Left(sDriveLetter, 1));
nDriveNumber = -1;
Ret = false;
local objWMIService = luacom.GetObject("winmgmts:\\\\.\\root\\CIMV2");
local objColItems = objWMIService:ExecQuery("SELECT * FROM Win32_LogicalDiskToPartition", "WQL", 48);
if (objColItems) then
local oEnum = luacom.GetEnumerator(objColItems);
local objItem = oEnum:Next();
while (objItem) do
if sDriveLetter == string.match(objItem:Dependent(), 'Win32_LogicalDisk.DeviceID="(.):"') then
nDriveNumber = tonumber(string.match(objItem:Antecedent(), 'Disk #(.), Partition'));
break;
end
objItem = oEnum:Next();
end
end
if (nDriveNumber ~= -1) then
objColItems = objWMIService:ExecQuery('SELECT * FROM Win32_DiskDrive', "WQL", 48);
if (objColItems) then
oEnum = luacom.GetEnumerator(objColItems);
objItem = oEnum:Next();
while (objItem) do
if (objItem:DeviceID() == "\\\\.\\PHYSICALDRIVE"..nDriveNumber) then
Ret = (String.Find(objItem:PNPDeviceID(), "SSD") ~= -1) and true or false;
end
objItem = oEnum:Next();
end
end
end
return Ret;
end
local IsSSD = Drive.IsSSD('C:');
Dialog.Message("",tostring(IsSSD));