lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,

Yesterday,  I sent this message to have a little help of lua friends ..

------------------------
Hello,

I need to retrieve HDD's infos in lua, and store them in variables.
Does someone has an idea, especially the physical serial number, not the 
one after formatting ?
Thanks,
JM Venet

-------------------
today, after hard searching on the net, I found this :

For windows, the disk informations are retrieveable via the library kernell32.dll
with the function GetVolumeInformation

this function sends these datas (contained in a data structure:

 _In_opt_  LPCTSTR lpRootPathName,
  _Out_opt_ LPTSTR  lpVolumeNameBuffer,
  _In_      DWORD   nVolumeNameSize,
  _Out_opt_ LPDWORD lpVolumeSerialNumber,
  _Out_opt_ LPDWORD lpMaximumComponentLength,
  _Out_opt_ LPDWORD lpFileSystemFlags,
  _Out_opt_ LPTSTR  lpFileSystemNameBuffer,
  _In_      DWORD   nFileSystemNameSize

I coded with Wscite this :

local path = 'C:\\Windows\\System32\\kernell32.dll'

local func = package.loadlib(path, 'GetVolumeInformation')

a = {}
a[1] = func.lpRootPathName
a[2] = func.lpVolumeNameBuffer
a[3] = func.nVolumeNameSize
a[4] = func.lpVolumeSerialNumber
a[5] = func.lpMaximumComponentLength
a[6] = func.lpFileSystemFlags
a[7] = func.lpFileSystemNameBuffer
a[8] = func.nFileSystemNameSize

after process by F5,
I received the following messages

>lua -e "io.stdout:setvbuf 'no'" "test.lua" 
lua: test.lua:6: attempt to index local 'func' (a nil value)
stack traceback:
	test.lua:6: in main chunk
	[C]: ?
>Exit code: 1

If I put the lines from the statement a = {}, to the end in comments
the messages are : (func is nil)

lua -e "io.stdout:setvbuf 'no'" "test.lua" 
>Exit code: 0

is there someone who can give me a little help to retrieve the datas contained
in the stucture returned by the function GetVolumeInformation

thanks for help

JM Venet
begin:vcard
fn:Jean Marc VENET
n:VENET;Jean Marc
email;internet:jmvenet@magic.fr
tel;cell:+33 609 915 825
x-mozilla-html:TRUE
version:2.1
end:vcard