安装之后,目录"Lua5.1lua"目录包含alien.lua和alien目录
或者直接下载LuaRocks
或者见
http://luarocks.org/en/Download
http://luarocks.org/releases/
http://luarocks.org/releases/luarocks-2.0.tar.gz
LuaRocks is a pure Lua application with no library dependencies. Its current release depends on some helper tools, but you shouldn't worry about them, as they are shipped by default on most Unix systems: LuaRocks requires as a basic Unix toolchain, zip, unzip and either wget (default on most Linux systems) or curl (default on Mac OSX). For Windows, these helper tools are provided by the UnxUtils project; the all-in-one Windows package already includes them, as a convenience.
调用Windows API实例
http://lua.iteye.com/blog/451757
http://www.hakkaku.net/articles/20090615-459
Sample
-- http://www.hakkaku.net/articles/20090615-459 -- http://blog.csdn.net/kowity/article/details/7256376 require "alien" MessageBox = alien.User32.MessageBoxA MessageBox:types{ret = 'long', abi = 'stdcall', 'long', 'string', 'string', 'long' } MessageBox(0, "itle for test","LUA call windows api", 0) --------------------------------------------------------------- local ExpandEnvironmentStrings = alien.Kernel32.ExpandEnvironmentStringsA ExpandEnvironmentStrings:types{ ret = "long", abi = 'stdcall', "string", "pointer", "long" } local buffer = alien.buffer(512) ExpandEnvironmentStrings("%USERPROFILE%", buffer, 512) print(tostring(buffer)) --------------------------------------------------------------- EnumWindows = alien.user32.EnumWindows EnumWindows:types {"callback", "pointer", abi="stdcall"} GetClassName = alien.user32.GetClassNameA GetClassName:types {"long", "pointer", "int", abi="stdcall" } local buf = alien.buffer(512) local function enum_func(hwnd, p) GetClassName(hwnd, buf, 511) print (hwnd..":"..tostring(buf)) return 1 end local callback_func = alien.callback( enum_func, {"int", "pointer", abi="stdcall"}) EnumWindows(callback_func, nil)
点击切换位置
分类浏览[lua]
other(18)
www(10)
bash(41)
wtl(14)
cpp(43)
network(15)
![Lua直接调用Dll中的函数 lua 调用dll](http://img.413yy.cn/images/31101031/31012031t011923483ec648473b.jpg)
windows(12)
lua(4)
js(6)
wingui(18)
linux(17)
game(3)