Index: base/shell/explorer-new/command_line.c =================================================================== --- base/shell/explorer-new/command_line.c (revision 0) +++ base/shell/explorer-new/command_line.c (revision 0) @@ -0,0 +1,199 @@ +#include + +HRESULT WINAPI SHOpenFolderAndSelectItems( + IN PCIDLIST_ABSOLUTE pidlFolder, + UINT cidl, + IN OPTIONAL PCUITEMID_CHILD_ARRAY *apidl, + DWORD dwFlags +); + +/* return values */ +#define NOT_ENOUGH_MEMORY 1 +#define IO_ERROR 2 + +/* common check of memory allocation results */ +#define CHECK_ENOUGH_MEMORY(p) \ +if (!(p)) \ +{ \ + exit(NOT_ENOUGH_MEMORY); \ +} + +TCHAR szProfilePath[MAX_PATH]; + +typedef enum +{ + ACTION_SELECT, ACTION_ROOT, ACTION_EXPLVIEW, ACTION_NEWWINDOW, ACTION_DEFAULT +} EXPLORER_ACTION; + +void get_file_name(LPWSTR *command_line, LPWSTR file_name) +{ + WCHAR *s = *command_line; + int pos = 0; /* position of pointer "s" in *command_line */ + file_name[0] = 0; + + if (!s[0]) + { + return; + } + + if (s[0] == L'"') + { + s++; + (*command_line)++; + while(s[0] != L'"') + { + s++; + pos++; + } + } + else + { + while(s[0] && !iswspace(s[0])) + { + s++; + pos++; + } + } + memcpy(file_name, *command_line, pos * sizeof((*command_line)[0])); + /* remove the last backslash */ + if (file_name[pos - 1] == L'\\') + { + file_name[pos - 1] = L'\0'; + } + else + { + file_name[pos] = L'\0'; + } + + if (s[0]) + { + s++; + pos++; + } + while(s[0] && iswspace(s[0])) + { + s++; + pos++; + } + (*command_line) += pos; +} + + +BOOL PerformExplAction(EXPLORER_ACTION action, LPWSTR s) +{ + wchar_t fpath[MAX_PATH]; + get_file_name(&s, fpath); + + switch (action) + { + case ACTION_SELECT: + { + if (!fpath[0]) + { + action = ACTION_DEFAULT; //No object is specified + } + else + { + PIDLIST_ABSOLUTE pidlFolder; + pidlFolder = ILCreateFromPath(fpath); + if (pidlFolder) + { + SHOpenFolderAndSelectItems(pidlFolder, 0, NULL, 0); + ILFree(pidlFolder); + } + } + break; + } + case ACTION_EXPLVIEW: + break; + + case ACTION_NEWWINDOW: + break; + + case ACTION_ROOT: + break; + + case ACTION_DEFAULT: + { + if(SUCCEEDED(SHGetFolderPath(NULL, + CSIDL_PROFILE|CSIDL_FLAG_CREATE, + NULL, + 0, + szProfilePath))) + { + //Enable ShellExecute and explorer-new will go to infinitive loop when explorer is replaced + //ShellExecute(NULL, NULL, szProfilePath, NULL, NULL, SW_SHOWNORMAL); + } + } + break; + + default: + action = ACTION_DEFAULT; + break; + } + return TRUE; +} + +BOOL ProcessCmdLine(LPWSTR lpCmdLine) +{ + EXPLORER_ACTION action = ACTION_DEFAULT; + LPWSTR s = lpCmdLine; /* command line pointer */ + WCHAR ch = *s; /* current character */ + + while (ch && (ch == L'/')) + { + WCHAR chu; + WCHAR ch2; + + s++; + ch = *s; + ch2 = *(s + 1); + chu = (WCHAR)towupper(ch); + if (ch2 == L',') + { + switch (chu) + { + case L'N': + s += 2; + action = ACTION_NEWWINDOW; + break; + + case L'E': + s += 2; + action = ACTION_EXPLVIEW; + break; + + default: + action = ACTION_DEFAULT; + break; + } + } + else + { + if (!_wcsnicmp(s, L"SELECT,", 7)) //there we deal with multi-letter options + { + s += 7; + action = ACTION_SELECT; + } + else + if (!_wcsnicmp(s, L"ROOT,", 5)) + { + s += 5; + action = ACTION_ROOT; + } + else + s--; // this is a file name, starting from '/' + break; + } + + /* skip spaces to the next parameter */ + ch = *s; + while (ch && iswspace(ch)) + { + s++; + ch = *s; + } + } + + return PerformExplAction(action, s); +} Index: base/shell/explorer-new/explorer.c =================================================================== --- base/shell/explorer-new/explorer.c (revision 51624) +++ base/shell/explorer-new/explorer.c (working copy) @@ -32,9 +32,6 @@ WORD wCodePage; } LANGCODEPAGE, *PLANGCODEPAGE; -/* undoc GUID */ -DEFINE_GUID(CLSID_RebarBandSite, 0xECD4FC4D, 0x521C, 0x11D0, 0xB7, 0x92, 0x00, 0xA0, 0xC9, 0x03, 0x12, 0xE1); - LONG SetWindowStyle(IN HWND hWnd, IN LONG dwStyleMask, @@ -404,10 +401,11 @@ } else { - /* A shell is already loaded. Parse the command line arguments - and unless we need to do something specific simply display - the desktop in a separate explorer window */ - /* FIXME */ + /* A shell is already loaded. Parse the command line arguments */ + if (ProcessCmdLine(lpCmdLine)) + { + return 0; + } } if (Tray != NULL) Index: base/shell/explorer-new/explorer.rbuild =================================================================== --- base/shell/explorer-new/explorer.rbuild (revision 51624) +++ base/shell/explorer-new/explorer.rbuild (working copy) @@ -24,5 +24,6 @@ trayntfy.c trayprop.c traywnd.c + command_line.c explorer.rc Index: base/shell/explorer-new/precomp.h =================================================================== --- base/shell/explorer-new/precomp.h (revision 51624) +++ base/shell/explorer-new/precomp.h (working copy) @@ -385,6 +385,10 @@ IN BOOL bHideClock); /* + * command_lince.c + */ +BOOL ProcessCmdLine(LPWSTR lpCmdLine); +/* * taskswnd.c */