News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Question about CreateProcess

Started by Troy Lundin, June 07, 2006, 04:23:37 AM

Previous topic - Next topic

Troy Lundin

I currently use the following to find the handle of a running process.

FindHandle PROC lpBaseAddress:DWORD, nValue:DWORD, iSize:BYTE
LOCAL phandle:DWORD
LOCAL pid:DWORD
LOCAL whandle:DWORD
Invoke FindWindow, NULL, addr wnd_name
mov whandle,eax
Invoke GetWindowThreadProcessId, whandle, addr pid
Invoke OpenProcess,PROCESS_ALL_ACCESS, 0, pid
mov phandle,eax
ret
FindHandle ENDP

Now, I want to use a button to open a create a new process using CreateProcess.
My question is do I need to go through all the same steps above to find the handle of the process I created?
Or, is there an easier way to do it.

Thank you.

miaomiao

I think that once created the process handle will not changed, so you can used it until the process was ended or deleted.

Ossa

As miaomiao says, the handle of a process remains the same until it terminates, at which point it no longer exists (but you can still use the handle for useful things). The handle is returned by CreateProcess (in the PROCESS_INFORMATION structure). So, no you don't have to do that for any process that you create.

Ossa

Website (very old): ossa.the-wot.co.uk