ReactOS 0.4.15-dev-7788-g1ad9096
CNewMenu.cpp
Go to the documentation of this file.
1/*
2 * provides new shell item service
3 *
4 * Copyright 2007 Johannes Anderwald (johannes.anderwald@reactos.org)
5 * Copyright 2009 Andrew Hill
6 * Copyright 2012 Rafal Harabien
7 * Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include "precomp.h"
25
27
29 m_pidlFolder(NULL),
30 m_pItems(NULL),
31 m_pLinkItem(NULL),
32 m_pSite(NULL),
33 m_idCmdFirst(0),
34 m_idCmdFolder(-1),
35 m_idCmdLink(-1),
36 m_bCustomIconFolder(FALSE),
37 m_bCustomIconLink(FALSE),
38 m_hIconFolder(NULL),
39 m_hIconLink(NULL)
40{
41}
42
44{
46
51 if (m_pidlFolder)
53}
54
56{
57 /* Note: free allows NULL as argument */
58 free(pItem->pData);
59 free(pItem->pwszDesc);
60 free(pItem->pwszExt);
61
62 if (pItem->hIcon)
63 DestroyIcon(pItem->hIcon);
64
65 HeapFree(GetProcessHeap(), 0, pItem);
66}
67
69{
70 SHELLNEW_ITEM *pCurItem;
71
72 /* Unload the handler items, including the link item */
73 while (m_pItems)
74 {
75 pCurItem = m_pItems;
77 UnloadItem(pCurItem);
78 }
79 m_pItems = NULL;
81}
82
84{
85 HKEY hKey;
86 WCHAR wszBuf[MAX_PATH];
88 DWORD cbData;
89
90 StringCbPrintfW(wszBuf, sizeof(wszBuf), L"%s\\ShellNew", pwszExt);
91
92 TRACE("LoadItem Keyname %s Name %s\n", debugstr_w(pwszExt), debugstr_w(wszBuf));
93
95 {
96 TRACE("Failed to open key\n");
97 return NULL;
98 }
99
100 /* Find first valid value */
101 struct
102 {
103 LPCWSTR pszName;
105 BOOL bNeedData;
106 BOOL bStr;
107 } Types[] = {
108 {L"FileName", SHELLNEW_TYPE_FILENAME, TRUE, TRUE},
109 {L"Command", SHELLNEW_TYPE_COMMAND, TRUE, TRUE},
110 {L"Data", SHELLNEW_TYPE_DATA, TRUE, FALSE},
111 {L"NullFile", SHELLNEW_TYPE_NULLFILE, FALSE},
112 {NULL}
113 };
114 UINT i;
115
116 for (i = 0; Types[i].pszName; ++i)
117 {
118 /* Note: We are using ANSI function because strings can be treated as data */
119 cbData = 0;
121 DWORD dwType;
122 if (RegGetValueW(hKey, NULL, Types[i].pszName, dwFlags, NULL, NULL, &cbData) == ERROR_SUCCESS)
123 {
124 if (Types[i].bNeedData && cbData > 0)
125 {
126 pData = (PBYTE)malloc(cbData);
127 RegGetValueW(hKey, NULL, Types[i].pszName, dwFlags, &dwType, pData, &cbData);
128 if (!Types[i].bStr && (dwType == REG_SZ || dwType == REG_EXPAND_SZ))
129 {
130 PBYTE pData2 = (PBYTE)malloc(cbData);
131 cbData = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)pData, -1, (LPSTR)pData2, cbData, NULL, NULL);
132 free(pData);
133 pData = pData2;
134 }
135 }
136 break;
137 }
138 }
140
141 /* Was any key found? */
142 if (!Types[i].pszName)
143 {
144 free(pData);
145 return NULL;
146 }
147
148 SHFILEINFOW fi;
150 {
151 free(pData);
152 return NULL;
153 }
154
155 /* Create new item */
156 SHELLNEW_ITEM *pNewItem = static_cast<SHELLNEW_ITEM *>(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SHELLNEW_ITEM)));
157 if (!pNewItem)
158 {
159 free(pData);
160 return NULL;
161 }
162
163 TRACE("new item %ls\n", fi.szTypeName);
164 pNewItem->Type = Types[i].Type;
165 pNewItem->pData = pData;
166 pNewItem->cbData = pData ? cbData : 0;
167 pNewItem->pwszExt = _wcsdup(pwszExt);
168 pNewItem->pwszDesc = _wcsdup(fi.szTypeName);
169 if (fi.hIcon)
170 pNewItem->hIcon = fi.hIcon;
171
172 return pNewItem;
173}
174
175BOOL
177{
178 HKEY hKey;
179 DWORD dwSize = 0;
180 DWORD dwIndex = 0;
181 LPWSTR lpValue;
182 LPWSTR lpValues;
183 WCHAR wszName[MAX_PATH];
184 SHELLNEW_ITEM *pNewItem;
185 SHELLNEW_ITEM *pCurItem = NULL;
186
187 /* Enumerate all extensions */
188 while (RegEnumKeyW(HKEY_CLASSES_ROOT, dwIndex++, wszName, _countof(wszName)) == ERROR_SUCCESS)
189 {
190 if (wszName[0] != L'.')
191 continue;
192
193 pNewItem = LoadItem(wszName);
194 if (pNewItem)
195 {
196 dwSize += wcslen(wszName) + 1;
197 if (!m_pLinkItem && wcsicmp(pNewItem->pwszExt, L".lnk") == 0)
198 {
199 /* The unique link handler */
200 m_pLinkItem = pNewItem;
201 }
202
203 /* Add at the end of the list */
204 if (pCurItem)
205 {
206 pCurItem->pNext = pNewItem;
207 pCurItem = pNewItem;
208 }
209 else
210 {
211 pCurItem = m_pItems = pNewItem;
212 }
213 }
214 }
215
216 dwSize++;
217
218 lpValues = (LPWSTR) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize * sizeof(WCHAR));
219 if (!lpValues)
220 return FALSE;
221
222 for (pCurItem = m_pItems, lpValue = lpValues; pCurItem; pCurItem = pCurItem->pNext)
223 {
224 memcpy(lpValue, pCurItem->pwszExt, (wcslen(pCurItem->pwszExt) + 1) * sizeof(WCHAR));
225 lpValue += wcslen(pCurItem->pwszExt) + 1;
226 }
227
229 {
230 HeapFree(GetProcessHeap(), 0, lpValues);
231 return FALSE;
232 }
233
234 if (RegSetValueExW(hKey, L"Classes", NULL, REG_MULTI_SZ, (LPBYTE)lpValues, dwSize * sizeof(WCHAR)) != ERROR_SUCCESS)
235 {
236 HeapFree(GetProcessHeap(), 0, lpValues);
238 return FALSE;
239 }
240
241 HeapFree(GetProcessHeap(), 0, lpValues);
243
244 return TRUE;
245}
246
247BOOL
249{
250 LPWSTR wszName;
251 LPWSTR lpValues;
253 HKEY hKey;
254 SHELLNEW_ITEM *pNewItem;
255 SHELLNEW_ITEM *pCurItem = NULL;
256
258 return FALSE;
259
260 if (RegQueryValueExW(hKey, L"Classes", NULL, NULL, NULL, &dwSize) != ERROR_SUCCESS)
261 return FALSE;
262
263 lpValues = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, dwSize);
264 if (!lpValues)
265 return FALSE;
266
267 if (RegQueryValueExW(hKey, L"Classes", NULL, NULL, (LPBYTE)lpValues, &dwSize) != ERROR_SUCCESS)
268 {
269 HeapFree(GetProcessHeap(), 0, lpValues);
270 return FALSE;
271 }
272
273 wszName = lpValues;
274
275 for (; *wszName != '\0'; wszName += wcslen(wszName) + 1)
276 {
277 pNewItem = LoadItem(wszName);
278 if (pNewItem)
279 {
280 if (!m_pLinkItem && wcsicmp(pNewItem->pwszExt, L".lnk") == 0)
281 {
282 /* The unique link handler */
283 m_pLinkItem = pNewItem;
284 }
285
286 /* Add at the end of the list */
287 if (pCurItem)
288 {
289 pCurItem->pNext = pNewItem;
290 pCurItem = pNewItem;
291 }
292 else
293 {
294 pCurItem = m_pItems = pNewItem;
295 }
296 }
297 }
298
299 HeapFree(GetProcessHeap(), 0, lpValues);
301
302 return TRUE;
303}
304
305BOOL
307{
308 // TODO: We need to find a way to refresh the cache from time to time, when
309 // e.g. new extensions with ShellNew handlers have been added or removed.
310
311 /* If there are any unload them */
313
314 if (!LoadCachedItems())
315 {
316 CacheItems();
317 }
318
319 return (m_pItems != NULL);
320}
321
322UINT
324{
325 MENUITEMINFOW mii;
326 UINT idCmd = idCmdFirst;
327 WCHAR wszBuf[256];
328
329 if (m_pItems == NULL)
330 {
331 if (!LoadAllItems())
332 return 0;
333 }
334
335 ZeroMemory(&mii, sizeof(mii));
336 mii.cbSize = sizeof(mii);
337
338 m_idCmdFirst = idCmd;
339
340 /* Insert the new folder action */
342 wszBuf[0] = 0;
344 mii.dwTypeData = wszBuf;
345 mii.cch = wcslen(mii.dwTypeData);
346 mii.wID = idCmd;
347 mii.hbmpItem = HBMMENU_CALLBACK;
348 if (InsertMenuItemW(hMenu, Pos++, TRUE, &mii))
349 m_idCmdFolder = idCmd++;
350
351 /* Insert the new shortcut action */
352 if (m_pLinkItem)
353 {
355 wszBuf[0] = 0;
356 mii.dwTypeData = wszBuf;
357 mii.cch = wcslen(mii.dwTypeData);
358 mii.wID = idCmd;
359 if (InsertMenuItemW(hMenu, Pos++, TRUE, &mii))
360 m_idCmdLink = idCmd++;
361 }
362
363 /* Insert a seperator for the custom new action */
364 mii.fMask = MIIM_TYPE | MIIM_ID;
365 mii.fType = MFT_SEPARATOR;
366 mii.wID = -1;
367 InsertMenuItemW(hMenu, Pos++, TRUE, &mii);
368
369 /* Insert the rest of the items */
371 mii.fType = 0;
372
373 for (SHELLNEW_ITEM *pCurItem = m_pItems; pCurItem; pCurItem = pCurItem->pNext)
374 {
375 /* Skip shortcut item */
376 if (pCurItem == m_pLinkItem)
377 continue;
378
379 TRACE("szDesc %s\n", debugstr_w(pCurItem->pwszDesc));
380 mii.dwItemData = (ULONG_PTR)pCurItem;
381 mii.dwTypeData = pCurItem->pwszDesc;
382 mii.cch = wcslen(mii.dwTypeData);
383 mii.wID = idCmd;
384 if (InsertMenuItemW(hMenu, Pos++, TRUE, &mii))
385 ++idCmd;
386 }
387
388 return idCmd - idCmdFirst;
389}
390
392{
393 /* Folder */
394 if (m_idCmdFirst + IdOffset == m_idCmdFolder)
395 return NULL;
396
397 /* Shortcut */
398 if (m_idCmdFirst + IdOffset == m_idCmdLink)
399 return m_pLinkItem;
400
401 /* Find shell new item - Retrieve menu item info */
402 MENUITEMINFOW mii;
403 ZeroMemory(&mii, sizeof(mii));
404 mii.cbSize = sizeof(mii);
405 mii.fMask = MIIM_DATA;
406
407 if (GetMenuItemInfoW(m_hSubMenu, m_idCmdFirst + IdOffset, FALSE, &mii) && mii.dwItemData)
408 return (SHELLNEW_ITEM *)mii.dwItemData;
409 else
410 return NULL;
411}
412
414{
417 HRESULT hr = E_FAIL;
418 LPITEMIDLIST pidl;
419 PITEMID_CHILD pidlNewItem;
420 DWORD dwSelectFlags;
421
422 dwSelectFlags = SVSI_DESELECTOTHERS | SVSI_ENSUREVISIBLE | SVSI_FOCUSED | SVSI_SELECT;
423 if (bRename)
424 dwSelectFlags |= SVSI_EDIT;
425
426 /* Notify the view object about the new item */
427 SHChangeNotify(wEventId, uFlags | SHCNF_FLUSH, (LPCVOID)pszName, NULL);
428
429 if (!m_pSite)
430 return S_OK;
431
432 /* Get a pointer to the shell view */
435 return S_OK;
436
437 /* Attempt to get the pidl of the new item */
438 hr = SHILCreateFromPathW(pszName, &pidl, NULL);
440 return hr;
441
442 pidlNewItem = ILFindLastID(pidl);
443
444 hr = lpSV->SelectItem(pidlNewItem, dwSelectFlags);
445
446 SHFree(pidl);
447
448 return hr;
449}
450
451// Code is duplicated in CDefaultContextMenu
453{
454 WCHAR wszPath[MAX_PATH];
455 WCHAR wszName[MAX_PATH];
456 WCHAR wszNewFolder[25];
457 HRESULT hr;
458
459 /* Get folder path */
462 return hr;
463
464 if (!LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, _countof(wszNewFolder)))
465 return E_FAIL;
466
467 /* Create the name of the new directory */
468 if (!PathYetAnotherMakeUniqueName(wszName, wszPath, NULL, wszNewFolder))
469 return E_FAIL;
470
471 /* Create the new directory and show the appropriate dialog in case of error */
472 if (SHCreateDirectory(lpici->hwnd, wszName) != ERROR_SUCCESS)
473 return E_FAIL;
474
475 /* Show and select the new item in the def view */
477
478 return S_OK;
479}
480
482{
483 WCHAR wszBuf[MAX_PATH];
484 LPWSTR Ptr, pwszCmd;
485 WCHAR wszTemp[MAX_PATH];
486 STARTUPINFOW si;
488
489 if (!ExpandEnvironmentStringsW((LPWSTR)pItem->pData, wszBuf, _countof(wszBuf)))
490 {
491 TRACE("ExpandEnvironmentStrings failed\n");
492 return E_FAIL;
493 }
494
495 /* Expand command parameter, FIXME: there can be more modifiers */
496 Ptr = wcsstr(wszBuf, L"%1");
497 if (Ptr)
498 {
499 Ptr[1] = L's';
500 StringCbPrintfW(wszTemp, sizeof(wszTemp), wszBuf, wszPath);
501 pwszCmd = wszTemp;
502 }
503 else
504 {
505 pwszCmd = wszBuf;
506 }
507
508 /* Create process */
509 ZeroMemory(&si, sizeof(si));
510 si.cb = sizeof(si);
511 if (CreateProcessW(NULL, pwszCmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
512 {
513 CloseHandle(pi.hProcess);
514 CloseHandle(pi.hThread);
515 return S_OK;
516 }
517 else
518 {
519 ERR("Failed to create process\n");
520 return E_FAIL;
521 }
522}
523
525 DWORD cchNameMax, LPCWSTR wszPath)
526{
528
529 CStringW strNewItem;
530 strNewItem.Format(IDS_NEWITEMFORMAT, pItem->pwszDesc);
531 strNewItem += pItem->pwszExt;
532
533 /* Create the name of the new file */
534 if (!PathYetAnotherMakeUniqueName(wszName, wszPath, NULL, strNewItem))
535 return E_FAIL;
536
537 /* Create new file */
540 {
541 if (pItem->Type == SHELLNEW_TYPE_DATA)
542 {
543 /* Write a content */
544 DWORD cbWritten;
545 WriteFile(hFile, pItem->pData, pItem->cbData, &cbWritten, NULL);
546 }
547
548 /* Close file now */
550 }
551 else
552 {
553 bSuccess = FALSE;
554 }
555
556 if (pItem->Type == SHELLNEW_TYPE_FILENAME)
557 {
558 /* Copy file */
559 if (!CopyFileW((LPWSTR)pItem->pData, wszName, FALSE))
560 ERR("Copy file failed: %ls\n", (LPWSTR)pItem->pData);
561 }
562
563 /* Show message if we failed */
564 if (bSuccess)
565 {
566 TRACE("Notifying fs %s\n", debugstr_w(wszName));
568 }
569 else
570 {
573 Message.FormatMessage(Message.GetString(), wszName);
575 }
576
577 return S_OK;
578}
579
581{
582 HRESULT hr;
583 WCHAR wszPath[MAX_PATH], wszName[MAX_PATH];
584
585 /* Get folder path */
588 return hr;
589
590 if (pItem == m_pLinkItem)
591 {
592 NewItemByNonCommand(pItem, wszName, _countof(wszName), wszPath);
593 NewItemByCommand(pItem, wszName);
594 return S_OK;
595 }
596
597 switch (pItem->Type)
598 {
600 NewItemByCommand(pItem, wszPath);
601 break;
602
606 NewItemByNonCommand(pItem, wszName, _countof(wszName), wszPath);
607 break;
608
610 ERR("Invalid type\n");
611 break;
612 }
613
614 return S_OK;
615}
616
618{
619 m_pSite = pUnkSite;
620 return S_OK;
621}
622
624{
625 return m_pSite->QueryInterface(riid, ppvSite);
626}
627
629WINAPI
631 UINT indexMenu,
632 UINT idCmdFirst,
633 UINT idCmdLast,
634 UINT uFlags)
635{
636 MENUITEMINFOW mii;
637 UINT cItems = 0;
638 WCHAR wszNew[200];
639
640 TRACE("%p %p %u %u %u %u\n", this,
641 hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
642
644 return E_FAIL;
645
647 if (!m_hSubMenu)
648 return E_FAIL;
649
650 cItems = InsertShellNewItems(m_hSubMenu, idCmdFirst, 0);
651
652 ZeroMemory(&mii, sizeof(mii));
653 mii.cbSize = sizeof(mii);
655 mii.fType = MFT_STRING;
656 mii.wID = -1;
657 mii.dwTypeData = wszNew;
658 mii.cch = wcslen(mii.dwTypeData);
659 mii.fState = MFS_ENABLED;
660 mii.hSubMenu = m_hSubMenu;
661
662 if (!InsertMenuItemW(hMenu, indexMenu, TRUE, &mii))
663 return E_FAIL;
664
665 return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cItems);
666}
667
669WINAPI
671{
672 HRESULT hr = E_FAIL;
673
674 if (m_idCmdFirst + LOWORD(lpici->lpVerb) == m_idCmdFolder)
675 {
676 hr = CreateNewFolder(lpici);
677 }
678 else
679 {
681 if (pItem)
682 hr = CreateNewItem(pItem, lpici);
683 }
684
685 TRACE("CNewMenu::InvokeCommand %x\n", hr);
686 return hr;
687}
688
690WINAPI
692 UINT uType,
693 UINT *pwReserved,
694 LPSTR pszName,
695 UINT cchMax)
696{
697 FIXME("%p %lu %u %p %p %u\n", this,
698 idCmd, uType, pwReserved, pszName, cchMax );
699
700 return E_NOTIMPL;
701}
702
704WINAPI
706{
707 return S_OK;
708}
709
711WINAPI
713{
714 switch (uMsg)
715 {
716 case WM_MEASUREITEM:
717 {
718 MEASUREITEMSTRUCT* lpmis = reinterpret_cast<MEASUREITEMSTRUCT*>(lParam);
719 if (!lpmis || lpmis->CtlType != ODT_MENU)
720 break;
721
724 if (lpmis->itemHeight < 16)
725 lpmis->itemHeight = 16;
726
727 if (plResult)
728 *plResult = TRUE;
729 break;
730 }
731 case WM_DRAWITEM:
732 {
733 DRAWITEMSTRUCT* lpdis = reinterpret_cast<DRAWITEMSTRUCT*>(lParam);
734 if (!lpdis || lpdis->CtlType != ODT_MENU)
735 break;
736
737 DWORD id = LOWORD(lpdis->itemID);
738 HICON hIcon = NULL;
739 if (m_idCmdFirst + id == m_idCmdFolder)
740 {
742 }
743 else if (m_idCmdFirst + id == m_idCmdLink)
744 {
746 }
747 else
748 {
750 if (pItem)
751 hIcon = pItem->hIcon;
752 }
753
754 if (!hIcon)
755 break;
756
757 DrawIconEx(lpdis->hDC,
758 2,
759 lpdis->rcItem.top + (lpdis->rcItem.bottom - lpdis->rcItem.top - 16) / 2,
760 hIcon,
761 16,
762 16,
763 0, NULL, DI_NORMAL);
764
765 if(plResult)
766 *plResult = TRUE;
767 }
768 }
769
770 return S_OK;
771}
772
775 IDataObject *pdtobj, HKEY hkeyProgID)
776{
778 WCHAR wszIconPath[MAX_PATH];
779 int icon_idx;
780
781 m_pidlFolder = ILClone(pidlFolder);
782
783 /* Load folder and shortcut icons */
784 if (HLM_GetIconW(IDI_SHELL_FOLDER - 1, wszIconPath, _countof(wszIconPath), &icon_idx))
785 {
786 ::ExtractIconExW(wszIconPath, icon_idx, &m_hIconFolder, NULL, 1);
788 }
789 else
790 {
792 }
793
794 if (HLM_GetIconW(IDI_SHELL_SHORTCUT - 1, wszIconPath, _countof(wszIconPath), &icon_idx))
795 {
796 ::ExtractIconExW(wszIconPath, icon_idx, &m_hIconLink, NULL, 1);
798 }
799 else
800 {
802 }
803
804 return S_OK;
805}
const WCHAR ShellNewKey[]
Definition: CNewMenu.h:26
#define shell32_hInstance
UINT cchMax
Type
Definition: Type.h:7
char ACPI_OBJECT_TYPE * Types
Definition: acdebug.h:354
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
#define IDI_SHELL_FOLDER
Definition: treeview.c:36
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERR(fmt,...)
Definition: debug.h:110
#define RegCloseKey(hKey)
Definition: registry.h:49
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
HRESULT SelectNewItem(LONG wEventId, UINT uFlags, LPWSTR pszName, BOOL bRename)
Definition: CNewMenu.cpp:413
STDMETHOD() GetSite(REFIID riid, void **ppvSite) override
Definition: CNewMenu.cpp:623
STDMETHOD() QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) override
Definition: CNewMenu.cpp:630
STDMETHOD() SetSite(IUnknown *pUnkSite) override
Definition: CNewMenu.cpp:617
UINT InsertShellNewItems(HMENU hMenu, UINT idFirst, UINT idMenu)
Definition: CNewMenu.cpp:323
STDMETHOD() GetCommandString(UINT_PTR idCommand, UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen) override
Definition: CNewMenu.cpp:691
HICON m_hIconFolder
Definition: CNewMenu.h:63
HRESULT NewItemByNonCommand(SHELLNEW_ITEM *pItem, LPWSTR wszName, DWORD cchNameMax, LPCWSTR wszPath)
Definition: CNewMenu.cpp:524
CNewMenu()
Definition: CNewMenu.cpp:28
SHELLNEW_TYPE
Definition: CNewMenu.h:37
@ SHELLNEW_TYPE_COMMAND
Definition: CNewMenu.h:39
@ SHELLNEW_TYPE_FILENAME
Definition: CNewMenu.h:41
@ SHELLNEW_TYPE_DATA
Definition: CNewMenu.h:40
@ SHELLNEW_TYPE_NULLFILE
Definition: CNewMenu.h:42
@ SHELLNEW_TYPE_INVALID
Definition: CNewMenu.h:38
BOOL m_bCustomIconLink
Definition: CNewMenu.h:62
STDMETHOD() Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID) override
Definition: CNewMenu.cpp:774
UINT m_idCmdLink
Definition: CNewMenu.h:61
LPITEMIDLIST m_pidlFolder
Definition: CNewMenu.h:56
BOOL LoadCachedItems()
Definition: CNewMenu.cpp:248
void UnloadItem(SHELLNEW_ITEM *pItem)
Definition: CNewMenu.cpp:55
BOOL LoadAllItems()
Definition: CNewMenu.cpp:306
SHELLNEW_ITEM * m_pLinkItem
Definition: CNewMenu.h:58
BOOL m_bCustomIconFolder
Definition: CNewMenu.h:62
HICON m_hIconLink
Definition: CNewMenu.h:63
HRESULT CreateNewItem(SHELLNEW_ITEM *pItem, LPCMINVOKECOMMANDINFO lpcmi)
Definition: CNewMenu.cpp:580
STDMETHOD() HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam) override
Definition: CNewMenu.cpp:705
HMENU m_hSubMenu
Definition: CNewMenu.h:60
void UnloadAllItems()
Definition: CNewMenu.cpp:68
STDMETHOD() HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult) override
Definition: CNewMenu.cpp:712
SHELLNEW_ITEM * LoadItem(LPCWSTR pwszExt)
Definition: CNewMenu.cpp:83
SHELLNEW_ITEM * m_pItems
Definition: CNewMenu.h:57
~CNewMenu()
Definition: CNewMenu.cpp:43
UINT m_idCmdFirst
Definition: CNewMenu.h:61
UINT m_idCmdFolder
Definition: CNewMenu.h:61
STDMETHOD() InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi) override
Definition: CNewMenu.cpp:670
HRESULT NewItemByCommand(SHELLNEW_ITEM *pItem, LPCWSTR wszPath)
Definition: CNewMenu.cpp:481
HRESULT CreateNewFolder(LPCMINVOKECOMMANDINFO lpici)
Definition: CNewMenu.cpp:452
SHELLNEW_ITEM * FindItemFromIdOffset(UINT IdOffset)
Definition: CNewMenu.cpp:391
BOOL CacheItems()
Definition: CNewMenu.cpp:176
CComPtr< IUnknown > m_pSite
Definition: CNewMenu.h:59
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
ush Pos
Definition: deflate.h:92
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3362
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1969
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4911
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4132
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2422
UINT uFlags
Definition: api.c:59
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define WideCharToMultiByte
Definition: compat.h:111
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define wcsicmp
Definition: compat.h:15
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:439
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4592
#define RRF_RT_REG_SZ
Definition: driver.c:575
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR buffer, LPCWSTR path, LPCWSTR shortname, LPCWSTR longname)
Definition: shellpath.c:705
HRESULT WINAPI IUnknown_QueryService(IUnknown *, REFGUID, REFIID, LPVOID *)
Definition: ordinal.c:1497
static const WCHAR Message[]
Definition: register.c:74
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
static BOOLEAN bSuccess
Definition: drive.cpp:433
#define ULONG_PTR
Definition: config.h:101
#define IDS_NEWFOLDER
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
FxAutoRegKey hKey
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:849
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_w
Definition: kernel32.h:32
#define REG_SZ
Definition: layer.c:22
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CREATE_NEW
Definition: disk.h:69
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static HICON
Definition: imagelist.c:84
static refpint_t pi[]
Definition: server.c:96
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
HICON hIcon
Definition: msconfig.c:44
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
_In_ HANDLE hFile
Definition: mswsock.h:90
unsigned int UINT
Definition: ndis.h:50
#define KEY_READ
Definition: nt_native.h:1023
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define KEY_WRITE
Definition: nt_native.h:1031
#define GENERIC_WRITE
Definition: nt_native.h:90
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
BYTE * PBYTE
Definition: pedump.c:66
long LONG
Definition: pedump.c:60
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:929
HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:392
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1344
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
#define REFIID
Definition: guiddef.h:118
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:415
#define SHGFI_ICON
Definition: shellapi.h:161
#define SHGFI_TYPENAME
Definition: shellapi.h:164
#define SHGFI_USEFILEATTRIBUTES
Definition: shellapi.h:178
#define SHGFI_SMALLICON
Definition: shellapi.h:173
int WINAPI SHCreateDirectory(HWND hWnd, LPCWSTR path)
Definition: shlfileop.cpp:847
HRESULT hr
Definition: shlfolder.c:183
#define SID_IFolderView
#define SHCNE_MKDIR
Definition: shlobj.h:1878
#define SHCNE_CREATE
Definition: shlobj.h:1876
#define SHCNF_FLUSH
Definition: shlobj.h:1913
#define SHCNF_PATHW
Definition: shlobj.h:1910
#define IDS_NEWITEMFORMAT
Definition: shresdef.h:143
#define FCIDM_SHVIEW_NEW
Definition: shresdef.h:140
#define FCIDM_SHVIEW_NEWFOLDER
Definition: shresdef.h:847
#define IDI_SHELL_SHORTCUT
Definition: shresdef.h:578
#define IDS_CREATEFILE_DENIED
Definition: shresdef.h:121
#define FCIDM_SHVIEW_NEWLINK
Definition: shresdef.h:846
#define IDS_CREATEFILE_CAPTION
Definition: shresdef.h:120
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define _countof(array)
Definition: sndvol32.h:68
#define TRACE(s)
Definition: solgame.cpp:4
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
SHELLNEW_ITEM * pNext
Definition: CNewMenu.h:53
SHELLNEW_TYPE Type
Definition: CNewMenu.h:47
WCHAR szTypeName[80]
Definition: shellapi.h:373
HICON hIcon
Definition: shellapi.h:369
DWORD cb
Definition: winbase.h:852
ULONG_PTR dwItemData
Definition: winuser.h:3268
LPWSTR dwTypeData
Definition: winuser.h:3269
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
#define ZeroMemory
Definition: winbase.h:1712
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
CONST void * LPCVOID
Definition: windef.h:191
#define WINAPI
Definition: msvc.h:6
#define SEVERITY_SUCCESS
Definition: winerror.h:64
#define DI_NORMAL
Definition: wingdi.h:72
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RegCreateKeyEx
Definition: winreg.h:501
#define RRF_RT_ANY
Definition: winreg.h:64
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define MIIM_STRING
Definition: winuser.h:727
#define MIIM_ID
Definition: winuser.h:722
#define IMAGE_ICON
Definition: winuser.h:212
#define SM_CXMENUCHECK
Definition: winuser.h:1031
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HMENU WINAPI CreateMenu(void)
Definition: menu.c:829
#define SM_CYSMICON
Definition: winuser.h:1013
#define MFT_SEPARATOR
Definition: winuser.h:744
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define WM_DRAWITEM
Definition: winuser.h:1645
#define MIIM_STATE
Definition: winuser.h:721
#define SM_CXSMICON
Definition: winuser.h:1012
#define MIIM_SUBMENU
Definition: winuser.h:723
#define MIIM_BITMAP
Definition: winuser.h:728
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:2028
#define LR_SHARED
Definition: winuser.h:1100
#define MB_ICONEXCLAMATION
Definition: winuser.h:785
#define MB_OK
Definition: winuser.h:790
#define WM_MEASUREITEM
Definition: winuser.h:1646
#define MFS_ENABLED
Definition: winuser.h:750
#define LoadImage
Definition: winuser.h:5815
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define MFT_STRING
Definition: winuser.h:746
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define ODT_MENU
Definition: winuser.h:2537
#define HBMMENU_CALLBACK
Definition: winuser.h:2630
int WINAPI GetSystemMetrics(_In_ int)
#define MIIM_DATA
Definition: winuser.h:726
#define MIIM_TYPE
Definition: winuser.h:725
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2053
#define IID_PPV_ARG(Itype, ppType)
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185