2005-11-16 12:45:51 +01:00
|
|
|
/*
|
|
|
|
* explorer.exe
|
|
|
|
*
|
2006-02-19 18:50:27 +01:00
|
|
|
* Copyright 2004 CodeWeavers, Mike Hearn
|
2006-01-14 17:05:18 +01:00
|
|
|
* Copyright 2005,2006 CodeWeavers, Aric Stewart
|
2011-06-11 23:42:17 +02:00
|
|
|
* Copyright 2011 Jay Yang
|
2005-11-16 12:45:51 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-11-16 12:45:51 +01:00
|
|
|
*/
|
|
|
|
|
2011-06-11 23:42:17 +02:00
|
|
|
#define COBJMACROS
|
2005-11-16 12:45:51 +01:00
|
|
|
|
2011-06-11 23:42:17 +02:00
|
|
|
#include "wine/debug.h"
|
2018-03-06 17:58:24 +01:00
|
|
|
#include "wine/heap.h"
|
2006-03-07 11:41:52 +01:00
|
|
|
#include "explorer_private.h"
|
2011-06-11 23:42:17 +02:00
|
|
|
#include "resource.h"
|
|
|
|
|
|
|
|
#include <initguid.h>
|
|
|
|
#include <windows.h>
|
2012-01-23 12:16:36 +01:00
|
|
|
#include <shellapi.h>
|
2011-06-11 23:42:17 +02:00
|
|
|
#include <shobjidl.h>
|
|
|
|
#include <shlobj.h>
|
2011-08-29 10:15:00 +02:00
|
|
|
#include <shlwapi.h>
|
2011-07-04 03:35:55 +02:00
|
|
|
#include <commoncontrols.h>
|
|
|
|
#include <commctrl.h>
|
2011-06-11 23:42:17 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(explorer);
|
|
|
|
|
|
|
|
#define EXPLORER_INFO_INDEX 0
|
|
|
|
|
2011-07-04 03:35:55 +02:00
|
|
|
#define NAV_TOOLBAR_HEIGHT 30
|
2011-07-04 03:36:01 +02:00
|
|
|
#define PATHBOX_HEIGHT 24
|
2017-11-09 18:25:19 +01:00
|
|
|
static int nav_toolbar_height;
|
|
|
|
static int pathbox_height;
|
2011-07-04 03:35:55 +02:00
|
|
|
|
2011-06-11 23:42:17 +02:00
|
|
|
#define DEFAULT_WIDTH 640
|
|
|
|
#define DEFAULT_HEIGHT 480
|
2017-11-09 18:25:19 +01:00
|
|
|
static int default_width;
|
|
|
|
static int default_height;
|
2011-06-11 23:42:17 +02:00
|
|
|
|
|
|
|
|
2017-11-29 06:52:05 +01:00
|
|
|
static const WCHAR EXPLORER_CLASS[] = {'E','x','p','l','o','r','e','r','W','C','l','a','s','s',0};
|
2011-07-04 03:36:01 +02:00
|
|
|
static const WCHAR PATH_BOX_NAME[] = {'\0'};
|
2011-06-11 23:42:17 +02:00
|
|
|
|
|
|
|
HINSTANCE explorer_hInstance;
|
2006-02-19 18:50:27 +01:00
|
|
|
|
2005-11-16 12:45:51 +01:00
|
|
|
typedef struct parametersTAG {
|
|
|
|
BOOL explorer_mode;
|
|
|
|
WCHAR root[MAX_PATH];
|
|
|
|
WCHAR selection[MAX_PATH];
|
|
|
|
} parameters_struct;
|
|
|
|
|
2011-06-11 23:42:17 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
IExplorerBrowser *browser;
|
2011-07-04 03:36:01 +02:00
|
|
|
HWND main_window,path_box;
|
2011-07-04 03:35:55 +02:00
|
|
|
INT rebar_height;
|
2011-07-22 04:59:20 +02:00
|
|
|
LPITEMIDLIST pidl;
|
2011-07-04 03:36:05 +02:00
|
|
|
IImageList *icon_list;
|
2011-07-22 04:59:20 +02:00
|
|
|
DWORD advise_cookie;
|
2020-05-18 06:29:44 +02:00
|
|
|
|
|
|
|
IShellWindows *sw;
|
|
|
|
LONG sw_cookie;
|
2011-06-11 23:42:17 +02:00
|
|
|
} explorer_info;
|
|
|
|
|
2011-07-04 03:35:55 +02:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
BACK_BUTTON,FORWARD_BUTTON,UP_BUTTON
|
|
|
|
};
|
|
|
|
|
2020-05-18 06:29:44 +02:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2011-07-04 03:36:01 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
IExplorerBrowserEvents IExplorerBrowserEvents_iface;
|
|
|
|
explorer_info* info;
|
|
|
|
LONG ref;
|
|
|
|
} IExplorerBrowserEventsImpl;
|
|
|
|
|
|
|
|
static IExplorerBrowserEventsImpl *impl_from_IExplorerBrowserEvents(IExplorerBrowserEvents *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IExplorerBrowserEventsImpl, IExplorerBrowserEvents_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IExplorerBrowserEventsImpl_fnQueryInterface(IExplorerBrowserEvents *iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IExplorerBrowserEventsImpl_fnAddRef(IExplorerBrowserEvents *iface)
|
|
|
|
{
|
|
|
|
IExplorerBrowserEventsImpl *This = impl_from_IExplorerBrowserEvents(iface);
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IExplorerBrowserEventsImpl_fnRelease(IExplorerBrowserEvents *iface)
|
|
|
|
{
|
|
|
|
IExplorerBrowserEventsImpl *This = impl_from_IExplorerBrowserEvents(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
if(!ref)
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2017-04-24 09:59:42 +02:00
|
|
|
static BOOL create_combobox_item(IShellFolder *folder, LPCITEMIDLIST child_pidl, IImageList *icon_list, COMBOBOXEXITEMW *item)
|
2011-07-04 03:36:05 +02:00
|
|
|
{
|
|
|
|
STRRET strret;
|
|
|
|
HRESULT hres;
|
2017-04-24 09:59:42 +02:00
|
|
|
PIDLIST_ABSOLUTE parent_pidl, pidl;
|
|
|
|
SHFILEINFOW info;
|
|
|
|
IImageList *list;
|
|
|
|
|
2011-07-04 03:36:05 +02:00
|
|
|
strret.uType=STRRET_WSTR;
|
2017-04-24 09:59:42 +02:00
|
|
|
hres = IShellFolder_GetDisplayNameOf( folder, child_pidl, SHGDN_FORADDRESSBAR, &strret );
|
2013-10-30 20:50:51 +01:00
|
|
|
if(SUCCEEDED(hres))
|
2017-04-24 09:59:42 +02:00
|
|
|
hres = StrRetToStrW(&strret, child_pidl, &item->pszText);
|
2011-07-04 03:36:05 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
{
|
|
|
|
WINE_WARN("Could not get name for pidl\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-04-24 09:59:42 +02:00
|
|
|
|
|
|
|
item->mask &= ~CBEIF_IMAGE;
|
|
|
|
hres = SHGetIDListFromObject( (IUnknown *)folder, &parent_pidl );
|
|
|
|
if (FAILED(hres)) return FALSE;
|
|
|
|
|
|
|
|
pidl = ILCombine( parent_pidl, child_pidl );
|
|
|
|
if (pidl)
|
2011-07-04 03:36:05 +02:00
|
|
|
{
|
2017-04-24 09:59:42 +02:00
|
|
|
list = (IImageList *)SHGetFileInfoW( (WCHAR *)pidl, 0, &info, sizeof(info),
|
|
|
|
SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_SYSICONINDEX );
|
|
|
|
if (list)
|
|
|
|
{
|
|
|
|
IImageList_Release( list );
|
|
|
|
item->iImage = info.iIcon;
|
|
|
|
item->mask |= CBEIF_IMAGE;
|
|
|
|
}
|
|
|
|
ILFree( pidl );
|
2011-07-04 03:36:05 +02:00
|
|
|
}
|
2017-04-24 09:59:42 +02:00
|
|
|
ILFree( parent_pidl );
|
|
|
|
|
2011-07-04 03:36:05 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-07-04 03:36:01 +02:00
|
|
|
static void update_path_box(explorer_info *info)
|
|
|
|
{
|
2011-07-04 03:36:05 +02:00
|
|
|
COMBOBOXEXITEMW item;
|
|
|
|
COMBOBOXEXITEMW main_item;
|
|
|
|
IShellFolder *desktop;
|
|
|
|
IPersistFolder2 *persist;
|
|
|
|
LPITEMIDLIST desktop_pidl;
|
|
|
|
IEnumIDList *ids;
|
|
|
|
|
|
|
|
SendMessageW(info->path_box,CB_RESETCONTENT,0,0);
|
|
|
|
SHGetDesktopFolder(&desktop);
|
|
|
|
IShellFolder_QueryInterface(desktop,&IID_IPersistFolder2,(void**)&persist);
|
|
|
|
IPersistFolder2_GetCurFolder(persist,&desktop_pidl);
|
|
|
|
IPersistFolder2_Release(persist);
|
|
|
|
persist = NULL;
|
|
|
|
/*Add Desktop*/
|
|
|
|
item.iItem = -1;
|
|
|
|
item.mask = CBEIF_TEXT | CBEIF_INDENT | CBEIF_LPARAM;
|
|
|
|
item.iIndent = 0;
|
|
|
|
create_combobox_item(desktop,desktop_pidl,info->icon_list,&item);
|
|
|
|
item.lParam = (LPARAM)desktop_pidl;
|
|
|
|
SendMessageW(info->path_box,CBEM_INSERTITEMW,0,(LPARAM)&item);
|
|
|
|
if(ILIsEqual(info->pidl,desktop_pidl))
|
|
|
|
main_item = item;
|
|
|
|
else
|
|
|
|
CoTaskMemFree(item.pszText);
|
|
|
|
/*Add all direct subfolders of Desktop*/
|
|
|
|
if(SUCCEEDED(IShellFolder_EnumObjects(desktop,NULL,SHCONTF_FOLDERS,&ids))
|
|
|
|
&& ids!=NULL)
|
|
|
|
{
|
2011-07-22 04:59:20 +02:00
|
|
|
LPITEMIDLIST curr_pidl=NULL;
|
2011-07-04 03:36:05 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
item.iIndent = 1;
|
|
|
|
while(1)
|
|
|
|
{
|
2011-07-22 04:59:20 +02:00
|
|
|
ILFree(curr_pidl);
|
|
|
|
curr_pidl=NULL;
|
2011-07-04 03:36:05 +02:00
|
|
|
hres = IEnumIDList_Next(ids,1,&curr_pidl,NULL);
|
|
|
|
if(FAILED(hres) || hres == S_FALSE)
|
|
|
|
break;
|
|
|
|
if(!create_combobox_item(desktop,curr_pidl,info->icon_list,&item))
|
|
|
|
WINE_WARN("Could not create a combobox item\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LPITEMIDLIST full_pidl = ILCombine(desktop_pidl,curr_pidl);
|
|
|
|
item.lParam = (LPARAM)full_pidl;
|
|
|
|
SendMessageW(info->path_box,CBEM_INSERTITEMW,0,(LPARAM)&item);
|
|
|
|
if(ILIsEqual(full_pidl,info->pidl))
|
|
|
|
main_item = item;
|
|
|
|
else if(ILIsParent(full_pidl,info->pidl,FALSE))
|
|
|
|
{
|
|
|
|
/*add all parents of the pidl passed in*/
|
|
|
|
LPITEMIDLIST next_pidl = ILFindChild(full_pidl,info->pidl);
|
|
|
|
IShellFolder *curr_folder = NULL, *temp;
|
|
|
|
hres = IShellFolder_BindToObject(desktop,curr_pidl,NULL,
|
|
|
|
&IID_IShellFolder,
|
|
|
|
(void**)&curr_folder);
|
|
|
|
if(FAILED(hres))
|
|
|
|
WINE_WARN("Could not get an IShellFolder\n");
|
|
|
|
while(!ILIsEmpty(next_pidl))
|
|
|
|
{
|
|
|
|
LPITEMIDLIST first = ILCloneFirst(next_pidl);
|
|
|
|
CoTaskMemFree(item.pszText);
|
|
|
|
if(!create_combobox_item(curr_folder,first,
|
|
|
|
info->icon_list,&item))
|
|
|
|
{
|
|
|
|
WINE_WARN("Could not create a combobox item\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
++item.iIndent;
|
|
|
|
full_pidl = ILCombine(full_pidl,first);
|
|
|
|
item.lParam = (LPARAM)full_pidl;
|
|
|
|
SendMessageW(info->path_box,CBEM_INSERTITEMW,0,(LPARAM)&item);
|
|
|
|
temp=NULL;
|
|
|
|
hres = IShellFolder_BindToObject(curr_folder,first,NULL,
|
|
|
|
&IID_IShellFolder,
|
|
|
|
(void**)&temp);
|
|
|
|
if(FAILED(hres))
|
|
|
|
{
|
|
|
|
WINE_WARN("Could not get an IShellFolder\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
IShellFolder_Release(curr_folder);
|
|
|
|
curr_folder = temp;
|
|
|
|
|
|
|
|
ILFree(first);
|
|
|
|
next_pidl = ILGetNext(next_pidl);
|
|
|
|
}
|
|
|
|
memcpy(&main_item,&item,sizeof(item));
|
|
|
|
if(curr_folder)
|
|
|
|
IShellFolder_Release(curr_folder);
|
|
|
|
item.iIndent = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
CoTaskMemFree(item.pszText);
|
|
|
|
}
|
|
|
|
}
|
2011-07-22 04:59:20 +02:00
|
|
|
ILFree(curr_pidl);
|
|
|
|
IEnumIDList_Release(ids);
|
2011-07-04 03:36:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
WINE_WARN("Could not enumerate the desktop\n");
|
|
|
|
SendMessageW(info->path_box,CBEM_SETITEMW,0,(LPARAM)&main_item);
|
|
|
|
CoTaskMemFree(main_item.pszText);
|
2011-07-04 03:36:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IExplorerBrowserEventsImpl_fnOnNavigationComplete(IExplorerBrowserEvents *iface, PCIDLIST_ABSOLUTE pidl)
|
|
|
|
{
|
|
|
|
IExplorerBrowserEventsImpl *This = impl_from_IExplorerBrowserEvents(iface);
|
2017-11-29 06:52:06 +01:00
|
|
|
IShellFolder *parent;
|
|
|
|
PCUITEMID_CHILD child_pidl;
|
|
|
|
HRESULT hres;
|
|
|
|
STRRET strret;
|
|
|
|
WCHAR *name;
|
|
|
|
|
2020-05-18 06:29:44 +02:00
|
|
|
if (This->info->sw)
|
|
|
|
{
|
|
|
|
VARIANT var;
|
|
|
|
|
|
|
|
variant_from_pidl(&var, pidl);
|
|
|
|
IShellWindows_OnNavigate(This->info->sw, This->info->sw_cookie, &var);
|
|
|
|
VariantClear(&var);
|
|
|
|
}
|
|
|
|
|
2011-07-22 04:59:20 +02:00
|
|
|
ILFree(This->info->pidl);
|
|
|
|
This->info->pidl = ILClone(pidl);
|
2011-07-04 03:36:01 +02:00
|
|
|
update_path_box(This->info);
|
2017-11-29 06:52:06 +01:00
|
|
|
|
|
|
|
hres = SHBindToParent(pidl, &IID_IShellFolder, (void **)&parent, &child_pidl);
|
|
|
|
if (SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
hres = IShellFolder_GetDisplayNameOf(parent, child_pidl, SHGDN_FORADDRESSBAR, &strret);
|
|
|
|
if (SUCCEEDED(hres))
|
|
|
|
hres = StrRetToStrW(&strret, child_pidl, &name);
|
|
|
|
if (SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
SetWindowTextW(This->info->main_window, name);
|
|
|
|
CoTaskMemFree(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
IShellFolder_Release(parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hres;
|
2011-07-04 03:36:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IExplorerBrowserEventsImpl_fnOnNavigationFailed(IExplorerBrowserEvents *iface, PCIDLIST_ABSOLUTE pidl)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IExplorerBrowserEventsImpl_fnOnNavigationPending(IExplorerBrowserEvents *iface, PCIDLIST_ABSOLUTE pidl)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IExplorerBrowserEventsImpl_fnOnViewCreated(IExplorerBrowserEvents *iface, IShellView *psv)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IExplorerBrowserEventsVtbl vt_IExplorerBrowserEvents =
|
|
|
|
{
|
|
|
|
IExplorerBrowserEventsImpl_fnQueryInterface,
|
|
|
|
IExplorerBrowserEventsImpl_fnAddRef,
|
|
|
|
IExplorerBrowserEventsImpl_fnRelease,
|
|
|
|
IExplorerBrowserEventsImpl_fnOnNavigationPending,
|
|
|
|
IExplorerBrowserEventsImpl_fnOnViewCreated,
|
|
|
|
IExplorerBrowserEventsImpl_fnOnNavigationComplete,
|
|
|
|
IExplorerBrowserEventsImpl_fnOnNavigationFailed
|
|
|
|
};
|
|
|
|
|
|
|
|
static IExplorerBrowserEvents *make_explorer_events(explorer_info *info)
|
|
|
|
{
|
|
|
|
IExplorerBrowserEventsImpl *ret
|
|
|
|
= HeapAlloc(GetProcessHeap(), 0, sizeof(IExplorerBrowserEventsImpl));
|
|
|
|
ret->IExplorerBrowserEvents_iface.lpVtbl = &vt_IExplorerBrowserEvents;
|
|
|
|
ret->info = info;
|
2011-07-22 04:59:20 +02:00
|
|
|
ret->ref = 1;
|
2011-07-04 03:36:05 +02:00
|
|
|
SHGetImageList(SHIL_SMALL,&IID_IImageList,(void**)&(ret->info->icon_list));
|
|
|
|
SendMessageW(info->path_box,CBEM_SETIMAGELIST,0,(LPARAM)ret->info->icon_list);
|
2011-07-04 03:36:01 +02:00
|
|
|
return &ret->IExplorerBrowserEvents_iface;
|
|
|
|
}
|
|
|
|
|
2020-05-18 06:29:44 +02:00
|
|
|
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)
|
2011-06-11 23:42:17 +02:00
|
|
|
{
|
2017-05-02 12:03:18 +02:00
|
|
|
RECT rect;
|
2011-07-04 03:35:55 +02:00
|
|
|
HWND rebar,nav_toolbar;
|
2011-06-11 23:42:17 +02:00
|
|
|
FOLDERSETTINGS fs;
|
2011-07-04 03:36:01 +02:00
|
|
|
IExplorerBrowserEvents *events;
|
2011-06-11 23:42:17 +02:00
|
|
|
explorer_info *info;
|
|
|
|
HRESULT hres;
|
|
|
|
WCHAR explorer_title[100];
|
2011-07-04 03:36:01 +02:00
|
|
|
WCHAR pathbox_label[50];
|
2011-07-04 03:35:55 +02:00
|
|
|
TBADDBITMAP bitmap_info;
|
|
|
|
TBBUTTON nav_buttons[3];
|
|
|
|
int hist_offset,view_offset;
|
|
|
|
REBARBANDINFOW band_info;
|
2020-05-18 06:29:44 +02:00
|
|
|
VARIANT var, empty_var;
|
|
|
|
IShellFolder *folder;
|
|
|
|
IDispatch *dispatch;
|
|
|
|
WCHAR *path = NULL;
|
|
|
|
IShellWindows *sw;
|
|
|
|
ITEMIDLIST *pidl;
|
2017-11-09 18:25:19 +01:00
|
|
|
UINT dpix, dpiy;
|
2020-05-18 06:29:44 +02:00
|
|
|
DWORD size;
|
|
|
|
LONG hwnd;
|
2017-11-09 18:25:19 +01:00
|
|
|
HDC hdc;
|
2020-05-18 06:29:44 +02:00
|
|
|
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);
|
|
|
|
}
|
2017-11-09 18:25:19 +01:00
|
|
|
|
2011-07-04 03:35:55 +02:00
|
|
|
memset(nav_buttons,0,sizeof(nav_buttons));
|
2017-11-09 18:25:19 +01:00
|
|
|
|
2018-08-21 23:10:20 +02:00
|
|
|
LoadStringW(explorer_hInstance,IDS_EXPLORER_TITLE,explorer_title, ARRAY_SIZE( explorer_title ));
|
|
|
|
LoadStringW(explorer_hInstance,IDS_PATHBOX_LABEL,pathbox_label, ARRAY_SIZE( pathbox_label ));
|
2017-11-09 18:25:19 +01:00
|
|
|
|
|
|
|
hdc = GetDC(0);
|
|
|
|
dpix = GetDeviceCaps(hdc, LOGPIXELSX);
|
|
|
|
dpiy = GetDeviceCaps(hdc, LOGPIXELSY);
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
nav_toolbar_height = MulDiv(NAV_TOOLBAR_HEIGHT, dpiy, USER_DEFAULT_SCREEN_DPI);
|
|
|
|
pathbox_height = MulDiv(PATHBOX_HEIGHT, dpiy, USER_DEFAULT_SCREEN_DPI);
|
|
|
|
default_width = MulDiv(DEFAULT_WIDTH, dpix, USER_DEFAULT_SCREEN_DPI);
|
|
|
|
default_height = MulDiv(DEFAULT_HEIGHT, dpiy, USER_DEFAULT_SCREEN_DPI);
|
|
|
|
|
2011-07-22 04:59:20 +02:00
|
|
|
info = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(explorer_info));
|
2011-06-11 23:42:17 +02:00
|
|
|
if(!info)
|
|
|
|
{
|
2013-12-03 14:25:04 +01:00
|
|
|
WINE_ERR("Could not allocate an explorer_info struct\n");
|
2011-06-11 23:42:17 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
hres = CoCreateInstance(&CLSID_ExplorerBrowser,NULL,CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IExplorerBrowser,(LPVOID*)&info->browser);
|
2011-07-19 15:09:12 +02:00
|
|
|
if(FAILED(hres))
|
2011-06-11 23:42:17 +02:00
|
|
|
{
|
|
|
|
WINE_ERR("Could not obtain an instance of IExplorerBrowser\n");
|
|
|
|
HeapFree(GetProcessHeap(),0,info);
|
|
|
|
return;
|
|
|
|
}
|
2011-07-04 03:35:55 +02:00
|
|
|
info->rebar_height=0;
|
|
|
|
info->main_window
|
|
|
|
= CreateWindowW(EXPLORER_CLASS,explorer_title,WS_OVERLAPPEDWINDOW,
|
2017-11-09 18:25:19 +01:00
|
|
|
CW_USEDEFAULT,CW_USEDEFAULT,default_width,
|
|
|
|
default_height,NULL,NULL,explorer_hInstance,NULL);
|
2011-06-11 23:42:17 +02:00
|
|
|
|
2020-05-18 06:29:44 +02:00
|
|
|
if (sw)
|
|
|
|
{
|
|
|
|
IShellWindows_Register(sw, NULL, (LONG_PTR)info->main_window, SWC_EXPLORER, &info->sw_cookie);
|
|
|
|
info->sw = sw;
|
|
|
|
}
|
|
|
|
|
2011-06-11 23:42:17 +02:00
|
|
|
fs.ViewMode = FVM_DETAILS;
|
|
|
|
fs.fFlags = FWF_AUTOARRANGE;
|
|
|
|
|
2017-11-09 18:25:19 +01:00
|
|
|
SetRect(&rect, 0, 0, default_width, default_height);
|
2017-05-02 12:03:18 +02:00
|
|
|
IExplorerBrowser_Initialize(info->browser,info->main_window,&rect,&fs);
|
2011-06-11 23:42:17 +02:00
|
|
|
IExplorerBrowser_SetOptions(info->browser,EBO_SHOWFRAMES);
|
2011-07-05 19:17:45 +02:00
|
|
|
SetWindowLongPtrW(info->main_window,EXPLORER_INFO_INDEX,(LONG_PTR)info);
|
2011-07-04 03:35:55 +02:00
|
|
|
|
|
|
|
/*setup navbar*/
|
|
|
|
rebar = CreateWindowExW(WS_EX_TOOLWINDOW,REBARCLASSNAMEW,NULL,
|
|
|
|
WS_CHILD|WS_VISIBLE|RBS_VARHEIGHT|CCS_TOP|CCS_NODIVIDER,
|
|
|
|
0,0,0,0,info->main_window,NULL,explorer_hInstance,NULL);
|
|
|
|
nav_toolbar
|
|
|
|
= CreateWindowExW(TBSTYLE_EX_MIXEDBUTTONS,TOOLBARCLASSNAMEW,NULL,
|
|
|
|
WS_CHILD|WS_VISIBLE|TBSTYLE_FLAT,0,0,0,0,rebar,NULL,
|
|
|
|
explorer_hInstance,NULL);
|
|
|
|
|
|
|
|
bitmap_info.hInst = HINST_COMMCTRL;
|
|
|
|
bitmap_info.nID = IDB_HIST_LARGE_COLOR;
|
|
|
|
hist_offset= SendMessageW(nav_toolbar,TB_ADDBITMAP,0,(LPARAM)&bitmap_info);
|
|
|
|
bitmap_info.nID = IDB_VIEW_LARGE_COLOR;
|
|
|
|
view_offset= SendMessageW(nav_toolbar,TB_ADDBITMAP,0,(LPARAM)&bitmap_info);
|
|
|
|
|
|
|
|
nav_buttons[0].iBitmap=hist_offset+HIST_BACK;
|
|
|
|
nav_buttons[0].idCommand=BACK_BUTTON;
|
|
|
|
nav_buttons[0].fsState=TBSTATE_ENABLED;
|
|
|
|
nav_buttons[0].fsStyle=BTNS_BUTTON|BTNS_AUTOSIZE;
|
|
|
|
nav_buttons[1].iBitmap=hist_offset+HIST_FORWARD;
|
|
|
|
nav_buttons[1].idCommand=FORWARD_BUTTON;
|
|
|
|
nav_buttons[1].fsState=TBSTATE_ENABLED;
|
|
|
|
nav_buttons[1].fsStyle=BTNS_BUTTON|BTNS_AUTOSIZE;
|
|
|
|
nav_buttons[2].iBitmap=view_offset+VIEW_PARENTFOLDER;
|
|
|
|
nav_buttons[2].idCommand=UP_BUTTON;
|
|
|
|
nav_buttons[2].fsState=TBSTATE_ENABLED;
|
|
|
|
nav_buttons[2].fsStyle=BTNS_BUTTON|BTNS_AUTOSIZE;
|
|
|
|
SendMessageW(nav_toolbar,TB_BUTTONSTRUCTSIZE,sizeof(TBBUTTON),0);
|
2018-08-21 23:10:20 +02:00
|
|
|
SendMessageW(nav_toolbar,TB_ADDBUTTONSW,ARRAY_SIZE( nav_buttons ),(LPARAM)nav_buttons);
|
2011-07-04 03:35:55 +02:00
|
|
|
|
|
|
|
band_info.cbSize = sizeof(band_info);
|
|
|
|
band_info.fMask = RBBIM_STYLE|RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_SIZE;
|
|
|
|
band_info.hwndChild = nav_toolbar;
|
|
|
|
band_info.fStyle=RBBS_GRIPPERALWAYS|RBBS_CHILDEDGE;
|
2017-11-09 18:25:19 +01:00
|
|
|
band_info.cyChild=nav_toolbar_height;
|
2011-07-04 03:35:55 +02:00
|
|
|
band_info.cx=0;
|
2017-11-09 18:25:19 +01:00
|
|
|
band_info.cyMinChild=nav_toolbar_height;
|
2011-07-04 03:35:55 +02:00
|
|
|
band_info.cxMinChild=0;
|
|
|
|
SendMessageW(rebar,RB_INSERTBANDW,-1,(LPARAM)&band_info);
|
2011-07-04 03:36:01 +02:00
|
|
|
info->path_box = CreateWindowW(WC_COMBOBOXEXW,PATH_BOX_NAME,
|
|
|
|
WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,
|
2017-11-09 18:25:19 +01:00
|
|
|
0,0,default_width,pathbox_height,rebar,NULL,
|
2011-07-04 03:36:01 +02:00
|
|
|
explorer_hInstance,NULL);
|
2017-05-02 12:03:18 +02:00
|
|
|
GetWindowRect(info->path_box, &rect);
|
|
|
|
band_info.cyChild = rect.bottom - rect.top;
|
2011-07-04 03:36:01 +02:00
|
|
|
band_info.cx=0;
|
2017-05-02 12:03:18 +02:00
|
|
|
band_info.cyMinChild = rect.bottom - rect.top;
|
2011-07-04 03:36:01 +02:00
|
|
|
band_info.cxMinChild=0;
|
|
|
|
band_info.fMask|=RBBIM_TEXT;
|
|
|
|
band_info.lpText=pathbox_label;
|
|
|
|
band_info.fStyle|=RBBS_BREAK;
|
|
|
|
band_info.hwndChild=info->path_box;
|
|
|
|
SendMessageW(rebar,RB_INSERTBANDW,-1,(LPARAM)&band_info);
|
|
|
|
events = make_explorer_events(info);
|
2011-07-22 04:59:20 +02:00
|
|
|
IExplorerBrowser_Advise(info->browser,events,&info->advise_cookie);
|
2020-05-18 06:29:44 +02:00
|
|
|
|
|
|
|
folder = get_starting_shell_folder(path);
|
|
|
|
IExplorerBrowser_BrowseToObject(info->browser, (IUnknown *)folder, SBSP_ABSOLUTE);
|
|
|
|
IShellFolder_Release(folder);
|
|
|
|
|
2011-07-04 03:35:55 +02:00
|
|
|
ShowWindow(info->main_window,SW_SHOWDEFAULT);
|
|
|
|
UpdateWindow(info->main_window);
|
2011-07-04 03:36:01 +02:00
|
|
|
IExplorerBrowserEvents_Release(events);
|
2020-05-18 06:29:44 +02:00
|
|
|
|
|
|
|
while (GetMessageW(&msg, NULL, 0, 0))
|
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessageW(&msg);
|
|
|
|
}
|
2011-06-11 23:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void update_window_size(explorer_info *info, int height, int width)
|
|
|
|
{
|
|
|
|
RECT new_rect;
|
|
|
|
new_rect.left = 0;
|
2011-07-04 03:35:55 +02:00
|
|
|
new_rect.top = info->rebar_height;
|
2011-06-11 23:42:17 +02:00
|
|
|
new_rect.right = width;
|
|
|
|
new_rect.bottom = height;
|
|
|
|
IExplorerBrowser_SetRect(info->browser,NULL,new_rect);
|
|
|
|
}
|
2005-11-16 12:45:51 +01:00
|
|
|
|
2011-06-11 23:42:17 +02:00
|
|
|
static void do_exit(int code)
|
|
|
|
{
|
|
|
|
OleUninitialize();
|
|
|
|
ExitProcess(code);
|
|
|
|
}
|
|
|
|
|
2011-07-04 03:36:01 +02:00
|
|
|
static LRESULT explorer_on_end_edit(explorer_info *info,NMCBEENDEDITW *edit_info)
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl = NULL;
|
|
|
|
|
|
|
|
WINE_TRACE("iWhy=%x\n",edit_info->iWhy);
|
|
|
|
switch(edit_info->iWhy)
|
|
|
|
{
|
2011-07-04 03:36:05 +02:00
|
|
|
case CBENF_DROPDOWN:
|
|
|
|
if(edit_info->iNewSelection!=CB_ERR)
|
|
|
|
pidl = (LPITEMIDLIST)SendMessageW(edit_info->hdr.hwndFrom,
|
|
|
|
CB_GETITEMDATA,
|
|
|
|
edit_info->iNewSelection,0);
|
|
|
|
break;
|
2011-07-04 03:36:01 +02:00
|
|
|
case CBENF_RETURN:
|
|
|
|
{
|
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
HWND edit_ctrl = (HWND)SendMessageW(edit_info->hdr.hwndFrom,
|
|
|
|
CBEM_GETEDITCONTROL,0,0);
|
|
|
|
*((WORD*)path)=MAX_PATH;
|
|
|
|
SendMessageW(edit_ctrl,EM_GETLINE,0,(LPARAM)path);
|
|
|
|
pidl = ILCreateFromPathW(path);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CBENF_ESCAPE:
|
|
|
|
/*make sure the that the path box resets*/
|
|
|
|
update_path_box(info);
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if(pidl)
|
|
|
|
IExplorerBrowser_BrowseToIDList(info->browser,pidl,SBSP_ABSOLUTE);
|
|
|
|
if(edit_info->iWhy==CBENF_RETURN)
|
|
|
|
ILFree(pidl);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-04 03:35:55 +02:00
|
|
|
static LRESULT update_rebar_size(explorer_info* info,NMRBAUTOSIZE *size_info)
|
|
|
|
{
|
|
|
|
RECT new_rect;
|
|
|
|
RECT window_rect;
|
|
|
|
info->rebar_height = size_info->rcTarget.bottom-size_info->rcTarget.top;
|
|
|
|
GetWindowRect(info->main_window,&window_rect);
|
|
|
|
new_rect.left = 0;
|
|
|
|
new_rect.top = info->rebar_height;
|
|
|
|
new_rect.right = window_rect.right-window_rect.left;
|
|
|
|
new_rect.bottom = window_rect.bottom-window_rect.top;
|
|
|
|
IExplorerBrowser_SetRect(info->browser,NULL,new_rect);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT explorer_on_notify(explorer_info* info,NMHDR* notification)
|
|
|
|
{
|
|
|
|
WINE_TRACE("code=%i\n",notification->code);
|
|
|
|
switch(notification->code)
|
|
|
|
{
|
2011-07-04 03:36:05 +02:00
|
|
|
case CBEN_BEGINEDIT:
|
|
|
|
{
|
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
HWND edit_ctrl = (HWND)SendMessageW(notification->hwndFrom,
|
|
|
|
CBEM_GETEDITCONTROL,0,0);
|
|
|
|
SHGetPathFromIDListW(info->pidl,path);
|
|
|
|
SetWindowTextW(edit_ctrl,path);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CBEN_ENDEDITA:
|
|
|
|
{
|
|
|
|
NMCBEENDEDITA *edit_info_a = (NMCBEENDEDITA*)notification;
|
|
|
|
NMCBEENDEDITW edit_info_w;
|
|
|
|
edit_info_w.hdr = edit_info_a->hdr;
|
|
|
|
edit_info_w.fChanged = edit_info_a->fChanged;
|
|
|
|
edit_info_w.iNewSelection = edit_info_a->iNewSelection;
|
|
|
|
MultiByteToWideChar(CP_ACP,0,edit_info_a->szText,-1,
|
|
|
|
edit_info_w.szText,CBEMAXSTRLEN);
|
|
|
|
edit_info_w.iWhy = edit_info_a->iWhy;
|
|
|
|
return explorer_on_end_edit(info,&edit_info_w);
|
|
|
|
}
|
2011-07-04 03:36:01 +02:00
|
|
|
case CBEN_ENDEDITW:
|
|
|
|
return explorer_on_end_edit(info,(NMCBEENDEDITW*)notification);
|
2011-07-04 03:36:05 +02:00
|
|
|
case CBEN_DELETEITEM:
|
|
|
|
{
|
|
|
|
NMCOMBOBOXEXW *entry = (NMCOMBOBOXEXW*)notification;
|
|
|
|
if(entry->ceItem.lParam)
|
|
|
|
ILFree((LPITEMIDLIST)entry->ceItem.lParam);
|
|
|
|
break;
|
|
|
|
}
|
2011-07-04 03:35:55 +02:00
|
|
|
case RBN_AUTOSIZE:
|
|
|
|
return update_rebar_size(info,(NMRBAUTOSIZE*)notification);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-06-19 14:09:31 +02:00
|
|
|
static LRESULT CALLBACK explorer_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
2011-06-11 23:42:17 +02:00
|
|
|
{
|
|
|
|
explorer_info *info
|
|
|
|
= (explorer_info*)GetWindowLongPtrW(hwnd,EXPLORER_INFO_INDEX);
|
|
|
|
IExplorerBrowser *browser = NULL;
|
|
|
|
|
2011-07-04 03:35:55 +02:00
|
|
|
WINE_TRACE("(hwnd=%p,uMsg=%u,wParam=%lx,lParam=%lx)\n",hwnd,uMsg,wParam,lParam);
|
2011-06-11 23:42:17 +02:00
|
|
|
if(info)
|
|
|
|
browser = info->browser;
|
|
|
|
switch(uMsg)
|
|
|
|
{
|
|
|
|
case WM_DESTROY:
|
2020-05-18 06:29:44 +02:00
|
|
|
IShellWindows_Revoke(info->sw, info->sw_cookie);
|
|
|
|
IShellWindows_Release(info->sw);
|
|
|
|
|
2011-07-22 04:59:20 +02:00
|
|
|
IExplorerBrowser_Unadvise(browser,info->advise_cookie);
|
|
|
|
IExplorerBrowser_Destroy(browser);
|
2011-06-11 23:42:17 +02:00
|
|
|
IExplorerBrowser_Release(browser);
|
2011-07-22 04:59:20 +02:00
|
|
|
ILFree(info->pidl);
|
|
|
|
IImageList_Release(info->icon_list);
|
2011-06-11 23:42:17 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,info);
|
2011-07-22 04:59:20 +02:00
|
|
|
SetWindowLongPtrW(hwnd,EXPLORER_INFO_INDEX,0);
|
2011-06-11 23:42:17 +02:00
|
|
|
PostQuitMessage(0);
|
|
|
|
break;
|
|
|
|
case WM_QUIT:
|
|
|
|
do_exit(wParam);
|
2011-07-04 03:35:55 +02:00
|
|
|
case WM_NOTIFY:
|
|
|
|
return explorer_on_notify(info,(NMHDR*)lParam);
|
|
|
|
case WM_COMMAND:
|
|
|
|
if(HIWORD(wParam)==BN_CLICKED)
|
|
|
|
{
|
|
|
|
switch(LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case BACK_BUTTON:
|
|
|
|
IExplorerBrowser_BrowseToObject(browser,NULL,SBSP_NAVIGATEBACK);
|
|
|
|
break;
|
|
|
|
case FORWARD_BUTTON:
|
|
|
|
IExplorerBrowser_BrowseToObject(browser,NULL,SBSP_NAVIGATEFORWARD);
|
|
|
|
break;
|
|
|
|
case UP_BUTTON:
|
|
|
|
IExplorerBrowser_BrowseToObject(browser,NULL,SBSP_PARENT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-06-11 23:42:17 +02:00
|
|
|
case WM_SIZE:
|
|
|
|
update_window_size(info,HIWORD(lParam),LOWORD(lParam));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return DefWindowProcW(hwnd,uMsg,wParam,lParam);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void register_explorer_window_class(void)
|
|
|
|
{
|
|
|
|
WNDCLASSEXW window_class;
|
|
|
|
window_class.cbSize = sizeof(WNDCLASSEXW);
|
|
|
|
window_class.style = 0;
|
|
|
|
window_class.cbClsExtra = 0;
|
|
|
|
window_class.cbWndExtra = sizeof(LONG_PTR);
|
|
|
|
window_class.lpfnWndProc = explorer_wnd_proc;
|
|
|
|
window_class.hInstance = explorer_hInstance;
|
|
|
|
window_class.hIcon = NULL;
|
|
|
|
window_class.hCursor = NULL;
|
2011-07-04 03:35:55 +02:00
|
|
|
window_class.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
|
2011-06-11 23:42:17 +02:00
|
|
|
window_class.lpszMenuName = NULL;
|
|
|
|
window_class.lpszClassName = EXPLORER_CLASS;
|
|
|
|
window_class.hIconSm = NULL;
|
|
|
|
RegisterClassExW(&window_class);
|
|
|
|
}
|
|
|
|
|
2017-12-12 09:33:32 +01:00
|
|
|
static WCHAR *copy_path_string(WCHAR *target, WCHAR *source)
|
2005-11-16 12:45:51 +01:00
|
|
|
{
|
|
|
|
INT i = 0;
|
|
|
|
|
2019-05-03 12:28:45 +02:00
|
|
|
while (iswspace(*source)) source++;
|
2005-11-16 12:45:51 +01:00
|
|
|
|
|
|
|
if (*source == '\"')
|
|
|
|
{
|
|
|
|
source ++;
|
2017-12-12 09:33:32 +01:00
|
|
|
while (*source && *source != '\"') target[i++] = *source++;
|
2008-04-23 18:04:43 +02:00
|
|
|
target[i] = 0;
|
2017-12-12 09:33:32 +01:00
|
|
|
if (*source) source++;
|
2005-11-16 12:45:51 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-14 14:11:28 +02:00
|
|
|
while (*source && *source != ',') target[i++] = *source++;
|
2008-04-23 18:04:43 +02:00
|
|
|
target[i] = 0;
|
2005-11-16 12:45:51 +01:00
|
|
|
}
|
2014-11-20 14:22:29 +01:00
|
|
|
PathRemoveBackslashW(target);
|
2017-12-12 09:33:32 +01:00
|
|
|
return source;
|
2005-11-16 12:45:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-11 23:42:17 +02:00
|
|
|
static void copy_path_root(LPWSTR root, LPWSTR path)
|
2005-11-16 12:45:51 +01:00
|
|
|
{
|
|
|
|
LPWSTR p,p2;
|
|
|
|
INT i = 0;
|
|
|
|
|
|
|
|
p = path;
|
|
|
|
while (*p!=0)
|
|
|
|
p++;
|
|
|
|
|
|
|
|
while (*p!='\\' && p > path)
|
|
|
|
p--;
|
|
|
|
|
|
|
|
if (p == path)
|
|
|
|
return;
|
|
|
|
|
|
|
|
p2 = path;
|
|
|
|
while (p2 != p)
|
|
|
|
{
|
|
|
|
root[i] = *p2;
|
|
|
|
i++;
|
|
|
|
p2++;
|
|
|
|
}
|
|
|
|
root[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Command Line parameters are:
|
|
|
|
* [/n] Opens in single-paned view for each selected items. This is default
|
|
|
|
* [/e,] Uses Windows Explorer View
|
2020-03-27 08:14:52 +01:00
|
|
|
* [/cd,object] Specifies the root level of the view
|
2005-11-16 12:45:51 +01:00
|
|
|
* [/root,object] Specifies the root level of the view
|
|
|
|
* [/select,object] parent folder is opened and specified object is selected
|
|
|
|
*/
|
2011-06-11 23:42:17 +02:00
|
|
|
static void parse_command_line(LPWSTR commandline,parameters_struct *parameters)
|
2005-11-16 12:45:51 +01:00
|
|
|
{
|
2008-04-23 18:04:43 +02:00
|
|
|
static const WCHAR arg_n[] = {'/','n'};
|
|
|
|
static const WCHAR arg_e[] = {'/','e',','};
|
2020-03-27 08:14:52 +01:00
|
|
|
static const WCHAR arg_cd[] = {'/','c','d',','};
|
2008-04-23 18:04:43 +02:00
|
|
|
static const WCHAR arg_root[] = {'/','r','o','o','t',','};
|
|
|
|
static const WCHAR arg_select[] = {'/','s','e','l','e','c','t',','};
|
|
|
|
static const WCHAR arg_desktop[] = {'/','d','e','s','k','t','o','p'};
|
2016-01-14 11:41:49 +01:00
|
|
|
static const WCHAR arg_desktop_quotes[] = {'"','/','d','e','s','k','t','o','p'};
|
2008-04-23 18:04:43 +02:00
|
|
|
|
2015-11-24 09:36:53 +01:00
|
|
|
LPWSTR p = commandline;
|
2008-04-23 18:04:43 +02:00
|
|
|
|
2015-11-24 09:36:53 +01:00
|
|
|
while (*p)
|
2005-11-16 12:45:51 +01:00
|
|
|
{
|
2019-05-03 12:28:45 +02:00
|
|
|
while (iswspace(*p)) p++;
|
|
|
|
if (wcsncmp(p, arg_n, ARRAY_SIZE( arg_n ))==0)
|
2005-11-16 12:45:51 +01:00
|
|
|
{
|
|
|
|
parameters->explorer_mode = FALSE;
|
2018-08-21 23:10:20 +02:00
|
|
|
p += ARRAY_SIZE( arg_n );
|
2005-11-16 12:45:51 +01:00
|
|
|
}
|
2019-05-03 12:28:45 +02:00
|
|
|
else if (wcsncmp(p, arg_e, ARRAY_SIZE( arg_e ))==0)
|
2005-11-16 12:45:51 +01:00
|
|
|
{
|
|
|
|
parameters->explorer_mode = TRUE;
|
2018-08-21 23:10:20 +02:00
|
|
|
p += ARRAY_SIZE( arg_e );
|
2005-11-16 12:45:51 +01:00
|
|
|
}
|
2020-03-27 08:14:52 +01:00
|
|
|
else if (wcsncmp(p, arg_cd, ARRAY_SIZE( arg_cd ))==0)
|
|
|
|
{
|
|
|
|
p += ARRAY_SIZE( arg_cd );
|
|
|
|
p = copy_path_string(parameters->root,p);
|
|
|
|
}
|
2019-05-03 12:28:45 +02:00
|
|
|
else if (wcsncmp(p, arg_root, ARRAY_SIZE( arg_root ))==0)
|
2005-11-16 12:45:51 +01:00
|
|
|
{
|
2018-08-21 23:10:20 +02:00
|
|
|
p += ARRAY_SIZE( arg_root );
|
2017-12-12 09:33:32 +01:00
|
|
|
p = copy_path_string(parameters->root,p);
|
2005-11-16 12:45:51 +01:00
|
|
|
}
|
2019-05-03 12:28:45 +02:00
|
|
|
else if (wcsncmp(p, arg_select, ARRAY_SIZE( arg_select ))==0)
|
2005-11-16 12:45:51 +01:00
|
|
|
{
|
2018-08-21 23:10:20 +02:00
|
|
|
p += ARRAY_SIZE( arg_select );
|
2017-12-12 09:33:32 +01:00
|
|
|
p = copy_path_string(parameters->selection,p);
|
2005-11-16 12:45:51 +01:00
|
|
|
if (!parameters->root[0])
|
2011-06-11 23:42:17 +02:00
|
|
|
copy_path_root(parameters->root,
|
|
|
|
parameters->selection);
|
2005-11-16 12:45:51 +01:00
|
|
|
}
|
2019-05-03 12:28:45 +02:00
|
|
|
else if (wcsncmp(p, arg_desktop, ARRAY_SIZE( arg_desktop ))==0)
|
2006-03-07 11:41:52 +01:00
|
|
|
{
|
2018-08-21 23:10:20 +02:00
|
|
|
p += ARRAY_SIZE( arg_desktop );
|
2008-04-23 18:04:43 +02:00
|
|
|
manage_desktop( p ); /* the rest of the command line is handled by desktop mode */
|
2006-03-07 11:41:52 +01:00
|
|
|
}
|
2016-01-14 11:41:49 +01:00
|
|
|
/* workaround for Worms Armageddon that hardcodes a /desktop option with quotes */
|
2019-05-03 12:28:45 +02:00
|
|
|
else if (wcsncmp(p, arg_desktop_quotes, ARRAY_SIZE( arg_desktop_quotes ))==0)
|
2016-01-14 11:41:49 +01:00
|
|
|
{
|
2018-08-21 23:10:20 +02:00
|
|
|
p += ARRAY_SIZE( arg_desktop_quotes );
|
2016-01-14 11:41:49 +01:00
|
|
|
manage_desktop( p ); /* the rest of the command line is handled by desktop mode */
|
|
|
|
}
|
2015-11-24 09:36:53 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* left over command line is generally the path to be opened */
|
|
|
|
copy_path_string(parameters->root,p);
|
|
|
|
break;
|
|
|
|
}
|
2005-11-16 12:45:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-23 18:04:43 +02:00
|
|
|
int WINAPI wWinMain(HINSTANCE hinstance,
|
|
|
|
HINSTANCE previnstance,
|
|
|
|
LPWSTR cmdline,
|
|
|
|
int cmdshow)
|
2005-11-16 12:45:51 +01:00
|
|
|
{
|
2011-06-11 23:42:17 +02:00
|
|
|
|
2005-11-16 12:45:51 +01:00
|
|
|
parameters_struct parameters;
|
2011-06-11 23:42:17 +02:00
|
|
|
HRESULT hres;
|
2011-07-04 03:35:55 +02:00
|
|
|
INITCOMMONCONTROLSEX init_info;
|
2005-11-16 12:45:51 +01:00
|
|
|
|
|
|
|
memset(¶meters,0,sizeof(parameters));
|
2011-06-11 23:42:17 +02:00
|
|
|
explorer_hInstance = hinstance;
|
|
|
|
parse_command_line(cmdline,¶meters);
|
|
|
|
hres = OleInitialize(NULL);
|
2011-07-19 15:09:12 +02:00
|
|
|
if(FAILED(hres))
|
2006-01-14 17:05:18 +01:00
|
|
|
{
|
2011-06-11 23:42:17 +02:00
|
|
|
WINE_ERR("Could not initialize COM\n");
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
2006-01-14 17:05:18 +01:00
|
|
|
}
|
2011-08-29 10:15:00 +02:00
|
|
|
if(parameters.root[0] && !PathIsDirectoryW(parameters.root))
|
|
|
|
if(ShellExecuteW(NULL,NULL,parameters.root,NULL,NULL,SW_SHOWDEFAULT) > (HINSTANCE)32)
|
|
|
|
ExitProcess(EXIT_SUCCESS);
|
2011-07-04 03:35:55 +02:00
|
|
|
init_info.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
2011-07-04 03:36:01 +02:00
|
|
|
init_info.dwICC = ICC_USEREX_CLASSES | ICC_BAR_CLASSES | ICC_COOL_CLASSES;
|
2011-07-04 03:35:55 +02:00
|
|
|
if(!InitCommonControlsEx(&init_info))
|
|
|
|
{
|
|
|
|
WINE_ERR("Could not initialize Comctl\n");
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
2011-06-11 23:42:17 +02:00
|
|
|
register_explorer_window_class();
|
2020-05-18 06:29:44 +02:00
|
|
|
make_explorer_window(¶meters);
|
2005-11-16 12:45:51 +01:00
|
|
|
return 0;
|
|
|
|
}
|