无聊的时候写了个执行Lua脚本的Shell Context Menu.
1.使用内含的RegisterShellMenu.bat文件进行Shell DLL插件注册.
2.任意选择一个.lua后缀文件,在其右键单击快捷菜单中选择Run Lua Script命令.
3.有语法错误的会报错,正确执行的会输出脚本中所有的print函数调用到对话框上。
4.支持到luaopen_base,luaopen_table,luaopen_string,luaopen_math,luaopen_io,不能把dll放到中文目录下.
5.用来做一些方便的Lua脚本Widget不错.
6.1.20:加入lua扩展支持:Windows API,Zip,COM,odbc,mysql,wxWidgets GUI.
7.1.22加入OpenGL支持.
-- Load package
function LoadPackage(pname, fname)
local gf, err = loadlib(pname, fname or ("luaopen_" .. pname));
if(gf) then gf();
else error(err) end;
end
--**************************************************************
LoadPackage("zip");
local zfile, err = zip.open('C:\\view.zip')
for file in zfile:files() do
print(file.filename);
end
zfile:close();
-- *************************************************************
LoadPackage("odbc", "luaopen_luasqlodbc");
local env = assert(luasql.odbc());
local conn = assert(env:connect("nwind"));
local cur = conn:execute("SELECT * FROM Customers");
if(cur) then
print(table.concat(cur:getcolnames(), "\t"));
local data = {};
cur:fetch(data);
print(table.concat(data, "\t"));
end
cur:close();
conn:close();
env:close();
-- *************************************************************
LoadPackage("mysql", "luaopen_luasqlmysql");
local env = assert(luasql.mysql());
local conn = assert(env:connect("wow", "linghuye", "yzwzsq"));
local cur = conn:execute("SELECT * FROM creature_names");
if(cur) then
print(table.concat(cur:getcolnames(), "\t"));
local data = {};
cur:fetch(data);
print(table.concat(data, "\t"));
end
cur:close();
conn:close();
env:close();
-- *************************************************************
LoadPackage("lfs");
local attrs = lfs.attributes("C:\\view.zip");
print(attrs.size);
print(lfs.currentdir());
http://www.cnitblog.com/Files/linghuye/LuaShell.7z.rar