Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/shell32/tests/shelldispatch.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c index e9948ae6305..c1e3fbcdaf1 100644 --- a/dlls/shell32/tests/shelldispatch.c +++ b/dlls/shell32/tests/shelldispatch.c @@ -1018,6 +1018,7 @@ static void test_ShellWindows(void) { IShellWindows *shellwindows; LONG cookie, cookie2, ret; + ITEMIDLIST *pidl; IDispatch *disp; VARIANT v, v2; HRESULT hr; @@ -1061,9 +1062,35 @@ todo_wine { ok(hr == S_OK, "got 0x%08x\n", hr); ok(cookie2 != 0 && cookie2 != cookie, "got %d\n", cookie2); } + + pidl = ILCreateFromPathA("C:\"); + V_VT(&v) = VT_ARRAY | VT_UI1; + V_ARRAY(&v) = SafeArrayCreateVector(VT_UI1, 0, ILGetSize(pidl)); + memcpy(V_ARRAY(&v)->pvData, pidl, ILGetSize(pidl)); + + VariantInit(&v2); + hr = IShellWindows_FindWindowSW(shellwindows, &v, &v2, SWC_EXPLORER, &ret, 0, &disp); + todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(!ret, "Got window %#x.\n", ret); + ok(!disp, "Got IDispatch %p.\n", &disp); + + hr = IShellWindows_OnNavigate(shellwindows, cookie, &v); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IShellWindows_FindWindowSW(shellwindows, &v, &v2, SWC_EXPLORER, &ret, 0, &disp); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(ret == (LONG)(LONG_PTR)hwnd, "Expected %p, got %#x.\n", hwnd, ret); + ok(!disp, "Got IDispatch %p.\n", &disp); + hr = IShellWindows_Revoke(shellwindows, cookie); todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IShellWindows_FindWindowSW(shellwindows, &v, &v2, SWC_EXPLORER, &ret, 0, &disp); + todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(!ret, "Got window %#x.\n", ret); + ok(!disp, "Got IDispatch %p.\n", &disp); + hr = IShellWindows_Revoke(shellwindows, cookie2); todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/shell32/tests/shelldispatch.c | 15 +---- programs/explorer/desktop.c | 93 ++++++++++++++++++++++++++++-- 2 files changed, 90 insertions(+), 18 deletions(-)
diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c index c1e3fbcdaf1..eea505ff61d 100644 --- a/dlls/shell32/tests/shelldispatch.c +++ b/dlls/shell32/tests/shelldispatch.c @@ -1035,15 +1035,12 @@ static void test_ShellWindows(void) ok(hr == HRESULT_FROM_WIN32(RPC_X_NULL_REF_POINTER), "got 0x%08x\n", hr);
hr = IShellWindows_Register(shellwindows, NULL, 0, SWC_EXPLORER, &cookie); -todo_wine ok(hr == E_POINTER, "got 0x%08x\n", hr);
hr = IShellWindows_Register(shellwindows, (IDispatch*)shellwindows, 0, SWC_EXPLORER, &cookie); -todo_wine ok(hr == E_POINTER, "got 0x%08x\n", hr);
hr = IShellWindows_Register(shellwindows, (IDispatch*)shellwindows, 0, SWC_EXPLORER, &cookie); -todo_wine ok(hr == E_POINTER, "got 0x%08x\n", hr);
hwnd = CreateWindowExA(0, "button", "test", BS_CHECKBOX | WS_VISIBLE | WS_POPUP, @@ -1052,16 +1049,13 @@ todo_wine
cookie = 0; hr = IShellWindows_Register(shellwindows, NULL, HandleToLong(hwnd), SWC_EXPLORER, &cookie); -todo_wine { ok(hr == S_OK, "got 0x%08x\n", hr); ok(cookie != 0, "got %d\n", cookie); -} + cookie2 = 0; hr = IShellWindows_Register(shellwindows, NULL, HandleToLong(hwnd), SWC_EXPLORER, &cookie2); -todo_wine { ok(hr == S_OK, "got 0x%08x\n", hr); ok(cookie2 != 0 && cookie2 != cookie, "got %d\n", cookie2); -}
pidl = ILCreateFromPathA("C:\"); V_VT(&v) = VT_ARRAY | VT_UI1; @@ -1083,7 +1077,6 @@ todo_wine { ok(!disp, "Got IDispatch %p.\n", &disp);
hr = IShellWindows_Revoke(shellwindows, cookie); -todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IShellWindows_FindWindowSW(shellwindows, &v, &v2, SWC_EXPLORER, &ret, 0, &disp); @@ -1092,20 +1085,17 @@ todo_wine ok(!disp, "Got IDispatch %p.\n", &disp);
hr = IShellWindows_Revoke(shellwindows, cookie2); -todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IShellWindows_Revoke(shellwindows, 0); -todo_wine ok(hr == S_FALSE, "got 0x%08x\n", hr);
/* we can register ourselves as desktop, but FindWindowSW still returns real desktop window */ cookie = 0; hr = IShellWindows_Register(shellwindows, NULL, HandleToLong(hwnd), SWC_DESKTOP, &cookie); -todo_wine { ok(hr == S_OK, "got 0x%08x\n", hr); ok(cookie != 0, "got %d\n", cookie); -} + disp = (void*)0xdeadbeef; ret = 0xdead; VariantInit(&v); @@ -1235,7 +1225,6 @@ todo_wine ok(ret == 0, "got %d\n", ret);
hr = IShellWindows_Revoke(shellwindows, cookie); -todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); DestroyWindow(hwnd); IShellWindows_Release(shellwindows); diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c index 8f515c045f3..137544567e4 100644 --- a/programs/explorer/desktop.c +++ b/programs/explorer/desktop.c @@ -118,9 +118,48 @@ static HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo) return S_OK; }
+static BOOL array_reserve(void **elements, unsigned int *capacity, unsigned int count, unsigned int size) +{ + unsigned int new_capacity, max_capacity; + void *new_elements; + + if (count <= *capacity) + return TRUE; + + max_capacity = ~(SIZE_T)0 / size; + if (count > max_capacity) + return FALSE; + + new_capacity = max(4, *capacity); + while (new_capacity < count && new_capacity <= max_capacity / 2) + new_capacity *= 2; + if (new_capacity < count) + new_capacity = max_capacity; + + if (!(new_elements = realloc(*elements, new_capacity * size))) + return FALSE; + + *elements = new_elements; + *capacity = new_capacity; + + return TRUE; +} + +static LONG cookie_counter; + +struct window +{ + LONG cookie, hwnd; + int class; +}; + struct shellwindows { IShellWindows IShellWindows_iface; + CRITICAL_SECTION cs; + + unsigned int count, max; + struct window *windows; };
/* This is not limited to desktop itself, every file browser window that @@ -1139,10 +1178,34 @@ static HRESULT WINAPI shellwindows__NewEnum(IShellWindows *iface, IUnknown **ppu }
static HRESULT WINAPI shellwindows_Register(IShellWindows *iface, - IDispatch *disp, LONG hWnd, int class, LONG *cookie) + IDispatch *disp, LONG hwnd, int class, LONG *cookie) { - FIXME("%p 0x%x 0x%x %p\n", disp, hWnd, class, cookie); - return E_NOTIMPL; + struct shellwindows *sw = impl_from_IShellWindows(iface); + struct window *window; + + TRACE("iface %p, disp %p, hwnd %#x, class %u, cookie %p.\n", iface, disp, hwnd, class, cookie); + + if (!hwnd) + return E_POINTER; + + if (disp) + FIXME("Ignoring IDispatch %p.\n", disp); + + EnterCriticalSection(&sw->cs); + + if (!array_reserve((void **)&sw->windows, &sw->max, sw->count + 1, sizeof(*sw->windows))) + { + LeaveCriticalSection(&sw->cs); + return E_OUTOFMEMORY; + } + + window = &sw->windows[sw->count++]; + window->hwnd = hwnd; + window->class = class; + *cookie = window->cookie = ++cookie_counter; + + LeaveCriticalSection(&sw->cs); + return S_OK; }
static HRESULT WINAPI shellwindows_RegisterPending(IShellWindows *iface, @@ -1155,8 +1218,26 @@ static HRESULT WINAPI shellwindows_RegisterPending(IShellWindows *iface,
static HRESULT WINAPI shellwindows_Revoke(IShellWindows *iface, LONG cookie) { - FIXME("0x%x\n", cookie); - return E_NOTIMPL; + struct shellwindows *sw = impl_from_IShellWindows(iface); + unsigned int i; + + TRACE("iface %p, cookie %u.\n", iface, cookie); + + EnterCriticalSection(&sw->cs); + + for (i = 0; i < sw->count; ++i) + { + if (sw->windows[i].cookie == cookie) + { + --sw->count; + memmove(&sw->windows[i], &sw->windows[i + 1], (sw->count - i) * sizeof(*sw->windows)); + LeaveCriticalSection(&sw->cs); + return S_OK; + } + } + + LeaveCriticalSection(&sw->cs); + return S_FALSE; }
static HRESULT WINAPI shellwindows_OnNavigate(IShellWindows *iface, LONG cookie, VARIANT *loc) @@ -2156,6 +2237,8 @@ static void shellwindows_init(void) CoInitialize(NULL);
shellwindows.IShellWindows_iface.lpVtbl = &shellwindowsvtbl; + InitializeCriticalSection(&shellwindows.cs); + shellwindows.cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": shellwindows.cs");
hr = CoRegisterClassObject(&CLSID_ShellWindows, (IUnknown*)&shellwindows_classfactory.IClassFactory_iface,
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/shell32/tests/shelldispatch.c | 5 +++- programs/explorer/desktop.c | 37 +++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c index eea505ff61d..207733afe7e 100644 --- a/dlls/shell32/tests/shelldispatch.c +++ b/dlls/shell32/tests/shelldispatch.c @@ -1068,8 +1068,11 @@ static void test_ShellWindows(void) ok(!ret, "Got window %#x.\n", ret); ok(!disp, "Got IDispatch %p.\n", &disp);
+ hr = IShellWindows_OnNavigate(shellwindows, 0, &v); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IShellWindows_OnNavigate(shellwindows, cookie, &v); - todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IShellWindows_FindWindowSW(shellwindows, &v, &v2, SWC_EXPLORER, &ret, 0, &disp); todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c index 137544567e4..5d0ca9948ef 100644 --- a/programs/explorer/desktop.c +++ b/programs/explorer/desktop.c @@ -151,6 +151,7 @@ struct window { LONG cookie, hwnd; int class; + ITEMIDLIST *pidl; };
struct shellwindows @@ -1240,10 +1241,40 @@ static HRESULT WINAPI shellwindows_Revoke(IShellWindows *iface, LONG cookie) return S_FALSE; }
-static HRESULT WINAPI shellwindows_OnNavigate(IShellWindows *iface, LONG cookie, VARIANT *loc) +static HRESULT WINAPI shellwindows_OnNavigate(IShellWindows *iface, LONG cookie, VARIANT *location) { - FIXME("0x%x %s\n", cookie, debugstr_variant(loc)); - return E_NOTIMPL; + struct shellwindows *sw = impl_from_IShellWindows(iface); + unsigned int i; + + TRACE("iface %p, cookie %u, location %s.\n", iface, cookie, debugstr_variant(location)); + + if (V_VT(location) != (VT_ARRAY | VT_UI1)) + { + FIXME("Unexpected variant type %s.\n", debugstr_vt(V_VT(location))); + return E_NOTIMPL; + } + + EnterCriticalSection(&sw->cs); + + for (i = 0; i < sw->count; ++i) + { + if (sw->windows[i].cookie == cookie) + { + size_t len = V_ARRAY(location)->rgsabound[0].cElements; + if (!(sw->windows[i].pidl = realloc(sw->windows[i].pidl, len))) + { + LeaveCriticalSection(&sw->cs); + return E_OUTOFMEMORY; + } + memcpy(sw->windows[i].pidl, V_ARRAY(location)->pvData, len); + + LeaveCriticalSection(&sw->cs); + return S_OK; + } + } + + LeaveCriticalSection(&sw->cs); + return E_INVALIDARG; }
static HRESULT WINAPI shellwindows_OnActivated(IShellWindows *iface, LONG cookie, VARIANT_BOOL active)
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/shell32/tests/shelldispatch.c | 8 +++--- programs/explorer/desktop.c | 45 ++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 15 deletions(-)
diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c index 207733afe7e..54957875615 100644 --- a/dlls/shell32/tests/shelldispatch.c +++ b/dlls/shell32/tests/shelldispatch.c @@ -1064,7 +1064,7 @@ static void test_ShellWindows(void)
VariantInit(&v2); hr = IShellWindows_FindWindowSW(shellwindows, &v, &v2, SWC_EXPLORER, &ret, 0, &disp); - todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); ok(!ret, "Got window %#x.\n", ret); ok(!disp, "Got IDispatch %p.\n", &disp);
@@ -1075,15 +1075,15 @@ static void test_ShellWindows(void) ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IShellWindows_FindWindowSW(shellwindows, &v, &v2, SWC_EXPLORER, &ret, 0, &disp); - todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(ret == (LONG)(LONG_PTR)hwnd, "Expected %p, got %#x.\n", hwnd, ret); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(ret == (LONG)(LONG_PTR)hwnd, "Expected %p, got %#x.\n", hwnd, ret); ok(!disp, "Got IDispatch %p.\n", &disp);
hr = IShellWindows_Revoke(shellwindows, cookie); ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IShellWindows_FindWindowSW(shellwindows, &v, &v2, SWC_EXPLORER, &ret, 0, &disp); - todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); ok(!ret, "Got window %#x.\n", ret); ok(!disp, "Got IDispatch %p.\n", &disp);
diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c index 5d0ca9948ef..035a1e03288 100644 --- a/programs/explorer/desktop.c +++ b/programs/explorer/desktop.c @@ -1283,26 +1283,49 @@ static HRESULT WINAPI shellwindows_OnActivated(IShellWindows *iface, LONG cookie return E_NOTIMPL; }
-static HRESULT WINAPI shellwindows_FindWindowSW(IShellWindows *iface, VARIANT *loc, - VARIANT *root, int class, LONG *hwnd, int options, IDispatch **disp) +static HRESULT WINAPI shellwindows_FindWindowSW(IShellWindows *iface, VARIANT *location, + VARIANT *root, int class, LONG *hwnd, int options, IDispatch **disp) { - TRACE("%s %s 0x%x %p 0x%x %p\n", debugstr_variant(loc), debugstr_variant(root), - class, hwnd, options, disp); + struct shellwindows *sw = impl_from_IShellWindows(iface); + unsigned int i; + + TRACE("iface %p, location %p, root %p, class %#x, hwnd %p, options %#x, disp %p.\n", + iface, location, root, class, hwnd, options, disp);
- if (class != SWC_DESKTOP) + if (class == SWC_DESKTOP) + { + *hwnd = (LONG)(LONG_PTR)GetDesktopWindow(); + if (options & SWFO_NEEDDISPATCH) + { + *disp = (IDispatch *)&desktopshellbrowserwindow.IWebBrowser2_iface; + IDispatch_AddRef(*disp); + } + return S_OK; + } + + if (options) + FIXME("Ignoring options %#x.\n", options); + + if (V_VT(location) != (VT_ARRAY | VT_UI1)) { - WARN("only SWC_DESKTOP class supported.\n"); + FIXME("Unexpected variant type %s.\n", debugstr_vt(V_VT(location))); return E_NOTIMPL; }
- *hwnd = HandleToLong(GetDesktopWindow()); - if (options & SWFO_NEEDDISPATCH) + EnterCriticalSection(&sw->cs); + + for (i = 0; i < sw->count; ++i) { - *disp = (IDispatch*)&desktopshellbrowserwindow.IWebBrowser2_iface; - IDispatch_AddRef(*disp); + if (sw->windows[i].class == class && ILIsEqual(V_ARRAY(location)->pvData, sw->windows[i].pidl)) + { + *hwnd = sw->windows[i].hwnd; + LeaveCriticalSection(&sw->cs); + return S_OK; + } }
- return S_OK; + LeaveCriticalSection(&sw->cs); + return S_FALSE; }
static HRESULT WINAPI shellwindows_OnCreated(IShellWindows *iface, LONG cookie, IUnknown *punk)
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- The main motivation for this patch is to alleviate a minor usability annoyance introduced by progman DDE support. Programs using progman DDE to create links often execute the CreateGroup and ShowGroup commands multiple times, leading to multiple redundant explorer windows being created. With this patch only one window is created per directory.
Because of what is broadly bug 41713, this functionality does not work if the first explorer window created is the first GUI process launched in the prefix. Other windows work as expected, however.
programs/explorer/explorer.c | 164 +++++++++++++++++++++++------------ 1 file changed, 110 insertions(+), 54 deletions(-)
diff --git a/programs/explorer/explorer.c b/programs/explorer/explorer.c index 763fca381b7..43bd4ef13a8 100644 --- a/programs/explorer/explorer.c +++ b/programs/explorer/explorer.c @@ -70,6 +70,9 @@ typedef struct LPITEMIDLIST pidl; IImageList *icon_list; DWORD advise_cookie; + + IShellWindows *sw; + LONG sw_cookie; } explorer_info;
enum @@ -77,6 +80,13 @@ enum BACK_BUTTON,FORWARD_BUTTON,UP_BUTTON };
+static void variant_from_pidl(VARIANT *var, const ITEMIDLIST *pidl) +{ + V_VT(var) = VT_ARRAY | VT_UI1; + V_ARRAY(var) = SafeArrayCreateVector(VT_UI1, 0, ILGetSize(pidl)); + memcpy(V_ARRAY(var)->pvData, pidl, ILGetSize(pidl)); +} + typedef struct { IExplorerBrowserEvents IExplorerBrowserEvents_iface; @@ -265,6 +275,15 @@ static HRESULT WINAPI IExplorerBrowserEventsImpl_fnOnNavigationComplete(IExplore STRRET strret; WCHAR *name;
+ if (This->info->sw) + { + VARIANT var; + + variant_from_pidl(&var, pidl); + IShellWindows_OnNavigate(This->info->sw, This->info->sw_cookie, &var); + VariantClear(&var); + } + ILFree(This->info->pidl); This->info->pidl = ILClone(pidl); update_path_box(This->info); @@ -325,7 +344,35 @@ static IExplorerBrowserEvents *make_explorer_events(explorer_info *info) return &ret->IExplorerBrowserEvents_iface; }
-static void make_explorer_window(IShellFolder* startFolder) +static IShellFolder *get_starting_shell_folder(WCHAR *path) +{ + IShellFolder* desktop,*folder; + LPITEMIDLIST root_pidl; + HRESULT hres; + + SHGetDesktopFolder(&desktop); + + if (!path) + return desktop; + + hres = IShellFolder_ParseDisplayName(desktop, NULL, NULL, path, NULL, &root_pidl, NULL); + if(FAILED(hres)) + { + return desktop; + } + hres = IShellFolder_BindToObject(desktop,root_pidl,NULL, + &IID_IShellFolder, + (void**)&folder); + ILFree(root_pidl); + if(FAILED(hres)) + { + return desktop; + } + IShellFolder_Release(desktop); + return folder; +} + +static void make_explorer_window(parameters_struct *params) { RECT rect; HWND rebar,nav_toolbar; @@ -339,8 +386,49 @@ static void make_explorer_window(IShellFolder* startFolder) TBBUTTON nav_buttons[3]; int hist_offset,view_offset; REBARBANDINFOW band_info; + VARIANT var, empty_var; + IShellFolder *folder; + IDispatch *dispatch; + WCHAR *path = NULL; + IShellWindows *sw; + ITEMIDLIST *pidl; UINT dpix, dpiy; + DWORD size; + LONG hwnd; HDC hdc; + MSG msg; + + CoCreateInstance(&CLSID_ShellWindows, NULL, CLSCTX_LOCAL_SERVER, + &IID_IShellWindows, (void **)&sw); + + if (params->root[0]) + { + size = GetFullPathNameW(params->root, 0, NULL, NULL); + path = malloc(size); + GetFullPathNameW(params->root, size, path, NULL); + } + + if (sw && path) + { + if (!(pidl = ILCreateFromPathW(path))) + { + ERR("Failed to create PIDL for %s.\n", debugstr_w(path)); + IShellWindows_Release(sw); + return; + } + + variant_from_pidl(&var, pidl); + V_VT(&empty_var) = VT_EMPTY; + if (IShellWindows_FindWindowSW(sw, &var, &empty_var, SWC_EXPLORER, &hwnd, 0, &dispatch) == S_OK) + { + TRACE("Found window %#x already browsing path %s.\n", hwnd, debugstr_w(path)); + SetForegroundWindow((HWND)(LONG_PTR)hwnd); + IShellWindows_Release(sw); + return; + } + ILFree(pidl); + VariantClear(&var); + }
memset(nav_buttons,0,sizeof(nav_buttons));
@@ -376,6 +464,12 @@ static void make_explorer_window(IShellFolder* startFolder) CW_USEDEFAULT,CW_USEDEFAULT,default_width, default_height,NULL,NULL,explorer_hInstance,NULL);
+ if (sw) + { + IShellWindows_Register(sw, NULL, (LONG_PTR)info->main_window, SWC_EXPLORER, &info->sw_cookie); + info->sw = sw; + } + fs.ViewMode = FVM_DETAILS; fs.fFlags = FWF_AUTOARRANGE;
@@ -439,11 +533,20 @@ static void make_explorer_window(IShellFolder* startFolder) SendMessageW(rebar,RB_INSERTBANDW,-1,(LPARAM)&band_info); events = make_explorer_events(info); IExplorerBrowser_Advise(info->browser,events,&info->advise_cookie); - IExplorerBrowser_BrowseToObject(info->browser,(IUnknown*)startFolder, - SBSP_ABSOLUTE); + + folder = get_starting_shell_folder(path); + IExplorerBrowser_BrowseToObject(info->browser, (IUnknown *)folder, SBSP_ABSOLUTE); + IShellFolder_Release(folder); + ShowWindow(info->main_window,SW_SHOWDEFAULT); UpdateWindow(info->main_window); IExplorerBrowserEvents_Release(events); + + while (GetMessageW(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessageW(&msg); + } }
static void update_window_size(explorer_info *info, int height, int width) @@ -568,6 +671,9 @@ static LRESULT CALLBACK explorer_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, L switch(uMsg) { case WM_DESTROY: + IShellWindows_Revoke(info->sw, info->sw_cookie); + IShellWindows_Release(info->sw); + IExplorerBrowser_Unadvise(browser,info->advise_cookie); IExplorerBrowser_Destroy(browser); IExplorerBrowser_Release(browser); @@ -625,47 +731,6 @@ static void register_explorer_window_class(void) RegisterClassExW(&window_class); }
-static IShellFolder* get_starting_shell_folder(parameters_struct* params) -{ - IShellFolder* desktop,*folder; - LPITEMIDLIST root_pidl; - WCHAR *fullpath = NULL; - HRESULT hres; - DWORD size; - - SHGetDesktopFolder(&desktop); - if (!params->root[0]) - { - return desktop; - } - - size = GetFullPathNameW(params->root, 0, fullpath, NULL); - if (!size) - return desktop; - fullpath = heap_alloc(size * sizeof(WCHAR)); - GetFullPathNameW(params->root, size, fullpath, NULL); - - hres = IShellFolder_ParseDisplayName(desktop,NULL,NULL, - fullpath,NULL, - &root_pidl,NULL); - heap_free(fullpath); - - if(FAILED(hres)) - { - return desktop; - } - hres = IShellFolder_BindToObject(desktop,root_pidl,NULL, - &IID_IShellFolder, - (void**)&folder); - ILFree(root_pidl); - if(FAILED(hres)) - { - return desktop; - } - IShellFolder_Release(desktop); - return folder; -} - static WCHAR *copy_path_string(WCHAR *target, WCHAR *source) { INT i = 0; @@ -793,8 +858,6 @@ int WINAPI wWinMain(HINSTANCE hinstance,
parameters_struct parameters; HRESULT hres; - MSG msg; - IShellFolder *folder; INITCOMMONCONTROLSEX init_info;
memset(¶meters,0,sizeof(parameters)); @@ -817,13 +880,6 @@ int WINAPI wWinMain(HINSTANCE hinstance, ExitProcess(EXIT_FAILURE); } register_explorer_window_class(); - folder = get_starting_shell_folder(¶meters); - make_explorer_window(folder); - IShellFolder_Release(folder); - while(GetMessageW( &msg, NULL, 0, 0 ) != 0) - { - TranslateMessage(&msg); - DispatchMessageW(&msg); - } + make_explorer_window(¶meters); return 0; }