ReactOS 0.4.16-dev-1260-g901af6a
COpenWithMenu.cpp
Go to the documentation of this file.
1/*
2 * Open With Context Menu extension
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
27//
28// [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system]
29// "NoInternetOpenWith"=dword:00000001
30//
31
33
35{
36 SIZE_T count = 0;
37 WCHAR stop = ' ';
38 if (pszIn[0] == '"')
39 stop = *(pszIn++);
40
41 for (LPCWSTR pwszSrc = pszIn; *pwszSrc && *pwszSrc != stop; ++pwszSrc)
42 {
43 if (++count >= cchMax)
44 return 0;
45 *(pszOut++) = *pwszSrc;
46 }
47 *pszOut = UNICODE_NULL;
48 return count;
49}
50
52{
53 WCHAR szDll[MAX_PATH + 100];
54 if (!PathGetAppFromCommandLine(pszCmd, szDll, _countof(szDll)))
56
57 PWSTR pszName = PathFindFileNameW(szDll);
58 if (_wcsicmp(pszName, L"rundll32") && _wcsicmp(pszName, L"rundll32.exe"))
59 return E_UNEXPECTED;
60
61 PCWSTR pszDllStart = pszCmd + (pszName - szDll) + lstrlenW(pszName);
62
63 if (*pszDllStart == '\"')
64 ++pszDllStart; // Skip possible end quote of ..\rundll32.exe" foo.dll,func
65 while (*pszDllStart <= ' ' && *pszDllStart)
66 ++pszDllStart;
67 if (PathGetAppFromCommandLine(pszDllStart, szDll, _countof(szDll)))
68 {
69 BOOL quoted = *pszDllStart == '\"';
70 PWSTR pszComma = szDll + lstrlenW(szDll);
71 while (!quoted && pszComma > szDll && *pszComma != ',' && *pszComma != '\\' && *pszComma != '/')
72 --pszComma;
73 SIZE_T cch = pszComma - szDll;
74 if (cch <= cchMax && (quoted || *pszComma == ','))
75 {
76 *pszComma = UNICODE_NULL;
77 lstrcpynW(pszOut, szDll, cchMax);
78 return S_OK;
79 }
80 }
82}
83
85{
86 // FIXME: SHEvaluateSystemCommandTemplate is not implemented yet, using a minimal version.
87 if (!PathGetAppFromCommandLine(pszCmd, pszCmd, cchMax))
88 return E_FAIL;
89
91 WCHAR szCurrDir[MAX_PATH];
92 LPCWSTR pszDirsArr[2] = { szCurrDir, NULL }, *ppszDirs = NULL;
93 if (GetCurrentDirectoryW(_countof(szCurrDir), szCurrDir))
94 ppszDirs = pszDirsArr;
95 if (PathResolveW(pszCmd, ppszDirs, fPRF | (ppszDirs ? PRF_FIRSTDIRDEF : 0)))
96 return S_OK;
97 return E_FAIL;
98}
99
100HRESULT SH32_InvokeOpenWith(_In_ PCWSTR pszPath, _In_ LPCMINVOKECOMMANDINFO pici, _Out_ HANDLE *phProcess)
101{
102 if (!pszPath || !pici)
104
106 SHELLEXECUTEINFOW sei = { sizeof(sei), CmicFlagsToSeeFlags(pici->fMask), pici->hwnd };
108 sei.lpFile = pszPath;
109 sei.nShow = pici->nShow;
110 if (phProcess)
111 {
113 sei.hProcess = NULL;
114 }
115
116 if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, L"Unknown", 0, KEY_READ, &sei.hkeyClass))
117 {
118 // Use the internal dialog only if HKCR\Unknown\shell\openas\command exists but is invalid.
119 WCHAR szCmd[MAX_PATH * 2];
120 DWORD cch = _countof(szCmd);
123 ASSOCSTR_COMMAND, sei.hkeyClass, NULL, szCmd, &cch);
124 if (SUCCEEDED(hr) && FAILED(SH32_EvaluateValidExecApp(szCmd, _countof(szCmd))))
125 {
127 hr = SHOpenWithDialog(sei.hwnd, &info);
128 }
129 else
130 {
132 }
134 }
135 else if (!(pici->fMask & CMIC_MASK_FLAG_NO_UI))
136 {
137 SHELL_ErrorBox(sei.hwnd, hr);
138 }
139
140 if (phProcess)
141 *phProcess = sei.hProcess;
142 return hr;
143}
144
146{
147 public:
148 struct SApp
149 {
152 //WCHAR wszManufacturer[256];
158 };
159
162
163 BOOL Load();
164 SApp *Add(LPCWSTR pwszPath);
165 static BOOL SaveApp(SApp *pApp);
166 SApp *Find(LPCWSTR pwszFilename);
167 static LPCWSTR GetName(SApp *pApp);
168 static HICON GetIcon(SApp *pApp);
169 static BOOL Execute(SApp *pApp, LPCWSTR pwszFilePath);
170 static BOOL IsHidden(SApp *pApp);
171 inline BOOL IsNoOpen(VOID) { return m_bNoOpen; }
172 BOOL LoadRecommended(LPCWSTR pwszFilePath);
173 BOOL SetDefaultHandler(SApp *pApp, LPCWSTR pwszFilename);
174
175 inline SApp *GetList() { return m_pApp; }
176 inline UINT GetCount() { return m_cApp; }
178
179 private:
180 typedef struct _LANGANDCODEPAGE
181 {
185
189
190 SApp *AddInternal(LPCWSTR pwszFilename);
191 static BOOL LoadInfo(SApp *pApp);
192 static BOOL GetPathFromCmd(LPWSTR pwszAppPath, LPCWSTR pwszCmd);
194 static HANDLE OpenMRUList(HKEY hKey);
200 static BOOL AddAppToMRUList(SApp *pApp, LPCWSTR pwszFilename);
201
203 {
204 if (!pApp->bRecommended)
206 pApp->bRecommended = TRUE;
207 }
208};
209
211 m_pApp(NULL), m_cApp(0), m_cRecommended(0), m_bNoOpen(FALSE) {}
212
214{
215 for (UINT i = 0; i < m_cApp; ++i)
216 if (m_pApp[i].hIcon)
218
220}
221
223{
224 HKEY hKey, hKeyApp;
225 WCHAR wszName[256], wszBuf[100];
226 DWORD i = 0, cchName, dwSize;
227 SApp *pApp;
228
229 if (RegOpenKeyEx(HKEY_CLASSES_ROOT, L"Applications", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
230 {
231 ERR("RegOpenKeyEx HKCR\\Applications failed!\n");
232 return FALSE;
233 }
234
235 while (TRUE)
236 {
237 cchName = _countof(wszName);
238 if (RegEnumKeyEx(hKey, i++, wszName, &cchName, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
239 break;
240
241 pApp = AddInternal(wszName);
242
243 if (pApp)
244 {
245 if (RegOpenKeyW(hKey, wszName, &hKeyApp) == ERROR_SUCCESS)
246 {
247 if ((RegQueryValueExW(hKeyApp, L"NoOpenWith", NULL, NULL, NULL, NULL) != ERROR_SUCCESS) &&
248 (RegQueryValueExW(hKeyApp, L"NoStartPage", NULL, NULL, NULL, NULL) != ERROR_SUCCESS))
249 {
250 StringCbPrintfW(wszBuf, sizeof(wszBuf), L"%s\\shell\\open\\command", wszName);
251 dwSize = sizeof(pApp->wszCmd);
252 if (RegGetValueW(hKey, wszBuf, L"", RRF_RT_REG_SZ, NULL, pApp->wszCmd, &dwSize) != ERROR_SUCCESS)
253 {
254 ERR("Failed to add app %ls\n", wszName);
255 pApp->bHidden = TRUE;
256 }
257 else
258 {
259 TRACE("App added %ls\n", pApp->wszCmd);
260 }
261 }
262 else
263 {
264 pApp->bHidden = TRUE;
265 }
266 RegCloseKey(hKeyApp);
267 }
268 else
269 {
270 pApp->bHidden = TRUE;
271 }
272 }
273 else
274 {
275 ERR("AddInternal failed\n");
276 }
277 }
278
280 return TRUE;
281}
282
284{
285 SApp *pApp = AddInternal(PathFindFileNameW(pwszPath));
286
287 if (pApp)
288 {
289 StringCbPrintfW(pApp->wszCmd, sizeof(pApp->wszCmd), L"\"%s\" \"%%1\"", pwszPath);
290 SaveApp(pApp);
291 }
292
293 return pApp;
294}
295
297{
298 WCHAR wszBuf[256];
299 HKEY hKey;
300
301 StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Applications\\%s\\shell\\open\\command", pApp->wszFilename);
303 {
304 ERR("RegOpenKeyEx failed\n");
305 return FALSE;
306 }
307
308 if (RegSetValueEx(hKey, L"", 0, REG_SZ, (PBYTE)pApp->wszCmd, (wcslen(pApp->wszCmd)+1)*sizeof(WCHAR)) != ERROR_SUCCESS)
309 ERR("Cannot add app to registry\n");
310
312 return TRUE;
313}
314
316{
317 for (UINT i = 0; i < m_cApp; ++i)
318 if (_wcsicmp(m_pApp[i].wszFilename, pwszFilename) == 0)
319 return &m_pApp[i];
320 return NULL;
321}
322
324{
325 if (!pApp->wszName[0])
326 {
327 if (!LoadInfo(pApp))
328 {
329 WARN("Failed to load %ls info\n", pApp->wszFilename);
330 StringCbCopyW(pApp->wszName, sizeof(pApp->wszName), pApp->wszFilename);
331
332 WCHAR wszPath[MAX_PATH];
333 if (!GetPathFromCmd(wszPath, pApp->wszCmd))
334 {
335 return NULL;
336 }
337 }
338 }
339
340 TRACE("%ls name: %ls\n", pApp->wszFilename, pApp->wszName);
341 return pApp->wszName;
342}
343
345{
346 if (!pApp->hIcon)
347 {
348 WCHAR wszPath[MAX_PATH];
349
350 GetPathFromCmd(wszPath, pApp->wszCmd);
351 if (!ExtractIconExW(wszPath, 0, NULL, &pApp->hIcon, 1))
352 {
353 SHFILEINFO fi;
354 /* FIXME: Ideally we should include SHGFI_USEFILEATTRIBUTES because we already
355 ** know the file has no icons but SHGetFileInfo is broken in that case (CORE-19122).
356 ** Without SHGFI_USEFILEATTRIBUTES we needlessly hit the disk again but it will
357 ** return the correct default .exe icon.
358 */
359 SHGetFileInfoW(wszPath, 0, &fi, sizeof(fi), SHGFI_ICON|SHGFI_SMALLICON|SHGFI_SHELLICONSIZE);
360 pApp->hIcon = fi.hIcon;
361 }
362 }
363
364 TRACE("%ls icon: %p\n", pApp->wszFilename, pApp->hIcon);
365
366 return pApp->hIcon;
367}
368
370{
371 WCHAR wszBuf[256];
372 HKEY hKey;
373
374 /* Add app to registry if it wasnt there before */
375 SaveApp(pApp);
376 if (!pApp->bMRUList)
377 AddAppToMRUList(pApp, pwszFilePath);
378
379 /* Get a handle to the reg key */
380 StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Applications\\%s", pApp->wszFilename);
382 {
383 ERR("RegOpenKeyEx failed\n");
384 return FALSE;
385 }
386
387 /* Let ShellExecuteExW do the work */
389 sei.nShow = SW_SHOWNORMAL;
390 sei.hkeyClass = hKey;
391 sei.lpFile = pwszFilePath;
392
393 ShellExecuteExW(&sei);
394
395 return TRUE;
396}
397
399{
400 WCHAR wszBuf[100];
401 DWORD dwSize = 0;
402
403 if (pApp->bHidden)
404 return pApp->bHidden;
405
406 if (FAILED(StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Applications\\%s", pApp->wszFilename)))
407 {
408 ERR("insufficient buffer\n");
409 return FALSE;
410 }
411
412 if (RegGetValueW(HKEY_CLASSES_ROOT, wszBuf, L"NoOpenWith", RRF_RT_REG_SZ, NULL, NULL, &dwSize) != ERROR_SUCCESS)
413 return FALSE;
414
415 pApp->bHidden = TRUE;
416 return TRUE;
417}
418
420{
421 /* Check for duplicate */
422 SApp *pApp = Find(pwszFilename);
423 if (pApp)
424 return pApp;
425
426 /* Create new item */
427 if (!m_pApp)
428 m_pApp = static_cast<SApp *>(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(m_pApp[0])));
429 else
430 m_pApp = static_cast<SApp *>(HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, m_pApp, (m_cApp + 1)*sizeof(m_pApp[0])));
431 if (!m_pApp)
432 {
433 ERR("Allocation failed\n");
434 return NULL;
435 }
436
437 pApp = &m_pApp[m_cApp++];
438 wcscpy(pApp->wszFilename, pwszFilename);
439 return pApp;
440}
441
443{
444 UINT cbSize, cchLen;
445 LPVOID pBuf;
446 WORD wLang = 0, wCode = 0;
447 LPLANGANDCODEPAGE lpLangCode;
448 WCHAR wszBuf[100];
449 WCHAR *pResult;
450 WCHAR wszPath[MAX_PATH];
452
453 GetPathFromCmd(wszPath, pApp->wszCmd);
454 TRACE("LoadInfo %ls\n", wszPath);
455
456 /* query version info size */
457 cbSize = GetFileVersionInfoSizeW(wszPath, NULL);
458 if (!cbSize)
459 {
460 ERR("GetFileVersionInfoSizeW %ls failed: %lu\n", wszPath, GetLastError());
461 return FALSE;
462 }
463
464 /* allocate buffer */
465 pBuf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbSize + 200);
466 if (!pBuf)
467 {
468 ERR("HeapAlloc failed\n");
469 return FALSE;
470 }
471
472 /* query version info */
473 if (!GetFileVersionInfoW(wszPath, 0, cbSize, pBuf))
474 {
475 ERR("GetFileVersionInfoW %ls failed: %lu\n", wszPath, GetLastError());
476 HeapFree(GetProcessHeap(), 0, pBuf);
477 return FALSE;
478 }
479
480 /* query lang code */
481 if (VerQueryValueW(pBuf, L"VarFileInfo\\Translation", (LPVOID*)&lpLangCode, &cbSize))
482 {
483 /* FIXME: find language from current locale / if not available,
484 * default to english
485 * for now default to first available language
486 */
487 wLang = lpLangCode->lang;
488 wCode = lpLangCode->code;
489 }
490
491 /* Query name */
492 swprintf(wszBuf, L"\\StringFileInfo\\%04x%04x\\FileDescription", wLang, wCode);
493 success = VerQueryValueW(pBuf, wszBuf, (LPVOID *)&pResult, &cchLen) && (cchLen > 1);
494 if (success)
495 StringCchCopyNW(pApp->wszName, _countof(pApp->wszName), pResult, cchLen);
496 else
497 ERR("Cannot get app name\n");
498
499 /* Query manufacturer */
500 /*swprintf(wszBuf, L"\\StringFileInfo\\%04x%04x\\CompanyName", wLang, wCode);
501
502 if (VerQueryValueW(pBuf, wszBuf, (LPVOID *)&pResult, &cchLen))
503 StringCchCopyNW(pApp->wszManufacturer, _countof(pApp->wszManufacturer), pResult, cchLen);*/
504 HeapFree(GetProcessHeap(), 0, pBuf);
505 return success;
506}
507
509{
510 WCHAR wszBuf[MAX_PATH];
511
512 /* Remove arguments */
513 if (!PathGetAppFromCommandLine(pwszCmd, wszBuf, _countof(wszBuf)))
514 return FALSE;
515
516 /* Replace rundll32.exe with the dll path */
517 SHELL32_GetDllFromRundll32CommandLine(pwszCmd, wszBuf, _countof(wszBuf));
518
519 /* Expand env. vars and optionally search for path */
520 ExpandEnvironmentStrings(wszBuf, pwszAppPath, MAX_PATH);
521 if (!PathFileExists(pwszAppPath))
522 {
523 UINT cch = SearchPathW(NULL, pwszAppPath, NULL, MAX_PATH, pwszAppPath, NULL);
524 if (!cch || cch >= MAX_PATH)
525 return FALSE;
526 }
527 return TRUE;
528}
529
531{
532 LPCWSTR pwszExt;
533
534 pwszExt = PathFindExtensionW(pwszFilePath);
535 if (!pwszExt[0])
536 return FALSE;
537
538 /* load programs directly associated from HKCU */
540
541 /* load programs associated from HKCR\Extension */
543
544 return TRUE;
545}
546
548{
549 HKEY hSubkey, hSubkey2;
550 WCHAR wszProgId[256];
551 DWORD i = 0, cchProgId;
552
553 if (RegOpenKeyExW(hKey, L"OpenWithProgIDs", 0, KEY_READ, &hSubkey) != ERROR_SUCCESS)
554 return FALSE;
555
556 while (TRUE)
557 {
558 /* Enumerate values - value name is ProgId */
559 cchProgId = _countof(wszProgId);
560 if (RegEnumValue(hSubkey, i++, wszProgId, &cchProgId, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
561 break;
562
563 /* If ProgId exists load it */
564 if (RegOpenKeyExW(HKEY_CLASSES_ROOT, wszProgId, 0, KEY_READ, &hSubkey2) == ERROR_SUCCESS)
565 {
566 LoadFromProgIdKey(hSubkey2, pwszExt);
567 RegCloseKey(hSubkey2);
568 }
569 }
570
571 RegCloseKey(hSubkey);
572 return TRUE;
573}
574
576{
578
579 /* Initialize mru list info */
580 Info.cbSize = sizeof(Info);
581 Info.uMax = 32;
582 Info.fFlags = MRU_STRING;
583 Info.hKey = hKey;
584 Info.lpszSubKey = L"OpenWithList";
585 Info.lpfnCompare = NULL;
586
587 return CreateMRUListW(&Info);
588}
589
591{
593 int nItem, nCount, nResult;
594 WCHAR wszAppFilename[MAX_PATH];
595
596 /* Open MRU list */
598 if (!hList)
599 {
600 TRACE("OpenMRUList failed\n");
601 return FALSE;
602 }
603
604 /* Get list count */
605 nCount = EnumMRUListW(hList, -1, NULL, 0);
606
607 for(nItem = 0; nItem < nCount; nItem++)
608 {
609 nResult = EnumMRUListW(hList, nItem, wszAppFilename, _countof(wszAppFilename));
610 if (nResult <= 0)
611 continue;
612
613 /* Insert item */
614 SApp *pApp = Find(wszAppFilename);
615
616 TRACE("Recommended app %ls: %p\n", wszAppFilename, pApp);
617 if (pApp)
618 {
619 pApp->bMRUList = TRUE;
620 SetRecommended(pApp);
621 }
622 }
623
624 /* Free the MRU list */
626 return TRUE;
627}
628
630{
631 WCHAR wszAppFilename[MAX_PATH];
632 HKEY hSubkey;
633 DWORD i = 0, cchAppFilename;
634
635 if (RegOpenKeyExW(hKey, L"OpenWithList", 0, KEY_READ, &hSubkey) != ERROR_SUCCESS)
636 return FALSE;
637
638 while (TRUE)
639 {
640 /* Enum registry keys - each of them is app name */
641 cchAppFilename = _countof(wszAppFilename);
642 if (RegEnumKeyExW(hSubkey, i++, wszAppFilename, &cchAppFilename, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
643 break;
644
645 /* Set application as recommended */
646 SApp *pApp = Find(wszAppFilename);
647
648 TRACE("Recommended app %ls: %p\n", wszAppFilename, pApp);
649 if (pApp)
650 SetRecommended(pApp);
651 }
652
653 RegCloseKey(hSubkey);
654 return TRUE;
655}
656
658{
659 WCHAR wszCmd[MAX_PATH], wszPath[MAX_PATH];
660 DWORD dwSize = 0;
661
662 /* Check if NoOpen value exists */
664 {
665 /* Display warning dialog */
666 m_bNoOpen = TRUE;
667 }
668
669 /* Check if there is a directly available execute key */
670 dwSize = sizeof(wszCmd);
671 if (RegGetValueW(hKey, L"shell\\open\\command", NULL, RRF_RT_REG_SZ, NULL, (PVOID)wszCmd, &dwSize) == ERROR_SUCCESS)
672 {
673 /* Erase extra arguments */
674 GetPathFromCmd(wszPath, wszCmd);
675
676 /* Add application */
677 SApp *pApp = AddInternal(PathFindFileNameW(wszPath));
678 TRACE("Add app %ls: %p\n", wszPath, pApp);
679
680 if (pApp)
681 {
682 StringCbCopyW(pApp->wszCmd, sizeof(pApp->wszCmd), wszCmd);
683 SetRecommended(pApp);
684 }
685 }
686}
687
689{
690 HKEY hKey, hSubkey;
691 WCHAR wszBuf[MAX_PATH], wszBuf2[MAX_PATH];
693
694 /* Check if extension exists */
696 {
697 /* Load items from SystemFileAssociations\Ext key */
698 StringCbPrintfW(wszBuf, sizeof(wszBuf), L"SystemFileAssociations\\%s", pwszExt);
700 return;
701 }
702
703 /* Load programs referenced from HKCR\ProgId */
704 dwSize = sizeof(wszBuf);
705 if (RegGetValueW(hKey, NULL, L"", RRF_RT_REG_SZ, NULL, wszBuf, &dwSize) == ERROR_SUCCESS &&
706 RegOpenKeyExW(HKEY_CLASSES_ROOT, wszBuf, 0, KEY_READ, &hSubkey) == ERROR_SUCCESS)
707 {
708 LoadFromProgIdKey(hSubkey, pwszExt);
709 RegCloseKey(hSubkey);
710 }
711 else
712 LoadFromProgIdKey(hKey, pwszExt);
713
714 /* Load items from HKCR\Ext\OpenWithList */
716
717 /* Load items from HKCR\Ext\OpenWithProgIDs */
718 if (RegOpenKeyExW(hKey, L"OpenWithProgIDs", 0, KEY_READ, &hSubkey) == ERROR_SUCCESS)
719 {
720 LoadProgIdList(hSubkey, pwszExt);
721 RegCloseKey(hSubkey);
722 }
723
724 /* Load additional items from referenced PerceivedType */
725 dwSize = sizeof(wszBuf);
726 if (RegGetValueW(hKey, NULL, L"PerceivedType", RRF_RT_REG_SZ, NULL, wszBuf, &dwSize) == ERROR_SUCCESS)
727 {
728 StringCbPrintfW(wszBuf2, sizeof(wszBuf2), L"SystemFileAssociations\\%s", wszBuf);
729 if (RegOpenKeyExW(HKEY_CLASSES_ROOT, wszBuf2, 0, KEY_READ | KEY_WRITE, &hSubkey) == ERROR_SUCCESS)
730 {
731 /* Load from OpenWithList key */
732 LoadAppList(hSubkey);
733 RegCloseKey(hSubkey);
734 }
735 }
736
737 /* Close the key */
739}
740
742{
743 WCHAR wszBuf[MAX_PATH];
744 HKEY hKey;
745
746 StringCbPrintfW(wszBuf, sizeof(wszBuf),
747 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%s",
748 pwszExt);
750 {
751 /* Load MRU and ProgId lists */
753 LoadProgIdList(hKey, pwszExt);
754
755 /* Handle "Application" value */
756 DWORD cbBuf = sizeof(wszBuf);
757 if (RegGetValueW(hKey, NULL, L"Application", RRF_RT_REG_SZ, NULL, wszBuf, &cbBuf) == ERROR_SUCCESS)
758 {
759 SApp *pApp = Find(wszBuf);
760 if (pApp)
761 SetRecommended(pApp);
762 }
763
764 /* Close the key */
766 }
767}
768
770{
771 WCHAR wszBuf[100];
772 LPCWSTR pwszExt;
773 HKEY hKey;
775
776 /* Get file extension */
777 pwszExt = PathFindExtensionW(pwszFilename);
778 if (!pwszExt[0])
779 return FALSE;
780
781 /* Build registry key */
782 if (FAILED(StringCbPrintfW(wszBuf, sizeof(wszBuf),
783 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%s",
784 pwszExt)))
785 {
786 ERR("insufficient buffer\n");
787 return FALSE;
788 }
789
790 /* Open base key for this file extension */
792 return FALSE;
793
794 /* Open MRU list */
796 if (hList)
797 {
798 /* Insert the entry */
800
801 /* Set MRU presence */
802 pApp->bMRUList = TRUE;
803
804 /* Close MRU list */
806 }
807
809 return TRUE;
810}
811
813{
814 HKEY hKey, hSrcKey, hDestKey;
815 WCHAR wszBuf[256];
816
817 TRACE("SetDefaultHandler %ls %ls\n", pApp->wszFilename, pwszFilename);
818
819 /* Extract file extension */
820 LPCWSTR pwszExt = PathFindExtensionW(pwszFilename);
821 if (!pwszExt[0] || !pwszExt[1])
822 return FALSE;
823
824 /* Create file extension key */
826 {
827 ERR("Can't open ext key\n");
828 return FALSE;
829 }
830
831 DWORD dwSize = sizeof(wszBuf);
832 LONG lResult = RegGetValueW(hKey, NULL, L"", RRF_RT_REG_SZ, NULL, wszBuf, &dwSize);
833
834 if (lResult == ERROR_FILE_NOT_FOUND)
835 {
836 /* A new entry was created or the default key is not set: set the prog key id */
837 StringCbPrintfW(wszBuf, sizeof(wszBuf), L"%s_auto_file", pwszExt + 1);
838 if (RegSetValueExW(hKey, L"", 0, REG_SZ, (const BYTE*)wszBuf, (wcslen(wszBuf) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
839 {
841 ERR("RegSetValueExW failed\n");
842 return FALSE;
843 }
844 }
845 else if (lResult != ERROR_SUCCESS)
846 {
848 ERR("RegGetValueExW failed: 0x%08x\n", lResult);
849 return FALSE;
850 }
851
852 /* Close file extension key */
854
855 /* Create prog id key */
857 {
858 ERR("RegCreateKeyExW failed\n");
859 return FALSE;
860 }
861
862 /* Check if there already verbs existing for that app */
863 StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Applications\\%s\\shell", pApp->wszFilename);
864 if (RegOpenKeyExW(HKEY_CLASSES_ROOT, wszBuf, 0, KEY_READ, &hSrcKey) != ERROR_SUCCESS)
865 {
866 ERR("RegOpenKeyExW %ls failed\n", wszBuf);
868 return FALSE;
869 }
870
871 /* Open destination key */
872 if (RegCreateKeyExW(hKey, L"shell", 0, NULL, 0, KEY_WRITE, NULL, &hDestKey, NULL) != ERROR_SUCCESS)
873 {
874 ERR("RegCreateKeyExW failed\n");
875 RegCloseKey(hSrcKey);
877 return FALSE;
878 }
879
880 /* Copy static verbs from Classes\Applications key */
881 /* FIXME: SHCopyKey does not copy the security attributes of the keys */
882 /* FIXME: Windows does not actually copy the verb keys */
883 /* FIXME: Should probably delete any existing DelegateExecute/DropTarget/DDE verb information first */
884 LSTATUS Result = SHCopyKeyW(hSrcKey, NULL, hDestKey, 0);
885#ifdef __REACTOS__
886 // FIXME: When OpenWith is used to set a new default on Windows, the FileExts key
887 // is changed to force this association. ROS does not support this. The best
888 // we can do is to try to set the verb we (incorrectly) copied as the new default.
889 HKEY hAppKey;
890 StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Applications\\%s", pApp->wszFilename);
891 if (Result == ERROR_SUCCESS && !RegOpenKeyExW(HKEY_CLASSES_ROOT, wszBuf, 0, KEY_READ, &hAppKey))
892 {
893 if (HCR_GetDefaultVerbW(hAppKey, NULL, wszBuf, _countof(wszBuf)) && *wszBuf)
894 RegSetString(hDestKey, NULL, wszBuf, REG_SZ);
895 RegCloseKey(hAppKey);
896 }
897#endif // __REACTOS__
898 RegCloseKey(hDestKey);
899 RegCloseKey(hSrcKey);
901
902 if (Result != ERROR_SUCCESS)
903 {
904 ERR("SHCopyKeyW failed\n");
905 return FALSE;
906 }
907
908 return TRUE;
909}
910
912{
913 public:
914 COpenWithDialog(const OPENASINFO *pInfo, COpenWithList *pAppList);
916 static INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
918
919 private:
921 VOID AddApp(COpenWithList::SApp *pApp, BOOL bSelected);
922 VOID Browse();
923 VOID Accept();
926
936};
937
939 m_pInfo(pInfo), m_pAppList(pAppList), m_hImgList(NULL), m_bNoOpen(FALSE)
940{
941 if (!m_pAppList)
942 {
945 }
946 else
948}
949
951{
953 delete m_pAppList;
954 if (m_hImgList)
956}
957
959{
960 switch(Message)
961 {
962 case WM_INITDIALOG:
963 {
964 return TRUE;
965 }
966 case WM_CLOSE:
968 break;
969 case WM_COMMAND:
970 switch(LOWORD(wParam))
971 {
972 case IDYES:
974 break;
975 case IDNO:
977 break;
978 }
979 break;
980 default:
981 return FALSE;
982 }
983 return TRUE;
984}
985
987{
988 /* Only do the actual check if the file type has the 'NoOpen' flag. */
989 if (m_bNoOpen)
990 {
992
993 if (dReturnValue == IDNO)
994 return TRUE;
995 else if (dReturnValue == -1)
996 {
997 ERR("IsNoOpen failed to load dialog box\n");
998 return TRUE;
999 }
1000 }
1001
1002 return FALSE;
1003}
1004
1006{
1007 LPCWSTR pwszName = m_pAppList->GetName(pApp);
1008 if (!pwszName) return;
1009 HICON hIcon = m_pAppList->GetIcon(pApp);
1010
1011 TRACE("AddApp Cmd %ls Name %ls\n", pApp->wszCmd, pwszName);
1012
1013 /* Add item to the list */
1014 TVINSERTSTRUCT tvins;
1015
1016 if (pApp->bRecommended)
1017 tvins.hParent = tvins.hInsertAfter = m_hRecommend;
1018 else
1019 tvins.hParent = tvins.hInsertAfter = m_hOther;
1020
1021 tvins.item.mask = TVIF_TEXT|TVIF_PARAM;
1022 tvins.item.pszText = const_cast<LPWSTR>(pwszName);
1023 tvins.item.lParam = (LPARAM)pApp;
1024
1025 if (hIcon)
1026 {
1027 tvins.item.mask |= TVIF_IMAGE | TVIF_SELECTEDIMAGE;
1028 tvins.item.iImage = tvins.item.iSelectedImage = ImageList_AddIcon(m_hImgList, hIcon);
1029 }
1030
1032
1033 if (bSelected)
1035}
1036
1038{
1039 WCHAR wszTitle[64];
1040 WCHAR wszFilter[256];
1041 WCHAR wszPath[MAX_PATH];
1043
1044 /* Initialize OPENFILENAMEW structure */
1045 ZeroMemory(&ofn, sizeof(OPENFILENAMEW));
1046 ofn.lStructSize = sizeof(OPENFILENAMEW);
1050 ofn.nMaxFile = (sizeof(wszPath) / sizeof(WCHAR));
1051 ofn.lpstrFile = wszPath;
1052 ofn.lpstrInitialDir = L"%programfiles%";
1053
1054 /* Init title */
1055 if (LoadStringW(shell32_hInstance, IDS_OPEN_WITH, wszTitle, sizeof(wszTitle) / sizeof(WCHAR)))
1056 {
1057 ofn.lpstrTitle = wszTitle;
1058 ofn.nMaxFileTitle = wcslen(wszTitle);
1059 }
1060
1061 /* Init the filter string */
1064 ZeroMemory(wszPath, sizeof(wszPath));
1065
1066 /* Create OpenFile dialog */
1067 if (!GetOpenFileNameW(&ofn))
1068 return;
1069
1070 /* Setup context for insert proc */
1071 COpenWithList::SApp *pApp = m_pAppList->Add(wszPath);
1072 AddApp(pApp, TRUE);
1073}
1074
1076{
1077 TVITEM tvi;
1079 if (!tvi.hItem)
1080 return NULL;
1081
1082 tvi.mask = TVIF_PARAM;
1083 if (!TreeView_GetItem(m_hTreeView, &tvi))
1084 return NULL;
1085
1086 return (COpenWithList::SApp*)tvi.lParam;
1087}
1088
1090{
1091 TRACE("COpenWithDialog::Init hwnd %p\n", hwnd);
1092
1093 m_hDialog = hwnd;
1095
1096 UINT fDisallow = 0;
1098 // Don't allow registration for "" nor "." nor ".exe" etc.
1099 if (!pszExt || !pszExt[0] || !pszExt[1] || PathIsExeW(m_pInfo->pcszFile))
1103
1104 /* Handle register checkbox */
1105 m_InFlags = m_pInfo->oaifInFlags & ~fDisallow;
1106 HWND hRegisterCheckbox = GetDlgItem(hwnd, 14003);
1108 EnableWindow(hRegisterCheckbox, FALSE);
1110 SendMessage(hRegisterCheckbox, BM_SETCHECK, BST_CHECKED, 0);
1112 ShowWindow(hRegisterCheckbox, SW_HIDE);
1113
1114 if (m_pInfo->pcszFile)
1115 {
1116 WCHAR wszBuf[MAX_PATH];
1117 UINT cchBuf;
1118
1119 /* Add filename to label */
1120 cchBuf = GetDlgItemTextW(hwnd, 14001, wszBuf, _countof(wszBuf));
1121 StringCchCopyW(wszBuf + cchBuf, _countof(wszBuf) - cchBuf, PathFindFileNameW(m_pInfo->pcszFile));
1122 SetDlgItemTextW(hwnd, 14001, wszBuf);
1123
1124 /* Load applications from registry */
1125 m_pAppList->Load();
1127
1128 /* Determine if the type of file can be opened directly from the shell */
1129 if (m_pAppList->IsNoOpen() != FALSE)
1130 m_bNoOpen = TRUE;
1131
1132 /* Init treeview */
1133 m_hTreeView = GetDlgItem(hwnd, 14002);
1136
1137 /* If there are some recommendations add parent nodes: Recommended and Others */
1138 UINT cRecommended = m_pAppList->GetRecommendedCount();
1139 if (cRecommended > 0)
1140 {
1141 TVINSERTSTRUCT tvins;
1142 HICON hFolderIcon;
1143
1144 tvins.hParent = tvins.hInsertAfter = TVI_ROOT;
1146 tvins.item.pszText = (LPWSTR)wszBuf;
1147 tvins.item.state = tvins.item.stateMask = TVIS_EXPANDED;
1149 tvins.item.iImage = tvins.item.iSelectedImage = ImageList_AddIcon(m_hImgList, hFolderIcon);
1150
1153
1156 }
1157 else
1159
1160 /* Add all applications */
1161 BOOL bNoAppSelected = TRUE;
1162 COpenWithList::SApp *pAppList = m_pAppList->GetList();
1163 for (UINT i = 0; i < m_pAppList->GetCount(); ++i)
1164 {
1165 if (!COpenWithList::IsHidden(&pAppList[i]))
1166 {
1167 if (bNoAppSelected && (pAppList[i].bRecommended || !cRecommended))
1168 {
1169 AddApp(&pAppList[i], TRUE);
1170 bNoAppSelected = FALSE;
1171 }
1172 else
1173 AddApp(&pAppList[i], FALSE);
1174 }
1175 }
1176 }
1177}
1178
1180{
1182 if (pApp)
1183 {
1184 /* Set programm as default handler */
1186 {
1188 // FIXME: Update DefaultIcon registry
1190 }
1191
1192 /* Execute program */
1193 if (m_InFlags & OAIF_EXEC)
1195
1196 EndDialog(m_hDialog, 1);
1197 }
1198}
1199
1201{
1202 COpenWithDialog *pThis = reinterpret_cast<COpenWithDialog *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
1203
1204 switch(uMsg)
1205 {
1206 case WM_INITDIALOG:
1207 {
1208 COpenWithDialog *pThis = reinterpret_cast<COpenWithDialog *>(lParam);
1209
1210 pThis->Init(hwndDlg);
1211 return TRUE;
1212 }
1213 case WM_COMMAND:
1214 switch(LOWORD(wParam))
1215 {
1216 case 14004: /* browse */
1217 {
1218 pThis->Browse();
1219 return TRUE;
1220 }
1221 case IDOK: /* ok */
1222 {
1223 pThis->Accept();
1224 return TRUE;
1225 }
1226 case IDCANCEL: /* cancel */
1227 EndDialog(hwndDlg, 0);
1228 return TRUE;
1229 default:
1230 break;
1231 }
1232 break;
1233 case WM_NOTIFY:
1234 switch (((LPNMHDR)lParam)->code)
1235 {
1236 case TVN_SELCHANGED:
1237 EnableWindow(GetDlgItem(hwndDlg, IDOK), pThis->GetCurrentApp() ? TRUE : FALSE);
1238 break;
1239 case NM_DBLCLK:
1240 case NM_RETURN:
1241 pThis->Accept();
1242 break;
1243 }
1244 break;
1245 case WM_CLOSE:
1246 EndDialog(hwndDlg, 0);
1247 return TRUE;
1248 default:
1249 break;
1250 }
1251 return FALSE;
1252}
1253
1255{
1256 m_idCmdFirst = 0;
1257 m_idCmdLast = 0;
1259}
1260
1262{
1263 TRACE("Destroying COpenWithMenu(%p)\n", this);
1264
1265 if (m_hSubMenu)
1266 {
1267 INT Count, Index;
1268 MENUITEMINFOW mii;
1269
1270 /* get item count */
1272 if (Count == -1)
1273 return;
1274
1275 /* setup menuitem info */
1276 ZeroMemory(&mii, sizeof(mii));
1277 mii.cbSize = sizeof(mii);
1279
1280 for(Index = 0; Index < Count; Index++)
1281 {
1283 {
1284 if (mii.hbmpChecked)
1286 }
1287 }
1288 }
1289
1290 if (m_pAppList)
1291 delete m_pAppList;
1292}
1293
1295{
1296 HDC hdc, hdcScr;
1297 HBITMAP hbm, hbmOld;
1298 RECT rc;
1299
1300 hdcScr = GetDC(NULL);
1301 hdc = CreateCompatibleDC(hdcScr);
1303 hbm = CreateCompatibleBitmap(hdcScr, rc.right, rc.bottom);
1304 ReleaseDC(NULL, hdcScr);
1305
1306 hbmOld = (HBITMAP)SelectObject(hdc, hbm);
1307 FillRect(hdc, &rc, (HBRUSH)(COLOR_MENU + 1));
1308 if (!DrawIconEx(hdc, 0, 0, hIcon, rc.right, rc.bottom, 0, NULL, DI_NORMAL))
1309 ERR("DrawIcon failed: %x\n", GetLastError());
1310 SelectObject(hdc, hbmOld);
1311
1312 DeleteDC(hdc);
1313
1314 return hbm;
1315}
1316
1318{
1319 MENUITEMINFOW mii;
1320 WCHAR wszBuf[128];
1321
1322 ZeroMemory(&mii, sizeof(mii));
1323 mii.cbSize = sizeof(mii);
1324 mii.fMask = MIIM_TYPE | MIIM_ID;
1325 mii.fType = MFT_SEPARATOR;
1326 mii.wID = -1;
1327 InsertMenuItemW(m_hSubMenu, -1, TRUE, &mii);
1328
1330 {
1331 ERR("Failed to load string\n");
1332 return;
1333 }
1334
1336 mii.fType = MFT_STRING;
1337 mii.fState = MFS_ENABLED;
1338 mii.wID = m_idCmdLast;
1339 mii.dwTypeData = (LPWSTR)wszBuf;
1340 mii.cch = wcslen(wszBuf);
1341
1342 InsertMenuItemW(m_hSubMenu, -1, TRUE, &mii);
1343}
1344
1346{
1347 MENUITEMINFOW mii;
1348 LPCWSTR pwszName = m_pAppList->GetName((COpenWithList::SApp*)pApp);
1349 if (!pwszName) return;
1350
1351 ZeroMemory(&mii, sizeof(mii));
1352 mii.cbSize = sizeof(mii);
1354 mii.fType = MFT_STRING;
1355 mii.fState = MFS_ENABLED;
1356 mii.wID = m_idCmdLast;
1357 mii.dwTypeData = const_cast<LPWSTR>(pwszName);
1358 mii.dwItemData = (ULONG_PTR)pApp;
1359
1361 if (hIcon)
1362 {
1363 mii.fMask |= MIIM_CHECKMARKS;
1365 }
1366
1367 if (InsertMenuItemW(m_hSubMenu, -1, TRUE, &mii))
1368 m_idCmdLast++;
1369}
1370
1371static const CMVERBMAP g_VerbMap[] =
1372{
1373 { "openas", 0 },
1374 { NULL }
1375};
1376
1378 HMENU hMenu,
1379 UINT indexMenu,
1380 UINT idCmdFirst,
1381 UINT idCmdLast,
1382 UINT uFlags)
1383{
1384 TRACE("hMenu %p indexMenu %u idFirst %u idLast %u uFlags %u\n", hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
1385
1386 INT DefaultPos = GetMenuDefaultItem(hMenu, TRUE, 0);
1387
1388 WCHAR wszName[100];
1389 UINT NameId = (DefaultPos == -1 ? IDS_OPEN : IDS_OPEN_WITH);
1390 if (!LoadStringW(shell32_hInstance, NameId, wszName, _countof(wszName)))
1391 {
1392 ERR("Failed to load string\n");
1393 return E_FAIL;
1394 }
1395
1396 /* Init first cmd id and submenu */
1397 m_idCmdFirst = m_idCmdLast = idCmdFirst;
1398 m_hSubMenu = NULL;
1399
1400 /* We can only be a submenu if we are not the default */
1401 if (DefaultPos != -1)
1402 {
1403 /* Load applications list */
1404 m_pAppList->Load();
1406
1407 /* Create submenu only if there is more than one application and menu has a default item */
1409 {
1411
1412 for(UINT i = 0; i < m_pAppList->GetCount(); ++i)
1413 {
1415 if (pApp->bRecommended)
1416 AddApp(pApp);
1417 }
1418
1420 }
1421 }
1422
1423 /* Insert menu item */
1424 MENUITEMINFOW mii;
1425 ZeroMemory(&mii, sizeof(mii));
1426 mii.cbSize = sizeof(mii);
1428 if (m_hSubMenu)
1429 {
1430 mii.fMask |= MIIM_SUBMENU;
1431 mii.hSubMenu = m_hSubMenu;
1432 mii.wID = -1;
1433 }
1434 else
1435 mii.wID = m_idCmdLast;
1436
1437 mii.fType = MFT_STRING;
1438 mii.dwTypeData = (LPWSTR)wszName;
1439 mii.fState = MFS_ENABLED;
1440 if (DefaultPos == -1)
1441 {
1442 mii.fState |= MFS_DEFAULT;
1443 indexMenu = 0;
1444 }
1445
1446 if (!InsertMenuItemW(hMenu, indexMenu, TRUE, &mii))
1447 return E_FAIL;
1448
1450}
1451
1454{
1455 const SIZE_T idChooseApp = m_idCmdLast;
1456 HRESULT hr = E_FAIL;
1457
1458 TRACE("This %p idFirst %u idLast %u idCmd %u\n", this, m_idCmdFirst, m_idCmdLast, m_idCmdFirst + LOWORD(lpici->lpVerb));
1459
1461 goto DoChooseApp;
1462
1463 if (IS_INTRESOURCE(lpici->lpVerb) && m_idCmdFirst + LOWORD(lpici->lpVerb) <= m_idCmdLast)
1464 {
1465 if (m_idCmdFirst + LOWORD(lpici->lpVerb) == idChooseApp)
1466 {
1467DoChooseApp:
1469 }
1470 else
1471 {
1472 /* retrieve menu item info */
1473 MENUITEMINFOW mii;
1474 ZeroMemory(&mii, sizeof(mii));
1475 mii.cbSize = sizeof(mii);
1476 mii.fMask = MIIM_DATA | MIIM_FTYPE;
1477
1478 if (GetMenuItemInfoW(m_hSubMenu, LOWORD(lpici->lpVerb), TRUE, &mii) && mii.dwItemData)
1479 {
1480 /* launch item with specified app */
1483 hr = S_OK;
1484 }
1485 }
1486 }
1487
1488 return hr;
1489}
1490
1493 UINT* pwReserved, LPSTR pszName, UINT cchMax )
1494{
1495 TRACE("%p %lu %u %p %p %u\n", this,
1496 idCmd, uType, pwReserved, pszName, cchMax );
1497
1498 const SIZE_T idChooseApp = m_idCmdLast;
1499 if (m_idCmdFirst + idCmd == idChooseApp)
1500 return SHELL_GetCommandStringImpl(0, uType, pszName, cchMax, g_VerbMap);
1501
1502 return E_NOTIMPL;
1503}
1504
1506 UINT uMsg,
1507 WPARAM wParam,
1508 LPARAM lParam)
1509{
1510 TRACE("This %p uMsg %x\n", this, uMsg);
1511
1512 return E_NOTIMPL;
1513}
1514
1517 IDataObject *pdtobj,
1518 HKEY hkeyProgID)
1519{
1520 LPCITEMIDLIST pidlFolder2;
1521 LPCITEMIDLIST pidlChild;
1522
1523 TRACE("This %p\n", this);
1524
1525 if (pdtobj == NULL)
1526 return E_INVALIDARG;
1527
1528 CDataObjectHIDA pida(pdtobj);
1529 if (FAILED(pida.hr()))
1530 {
1531 ERR("pdtobj->GetData failed with 0x%x\n", pida.hr());
1532 return pida.hr();
1533 }
1534
1535 ASSERT(pida->cidl >= 1);
1536
1537 pidlFolder2 = HIDA_GetPIDLFolder(pida);
1538 pidlChild = HIDA_GetPIDLItem(pida, 0);
1539
1540 if (!_ILIsValue(pidlChild))
1541 {
1542 TRACE("pidl is not a file\n");
1543 return E_FAIL;
1544 }
1545
1546 CComHeapPtr<ITEMIDLIST> pidl(ILCombine(pidlFolder2, pidlChild));
1547 if (!pidl)
1548 {
1549 ERR("no mem\n");
1550 return E_OUTOFMEMORY;
1551 }
1552
1553 if (!SHGetPathFromIDListW(pidl, m_wszPath))
1554 {
1555 ERR("SHGetPathFromIDListW failed\n");
1556 return E_FAIL;
1557 }
1558
1559 TRACE("szPath %s\n", debugstr_w(m_wszPath));
1560
1562 if (PathIsExeW(pwszExt) || !_wcsicmp(pwszExt, L".lnk"))
1563 {
1564 TRACE("file is a executable or shortcut\n");
1565 return E_FAIL;
1566 }
1567
1568 return S_OK;
1569}
1570
1573{
1574 INT_PTR ret;
1575
1576 TRACE("SHOpenWithDialog hwndParent %p poainfo %p\n", hwndParent, poainfo);
1577
1579
1580 if (poainfo->pcszClass == NULL && poainfo->pcszFile == NULL)
1581 return E_FAIL;
1582
1583 COpenWithDialog pDialog(poainfo);
1584
1585 if (pDialog.IsNoOpen(hwndParent))
1586 return S_OK;
1587
1590
1591 if (ret == (INT_PTR)-1)
1592 {
1593 ERR("Failed to create dialog: %u\n", GetLastError());
1594 return E_FAIL;
1595 }
1596
1597 return S_OK;
1598}
static const CMVERBMAP g_VerbMap[]
HRESULT WINAPI SHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo)
EXTERN_C BOOL PathIsExeW(LPCWSTR lpszPath)
Definition: shellpath.c:539
static SIZE_T PathGetAppFromCommandLine(LPCWSTR pszIn, LPWSTR pszOut, SIZE_T cchMax)
static HRESULT SH32_EvaluateValidExecApp(_Inout_ PWSTR pszCmd, _In_ SIZE_T cchMax)
static const CMVERBMAP g_VerbMap[]
HRESULT SH32_InvokeOpenWith(_In_ PCWSTR pszPath, _In_ LPCMINVOKECOMMANDINFO pici, _Out_ HANDLE *phProcess)
HRESULT SHELL32_GetDllFromRundll32CommandLine(LPCWSTR pszCmd, LPWSTR pszOut, SIZE_T cchMax)
#define PRF_VERIFYEXISTS
Definition: PathResolve.cpp:38
#define PRF_TRYPROGRAMEXTENSIONS
Definition: PathResolve.cpp:40
#define PRF_FIRSTDIRDEF
Definition: PathResolve.cpp:41
#define PRF_DONTFINDLNK
Definition: PathResolve.cpp:42
#define shell32_hInstance
UINT cchMax
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define IDS_OPEN
Definition: resource.h:18
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
static WCHAR wszFilter[MAX_STRING_LEN *4+6 *3+5]
Definition: wordpad.c:72
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
#define EXTERN_C
Definition: basetyps.h:12
#define RegCloseKey(hKey)
Definition: registry.h:49
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
COpenWithList * m_pAppList
VOID AddApp(COpenWithList::SApp *pApp, BOOL bSelected)
static INT_PTR CALLBACK NoOpenDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
HTREEITEM m_hRecommend
COpenWithList::SApp * GetCurrentApp()
HIMAGELIST m_hImgList
VOID Init(HWND hwnd)
BOOL IsNoOpen(HWND hwnd)
COpenWithDialog(const OPENASINFO *pInfo, COpenWithList *pAppList)
static INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
const OPENASINFO * m_pInfo
struct COpenWithList::_LANGANDCODEPAGE * LPLANGANDCODEPAGE
static BOOL SaveApp(SApp *pApp)
SApp * Find(LPCWSTR pwszFilename)
BOOL LoadRecommended(LPCWSTR pwszFilePath)
static LPCWSTR GetName(SApp *pApp)
BOOL LoadAppList(HKEY hKey)
static BOOL Execute(SApp *pApp, LPCWSTR pwszFilePath)
BOOL IsNoOpen(VOID)
static BOOL GetPathFromCmd(LPWSTR pwszAppPath, LPCWSTR pwszCmd)
static BOOL LoadInfo(SApp *pApp)
VOID LoadRecommendedFromHKCR(LPCWSTR pwszExt)
UINT GetRecommendedCount()
static HICON GetIcon(SApp *pApp)
SApp * Add(LPCWSTR pwszPath)
BOOL SetDefaultHandler(SApp *pApp, LPCWSTR pwszFilename)
struct COpenWithList::_LANGANDCODEPAGE LANGANDCODEPAGE
VOID LoadRecommendedFromHKCU(LPCWSTR pwszExt)
static BOOL AddAppToMRUList(SApp *pApp, LPCWSTR pwszFilename)
SApp * AddInternal(LPCWSTR pwszFilename)
VOID SetRecommended(SApp *pApp)
static BOOL IsHidden(SApp *pApp)
static HANDLE OpenMRUList(HKEY hKey)
VOID LoadFromProgIdKey(HKEY hKey, LPCWSTR pwszExt)
BOOL LoadMRUList(HKEY hKey)
BOOL LoadProgIdList(HKEY hKey, LPCWSTR pwszExt)
COpenWithList * m_pAppList
Definition: COpenWithMenu.h:38
VOID AddChooseProgramItem()
STDMETHOD() GetCommandString(UINT_PTR idCommand, UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen) override
HBITMAP IconToBitmap(HICON hIcon)
VOID AddApp(PVOID pApp)
STDMETHOD() Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID) override
WCHAR m_wszPath[MAX_PATH]
Definition: COpenWithMenu.h:36
STDMETHOD() QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) override
STDMETHOD() HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam) override
STDMETHOD() InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi) override
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
INT WINAPI AddMRUStringW(HANDLE hList, LPCWSTR lpszString)
INT WINAPI EnumMRUListW(HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize)
HANDLE WINAPI CreateMRUListW(const MRUINFOW *infoW)
void WINAPI FreeMRUList(HANDLE hMRUList)
#define MRU_STRING
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:874
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
struct tagOFNW OPENFILENAMEW
wcscpy
static HWND hwndParent
Definition: cryptui.c:300
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
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:4882
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
UINT uFlags
Definition: api.c:59
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:941
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:814
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4736
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
DWORD WINAPI SearchPathW(IN LPCWSTR lpPath OPTIONAL, IN LPCWSTR lpFileName, IN LPCWSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart OPTIONAL)
Definition: path.c:1298
#define IS_INTRESOURCE(x)
Definition: loader.c:613
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1644
LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
Definition: path.c:1217
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:967
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1171
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:738
#define RRF_RT_REG_SZ
Definition: driver.c:575
HRESULT SHELL_GetCommandStringImpl(SIZE_T CmdId, UINT uFlags, LPSTR Buf, UINT cchBuf, const CMVERBMAP *pMap)
Definition: utils.cpp:1783
HRESULT SHELL_MapContextMenuVerbToCmdId(LPCMINVOKECOMMANDINFO pICI, const CMVERBMAP *pMap)
Definition: utils.cpp:1749
static DWORD RegSetString(HKEY hKey, LPCWSTR Name, LPCWSTR Str, DWORD Type OPTIONAL_(REG_SZ))
Definition: utils.h:81
BOOL WINAPI PathResolveW(_Inout_ LPWSTR path, _Inout_opt_ LPCWSTR *dirs, _In_ DWORD flags)
Definition: shellpath.c:1032
HRESULT WINAPI AssocQueryStringByKeyW(ASSOCF cfFlags, ASSOCSTR str, HKEY hkAssoc, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut)
Definition: assoc.c:537
DWORD WINAPI SHCopyKeyW(HKEY hKeySrc, LPCWSTR lpszSrcSubKey, HKEY hKeyDst, DWORD dwReserved)
Definition: reg.c:2261
#define swprintf
Definition: precomp.h:40
static const WCHAR Message[]
Definition: register.c:74
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
#define ULONG_PTR
Definition: config.h:101
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
FxAutoRegKey hKey
pKey DeleteObject()
GLuint GLuint GLsizei count
Definition: gl.h:1545
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:855
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_w
Definition: kernel32.h:32
#define REG_SZ
Definition: layer.c:22
HWND hList
Definition: livecd.c:10
#define HResultFromWin32
Definition: loader.cpp:14
#define ASSERT(a)
Definition: mode.c:44
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
static HICON
Definition: imagelist.c:80
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
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
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
unsigned int UINT
Definition: ndis.h:50
#define _Inout_
Definition: no_sal2.h:162
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
int Count
Definition: noreturn.cpp:7
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_WRITE
Definition: nt_native.h:1031
#define UNICODE_NULL
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
#define L(x)
Definition: ntvdm.h:50
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
#define LOWORD(l)
Definition: pedump.c:82
BYTE * PBYTE
Definition: pedump.c:66
long LONG
Definition: pedump.c:60
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:816
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1489
BOOL _ILIsValue(LPCITEMIDLIST pidl)
Definition: pidl.c:2144
#define TVITEM
Definition: commctrl.h:3370
#define TVN_SELCHANGED
Definition: commctrl.h:3740
#define TVIF_TEXT
Definition: commctrl.h:3271
#define TreeView_SelectItem(hwnd, hitem)
Definition: commctrl.h:3486
#define NM_DBLCLK
Definition: commctrl.h:131
#define TVINSERTSTRUCT
Definition: commctrl.h:3407
#define TVIF_IMAGE
Definition: commctrl.h:3272
#define TVSIL_NORMAL
Definition: commctrl.h:3448
#define ILC_COLOR32
Definition: commctrl.h:358
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3478
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3495
#define TVI_ROOT
Definition: commctrl.h:3373
#define NM_RETURN
Definition: commctrl.h:132
#define TVIS_EXPANDED
Definition: commctrl.h:3289
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define ILC_MASK
Definition: commctrl.h:351
#define TVIF_PARAM
Definition: commctrl.h:3273
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3452
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3417
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3276
#define TVIF_STATE
Definition: commctrl.h:3274
#define WM_NOTIFY
Definition: richedit.h:61
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOL HCR_GetDefaultVerbW(HKEY hkeyClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len)
Definition: classes.c:152
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:430
#define SEE_MASK_CLASSKEY
Definition: shellapi.h:26
#define SEE_MASK_NOCLOSEPROCESS
Definition: shellapi.h:33
#define SHGFI_ICON
Definition: shellapi.h:164
struct _SHELLEXECUTEINFOW SHELLEXECUTEINFOW
#define SHGFI_SMALLICON
Definition: shellapi.h:176
#define SEE_MASK_NOZONECHECKS
Definition: shellapi.h:48
#define SHGFI_SHELLICONSIZE
Definition: shellapi.h:179
static PCUIDLIST_RELATIVE HIDA_GetPIDLItem(CIDA const *pida, SIZE_T i)
Definition: shellutils.h:698
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder(CIDA const *pida)
Definition: shellutils.h:693
#define SHELL_ErrorBox
Definition: shellutils.h:126
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2461
HRESULT hr
Definition: shlfolder.c:183
@ OAIF_EXEC
Definition: shlobj.h:2690
@ OAIF_REGISTER_EXT
Definition: shlobj.h:2689
@ OAIF_ALLOW_REGISTRATION
Definition: shlobj.h:2688
@ OAIF_HIDE_REGISTRATION
Definition: shlobj.h:2693
@ OAIF_FORCE_REGISTRATION
Definition: shlobj.h:2691
#define SHCNE_ASSOCCHANGED
Definition: shlobj.h:1919
#define SHCNF_FLUSHNOWAIT
Definition: shlobj.h:1937
@ REST_NOFILEASSOCIATE
Definition: shlobj.h:1876
@ ASSOCSTR_COMMAND
Definition: shlwapi.h:612
#define PathFileExists
Definition: shlwapi.h:942
@ ASSOCF_NOFIXUPS
Definition: shlwapi.h:600
@ ASSOCF_IGNOREBASECLASS
Definition: shlwapi.h:601
@ ASSOCF_INIT_IGNOREUNKNOWN
Definition: shlwapi.h:602
@ ASSOCF_NOTRUNCATE
Definition: shlwapi.h:597
DWORD WINAPI SHRestricted(RESTRICTIONS rest)
Definition: shpolicy.c:166
#define IDS_OPEN_WITH_FILTER
Definition: shresdef.h:146
#define IDD_OPEN_WITH
Definition: shresdef.h:544
#define IDS_OPEN_WITH_CHOOSE
Definition: shresdef.h:135
#define IDS_OPEN_WITH_RECOMMENDED
Definition: shresdef.h:192
#define IDI_SHELL_PROGRAMS_FOLDER
Definition: shresdef.h:598
#define IDD_NOOPEN
Definition: shresdef.h:547
#define IDS_OPEN_WITH
Definition: shresdef.h:134
#define IDS_OPEN_WITH_OTHER
Definition: shresdef.h:193
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
OPENFILENAME ofn
Definition: sndrec32.cpp:56
#define _countof(array)
Definition: sndvol32.h:70
#define TRACE(s)
Definition: solgame.cpp:4
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236
WCHAR wszFilename[MAX_PATH]
WCHAR wszCmd[MAX_PATH]
HICON hIcon
Definition: shellapi.h:377
Definition: inflate.c:139
ULONG_PTR dwItemData
Definition: winuser.h:3344
LPWSTR dwTypeData
Definition: winuser.h:3345
HBITMAP hbmpChecked
Definition: winuser.h:3342
HBITMAP hbmpUnchecked
Definition: winuser.h:3343
HWND hwndOwner
Definition: commdlg.h:330
LPCSTR lpstrTitle
Definition: commdlg.h:341
HINSTANCE hInstance
Definition: commdlg.h:331
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD nMaxFileTitle
Definition: commdlg.h:339
DWORD Flags
Definition: commdlg.h:342
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
LPCWSTR pcszFile
Definition: shlobj.h:2701
LPCWSTR pcszClass
Definition: shlobj.h:2702
OPEN_AS_INFO_FLAGS oaifInFlags
Definition: shlobj.h:2703
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT_PTR
Definition: typedefs.h:64
const uint16_t * PCWSTR
Definition: typedefs.h:57
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
int ret
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_In_ WDFCOLLECTION _In_ ULONG Index
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
#define success(from, fromstr, to, tostr)
#define ZeroMemory
Definition: winbase.h:1753
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ExpandEnvironmentStrings
Definition: winbase.h:3815
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2808
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
#define SEVERITY_SUCCESS
Definition: winerror.h:64
#define ERROR_NO_ASSOCIATION
Definition: winerror.h:677
#define E_UNEXPECTED
Definition: winerror.h:2456
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define DI_NORMAL
Definition: wingdi.h:72
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI DeleteDC(_In_ HDC)
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define RegEnumValue
Definition: winreg.h:511
#define RegEnumKeyEx
Definition: winreg.h:510
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define SW_SHOWNORMAL
Definition: winuser.h:781
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:838
#define SW_HIDE
Definition: winuser.h:779
UINT WINAPI GetMenuDefaultItem(_In_ HMENU hMenu, _In_ UINT fByPos, _In_ UINT gmdiFlags)
#define WM_CLOSE
Definition: winuser.h:1640
#define DWLP_USER
Definition: winuser.h:883
#define MIIM_ID
Definition: winuser.h:733
#define COLOR_MENU
Definition: winuser.h:928
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
#define IDCANCEL
Definition: winuser.h:842
#define IMAGE_ICON
Definition: winuser.h:212
#define SM_CXMENUCHECK
Definition: winuser.h:1042
#define MIIM_CHECKMARKS
Definition: winuser.h:735
#define WM_COMMAND
Definition: winuser.h:1759
#define MIIM_FTYPE
Definition: winuser.h:740
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define WM_INITDIALOG
Definition: winuser.h:1758
#define MFT_SEPARATOR
Definition: winuser.h:755
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:841
#define BM_SETCHECK
Definition: winuser.h:1940
#define MIIM_STATE
Definition: winuser.h:732
#define MFS_DEFAULT
Definition: winuser.h:759
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define SM_CYMENUCHECK
Definition: winuser.h:1043
#define MIIM_SUBMENU
Definition: winuser.h:734
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:2365
#define IDNO
Definition: winuser.h:847
#define SendMessage
Definition: winuser.h:5928
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HDC WINAPI GetDC(_In_opt_ HWND)
#define MFS_ENABLED
Definition: winuser.h:761
#define LoadImage
Definition: winuser.h:5900
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define MFT_STRING
Definition: winuser.h:757
#define IDYES
Definition: winuser.h:846
int WINAPI GetSystemMetrics(_In_ int)
#define MIIM_DATA
Definition: winuser.h:737
#define MIIM_TYPE
Definition: winuser.h:736
#define BST_CHECKED
Definition: winuser.h:197
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define DialogBox
Definition: winuser.h:5846
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2390
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
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
unsigned char BYTE
Definition: xxhash.c:193