简体   繁体   English

如何将Winapi添加到Windows的Lua

[英]How to add winapi to Lua for Windows

I've installed Lua for Windows "batteries included" 5.1.4-46. 我已经为Windows“包括电池”安装了Lua 5.1.4-46。 It doesn't have everything I want. 它没有我想要的一切。 I'm trying to re-write AutoIt scripts that I use on my personal PC. 我正在尝试重新编写在个人PC上使用的AutoIt脚本。 I can't find an easy way to access the windows registry. 我找不到访问Windows注册表的简单方法。 The WinAPI module by Steve Donovan looks like it will give me what I want. 史蒂夫·多诺万(Steve Donovan)WinAPI模块看起来会给我我想要的东西。 I also want to be able to retrieve file attributes in order to determine if a directory is a junction. 我还希望能够检索文件属性以确定目录是否为联结。

I realize my real issues are not WinAPI, but if I learn how to add it to Lua for Windows, I can hopefully add other Lua addons. 我意识到我真正的问题不是WinAPI,但是如果我学习如何将其添加到Windows的Lua中,则希望可以添加其他Lua插件。 How do I add WinAPI to the Lua installation from Lua for Windows? 如何从Windows的Lua将WinAPI添加到Lua安装中?

Edit: I've found a binary winapi.dll for Lua 5.1 lua for windows. 编辑:我已经为Windows的Lua 5.1 lua找到了一个二进制winapi.dll。 enter link description here 在此处输入链接说明

I copied it to the "Lua\\5.1\\clibs" folder. 我将其复制到“ Lua \\ 5.1 \\ clibs”文件夹中。 I added require("winapi") to the top of a short program. 我在一个简短程序的顶部添加了require(“ winapi”)。 I had to exit and restart SciTE editor and now it appears to be working. 我不得不退出并重新启动SciTE编辑器,现在它似乎正在运行。

The third party lib will ultimately (after build) be a DLL. 第三方库最终(在构建后)将是DLL。 As long as the DLL is on your LUA_CPATH, you can require dll_name and it will load dll_name.dll. 只要DLL在您的LUA_CPATH上,您就可以要求dll_name,它将加载dll_name.dll。 There are binary (pre-built) versions of winapi for LuaForWindows, like v1.0.1 . LuaForWindows有winapi的二进制(预构建)版本,例如v1.0.1 But you are probably better off getting the most recent release and building using one of the build scripts in root folder of .zip release . 但是,最好使用.zip版本的根文件夹中的构建脚本之一来获取最新版本并进行构建。 Once you have built, look for the .dll produced and move it to one of the locations on LUA_CPATH, or edit LUA_CPATH to include the folder where you want to put all your Lua extension modules. 构建完成后,查找生成的.dll并将其移动到LUA_CPATH上的某个位置,或编辑LUA_CPATH以包括要放置所有Lua扩展模块的文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM