4 * Copyright 2014 Giannis Adamopoulos
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 typedef HRESULT (WINAPI
*SH_OPEN_NEW_FRAME
)(LPITEMIDLIST pidl
, IUnknown
*paramC
, long param10
, long param14
);
29 int _tmain(int argc
, _TCHAR
* argv
[])
33 LPSHELLFOLDER pDesktopFolder
= NULL
;
34 LPITEMIDLIST pidlRoot
= NULL
;
35 typedef HRESULT(WINAPI
*SH_OPEN_NEW_FRAME
)(LPITEMIDLIST pidl
, IUnknown
*paramC
, long param10
, long param14
);
36 SH_OPEN_NEW_FRAME SHOpenNewFrame
;
38 HMODULE hBrowseui
= LoadLibraryW(L
"browseui.dll");
46 SH_OPEN_NEW_FRAME SHOpenNewFrame
= (SH_OPEN_NEW_FRAME
) GetProcAddress(hBrowseui
, (LPCSTR
) 103);
47 LPITEMIDLIST pidlDrives
;
48 SHGetSpecialFolderLocation(NULL
, CSIDL_DRIVES
, &pidlDrives
);
49 SHOpenNewFrame((LPITEMIDLIST
) pidlDrives
, NULL
, 0, 0);
53 /* A shell is already loaded. Parse the command line arguments
54 and unless we need to do something specific simply display
55 the desktop in a separate explorer window */
58 /* Commandline switches:
60 * /n Open a new window, even if an existing one still exists.
61 * /e Start with the explorer sidebar shown.
62 * /root,<object> Open a window for the given object path.
63 * /select,<object> Open a window with the given object selected.
66 /* FIXME: Do it right */
67 WCHAR
* tmp
= wcsstr(argv
[1], L
"/root,");
72 tmp
+= 6; // skip to beginning of path
73 tmp2
= wcschr(tmp
, L
',');
77 wcsncpy(root
, tmp
, tmp2
- tmp
);
86 wcscpy(root
, argv
[1]);
91 int len
= wcslen(root
) - 2;
92 wcsncpy(root
, root
+ 1, len
);
102 if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder
)))
104 hr
= pDesktopFolder
->lpVtbl
->ParseDisplayName(pDesktopFolder
,
120 hr
= SHGetSpecialFolderLocation(NULL
, CSIDL_DRIVES
, &pidlRoot
);
125 SHOpenNewFrame
= (SH_OPEN_NEW_FRAME
) GetProcAddress(hBrowseui
, (LPCSTR
) 103);
127 hr
= SHOpenNewFrame(pidlRoot
, (IUnknown
*) pDesktopFolder
, 0, 0);
132 /* FIXME: we should wait a bit here and see if a window was created. If not we should exit this process. */