Lexua

Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору DartKane Давненько не заходил, но если актуально, то делал для своего проекта Код: local sOutput = ""; if luacom.GetObject("winmgmts:\\\\.\\root\\CIMV2") then local oWMIService = luacom.GetObject("winmgmts:\\\\.\\root\\CIMV2"); local oClassName = "Win32_Processor"; toClassProperties = __LoadWMIClassProps(oClassName); local oColItems = oWMIService:ExecQuery("SELECT * FROM Win32_Processor", "WQL", 48); if oColItems then local oEnum = luacom.GetEnumerator(oColItems); local oItem = oEnum:Next(); while oItem do CPUName = String.TrimLeft(Escape(oItem:Name()), nil); maxclock = String.TrimLeft(Escape(oItem:MaxClockSpeed()), nil); curclock = String.TrimLeft(Escape(oItem:CurrentClockSpeed()), nil); CPUNameReg = Registry.GetValue(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", "ProcessorNameString", true); cpuClk = " / "..curclock.."MHz)\r\n"; if CPUName == CPUNameReg then sOutput = sOutput .. CPUName .. " ("..maxclock.."MHz)\r\n"; else sOutput = sOutput .. CPUNameReg .. " ("..maxclock.."MHz)\r\n"; end sOutput = sOutput .. Escape(oItem:Description()) .. "\r\n"; if toClassProperties.L2CacheSize then sOutput = sOutput .. "L2 Cache Size: " .. Escape(oItem:L2CacheSize()) .. " Mb\r\n"; end if toClassProperties.L3CacheSize then if tonumber(Escape(oItem:L3CacheSize())) > 0 then sOutput = sOutput .. "L3 Cache Size: " .. Escape(oItem:L3CacheSize()) .. " Mb\r\n"; end end if toClassProperties.NumberOfCores then sOutput = sOutput .. "Cores: " .. Escape(oItem:NumberOfCores()) .. "\r\n"; end if toClassProperties.NumberOfLogicalProcessors then sOutput = sOutput .. "Logical Processors: " .. Escape(oItem:NumberOfLogicalProcessors()) .. "\r\n"; end oItem = oEnum:Next(); end end Paragraph.SetText("CPUName", sOutput); | Для исользования подключить плагин luacom Забыл Это в глобал функции Код: --==========================WMI=============================== function WMIDateStringToDate(dtmDate) if dtmDate then dtmDate = tostring(dtmDate); return (String.Mid (dtmDate, 7, 2) .. "/" .. String.Mid (dtmDate, 5, 2) .. "/" .. String.Left(dtmDate, 4) .. " " .. String.Mid (dtmDate, 9, 2) .. ":" .. String.Mid (dtmDate, 11, 2) .. ":" .. String.Mid (dtmDate, 13, 2) ); else return ""; end end function Escape(v) if (type(v) == "nil" ) then return ""; end if (type(v) == nil ) then return ""; end if (type(v) == "table" ) then return Table.Concat(v, ", "); end if (type(v) == "boolean") then return (v == true) and "Yes" or "No"; end return v; end --============================================================= function __LoadWMIClassProps(ClassName) -- Get wmiClass Properties table tClassProp = {}; local oWMIService = luacom.GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\CIMV2"); if oWMIService then local oClass = oWMIService:Get(ClassName); if oClass then local oProperties = luacom.GetEnumerator(oClass.Properties_); local oProperty = oProperties:Next(); while oProperty do tClassProp[oProperty.Name] = "\""..oProperty.Name.."\""; oProperty = oProperties:Next(); end end end return tClassProp end | Добавлено: Ну а если нужно только имя проца, то можно его просто взять из реестра Код: CPUName = Registry.GetValue(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", "ProcessorNameString", true); Paragraph.SetText("CPUName", CPUName); |
| Всего записей: 2849 | Зарегистр. 15-10-2002 | Отправлено: 00:41 02-12-2021 | Исправлено: Lexua, 01:07 02-12-2021 |
|