Page 1 of 1

How to get the current process handle

Posted: Thu Aug 31, 2006 3:07 am
by james.chengguangwang
Hi All,

I have a DllCaller and a Dialog Dll, when the DllCaller module loads the dialog from the dll, I want to let the dialog itself to get the current process handle and set it as its process handle to implement a Modal dialog(but I don't want to pass in the DllCaller process handle), how can I do it? could you give me some suggestions? thanks in advance.

thanks
James

Posted: Thu Aug 31, 2006 8:34 am
by upCASE
Hi!
I suppose you mean the window handle of the main window, not the process handle.
The most simple way would be to use FindWindow() and pass it the class name of the main window if you know it and its title. The resulting HWND could be use to create a dialog modal to it.
Another option would be enumerating all windows of the process and trying to determine the main window that way.

Posted: Thu Aug 31, 2006 8:37 am
by james.chengguangwang
Hi upCASE,

I know the two strategies, but I don't want to use them, are there other methods which can be used to get the main window handle?

thanks
James

Posted: Thu Aug 31, 2006 8:55 am
by upCASE
I'm sorry, but I guess not...

Posted: Thu Aug 31, 2006 8:57 am
by james.chengguangwang
Get it, I also think so, thank you very much!