Commit ed924587 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

wshom.ocx: Implement Terminate().

parent 66e80602
MODULE = wshom.ocx MODULE = wshom.ocx
IMPORTS = uuid oleaut32 ole32 shell32 advapi32 IMPORTS = uuid oleaut32 ole32 shell32 user32 advapi32
C_SRCS = \ C_SRCS = \
shell.c \ shell.c \
......
...@@ -254,13 +254,37 @@ static HRESULT WINAPI WshExec_get_ExitCode(IWshExec *iface, DWORD *code) ...@@ -254,13 +254,37 @@ static HRESULT WINAPI WshExec_get_ExitCode(IWshExec *iface, DWORD *code)
return E_NOTIMPL; return E_NOTIMPL;
} }
BOOL CALLBACK enum_thread_wnd_proc(HWND hwnd, LPARAM lParam)
{
INT *count = (INT*)lParam;
(*count)++;
PostMessageW(hwnd, WM_CLOSE, 0, 0);
/* try to send it to all windows, even if failed for some */
return TRUE;
}
static HRESULT WINAPI WshExec_Terminate(IWshExec *iface) static HRESULT WINAPI WshExec_Terminate(IWshExec *iface)
{ {
WshExec *This = impl_from_IWshExec(iface); WshExec *This = impl_from_IWshExec(iface);
BOOL ret, kill = FALSE;
INT count = 0;
FIXME("(%p): stub\n", This); TRACE("(%p)\n", This);
return E_NOTIMPL; ret = EnumThreadWindows(This->info.dwThreadId, enum_thread_wnd_proc, (LPARAM)&count);
if (ret && count) {
/* manual testing shows that it waits 2 seconds before forcing termination */
if (WaitForSingleObject(This->info.hProcess, 2000) != WAIT_OBJECT_0)
kill = TRUE;
}
else
kill = TRUE;
if (kill)
TerminateProcess(This->info.hProcess, 0);
return S_OK;
} }
static const IWshExecVtbl WshExecVtbl = { static const IWshExecVtbl WshExecVtbl = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment