|
Thanks a lot!
I'll try it now (just after a small coffe break). It will be a great help. I also added a function to your module for my needs. My program need to interact with Excel, so I use LuaCOM (excel = luacom.CreateObject('excel.application')). To close the application, I try using excel:Quit(), releasing the object and launching a garbagecollect(), all this to be sure to close the application but the Excel process stays living. So I decided to use your module to kill the process. To do so, I get the hwnd of the excel main window, with excel.Hwnd, and then I added a function to your module to get a window object from the window handle: static int l_window_from_hwnd(lua_State *L) { lua_Integer li_hwnd = lua_tointeger(L,1); HWND hwnd; hwnd = (HWND)li_hwnd; return push_new_Window(L,hwnd); } from this object, I use the functions from your module to get the process and kill it. The compiler didn't let me convert a lua_Number to a HWND (a double to a pointer) so I converted the function parameter to a lua_Integer and then to a HWND. It worked so far, but do you think I could have a problem with the casting from the lua_Number (the function argument) to the lua_Integer and then the HWND? Hwnd values doesn't seem to be huge, but I didn't know much about the Windows API to be sure. Alexandre [[ example ]] luacom = require('luacom') winapi = require('winapi') excel = require('excel.application') excel.Visible = true -- Try to close the Excel application excel.Quit() luacom.releaseConnection(excel) excel = nil collectgarbage() -- but the process stays, so: hwnd = excel.Hwnd w = winapi.window_from_hwnd(hwnd) -- custom function added to winapi p = w:get_process() p:kill() -- I win! --------------------------------------------------------------------- Alexandre Rion Fuel and Fire Department (MEYGU) EADS / Airbus Military --------------------------------------------------------------------- > Date: Tue, 26 Jun 2012 09:24:53 +0200 > From: steve.j.donovan@gmail.com > To: lua-l@lists.lua.org > Subject: Re: Winapi help (RE: [ANN] winapi 1.4) > > On Tue, Jun 26, 2012 at 8:12 AM, Alexandre Rion <gaumerie@hotmail.com> wrote: > > winapi.use_gui(). My objective is to use watch_for_file_changes, but I made > > also some tries with make_timer to verify if it works. > > Right! Problem was overenthusiastic locking - now we don't lock when > submitting calls to the message queue, since it .. queues them for us > ;) > > The downloads page is now updated with winapi-1.4.1-lfw.zip and > winapi-1.4.1-51gcc.zip (just the dlls). > > steve d. > |