ReactOS  0.4.13-dev-66-gc714b7f
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  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22 
23 #include "precomp.h"
24 
26 
28  m_pidlFolder(NULL),
29  m_wszPath(NULL),
30  m_pItems(NULL),
31  m_pLinkItem(NULL),
32  m_pSite(NULL),
33  m_hiconFolder(NULL),
34  m_hiconLink(NULL)
35 {
36 }
37 
39 {
41 
42  if (m_pidlFolder)
44 }
45 
47 {
48  /* Note: free allows NULL as argument */
49  free(pItem->pData);
50  free(pItem->pwszDesc);
51  free(pItem->pwszExt);
52 
53  if (pItem->hIcon)
54  DestroyIcon(pItem->hIcon);
55 
56  HeapFree(GetProcessHeap(), 0, pItem);
57 }
58 
60 {
61  SHELLNEW_ITEM *pCurItem;
62 
63  /* Unload normal items */
64  while (m_pItems)
65  {
66  pCurItem = m_pItems;
68 
69  UnloadItem(pCurItem);
70  }
71 
72  /* Unload link item */
73  if (m_pLinkItem)
75  m_pLinkItem = NULL;
76 }
77 
79 {
80  HKEY hKey;
81  WCHAR wszBuf[MAX_PATH];
82  BYTE *pData = NULL;
83  DWORD cbData;
84 
85  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"%s\\ShellNew", pwszExt);
86 
87  TRACE("LoadItem Keyname %s Name %s\n", debugstr_w(pwszExt), debugstr_w(wszBuf));
88 
89  if (RegOpenKeyExW(HKEY_CLASSES_ROOT, wszBuf, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
90  {
91  TRACE("Failed to open key\n");
92  return NULL;
93  }
94 
95  /* Find first valid value */
96  struct
97  {
98  LPCWSTR pszName;
100  BOOL bNeedData;
101  BOOL bStr;
102  } Types[] = {
103  {L"FileName", SHELLNEW_TYPE_FILENAME, TRUE, TRUE},
104  {L"Command", SHELLNEW_TYPE_COMMAND, TRUE, TRUE},
105  {L"Data", SHELLNEW_TYPE_DATA, TRUE, FALSE},
106  {L"NullFile", SHELLNEW_TYPE_NULLFILE, FALSE},
107  {NULL}
108  };
109  UINT i;
110 
111  for (i = 0; Types[i].pszName; ++i)
112  {
113  /* Note: We are using ANSI function because strings can be treated as data */
114  cbData = 0;
116  DWORD dwType;
117  if (RegGetValueW(hKey, NULL, Types[i].pszName, dwFlags, NULL, NULL, &cbData) == ERROR_SUCCESS)
118  {
119  if (Types[i].bNeedData && cbData > 0)
120  {
121  pData = (BYTE*)malloc(cbData);
122  RegGetValueW(hKey, NULL, Types[i].pszName, dwFlags, &dwType, pData, &cbData);
123  if (!Types[i].bStr && (dwType == REG_SZ || dwType == REG_EXPAND_SZ))
124  {
125  PBYTE pData2 = (PBYTE)malloc(cbData);
126  cbData = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)pData, -1, (LPSTR)pData2, cbData, NULL, NULL);
127  free(pData);
128  pData = pData2;
129  }
130  }
131  break;
132  }
133  }
134  RegCloseKey(hKey);
135 
136  /* Was any key found? */
137  if (!Types[i].pszName)
138  return NULL;
139 
140  SHFILEINFOW fi;
142  return NULL;
143 
144  /* Create new item */
145  SHELLNEW_ITEM *pNewItem = static_cast<SHELLNEW_ITEM *>(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SHELLNEW_ITEM)));
146  if (!pNewItem)
147  {
148  free(pData);
149  return NULL;
150  }
151 
152  TRACE("new item %ls\n", fi.szTypeName);
153  pNewItem->Type = Types[i].Type;
154  pNewItem->pData = pData;
155  pNewItem->cbData = pData ? cbData : 0;
156  pNewItem->pwszExt = _wcsdup(pwszExt);
157  pNewItem->pwszDesc = _wcsdup(fi.szTypeName);
158  if (fi.hIcon)
159  pNewItem->hIcon = fi.hIcon;
160 
161  return pNewItem;
162 }
163 
164 BOOL
166 {
167  HKEY hKey;
168  DWORD dwSize = 0;
169  DWORD dwIndex = 0;
170  LPWSTR lpValue;
171  LPWSTR lpValues;
172  WCHAR wszName[MAX_PATH];
173  SHELLNEW_ITEM *pNewItem;
174  SHELLNEW_ITEM *pCurItem = NULL;
175 
176  /* Enumerate all extensions */
177  while (RegEnumKeyW(HKEY_CLASSES_ROOT, dwIndex++, wszName, _countof(wszName)) == ERROR_SUCCESS)
178  {
179  if (wszName[0] != L'.')
180  continue;
181 
182  pNewItem = LoadItem(wszName);
183  if (pNewItem)
184  {
185  dwSize += wcslen(wszName) + 1;
186  if (wcsicmp(pNewItem->pwszExt, L".lnk") == 0)
187  {
188  /* Link handler */
189  m_pLinkItem = pNewItem;
190  }
191  else
192  {
193  /* Add at the end of list */
194  if (pCurItem)
195  {
196  pCurItem->pNext = pNewItem;
197  pCurItem = pNewItem;
198  }
199  else
200  pCurItem = m_pItems = pNewItem;
201  }
202  }
203  }
204 
205  dwSize++;
206 
207  lpValues = (LPWSTR) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize * sizeof(WCHAR));
208  if (!lpValues)
209  return FALSE;
210 
211  lpValue = lpValues;
212  pCurItem = m_pItems;
213  while (pCurItem)
214  {
215  memcpy(lpValue, pCurItem->pwszExt, (wcslen(pCurItem->pwszExt) + 1) * sizeof(WCHAR));
216  lpValue += wcslen(pCurItem->pwszExt) + 1;
217  pCurItem = pCurItem->pNext;
218  }
219 
221  {
222  HeapFree(GetProcessHeap(), 0, lpValues);
223  return FALSE;
224  }
225 
226  if (RegSetValueExW(hKey, L"Classes", NULL, REG_MULTI_SZ, (LPBYTE)lpValues, dwSize * sizeof(WCHAR)) != ERROR_SUCCESS)
227  {
228  HeapFree(GetProcessHeap(), 0, lpValues);
229  RegCloseKey(hKey);
230  return FALSE;
231  }
232 
233  HeapFree(GetProcessHeap(), 0, lpValues);
234  RegCloseKey(hKey);
235 
236  return TRUE;
237 }
238 
239 BOOL
241 {
242  LPWSTR wszName;
243  LPWSTR lpValues;
244  DWORD dwSize;
245  HKEY hKey;
246  SHELLNEW_ITEM *pNewItem;
247  SHELLNEW_ITEM *pCurItem = NULL;
248 
250  return FALSE;
251 
252  if (RegQueryValueExW(hKey, L"Classes", NULL, NULL, NULL, &dwSize) != ERROR_SUCCESS)
253  return FALSE;
254 
255  lpValues = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, dwSize);
256  if (!lpValues)
257  return FALSE;
258 
259  if (RegQueryValueExW(hKey, L"Classes", NULL, NULL, (LPBYTE)lpValues, &dwSize) != ERROR_SUCCESS)
260  {
261  HeapFree(GetProcessHeap(), 0, lpValues);
262  return FALSE;
263  }
264 
265  wszName = lpValues;
266 
267  for (; '\0' != *wszName; wszName += wcslen(wszName) + 1)
268  {
269  pNewItem = LoadItem(wszName);
270  if (pNewItem)
271  {
272  if (wcsicmp(pNewItem->pwszExt, L".lnk") == 0)
273  {
274  /* Link handler */
275  m_pLinkItem = pNewItem;
276  }
277  else
278  {
279  /* Add at the end of list */
280  if (pCurItem)
281  {
282  pCurItem->pNext = pNewItem;
283  pCurItem = pNewItem;
284  }
285  else
286  pCurItem = m_pItems = pNewItem;
287  }
288  }
289  }
290 
291  HeapFree(GetProcessHeap(), 0, lpValues);
292  RegCloseKey(hKey);
293 
294  return TRUE;
295 }
296 
297 BOOL
299 {
300  /* If there are any unload them */
301  UnloadAllItems();
302 
303  if (!LoadCachedItems())
304  {
305  CacheItems();
306  }
307 
308  if (!m_pLinkItem)
309  {
310  m_pLinkItem = static_cast<SHELLNEW_ITEM *>(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SHELLNEW_ITEM)));
311  if (m_pLinkItem)
312  {
314  m_pLinkItem->pwszDesc = _wcsdup(L"Link");
315  m_pLinkItem->pwszExt = _wcsdup(L".lnk");
316  }
317  }
318 
319  if (m_pItems == NULL)
320  return FALSE;
321  else
322  return TRUE;
323 }
324 
325 UINT
327 {
328  MENUITEMINFOW mii;
329  WCHAR wszBuf[256];
330  UINT idCmd = idCmdFirst;
331 
332  if (m_pItems == NULL)
333  {
334  if (!LoadAllItems())
335  return 0;
336  }
337 
338  ZeroMemory(&mii, sizeof(mii));
339  mii.cbSize = sizeof(mii);
340 
341  /* Insert new folder action */
343  wszBuf[0] = 0;
345  mii.dwTypeData = wszBuf;
346  mii.cch = wcslen(mii.dwTypeData);
347  mii.wID = idCmd;
348  mii.hbmpItem = HBMMENU_CALLBACK;
349  if (InsertMenuItemW(hMenu, Pos++, TRUE, &mii))
350  ++idCmd;
351 
352  /* Insert new shortcut action */
354  wszBuf[0] = 0;
355  mii.dwTypeData = wszBuf;
356  mii.cch = wcslen(mii.dwTypeData);
357  mii.wID = idCmd;
358  if (InsertMenuItemW(hMenu, Pos++, TRUE, &mii))
359  ++idCmd;
360 
361  /* Insert seperator for custom new action */
362  mii.fMask = MIIM_TYPE | MIIM_ID;
363  mii.fType = MFT_SEPARATOR;
364  mii.wID = -1;
365  InsertMenuItemW(hMenu, Pos++, TRUE, &mii);
366 
367  /* Insert rest of items */
369  mii.fType = 0;
370 
371  SHELLNEW_ITEM *pCurItem = m_pItems;
372  while (pCurItem)
373  {
374  TRACE("szDesc %s\n", debugstr_w(pCurItem->pwszDesc));
375  mii.dwTypeData = pCurItem->pwszDesc;
376  mii.cch = wcslen(mii.dwTypeData);
377  mii.wID = idCmd;
378  if (InsertMenuItemW(hMenu, Pos++, TRUE, &mii))
379  ++idCmd;
380  pCurItem = pCurItem->pNext;
381  }
382 
383  return idCmd - idCmdFirst;
384 }
385 
387 {
388  if (IdOffset == 0)
389  return NULL; /* Folder */
390 
391  if (IdOffset == 1)
392  return m_pLinkItem; /* shortcut */
393 
394  /* Find shell new item */
395  SHELLNEW_ITEM *pItem = m_pItems;
396  for (UINT i = 2; pItem; ++i)
397  {
398  if (i == IdOffset)
399  break;
400 
401  pItem = pItem->pNext;
402  }
403 
404  return pItem;
405 }
406 
408 {
410  CComPtr<IShellView> lpSV;
411  HRESULT hr = E_FAIL;
412  LPITEMIDLIST pidl;
413  PITEMID_CHILD pidlNewItem;
414 
415  /* Notify the view object about the new item */
416  SHChangeNotify(wEventId, uFlags, (LPCVOID) pszName, NULL);
417 
418  if (!m_pSite)
419  return S_OK;
420 
421  /* Get a pointer to the shell view */
423  if (FAILED_UNEXPECTEDLY(hr))
424  return S_OK;
425 
426  /* Attempt to get the pidl of the new item */
427  hr = SHILCreateFromPathW(pszName, &pidl, NULL);
428  if (FAILED_UNEXPECTEDLY(hr))
429  return hr;
430 
431  pidlNewItem = ILFindLastID(pidl);
432 
433  hr = lpSV->SelectItem(pidlNewItem, SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE |
434  SVSI_FOCUSED | SVSI_SELECT);
435 
436  SHFree(pidl);
437 
438  return hr;
439 }
440 
441 // Code is duplicated in CDefaultContextMenu
443 {
444  WCHAR wszPath[MAX_PATH];
445  WCHAR wszName[MAX_PATH];
446  WCHAR wszNewFolder[25];
447  HRESULT hr;
448 
449  /* Get folder path */
451  if (FAILED_UNEXPECTEDLY(hr))
452  return hr;
453 
454  if (!LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, _countof(wszNewFolder)))
455  return E_FAIL;
456 
457  /* Create the name of the new directory */
458  if (!PathYetAnotherMakeUniqueName(wszName, wszPath, NULL, wszNewFolder))
459  return E_FAIL;
460 
461  /* Create the new directory and show the appropriate dialog in case of error */
462  if (SHCreateDirectory(lpici->hwnd, wszName) != ERROR_SUCCESS)
463  return E_FAIL;
464 
465  /* Show and select the new item in the def view */
467 
468  return S_OK;
469 }
470 
472 {
473  WCHAR wszBuf[MAX_PATH];
474  WCHAR wszPath[MAX_PATH];
475  HRESULT hr;
476 
477  /* Get folder path */
479  if (FAILED_UNEXPECTEDLY(hr))
480  return hr;
481 
482  switch (pItem->Type)
483  {
485  {
486  LPWSTR Ptr, pwszCmd;
487  WCHAR wszTemp[MAX_PATH];
488  STARTUPINFOW si;
490 
491  if (!ExpandEnvironmentStringsW((LPWSTR)pItem->pData, wszBuf, _countof(wszBuf)))
492  {
493  TRACE("ExpandEnvironmentStrings failed\n");
494  break;
495  }
496 
497  /* Expand command parameter, FIXME: there can be more modifiers */
498  Ptr = wcsstr(wszBuf, L"%1");
499  if (Ptr)
500  {
501  Ptr[1] = L's';
502  StringCbPrintfW(wszTemp, sizeof(wszTemp), wszBuf, wszPath);
503  pwszCmd = wszTemp;
504  }
505  else
506  {
507  pwszCmd = wszBuf;
508  }
509 
510  /* Create process */
511  ZeroMemory(&si, sizeof(si));
512  si.cb = sizeof(si);
513  if (CreateProcessW(NULL, pwszCmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
514  {
515  CloseHandle(pi.hProcess);
516  CloseHandle(pi.hThread);
517  }
518  else
519  {
520  ERR("Failed to create process\n");
521  }
522  break;
523  }
524 
525  case SHELLNEW_TYPE_DATA:
528  {
529  BOOL bSuccess = TRUE;
530  WCHAR wszName[MAX_PATH];
531  WCHAR wszNewFile[MAX_PATH];
532 
533  if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEW, wszBuf, _countof(wszBuf)))
534  return E_FAIL;
535 
536  StringCchPrintfW(wszNewFile, _countof(wszNewFile), L"%s %s%s", wszBuf, pItem->pwszDesc, pItem->pwszExt);
537 
538  /* Create the name of the new file */
539  if (!PathYetAnotherMakeUniqueName(wszName, wszPath, NULL, wszNewFile))
540  return E_FAIL;
541 
542  /* Create new file */
545  {
546  if (pItem->Type == SHELLNEW_TYPE_DATA)
547  {
548  /* Write a content */
549  DWORD cbWritten;
550  WriteFile(hFile, pItem->pData, pItem->cbData, &cbWritten, NULL);
551  }
552 
553  /* Close file now */
555  }
556  else
557  {
558  bSuccess = FALSE;
559  }
560 
561  if (pItem->Type == SHELLNEW_TYPE_FILENAME)
562  {
563  /* Copy file */
564  if (!CopyFileW((LPWSTR)pItem->pData, wszName, FALSE))
565  ERR("Copy file failed: %ls\n", (LPWSTR)pItem->pData);
566  }
567 
568  /* Show message if we failed */
569  if (bSuccess)
570  {
571  TRACE("Notifying fs %s\n", debugstr_w(wszName));
573  }
574  else
575  {
576  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Cannot create file: %s", wszName);
577  MessageBoxW(NULL, wszBuf, L"Cannot create file", MB_OK|MB_ICONERROR); // FIXME load localized error msg
578  }
579  break;
580  }
581 
583  ERR("Invalid type\n");
584  break;
585  }
586 
587  return S_OK;
588 }
589 
591 {
592  m_pSite = pUnkSite;
593  return S_OK;
594 }
595 
597 {
598  return m_pSite->QueryInterface(riid, ppvSite);
599 }
600 
601 HRESULT
602 WINAPI
604  UINT indexMenu,
605  UINT idCmdFirst,
606  UINT idCmdLast,
607  UINT uFlags)
608 {
609  WCHAR wszNew[200];
610  MENUITEMINFOW mii;
611  UINT cItems = 0;
612 
613  TRACE("%p %p %u %u %u %u\n", this,
614  hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
615 
616  if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEW, wszNew, _countof(wszNew)))
617  return E_FAIL;
618 
620  if (!m_hSubMenu)
621  return E_FAIL;
622 
623  cItems = InsertShellNewItems(m_hSubMenu, idCmdFirst, 0);
624 
625  memset(&mii, 0, sizeof(mii));
626  mii.cbSize = sizeof(mii);
628  mii.fType = MFT_STRING;
629  mii.wID = -1;
630  mii.dwTypeData = wszNew;
631  mii.cch = wcslen(mii.dwTypeData);
632  mii.fState = MFS_ENABLED;
633  mii.hSubMenu = m_hSubMenu;
634 
635  if (!InsertMenuItemW(hMenu, indexMenu, TRUE, &mii))
636  return E_FAIL;
637 
638  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cItems);
639 }
640 
641 HRESULT
642 WINAPI
644 {
645  HRESULT hr = E_FAIL;
646 
647  if (LOWORD(lpici->lpVerb) == 0)
648  hr = CreateNewFolder(lpici);
649  else
650  {
652  if (pItem)
653  hr = CreateNewItem(pItem, lpici);
654  }
655 
656  TRACE("CNewMenu::InvokeCommand %x\n", hr);
657  return hr;
658 }
659 
660 HRESULT
661 WINAPI
663  UINT uType,
664  UINT *pwReserved,
665  LPSTR pszName,
666  UINT cchMax)
667 {
668  FIXME("%p %lu %u %p %p %u\n", this,
669  idCmd, uType, pwReserved, pszName, cchMax );
670 
671  return E_NOTIMPL;
672 }
673 
674 HRESULT
675 WINAPI
677 {
678  return S_OK;
679 }
680 
681 HRESULT
682 WINAPI
684 {
685  switch (uMsg)
686  {
687  case WM_MEASUREITEM:
688  {
689  MEASUREITEMSTRUCT* lpmis = reinterpret_cast<MEASUREITEMSTRUCT*>(lParam);
690  if (!lpmis || lpmis->CtlType != ODT_MENU)
691  break;
692 
695  if (lpmis->itemHeight < 16)
696  lpmis->itemHeight = 16;
697 
698  if (plResult)
699  *plResult = TRUE;
700  break;
701  }
702  case WM_DRAWITEM:
703  {
704  DRAWITEMSTRUCT* lpdis = reinterpret_cast<DRAWITEMSTRUCT*>(lParam);
705  if (!lpdis || lpdis->CtlType != ODT_MENU)
706  break;
707 
708  DWORD id = LOWORD(lpdis->itemID);
709  HICON hIcon = 0;
710  if (id == 0)
711  hIcon = m_hiconFolder;
712  else if (id == 1)
713  hIcon = m_hiconLink;
714  else
715  {
716  SHELLNEW_ITEM *pItem = FindItemFromIdOffset(id);
717  if (pItem)
718  hIcon = pItem->hIcon;
719  }
720 
721  if (!hIcon)
722  break;
723 
724  DrawIconEx(lpdis->hDC,
725  2,
726  lpdis->rcItem.top + (lpdis->rcItem.bottom - lpdis->rcItem.top - 16) / 2,
727  hIcon,
728  16,
729  16,
730  0, NULL, DI_NORMAL);
731 
732  if(plResult)
733  *plResult = TRUE;
734  }
735  }
736 
737  return S_OK;
738 }
739 
742  IDataObject *pdtobj, HKEY hkeyProgID)
743 {
744  m_pidlFolder = ILClone(pidlFolder);
745 
746  /* Load folder and shortcut icons */
749  return S_OK;
750 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1975
#define SHCNE_MKDIR
Definition: shlobj.h:1723
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define MAKEINTRESOURCE
Definition: winuser.h:591
HMENU WINAPI CreateMenu(void)
Definition: menu.c:837
static HICON
Definition: imagelist.c:84
#define IDS_NEWFOLDER
#define MFT_STRING
Definition: winuser.h:741
#define REFIID
Definition: guiddef.h:113
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define LR_SHARED
Definition: winuser.h:1090
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
#define IMAGE_ICON
Definition: winuser.h:212
~CNewMenu()
Definition: CNewMenu.cpp:38
#define SHGFI_TYPENAME
Definition: shellapi.h:165
Type
Definition: Type.h:6
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define KEY_READ
Definition: nt_native.h:1023
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
REFIID riid
Definition: precomp.h:44
#define CP_ACP
Definition: compat.h:99
#define _countof(array)
Definition: fontsub.cpp:30
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define free
Definition: debug_ros.c:5
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
HICON m_hiconFolder
Definition: CNewMenu.h:62
#define ODT_MENU
Definition: winuser.h:2491
HRESULT SelectNewItem(LONG wEventId, UINT uFlags, LPWSTR pszName)
Definition: CNewMenu.cpp:407
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1280
ush Pos
Definition: deflate.h:92
#define SM_CXMENUCHECK
Definition: winuser.h:1021
LONG top
Definition: windef.h:292
SHELLNEW_TYPE
Definition: CNewMenu.h:36
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define RRF_RT_REG_SZ
Definition: driver.c:575
#define ZeroMemory
Definition: winbase.h:1635
LPWSTR dwTypeData
Definition: winuser.h:3211
UINT_PTR WPARAM
Definition: windef.h:207
#define FCIDM_SHVIEW_NEWLINK
Definition: shresdef.h:756
UINT uFlags
Definition: api.c:60
char * LPSTR
Definition: xmlstorage.h:182
#define SID_IFolderView
WCHAR szTypeName[80]
Definition: shellapi.h:374
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
#define SHGFI_SMALLICON
Definition: shellapi.h:174
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
static BOOLEAN bSuccess
Definition: drive.cpp:417
HRESULT WINAPI IUnknown_QueryService(IUnknown *, REFGUID, REFIID, LPVOID *)
Definition: ordinal.c:1448
WPARAM wParam
Definition: combotst.c:138
#define MIIM_BITMAP
Definition: winuser.h:723
#define SEVERITY_SUCCESS
Definition: winerror.h:64
HICON m_hiconLink
Definition: CNewMenu.h:62
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
SHELLNEW_ITEM * LoadItem(LPCWSTR pwszExt)
Definition: CNewMenu.cpp:78
LPITEMIDLIST m_pidlFolder
Definition: CNewMenu.h:56
#define MIIM_SUBMENU
Definition: winuser.h:718
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
BOOL LoadCachedItems()
Definition: CNewMenu.cpp:240
unsigned char * LPBYTE
Definition: typedefs.h:52
#define MFS_ENABLED
Definition: winuser.h:745
SHELLNEW_ITEM * m_pItems
Definition: CNewMenu.h:58
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
#define MIIM_STATE
Definition: winuser.h:716
unsigned int BOOL
Definition: ntddk_ex.h:94
CNewMenu()
Definition: CNewMenu.cpp:27
long LONG
Definition: pedump.c:60
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define GENERIC_WRITE
Definition: nt_native.h:90
virtual HRESULT WINAPI InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
Definition: CNewMenu.cpp:643
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
SHELLNEW_ITEM * m_pLinkItem
Definition: CNewMenu.h:59
smooth NULL
Definition: ftsmooth.c:416
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
LONG_PTR LPARAM
Definition: windef.h:208
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
virtual HRESULT WINAPI GetCommandString(UINT_PTR idCommand, UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen)
Definition: CNewMenu.cpp:662
#define FCIDM_SHVIEW_NEWFOLDER
Definition: shresdef.h:757
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:4623
#define MIIM_ID
Definition: winuser.h:717
#define IDI_SHELL_SHORTCUT
Definition: shresdef.h:493
const WCHAR ShellNewKey[]
Definition: CNewMenu.h:26
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define HBMMENU_CALLBACK
Definition: winuser.h:2584
#define KEY_WRITE
Definition: nt_native.h:1031
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:4917
#define FCIDM_SHVIEW_NEW
Definition: shresdef.h:130
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
DWORD cb
Definition: winbase.h:817
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:410
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:1997
LONG HRESULT
Definition: typedefs.h:77
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:439
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:35
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:8
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WM_MEASUREITEM
Definition: winuser.h:1628
HRESULT CreateNewItem(SHELLNEW_ITEM *pItem, LPCMINVOKECOMMANDINFO lpcmi)
Definition: CNewMenu.cpp:471
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define SHGFI_USEFILEATTRIBUTES
Definition: shellapi.h:179
UINT cchMax
#define MFT_SEPARATOR
Definition: winuser.h:739
SHELLNEW_ITEM * FindItemFromIdOffset(UINT IdOffset)
Definition: CNewMenu.cpp:386
static DWORD pi
Definition: protocol.c:150
WINE_DEFAULT_DEBUG_CHANNEL(shell)
#define IDI_SHELL_FOLDER
Definition: shresdef.h:467
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
virtual HRESULT STDMETHODCALLTYPE Initialize(LPCITEMIDLIST pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID)
Definition: CNewMenu.cpp:741
static const WCHAR L[]
Definition: oid.c:1250
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define MIIM_TYPE
Definition: winuser.h:720
#define MB_ICONERROR
Definition: winuser.h:781
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define DI_NORMAL
Definition: wingdi.h:72
unsigned char BYTE
Definition: mem.h:68
void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
Definition: changenotify.c:340
_In_ HANDLE hFile
Definition: mswsock.h:90
HICON hIcon
Definition: shellapi.h:370
BOOL CacheItems()
Definition: CNewMenu.cpp:165
#define wcsicmp
Definition: string.h:1152
#define SHCNF_PATHW
Definition: shlobj.h:1755
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2430
virtual HRESULT WINAPI HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CNewMenu.cpp:676
#define ERR(fmt,...)
Definition: debug.h:109
int WINAPI SHCreateDirectory(HWND hWnd, LPCWSTR path)
Definition: shlfileop.cpp:788
#define MIIM_STRING
Definition: winuser.h:722
#define S_OK
Definition: intsafe.h:59
void UnloadAllItems()
Definition: CNewMenu.cpp:59
char ACPI_OBJECT_TYPE * Types
Definition: acdebug.h:343
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
HICON hIcon
Definition: msconfig.c:44
SHELLNEW_ITEM * pNext
Definition: CNewMenu.h:53
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
#define E_NOTIMPL
Definition: ddrawi.h:99
virtual HRESULT WINAPI QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
Definition: CNewMenu.cpp:603
HRESULT CreateNewFolder(LPCMINVOKECOMMANDINFO lpici)
Definition: CNewMenu.cpp:442
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
unsigned int UINT
Definition: ndis.h:50
#define MB_OK
Definition: winuser.h:784
BOOL LoadAllItems()
Definition: CNewMenu.cpp:298
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:392
virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, void **ppvSite)
Definition: CNewMenu.cpp:596
#define CreateFileW
Definition: compat.h:400
#define WM_DRAWITEM
Definition: winuser.h:1627
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:331
CONST void * LPCVOID
Definition: windef.h:191
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
HMENU m_hSubMenu
Definition: CNewMenu.h:61
CComPtr< IUnknown > m_pSite
Definition: CNewMenu.h:60
LONG bottom
Definition: windef.h:294
void UnloadItem(SHELLNEW_ITEM *pItem)
Definition: CNewMenu.cpp:46
#define malloc
Definition: debug_ros.c:4
#define LoadImage
Definition: winuser.h:5681
#define CREATE_NEW
Definition: disk.h:69
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR buffer, LPCWSTR path, LPCWSTR shortname, LPCWSTR longname)
Definition: shellpath.c:319
virtual HRESULT WINAPI HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult)
Definition: CNewMenu.cpp:683
#define RRF_RT_ANY
Definition: winreg.h:64
#define SHCNE_CREATE
Definition: shlobj.h:1721
WCHAR * LPWSTR
Definition: xmlstorage.h:184
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
LONG_PTR LRESULT
Definition: windef.h:209
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
#define SHGFI_ICON
Definition: shellapi.h:162
#define memset(x, y, z)
Definition: compat.h:39
virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite)
Definition: CNewMenu.cpp:590
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
BYTE * PBYTE
Definition: pedump.c:66
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define RegCreateKeyEx
Definition: winreg.h:501
UINT InsertShellNewItems(HMENU hMenu, UINT idFirst, UINT idMenu)
Definition: CNewMenu.cpp:326
SHELLNEW_TYPE Type
Definition: CNewMenu.h:47
#define REG_SZ
Definition: layer.c:22