winapi icon indicating copy to clipboard operation
winapi copied to clipboard

get_current_process():get_pid() returns 0

Open shviller opened this issue 10 years ago • 0 comments

Here's an example:

require 'winapi'

local P = winapi.get_current_process()
local current_name = P:get_process_name(true)
print("get_current_process:", P:get_pid(), current_name)

pids = winapi.get_processes()

for _,pid in ipairs(pids) do
   local P = winapi.process_from_id(pid)
   local name = P:get_process_name(true)
   if name == current_name then print("get_processes:\t", P:get_pid(), name) end
   P:close()
end

Output:

C:\>lua winapi_pid_test.lua
get_current_process:    0       c:\Lua\5.1\lua.exe
get_processes:          16920   c:\Lua\5.1\lua.exe

Tested with Lua 5.1.5, LuaJIT 2.0.2 and 2.0.3.

shviller avatar Feb 14 '15 12:02 shviller