The docs are a little thin. Module osproc has
proc processID(p: Process): int
but I have no idea what to provide as a parameter.
TIA
presumably, you need to give it a process object, which is usually created/given by one of the other procedures in the same module.
as of yet that module does not provide a way to get the own processes id, likely because it's not something that is usually needed. A quick search shows that Windows uses GetCurrentProcessId from kernel32.dll, while OpenBSD, Linux, Mac OSX, and the other Posix systens use getpid from unistd.h - It shouldn't be too hard to wrap those into one procedure.
Thanks for the clue. getpid() was in module posix already.
The pid is handy for unique filenames, like $$ in bash.
This is how I managed to get current process id:
import winim
proc vGetCurrentProcID*(): int32 =
var
hwnd: HWND = GetForegroundWindow()
pid: int32
GetWindowThreadProcessId(hwnd, pid.addr)
return pid