Hi Steve, I´m starting now with Zerobrane too, but this question is about Lua Itself where i can help a little. To reach the result you want probably the main problem you will face off is about the LuaThread you need open to have the same context of execution between the components. Since in your proxy DLL , or in a App running toguether , you have the same entry point on the application(where you open the first Luathread to bind your functions) The Treads in Lua are interesting because after you create the first one, you can open as many you need just “copying “ it from the original thread , and in this way all the components working as one main Lua execution. I have this implemented on my 3D engine and its working fine where I have 3 LuaThreads working with the same script to run the game(1 for the game, 1 for the 3D component (DLL), 1 for the system parameters) And they can share informations where in the Game script you can change the system parameters in execution time if you want. I hope it helps. Kind Regards. Wolff De: zerobrane-bounce@xxxxxxxxxxxxx [mailto:zerobrane-bounce@xxxxxxxxxxxxx] Em nome de Rob Probin Enviada em: quinta-feira, 2 de outubro de 2014 04:11 Para: zerobrane@xxxxxxxxxxxxx Assunto: [ZeroBrane Studio] Re: Call arbitrary Windows DLL Function Not sure about the Lua built into ZBS, but standard Lua doesn't support such things without extension. But that's not difficult. For instance LuaforWindows https://code.google.com/p/luaforwindows/ has various extension libraries, for instance Alien - which allows access to unknown DLLs. There are other ones like LuaInterface that allows access to the CLR. You can use Alien even if you are not using LuaForWindows - it's available as a LuaRock, for instance, the Lua package manager. On 1 Oct 2014, at 11:56, "Steve Russell" <steve.russell@xxxxxxxxxxxxxxxxxxxxx> wrote: Hi, Does anybody know if it is possible to call a function in any system DLL in Windows/Lua 5.2/ZBS? I would like to call 3rd party and system functions. Ideally I’d call the DLL functions from Lua directly, but I’m also considering writing a proxy DLL for Lua to load and this would then load the 3rd party DLL and interact with the functions contained therein. I started by creating a Win32 DLL in VS2010 but Lua command line and ZBS 0.80 hang/crash during the ‘require(“LuaProxy”)’, here’s the C code: // LuaProxy.cpp : Defines the exported functions for the DLL application. // #include "stdafx.h" #include <iostream> // LuaProxy.cpp : Defines the exported functions for the DLL application. // #include <lua.hpp> extern "C" { static int funval = 10; static int function_1(lua_State* l) { std::cout << "[DLL] Function 1 is very funny." << std::endl; std::cout << "[DLL] It's fun value is: " << funval << std::endl; lua_pushnumber(l, funval); return 1; } static int function_2(lua_State* l) { std::cout << "[DLL] Function 2 is twice as funny!" << std::endl; std::cout << "[DLL] It's fun value is: " << 2*funval << std::endl; lua_pushnumber(l, 2*funval); return 1; } /* * Registering functions */ static const struct luaL_Reg cfunctions[] = { {"fun1", function_1}, {"fun2", function_2}, {NULL, NULL} }; int __declspec(dllexport) luaopen_LuaProxy(lua_State* l) { // luaL_newlibtable(l, cfunctions); // luaL_setfuncs(l, cfunctions, 0); luaL_openlib(l, "lp", cfunctions, 0); std::cout << "fun1(), fun2()" << std::endl; return 1; } } // end extern "C" Cheers, Steve