我使用cmd命令通过lua脚本获取RAM信息:
cmd = 'wmic MEMORYCHIP get BankLabel, Capacity, DeviceLocator, MemoryType, TypeDetail, Speed,Tag >'..path..'MyRAMDetail.txt'
os.execute(cmd)
该代码将在我的本地磁盘上生成一个文件:MyRamDetail.txt。通过记事本打开时,它包含如下所示的文本:
BankLabel Capacity DeviceLocator MemoryType Speed Tag TypeDetail
BANK 0 8589934592 ChannelA-DIMM0 0 1333 Physical Memory 0 128
但是当我使用Lua脚本将所有文本追加到备忘录中或打印时,它会显示:
??B
我正在使用以下Lua脚本在备忘录中添加行:
local open = io.open
function read_file(fpath)
local file = open(fpath, "rb")
if not file then return nil end
local content = file:read "*a"
file:close()
return content
end
local path = 'C:\\'
local fileContent = read_file(path..'MyRAMDetail.txt')
-- print (fileContent) check it
memo1.Lines.Text = fileContent
如何正确打印文件内容或将所有文本附加到备忘录中?
致谢