Nikolay Sivov : wshom.ocx: Implement Terminate().

Alexandre Julliard julliard at wine.codeweavers.com
Thu Mar 12 10:48:19 CDT 2015


Module: wine
Branch: master
Commit: ed92458754ce21b4d4719168515866fc1bb340ad
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ed92458754ce21b4d4719168515866fc1bb340ad

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Wed Mar 11 10:36:46 2015 +0300

wshom.ocx: Implement Terminate().

---

 dlls/wshom.ocx/Makefile.in |  2 +-
 dlls/wshom.ocx/shell.c     | 28 ++++++++++++++++++++++++++--
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/dlls/wshom.ocx/Makefile.in b/dlls/wshom.ocx/Makefile.in
index 18e1b96..b1949ed 100644
--- a/dlls/wshom.ocx/Makefile.in
+++ b/dlls/wshom.ocx/Makefile.in
@@ -1,5 +1,5 @@
 MODULE    = wshom.ocx
-IMPORTS   = uuid oleaut32 ole32 shell32 advapi32
+IMPORTS   = uuid oleaut32 ole32 shell32 user32 advapi32
 
 C_SRCS = \
 	shell.c \
diff --git a/dlls/wshom.ocx/shell.c b/dlls/wshom.ocx/shell.c
index dcf1462..97781a5 100644
--- a/dlls/wshom.ocx/shell.c
+++ b/dlls/wshom.ocx/shell.c
@@ -254,13 +254,37 @@ static HRESULT WINAPI WshExec_get_ExitCode(IWshExec *iface, DWORD *code)
     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)
 {
     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 = {




More information about the wine-cvs mailing list