lua-users home
lua-l archive

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



I need to module to let my Lua scripts call
arbitrary functions in Windows DLLs.

Before I roll my own, has anyone written one already?

This might do what you want:

http://www.nongnu.org/cinvoke/lua.html

"C/Invoke is a library for connecting to C libraries at runtime."

Sample Win32 code from the tarball:

  require("cinvoke_lua")

  user32 = clibrary.new("user32.dll", "stdcall")

  MessageBox = user32:get_function(Cint, "MessageBoxA", Cptr,
                                   Cstring, Cstring, Cint32)

  MessageBox(0, "Hello From Lua",
             "C/Invoke Message Box", 0)


But be careful out there...no Lua runtime to manage your resources and to protect you from Crash City :-)