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./blog/451757
- http://www./articles/20090615-459
Sample -- http://www./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)
|