Gopi Krishna Komanduri wrote:
> Hi Everybody ,
> I want to convert between HANDLE to HWND . May I know hyow can I do it . My 
> requirement is I want to use SendMessage api to send some data to another 
> process using WM_COPYDATA . For SendMessage I need HWND for that process. 
> I have tried in this way . I used CreateToolHelp32SnapShot api and got the 
> list of all processes. Now using OpenProcess , I got Handle to the requiored 
> process . Now I strucked up here . I need to convert this Handle to HWND . 
> I thought like both are 4 bytes pointers so I can typecast easily (I don't 
> know exactly what those 2 represent). 
> So for verification purpose , I tried to use GetWindowText() api for the 
> current process , passing HANDLE of the current process and typecasting it to 
> HWND. But I got error code as 1400 (INvalid Handle) .
> So can any one please explain me on this topic.

Wrong way to find a window handle (there are different types of HANDLEs 
- very few of which can you actually typecast).  Use FindWindow().

You shouldn't be using WM_COPYDATA for IPC - it is slow, limited, and 
could expose your application to those with malicious intent.  Named 
Pipes are probably more appropriate.

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to