PDA

Click to See Complete Forum and Search --> : SendMessageTimeout


Fox
May 4th, 2000, 04:52 AM
Uhm, what about the SendMessageTimeout function?

I tried to figure out how it works, but I couldn't found anything... I tried this code, but it seems to have wrong parameters or something...

Function HungUp(iProcess As ProcessEntry32) As Boolean
Dim Temp As Long
Dim Process As Long

Process = OpenProcess(PROCESS_TERMINATE, 0, iProcess.ProcessID)

Temp = SendMessageTimeout(Process, WM_NULL, 0, 0,_
SMTO_NORMAL Or SMTO_ABORTIFHUNG Or SMTO_BLOCK, 1000, Temp)

If Temp = 0 Then
HungUp = True
End If
End Function


I think WM_NULL is not that good, but I have no idea what to use else... anyone knows?

Thanks in advance!

Sam Finch
May 4th, 2000, 07:11 AM
OK, yer big mistake is that where the procedure expects an hWnd you've given it a process handle.(first parameter)

the first four params are the parameters you normaly use for sendmessage, the fith is reserved for flags, you can probably get away with setting it to 0, the last parameter is how long the function should waid before it returns, if the message is not processed after this time the function returns 0.

WM_NULL always returns Zero. I can't offhand think of any message that will never return 0. but there must be a message you're trying to get to work, use that to test it.

Fox
May 4th, 2000, 12:04 PM
Well, I tried it with the hWnd, didn't work so I tried the process ;)

However, thx for your time, I'll play around with it :)

Fox
May 7th, 2000, 11:06 PM
I'd say it's the same as I tried, especially the function. My mistake was to take the process instead of the window handle ;)

Thx anyway...