[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Win32 api binding
- From: Jerome Vuarand <jerome.vuarand@...>
- Date: Tue, 12 May 2009 17:12:57 +0200
2009/5/11 Bulat Ziganshin <email@example.com>:
> is there binding to win32 api? i've searched LuaForge but don't found
> anything complete
I haven't read in details all other answers, but none mention my own
binding (and it's pretty normal since I've not yet properly packaged
and released it). It's incomplete, of course, but I think it's pretty
usable provided the functions you need are already bound. Doing it on
top Alien was not an option for me since Alien doesn't support 64bits
windows (and I've yet to find a working libffi patch for that
Anyway, if you want to have a look, there is a Mercurial repository
online . If Mercurial is out of your reach, just download a source
Until I find time to document it, look at the source. Since most win32
DLLs differ in their API standards, I've created a module per dll. So
for example you can start with:
And then you will have access to some functions of the shell32.dll
library. For example:
win32.shell32.SHChangeNotify( 'SHCNE_ASSOCCHANGED' )
win32.shell32.SHChangeNotify( win32.SHCNE_ASSOCCHANGED )
- All constants are passed as either strings or numbers.
- Number equivalents of string constants are available in the win32
table (see example above).
- When flag combinations are expected you pass them as string or
numbers in a Lua table.
- When the size of an input parameter is to be provided in another
parameter, it is usually ommited (it's computed by the binding).
- Output parameters are returned as multiple return values.
- Some function return the C return value, plus output parameters.
Some just return output parameters. Some return true.
- Some function returning a structure (as an output parameter) return
it as a userdata with an __index, some unpack it in a table.
- When an error is detected most return nil plus the win32 error
string (localized) as second return value, and the win32 error integer
as third return value.
- All functions that have a unicode variant use the unicode variant
(without the W suffix), and text strings are expected to contain utf-8
- Usually the convention is the same within a given submodule, but
they may differ between modules.
- HANDLE and similar datatypes are put in light userdata. Most number
types are put in Lua numbers.
If something described above doesn't work check the source. If you
want more examples just ask. If you want me to add a binding for any
win32 function just ask (use cases in Lua or C would be welcome of