lua-users home
lua-l archive

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


Hello Jerome,

Tuesday, May 12, 2009, 7:12:57 PM, you wrote:

thanks, it's very promising. hope that you will add it to LuaForge to
simplify searching

> 2009/5/11 Bulat Ziganshin <bulat.ziganshin@gmail.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
> platform).

> Anyway, if you want to have a look, there is a Mercurial repository
> online [1]. If Mercurial is out of your reach, just download a source
> tarball [2].

> 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:

> require 'win32.shell32'

> And then you will have access to some functions of the shell32.dll
> library. For example:

> win32.shell32.SHChangeNotify( 'SHCNE_ASSOCCHANGED' )

> or

> win32.shell32.SHChangeNotify( win32.SHCNE_ASSOCCHANGED )

> Some details:
> - 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
> encoded text.
> - 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
> course).

> [1] http://piratery.net/hg/lwin32/
> [2] http://piratery.net/hg/lwin32/archive/tip.tar.gz


-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin@gmail.com