From: Hermès Bélusca-Maïto Date: Fri, 6 Mar 2015 01:26:58 +0000 (+0000) Subject: [SHELL]: Move shell dlls to where they should belong. X-Git-Tag: ReactOS-0.3.17-CLT2015~164 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=829e58590e20e57b300b87e24a90eb417f2fbf1d [SHELL]: Move shell dlls to where they should belong. CORE-9111 svn path=/trunk/; revision=66582 --- diff --git a/reactos/base/shell/CMakeLists.txt b/reactos/base/shell/CMakeLists.txt index 5203c2b58ea..0b89f3116d0 100644 --- a/reactos/base/shell/CMakeLists.txt +++ b/reactos/base/shell/CMakeLists.txt @@ -5,4 +5,8 @@ add_subdirectory(explorer) add_subdirectory(filebrowser) add_subdirectory(ie) add_subdirectory(rshell) +add_subdirectory(shell32) +add_subdirectory(shfolder) +add_subdirectory(shimgvw) +add_subdirectory(shlwapi) add_subdirectory(shellext) diff --git a/reactos/dll/win32/shell32/CDefView.cpp b/reactos/base/shell/shell32/CDefView.cpp similarity index 100% rename from reactos/dll/win32/shell32/CDefView.cpp rename to reactos/base/shell/shell32/CDefView.cpp diff --git a/reactos/dll/win32/shell32/CDefaultContextMenu.cpp b/reactos/base/shell/shell32/CDefaultContextMenu.cpp similarity index 100% rename from reactos/dll/win32/shell32/CDefaultContextMenu.cpp rename to reactos/base/shell/shell32/CDefaultContextMenu.cpp diff --git a/reactos/dll/win32/shell32/CDesktopBrowser.cpp b/reactos/base/shell/shell32/CDesktopBrowser.cpp similarity index 100% rename from reactos/dll/win32/shell32/CDesktopBrowser.cpp rename to reactos/base/shell/shell32/CDesktopBrowser.cpp diff --git a/reactos/dll/win32/shell32/CDropTargetHelper.cpp b/reactos/base/shell/shell32/CDropTargetHelper.cpp similarity index 100% rename from reactos/dll/win32/shell32/CDropTargetHelper.cpp rename to reactos/base/shell/shell32/CDropTargetHelper.cpp diff --git a/reactos/dll/win32/shell32/CDropTargetHelper.h b/reactos/base/shell/shell32/CDropTargetHelper.h similarity index 100% rename from reactos/dll/win32/shell32/CDropTargetHelper.h rename to reactos/base/shell/shell32/CDropTargetHelper.h diff --git a/reactos/dll/win32/shell32/CEnumIDListBase.cpp b/reactos/base/shell/shell32/CEnumIDListBase.cpp similarity index 100% rename from reactos/dll/win32/shell32/CEnumIDListBase.cpp rename to reactos/base/shell/shell32/CEnumIDListBase.cpp diff --git a/reactos/dll/win32/shell32/CEnumIDListBase.h b/reactos/base/shell/shell32/CEnumIDListBase.h similarity index 100% rename from reactos/dll/win32/shell32/CEnumIDListBase.h rename to reactos/base/shell/shell32/CEnumIDListBase.h diff --git a/reactos/dll/win32/shell32/CExtractIcon.cpp b/reactos/base/shell/shell32/CExtractIcon.cpp similarity index 100% rename from reactos/dll/win32/shell32/CExtractIcon.cpp rename to reactos/base/shell/shell32/CExtractIcon.cpp diff --git a/reactos/dll/win32/shell32/CFileSysBindData.cpp b/reactos/base/shell/shell32/CFileSysBindData.cpp similarity index 100% rename from reactos/dll/win32/shell32/CFileSysBindData.cpp rename to reactos/base/shell/shell32/CFileSysBindData.cpp diff --git a/reactos/dll/win32/shell32/CIDLDataObj.cpp b/reactos/base/shell/shell32/CIDLDataObj.cpp similarity index 100% rename from reactos/dll/win32/shell32/CIDLDataObj.cpp rename to reactos/base/shell/shell32/CIDLDataObj.cpp diff --git a/reactos/dll/win32/shell32/CMakeLists.txt b/reactos/base/shell/shell32/CMakeLists.txt similarity index 100% rename from reactos/dll/win32/shell32/CMakeLists.txt rename to reactos/base/shell/shell32/CMakeLists.txt diff --git a/reactos/dll/win32/shell32/CMenuBand.cpp b/reactos/base/shell/shell32/CMenuBand.cpp similarity index 100% rename from reactos/dll/win32/shell32/CMenuBand.cpp rename to reactos/base/shell/shell32/CMenuBand.cpp diff --git a/reactos/dll/win32/shell32/CMenuBand.h b/reactos/base/shell/shell32/CMenuBand.h similarity index 100% rename from reactos/dll/win32/shell32/CMenuBand.h rename to reactos/base/shell/shell32/CMenuBand.h diff --git a/reactos/dll/win32/shell32/CMenuDeskBar.cpp b/reactos/base/shell/shell32/CMenuDeskBar.cpp similarity index 100% rename from reactos/dll/win32/shell32/CMenuDeskBar.cpp rename to reactos/base/shell/shell32/CMenuDeskBar.cpp diff --git a/reactos/dll/win32/shell32/CMenuDeskBar.h b/reactos/base/shell/shell32/CMenuDeskBar.h similarity index 100% rename from reactos/dll/win32/shell32/CMenuDeskBar.h rename to reactos/base/shell/shell32/CMenuDeskBar.h diff --git a/reactos/dll/win32/shell32/CNewMenu.cpp b/reactos/base/shell/shell32/CNewMenu.cpp similarity index 100% rename from reactos/dll/win32/shell32/CNewMenu.cpp rename to reactos/base/shell/shell32/CNewMenu.cpp diff --git a/reactos/dll/win32/shell32/CNewMenu.h b/reactos/base/shell/shell32/CNewMenu.h similarity index 100% rename from reactos/dll/win32/shell32/CNewMenu.h rename to reactos/base/shell/shell32/CNewMenu.h diff --git a/reactos/dll/win32/shell32/COpenWithMenu.cpp b/reactos/base/shell/shell32/COpenWithMenu.cpp similarity index 100% rename from reactos/dll/win32/shell32/COpenWithMenu.cpp rename to reactos/base/shell/shell32/COpenWithMenu.cpp diff --git a/reactos/dll/win32/shell32/COpenWithMenu.h b/reactos/base/shell/shell32/COpenWithMenu.h similarity index 100% rename from reactos/dll/win32/shell32/COpenWithMenu.h rename to reactos/base/shell/shell32/COpenWithMenu.h diff --git a/reactos/dll/win32/shell32/CShellItem.cpp b/reactos/base/shell/shell32/CShellItem.cpp similarity index 100% rename from reactos/dll/win32/shell32/CShellItem.cpp rename to reactos/base/shell/shell32/CShellItem.cpp diff --git a/reactos/dll/win32/shell32/CShellItem.h b/reactos/base/shell/shell32/CShellItem.h similarity index 100% rename from reactos/dll/win32/shell32/CShellItem.h rename to reactos/base/shell/shell32/CShellItem.h diff --git a/reactos/dll/win32/shell32/CShellLink.cpp b/reactos/base/shell/shell32/CShellLink.cpp similarity index 100% rename from reactos/dll/win32/shell32/CShellLink.cpp rename to reactos/base/shell/shell32/CShellLink.cpp diff --git a/reactos/dll/win32/shell32/CShellLink.h b/reactos/base/shell/shell32/CShellLink.h similarity index 100% rename from reactos/dll/win32/shell32/CShellLink.h rename to reactos/base/shell/shell32/CShellLink.h diff --git a/reactos/dll/win32/shell32/CStartMenu.cpp b/reactos/base/shell/shell32/CStartMenu.cpp similarity index 100% rename from reactos/dll/win32/shell32/CStartMenu.cpp rename to reactos/base/shell/shell32/CStartMenu.cpp diff --git a/reactos/dll/win32/shell32/CStartMenu.h b/reactos/base/shell/shell32/CStartMenu.h similarity index 100% rename from reactos/dll/win32/shell32/CStartMenu.h rename to reactos/base/shell/shell32/CStartMenu.h diff --git a/reactos/dll/win32/shell32/avi_res.rc b/reactos/base/shell/shell32/avi_res.rc similarity index 100% rename from reactos/dll/win32/shell32/avi_res.rc rename to reactos/base/shell/shell32/avi_res.rc diff --git a/reactos/dll/win32/shell32/bitmap_res.rc b/reactos/base/shell/shell32/bitmap_res.rc similarity index 100% rename from reactos/dll/win32/shell32/bitmap_res.rc rename to reactos/base/shell/shell32/bitmap_res.rc diff --git a/reactos/dll/win32/shell32/cpanel.h b/reactos/base/shell/shell32/cpanel.h similarity index 100% rename from reactos/dll/win32/shell32/cpanel.h rename to reactos/base/shell/shell32/cpanel.h diff --git a/reactos/dll/win32/shell32/dde.cpp b/reactos/base/shell/shell32/dde.cpp similarity index 100% rename from reactos/dll/win32/shell32/dde.cpp rename to reactos/base/shell/shell32/dde.cpp diff --git a/reactos/dll/win32/shell32/debughlp.cpp b/reactos/base/shell/shell32/debughlp.cpp similarity index 100% rename from reactos/dll/win32/shell32/debughlp.cpp rename to reactos/base/shell/shell32/debughlp.cpp diff --git a/reactos/dll/win32/shell32/debughlp.h b/reactos/base/shell/shell32/debughlp.h similarity index 100% rename from reactos/dll/win32/shell32/debughlp.h rename to reactos/base/shell/shell32/debughlp.h diff --git a/reactos/dll/win32/shell32/dialogs/dialogs.cpp b/reactos/base/shell/shell32/dialogs/dialogs.cpp similarity index 100% rename from reactos/dll/win32/shell32/dialogs/dialogs.cpp rename to reactos/base/shell/shell32/dialogs/dialogs.cpp diff --git a/reactos/dll/win32/shell32/dialogs/drive.cpp b/reactos/base/shell/shell32/dialogs/drive.cpp similarity index 100% rename from reactos/dll/win32/shell32/dialogs/drive.cpp rename to reactos/base/shell/shell32/dialogs/drive.cpp diff --git a/reactos/dll/win32/shell32/dialogs/drvdefext.cpp b/reactos/base/shell/shell32/dialogs/drvdefext.cpp similarity index 100% rename from reactos/dll/win32/shell32/dialogs/drvdefext.cpp rename to reactos/base/shell/shell32/dialogs/drvdefext.cpp diff --git a/reactos/dll/win32/shell32/dialogs/filedefext.cpp b/reactos/base/shell/shell32/dialogs/filedefext.cpp similarity index 100% rename from reactos/dll/win32/shell32/dialogs/filedefext.cpp rename to reactos/base/shell/shell32/dialogs/filedefext.cpp diff --git a/reactos/dll/win32/shell32/dialogs/folder_options.cpp b/reactos/base/shell/shell32/dialogs/folder_options.cpp similarity index 100% rename from reactos/dll/win32/shell32/dialogs/folder_options.cpp rename to reactos/base/shell/shell32/dialogs/folder_options.cpp diff --git a/reactos/dll/win32/shell32/dialogs/fprop.cpp b/reactos/base/shell/shell32/dialogs/fprop.cpp similarity index 100% rename from reactos/dll/win32/shell32/dialogs/fprop.cpp rename to reactos/base/shell/shell32/dialogs/fprop.cpp diff --git a/reactos/dll/win32/shell32/droptargets/CexeDropHandler.cpp b/reactos/base/shell/shell32/droptargets/CexeDropHandler.cpp similarity index 100% rename from reactos/dll/win32/shell32/droptargets/CexeDropHandler.cpp rename to reactos/base/shell/shell32/droptargets/CexeDropHandler.cpp diff --git a/reactos/dll/win32/shell32/droptargets/CexeDropHandler.h b/reactos/base/shell/shell32/droptargets/CexeDropHandler.h similarity index 100% rename from reactos/dll/win32/shell32/droptargets/CexeDropHandler.h rename to reactos/base/shell/shell32/droptargets/CexeDropHandler.h diff --git a/reactos/dll/win32/shell32/drvdefext.h b/reactos/base/shell/shell32/drvdefext.h similarity index 100% rename from reactos/dll/win32/shell32/drvdefext.h rename to reactos/base/shell/shell32/drvdefext.h diff --git a/reactos/dll/win32/shell32/filedefext.h b/reactos/base/shell/shell32/filedefext.h similarity index 100% rename from reactos/dll/win32/shell32/filedefext.h rename to reactos/base/shell/shell32/filedefext.h diff --git a/reactos/dll/win32/shell32/folders.cpp b/reactos/base/shell/shell32/folders.cpp similarity index 100% rename from reactos/dll/win32/shell32/folders.cpp rename to reactos/base/shell/shell32/folders.cpp diff --git a/reactos/dll/win32/shell32/folders/CAdminToolsFolder.cpp b/reactos/base/shell/shell32/folders/CAdminToolsFolder.cpp similarity index 100% rename from reactos/dll/win32/shell32/folders/CAdminToolsFolder.cpp rename to reactos/base/shell/shell32/folders/CAdminToolsFolder.cpp diff --git a/reactos/dll/win32/shell32/folders/CAdminToolsFolder.h b/reactos/base/shell/shell32/folders/CAdminToolsFolder.h similarity index 100% rename from reactos/dll/win32/shell32/folders/CAdminToolsFolder.h rename to reactos/base/shell/shell32/folders/CAdminToolsFolder.h diff --git a/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp b/reactos/base/shell/shell32/folders/CControlPanelFolder.cpp similarity index 100% rename from reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp rename to reactos/base/shell/shell32/folders/CControlPanelFolder.cpp diff --git a/reactos/dll/win32/shell32/folders/CControlPanelFolder.h b/reactos/base/shell/shell32/folders/CControlPanelFolder.h similarity index 100% rename from reactos/dll/win32/shell32/folders/CControlPanelFolder.h rename to reactos/base/shell/shell32/folders/CControlPanelFolder.h diff --git a/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp b/reactos/base/shell/shell32/folders/CDesktopFolder.cpp similarity index 100% rename from reactos/dll/win32/shell32/folders/CDesktopFolder.cpp rename to reactos/base/shell/shell32/folders/CDesktopFolder.cpp diff --git a/reactos/dll/win32/shell32/folders/CDesktopFolder.h b/reactos/base/shell/shell32/folders/CDesktopFolder.h similarity index 100% rename from reactos/dll/win32/shell32/folders/CDesktopFolder.h rename to reactos/base/shell/shell32/folders/CDesktopFolder.h diff --git a/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp b/reactos/base/shell/shell32/folders/CDrivesFolder.cpp similarity index 100% rename from reactos/dll/win32/shell32/folders/CDrivesFolder.cpp rename to reactos/base/shell/shell32/folders/CDrivesFolder.cpp diff --git a/reactos/dll/win32/shell32/folders/CDrivesFolder.h b/reactos/base/shell/shell32/folders/CDrivesFolder.h similarity index 100% rename from reactos/dll/win32/shell32/folders/CDrivesFolder.h rename to reactos/base/shell/shell32/folders/CDrivesFolder.h diff --git a/reactos/dll/win32/shell32/folders/CFSFolder.cpp b/reactos/base/shell/shell32/folders/CFSFolder.cpp similarity index 100% rename from reactos/dll/win32/shell32/folders/CFSFolder.cpp rename to reactos/base/shell/shell32/folders/CFSFolder.cpp diff --git a/reactos/dll/win32/shell32/folders/CFSFolder.h b/reactos/base/shell/shell32/folders/CFSFolder.h similarity index 100% rename from reactos/dll/win32/shell32/folders/CFSFolder.h rename to reactos/base/shell/shell32/folders/CFSFolder.h diff --git a/reactos/dll/win32/shell32/folders/CFontsFolder.cpp b/reactos/base/shell/shell32/folders/CFontsFolder.cpp similarity index 100% rename from reactos/dll/win32/shell32/folders/CFontsFolder.cpp rename to reactos/base/shell/shell32/folders/CFontsFolder.cpp diff --git a/reactos/dll/win32/shell32/folders/CFontsFolder.h b/reactos/base/shell/shell32/folders/CFontsFolder.h similarity index 100% rename from reactos/dll/win32/shell32/folders/CFontsFolder.h rename to reactos/base/shell/shell32/folders/CFontsFolder.h diff --git a/reactos/dll/win32/shell32/folders/CMyDocsFolder.cpp b/reactos/base/shell/shell32/folders/CMyDocsFolder.cpp similarity index 100% rename from reactos/dll/win32/shell32/folders/CMyDocsFolder.cpp rename to reactos/base/shell/shell32/folders/CMyDocsFolder.cpp diff --git a/reactos/dll/win32/shell32/folders/CMyDocsFolder.h b/reactos/base/shell/shell32/folders/CMyDocsFolder.h similarity index 100% rename from reactos/dll/win32/shell32/folders/CMyDocsFolder.h rename to reactos/base/shell/shell32/folders/CMyDocsFolder.h diff --git a/reactos/dll/win32/shell32/folders/CNetFolder.cpp b/reactos/base/shell/shell32/folders/CNetFolder.cpp similarity index 100% rename from reactos/dll/win32/shell32/folders/CNetFolder.cpp rename to reactos/base/shell/shell32/folders/CNetFolder.cpp diff --git a/reactos/dll/win32/shell32/folders/CNetFolder.h b/reactos/base/shell/shell32/folders/CNetFolder.h similarity index 100% rename from reactos/dll/win32/shell32/folders/CNetFolder.h rename to reactos/base/shell/shell32/folders/CNetFolder.h diff --git a/reactos/dll/win32/shell32/folders/CPrinterFolder.cpp b/reactos/base/shell/shell32/folders/CPrinterFolder.cpp similarity index 100% rename from reactos/dll/win32/shell32/folders/CPrinterFolder.cpp rename to reactos/base/shell/shell32/folders/CPrinterFolder.cpp diff --git a/reactos/dll/win32/shell32/folders/CPrinterFolder.h b/reactos/base/shell/shell32/folders/CPrinterFolder.h similarity index 100% rename from reactos/dll/win32/shell32/folders/CPrinterFolder.h rename to reactos/base/shell/shell32/folders/CPrinterFolder.h diff --git a/reactos/dll/win32/shell32/folders/CRecycleBin.cpp b/reactos/base/shell/shell32/folders/CRecycleBin.cpp similarity index 100% rename from reactos/dll/win32/shell32/folders/CRecycleBin.cpp rename to reactos/base/shell/shell32/folders/CRecycleBin.cpp diff --git a/reactos/dll/win32/shell32/folders/CRecycleBin.h b/reactos/base/shell/shell32/folders/CRecycleBin.h similarity index 100% rename from reactos/dll/win32/shell32/folders/CRecycleBin.h rename to reactos/base/shell/shell32/folders/CRecycleBin.h diff --git a/reactos/dll/win32/shell32/icon_res.rc b/reactos/base/shell/shell32/icon_res.rc similarity index 100% rename from reactos/dll/win32/shell32/icon_res.rc rename to reactos/base/shell/shell32/icon_res.rc diff --git a/reactos/dll/win32/shell32/iconcache.cpp b/reactos/base/shell/shell32/iconcache.cpp similarity index 100% rename from reactos/dll/win32/shell32/iconcache.cpp rename to reactos/base/shell/shell32/iconcache.cpp diff --git a/reactos/dll/win32/shell32/lang/bg-BG.rc b/reactos/base/shell/shell32/lang/bg-BG.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/bg-BG.rc rename to reactos/base/shell/shell32/lang/bg-BG.rc diff --git a/reactos/dll/win32/shell32/lang/ca-ES.rc b/reactos/base/shell/shell32/lang/ca-ES.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/ca-ES.rc rename to reactos/base/shell/shell32/lang/ca-ES.rc diff --git a/reactos/dll/win32/shell32/lang/cs-CZ.rc b/reactos/base/shell/shell32/lang/cs-CZ.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/cs-CZ.rc rename to reactos/base/shell/shell32/lang/cs-CZ.rc diff --git a/reactos/dll/win32/shell32/lang/da-DK.rc b/reactos/base/shell/shell32/lang/da-DK.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/da-DK.rc rename to reactos/base/shell/shell32/lang/da-DK.rc diff --git a/reactos/dll/win32/shell32/lang/de-DE.rc b/reactos/base/shell/shell32/lang/de-DE.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/de-DE.rc rename to reactos/base/shell/shell32/lang/de-DE.rc diff --git a/reactos/dll/win32/shell32/lang/el-GR.rc b/reactos/base/shell/shell32/lang/el-GR.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/el-GR.rc rename to reactos/base/shell/shell32/lang/el-GR.rc diff --git a/reactos/dll/win32/shell32/lang/en-GB.rc b/reactos/base/shell/shell32/lang/en-GB.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/en-GB.rc rename to reactos/base/shell/shell32/lang/en-GB.rc diff --git a/reactos/dll/win32/shell32/lang/en-US.rc b/reactos/base/shell/shell32/lang/en-US.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/en-US.rc rename to reactos/base/shell/shell32/lang/en-US.rc diff --git a/reactos/dll/win32/shell32/lang/es-ES.rc b/reactos/base/shell/shell32/lang/es-ES.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/es-ES.rc rename to reactos/base/shell/shell32/lang/es-ES.rc diff --git a/reactos/dll/win32/shell32/lang/fi-FI.rc b/reactos/base/shell/shell32/lang/fi-FI.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/fi-FI.rc rename to reactos/base/shell/shell32/lang/fi-FI.rc diff --git a/reactos/dll/win32/shell32/lang/fr-FR.rc b/reactos/base/shell/shell32/lang/fr-FR.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/fr-FR.rc rename to reactos/base/shell/shell32/lang/fr-FR.rc diff --git a/reactos/dll/win32/shell32/lang/he-IL.rc b/reactos/base/shell/shell32/lang/he-IL.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/he-IL.rc rename to reactos/base/shell/shell32/lang/he-IL.rc diff --git a/reactos/dll/win32/shell32/lang/hu-HU.rc b/reactos/base/shell/shell32/lang/hu-HU.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/hu-HU.rc rename to reactos/base/shell/shell32/lang/hu-HU.rc diff --git a/reactos/dll/win32/shell32/lang/it-IT.rc b/reactos/base/shell/shell32/lang/it-IT.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/it-IT.rc rename to reactos/base/shell/shell32/lang/it-IT.rc diff --git a/reactos/dll/win32/shell32/lang/ja-JP.rc b/reactos/base/shell/shell32/lang/ja-JP.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/ja-JP.rc rename to reactos/base/shell/shell32/lang/ja-JP.rc diff --git a/reactos/dll/win32/shell32/lang/ko-KR.rc b/reactos/base/shell/shell32/lang/ko-KR.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/ko-KR.rc rename to reactos/base/shell/shell32/lang/ko-KR.rc diff --git a/reactos/dll/win32/shell32/lang/nl-NL.rc b/reactos/base/shell/shell32/lang/nl-NL.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/nl-NL.rc rename to reactos/base/shell/shell32/lang/nl-NL.rc diff --git a/reactos/dll/win32/shell32/lang/no-NO.rc b/reactos/base/shell/shell32/lang/no-NO.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/no-NO.rc rename to reactos/base/shell/shell32/lang/no-NO.rc diff --git a/reactos/dll/win32/shell32/lang/pl-PL.rc b/reactos/base/shell/shell32/lang/pl-PL.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/pl-PL.rc rename to reactos/base/shell/shell32/lang/pl-PL.rc diff --git a/reactos/dll/win32/shell32/lang/pt-BR.rc b/reactos/base/shell/shell32/lang/pt-BR.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/pt-BR.rc rename to reactos/base/shell/shell32/lang/pt-BR.rc diff --git a/reactos/dll/win32/shell32/lang/pt-PT.rc b/reactos/base/shell/shell32/lang/pt-PT.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/pt-PT.rc rename to reactos/base/shell/shell32/lang/pt-PT.rc diff --git a/reactos/dll/win32/shell32/lang/ro-RO.rc b/reactos/base/shell/shell32/lang/ro-RO.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/ro-RO.rc rename to reactos/base/shell/shell32/lang/ro-RO.rc diff --git a/reactos/dll/win32/shell32/lang/ru-RU.rc b/reactos/base/shell/shell32/lang/ru-RU.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/ru-RU.rc rename to reactos/base/shell/shell32/lang/ru-RU.rc diff --git a/reactos/dll/win32/shell32/lang/sk-SK.rc b/reactos/base/shell/shell32/lang/sk-SK.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/sk-SK.rc rename to reactos/base/shell/shell32/lang/sk-SK.rc diff --git a/reactos/dll/win32/shell32/lang/sl-SI.rc b/reactos/base/shell/shell32/lang/sl-SI.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/sl-SI.rc rename to reactos/base/shell/shell32/lang/sl-SI.rc diff --git a/reactos/dll/win32/shell32/lang/sq-AL.rc b/reactos/base/shell/shell32/lang/sq-AL.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/sq-AL.rc rename to reactos/base/shell/shell32/lang/sq-AL.rc diff --git a/reactos/dll/win32/shell32/lang/sv-SE.rc b/reactos/base/shell/shell32/lang/sv-SE.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/sv-SE.rc rename to reactos/base/shell/shell32/lang/sv-SE.rc diff --git a/reactos/dll/win32/shell32/lang/tr-TR.rc b/reactos/base/shell/shell32/lang/tr-TR.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/tr-TR.rc rename to reactos/base/shell/shell32/lang/tr-TR.rc diff --git a/reactos/dll/win32/shell32/lang/uk-UA.rc b/reactos/base/shell/shell32/lang/uk-UA.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/uk-UA.rc rename to reactos/base/shell/shell32/lang/uk-UA.rc diff --git a/reactos/dll/win32/shell32/lang/zh-CN.rc b/reactos/base/shell/shell32/lang/zh-CN.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/zh-CN.rc rename to reactos/base/shell/shell32/lang/zh-CN.rc diff --git a/reactos/dll/win32/shell32/lang/zh-TW.rc b/reactos/base/shell/shell32/lang/zh-TW.rc similarity index 100% rename from reactos/dll/win32/shell32/lang/zh-TW.rc rename to reactos/base/shell/shell32/lang/zh-TW.rc diff --git a/reactos/dll/win32/shell32/precomp.h b/reactos/base/shell/shell32/precomp.h similarity index 100% rename from reactos/dll/win32/shell32/precomp.h rename to reactos/base/shell/shell32/precomp.h diff --git a/reactos/dll/win32/shell32/res/avis/160+161+167+168.avi b/reactos/base/shell/shell32/res/avis/160+161+167+168.avi similarity index 100% rename from reactos/dll/win32/shell32/res/avis/160+161+167+168.avi rename to reactos/base/shell/shell32/res/avis/160+161+167+168.avi diff --git a/reactos/dll/win32/shell32/res/avis/162.avi b/reactos/base/shell/shell32/res/avis/162.avi similarity index 100% rename from reactos/dll/win32/shell32/res/avis/162.avi rename to reactos/base/shell/shell32/res/avis/162.avi diff --git a/reactos/dll/win32/shell32/res/avis/163.avi b/reactos/base/shell/shell32/res/avis/163.avi similarity index 100% rename from reactos/dll/win32/shell32/res/avis/163.avi rename to reactos/base/shell/shell32/res/avis/163.avi diff --git a/reactos/dll/win32/shell32/res/avis/164+169.avi b/reactos/base/shell/shell32/res/avis/164+169.avi similarity index 100% rename from reactos/dll/win32/shell32/res/avis/164+169.avi rename to reactos/base/shell/shell32/res/avis/164+169.avi diff --git a/reactos/dll/win32/shell32/res/avis/170.avi b/reactos/base/shell/shell32/res/avis/170.avi similarity index 100% rename from reactos/dll/win32/shell32/res/avis/170.avi rename to reactos/base/shell/shell32/res/avis/170.avi diff --git a/reactos/dll/win32/shell32/res/avis/Licence/COPYING b/reactos/base/shell/shell32/res/avis/Licence/COPYING similarity index 100% rename from reactos/dll/win32/shell32/res/avis/Licence/COPYING rename to reactos/base/shell/shell32/res/avis/Licence/COPYING diff --git a/reactos/dll/win32/shell32/res/avis/Licence/Tango.txt b/reactos/base/shell/shell32/res/avis/Licence/Tango.txt similarity index 100% rename from reactos/dll/win32/shell32/res/avis/Licence/Tango.txt rename to reactos/base/shell/shell32/res/avis/Licence/Tango.txt diff --git a/reactos/dll/win32/shell32/res/bitmaps/204.bmp b/reactos/base/shell/shell32/res/bitmaps/204.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/204.bmp rename to reactos/base/shell/shell32/res/bitmaps/204.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/205.bmp b/reactos/base/shell/shell32/res/bitmaps/205.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/205.bmp rename to reactos/base/shell/shell32/res/bitmaps/205.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/206.bmp b/reactos/base/shell/shell32/res/bitmaps/206.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/206.bmp rename to reactos/base/shell/shell32/res/bitmaps/206.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/207.bmp b/reactos/base/shell/shell32/res/bitmaps/207.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/207.bmp rename to reactos/base/shell/shell32/res/bitmaps/207.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/214.bmp b/reactos/base/shell/shell32/res/bitmaps/214.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/214.bmp rename to reactos/base/shell/shell32/res/bitmaps/214.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/215.bmp b/reactos/base/shell/shell32/res/bitmaps/215.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/215.bmp rename to reactos/base/shell/shell32/res/bitmaps/215.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/216.bmp b/reactos/base/shell/shell32/res/bitmaps/216.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/216.bmp rename to reactos/base/shell/shell32/res/bitmaps/216.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/217.bmp b/reactos/base/shell/shell32/res/bitmaps/217.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/217.bmp rename to reactos/base/shell/shell32/res/bitmaps/217.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/225.bmp b/reactos/base/shell/shell32/res/bitmaps/225.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/225.bmp rename to reactos/base/shell/shell32/res/bitmaps/225.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/226.bmp b/reactos/base/shell/shell32/res/bitmaps/226.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/226.bmp rename to reactos/base/shell/shell32/res/bitmaps/226.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/227.bmp b/reactos/base/shell/shell32/res/bitmaps/227.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/227.bmp rename to reactos/base/shell/shell32/res/bitmaps/227.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/228.bmp b/reactos/base/shell/shell32/res/bitmaps/228.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/228.bmp rename to reactos/base/shell/shell32/res/bitmaps/228.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/230.bmp b/reactos/base/shell/shell32/res/bitmaps/230.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/230.bmp rename to reactos/base/shell/shell32/res/bitmaps/230.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/231.bmp b/reactos/base/shell/shell32/res/bitmaps/231.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/231.bmp rename to reactos/base/shell/shell32/res/bitmaps/231.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/240.bmp b/reactos/base/shell/shell32/res/bitmaps/240.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/240.bmp rename to reactos/base/shell/shell32/res/bitmaps/240.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/241.bmp b/reactos/base/shell/shell32/res/bitmaps/241.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/241.bmp rename to reactos/base/shell/shell32/res/bitmaps/241.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/242.bmp b/reactos/base/shell/shell32/res/bitmaps/242.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/242.bmp rename to reactos/base/shell/shell32/res/bitmaps/242.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/245.bmp b/reactos/base/shell/shell32/res/bitmaps/245.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/245.bmp rename to reactos/base/shell/shell32/res/bitmaps/245.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/246.bmp b/reactos/base/shell/shell32/res/bitmaps/246.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/246.bmp rename to reactos/base/shell/shell32/res/bitmaps/246.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/247.bmp b/reactos/base/shell/shell32/res/bitmaps/247.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/247.bmp rename to reactos/base/shell/shell32/res/bitmaps/247.bmp diff --git a/reactos/dll/win32/shell32/res/bitmaps/reactos.bmp b/reactos/base/shell/shell32/res/bitmaps/reactos.bmp similarity index 100% rename from reactos/dll/win32/shell32/res/bitmaps/reactos.bmp rename to reactos/base/shell/shell32/res/bitmaps/reactos.bmp diff --git a/reactos/dll/win32/shell32/res/icons/1.ico b/reactos/base/shell/shell32/res/icons/1.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/1.ico rename to reactos/base/shell/shell32/res/icons/1.ico diff --git a/reactos/dll/win32/shell32/res/icons/10.ico b/reactos/base/shell/shell32/res/icons/10.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/10.ico rename to reactos/base/shell/shell32/res/icons/10.ico diff --git a/reactos/dll/win32/shell32/res/icons/1001.ico b/reactos/base/shell/shell32/res/icons/1001.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/1001.ico rename to reactos/base/shell/shell32/res/icons/1001.ico diff --git a/reactos/dll/win32/shell32/res/icons/1004.ico b/reactos/base/shell/shell32/res/icons/1004.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/1004.ico rename to reactos/base/shell/shell32/res/icons/1004.ico diff --git a/reactos/dll/win32/shell32/res/icons/11.ico b/reactos/base/shell/shell32/res/icons/11.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/11.ico rename to reactos/base/shell/shell32/res/icons/11.ico diff --git a/reactos/dll/win32/shell32/res/icons/12.ico b/reactos/base/shell/shell32/res/icons/12.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/12.ico rename to reactos/base/shell/shell32/res/icons/12.ico diff --git a/reactos/dll/win32/shell32/res/icons/13.ico b/reactos/base/shell/shell32/res/icons/13.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/13.ico rename to reactos/base/shell/shell32/res/icons/13.ico diff --git a/reactos/dll/win32/shell32/res/icons/134.ico b/reactos/base/shell/shell32/res/icons/134.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/134.ico rename to reactos/base/shell/shell32/res/icons/134.ico diff --git a/reactos/dll/win32/shell32/res/icons/135.ico b/reactos/base/shell/shell32/res/icons/135.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/135.ico rename to reactos/base/shell/shell32/res/icons/135.ico diff --git a/reactos/dll/win32/shell32/res/icons/137.ico b/reactos/base/shell/shell32/res/icons/137.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/137.ico rename to reactos/base/shell/shell32/res/icons/137.ico diff --git a/reactos/dll/win32/shell32/res/icons/138.ico b/reactos/base/shell/shell32/res/icons/138.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/138.ico rename to reactos/base/shell/shell32/res/icons/138.ico diff --git a/reactos/dll/win32/shell32/res/icons/14.ico b/reactos/base/shell/shell32/res/icons/14.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/14.ico rename to reactos/base/shell/shell32/res/icons/14.ico diff --git a/reactos/dll/win32/shell32/res/icons/15.ico b/reactos/base/shell/shell32/res/icons/15.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/15.ico rename to reactos/base/shell/shell32/res/icons/15.ico diff --git a/reactos/dll/win32/shell32/res/icons/151.ico b/reactos/base/shell/shell32/res/icons/151.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/151.ico rename to reactos/base/shell/shell32/res/icons/151.ico diff --git a/reactos/dll/win32/shell32/res/icons/152.ico b/reactos/base/shell/shell32/res/icons/152.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/152.ico rename to reactos/base/shell/shell32/res/icons/152.ico diff --git a/reactos/dll/win32/shell32/res/icons/153.ico b/reactos/base/shell/shell32/res/icons/153.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/153.ico rename to reactos/base/shell/shell32/res/icons/153.ico diff --git a/reactos/dll/win32/shell32/res/icons/154.ico b/reactos/base/shell/shell32/res/icons/154.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/154.ico rename to reactos/base/shell/shell32/res/icons/154.ico diff --git a/reactos/dll/win32/shell32/res/icons/155.ico b/reactos/base/shell/shell32/res/icons/155.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/155.ico rename to reactos/base/shell/shell32/res/icons/155.ico diff --git a/reactos/dll/win32/shell32/res/icons/156.ico b/reactos/base/shell/shell32/res/icons/156.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/156.ico rename to reactos/base/shell/shell32/res/icons/156.ico diff --git a/reactos/dll/win32/shell32/res/icons/157.ico b/reactos/base/shell/shell32/res/icons/157.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/157.ico rename to reactos/base/shell/shell32/res/icons/157.ico diff --git a/reactos/dll/win32/shell32/res/icons/16.ico b/reactos/base/shell/shell32/res/icons/16.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/16.ico rename to reactos/base/shell/shell32/res/icons/16.ico diff --git a/reactos/dll/win32/shell32/res/icons/160.ico b/reactos/base/shell/shell32/res/icons/160.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/160.ico rename to reactos/base/shell/shell32/res/icons/160.ico diff --git a/reactos/dll/win32/shell32/res/icons/161.ico b/reactos/base/shell/shell32/res/icons/161.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/161.ico rename to reactos/base/shell/shell32/res/icons/161.ico diff --git a/reactos/dll/win32/shell32/res/icons/16710.ico b/reactos/base/shell/shell32/res/icons/16710.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/16710.ico rename to reactos/base/shell/shell32/res/icons/16710.ico diff --git a/reactos/dll/win32/shell32/res/icons/16715.ico b/reactos/base/shell/shell32/res/icons/16715.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/16715.ico rename to reactos/base/shell/shell32/res/icons/16715.ico diff --git a/reactos/dll/win32/shell32/res/icons/16717.ico b/reactos/base/shell/shell32/res/icons/16717.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/16717.ico rename to reactos/base/shell/shell32/res/icons/16717.ico diff --git a/reactos/dll/win32/shell32/res/icons/16718.ico b/reactos/base/shell/shell32/res/icons/16718.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/16718.ico rename to reactos/base/shell/shell32/res/icons/16718.ico diff --git a/reactos/dll/win32/shell32/res/icons/16721.ico b/reactos/base/shell/shell32/res/icons/16721.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/16721.ico rename to reactos/base/shell/shell32/res/icons/16721.ico diff --git a/reactos/dll/win32/shell32/res/icons/17.ico b/reactos/base/shell/shell32/res/icons/17.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/17.ico rename to reactos/base/shell/shell32/res/icons/17.ico diff --git a/reactos/dll/win32/shell32/res/icons/1700.ico b/reactos/base/shell/shell32/res/icons/1700.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/1700.ico rename to reactos/base/shell/shell32/res/icons/1700.ico diff --git a/reactos/dll/win32/shell32/res/icons/172.ico b/reactos/base/shell/shell32/res/icons/172.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/172.ico rename to reactos/base/shell/shell32/res/icons/172.ico diff --git a/reactos/dll/win32/shell32/res/icons/173.ico b/reactos/base/shell/shell32/res/icons/173.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/173.ico rename to reactos/base/shell/shell32/res/icons/173.ico diff --git a/reactos/dll/win32/shell32/res/icons/18.ico b/reactos/base/shell/shell32/res/icons/18.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/18.ico rename to reactos/base/shell/shell32/res/icons/18.ico diff --git a/reactos/dll/win32/shell32/res/icons/182.ico b/reactos/base/shell/shell32/res/icons/182.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/182.ico rename to reactos/base/shell/shell32/res/icons/182.ico diff --git a/reactos/dll/win32/shell32/res/icons/183.ico b/reactos/base/shell/shell32/res/icons/183.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/183.ico rename to reactos/base/shell/shell32/res/icons/183.ico diff --git a/reactos/dll/win32/shell32/res/icons/184.ico b/reactos/base/shell/shell32/res/icons/184.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/184.ico rename to reactos/base/shell/shell32/res/icons/184.ico diff --git a/reactos/dll/win32/shell32/res/icons/185.ico b/reactos/base/shell/shell32/res/icons/185.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/185.ico rename to reactos/base/shell/shell32/res/icons/185.ico diff --git a/reactos/dll/win32/shell32/res/icons/186.ico b/reactos/base/shell/shell32/res/icons/186.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/186.ico rename to reactos/base/shell/shell32/res/icons/186.ico diff --git a/reactos/dll/win32/shell32/res/icons/187.ico b/reactos/base/shell/shell32/res/icons/187.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/187.ico rename to reactos/base/shell/shell32/res/icons/187.ico diff --git a/reactos/dll/win32/shell32/res/icons/19.ico b/reactos/base/shell/shell32/res/icons/19.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/19.ico rename to reactos/base/shell/shell32/res/icons/19.ico diff --git a/reactos/dll/win32/shell32/res/icons/191.ico b/reactos/base/shell/shell32/res/icons/191.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/191.ico rename to reactos/base/shell/shell32/res/icons/191.ico diff --git a/reactos/dll/win32/shell32/res/icons/192.ico b/reactos/base/shell/shell32/res/icons/192.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/192.ico rename to reactos/base/shell/shell32/res/icons/192.ico diff --git a/reactos/dll/win32/shell32/res/icons/2.ico b/reactos/base/shell/shell32/res/icons/2.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/2.ico rename to reactos/base/shell/shell32/res/icons/2.ico diff --git a/reactos/dll/win32/shell32/res/icons/20.ico b/reactos/base/shell/shell32/res/icons/20.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/20.ico rename to reactos/base/shell/shell32/res/icons/20.ico diff --git a/reactos/dll/win32/shell32/res/icons/21.ico b/reactos/base/shell/shell32/res/icons/21.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/21.ico rename to reactos/base/shell/shell32/res/icons/21.ico diff --git a/reactos/dll/win32/shell32/res/icons/210.ico b/reactos/base/shell/shell32/res/icons/210.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/210.ico rename to reactos/base/shell/shell32/res/icons/210.ico diff --git a/reactos/dll/win32/shell32/res/icons/22.ico b/reactos/base/shell/shell32/res/icons/22.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/22.ico rename to reactos/base/shell/shell32/res/icons/22.ico diff --git a/reactos/dll/win32/shell32/res/icons/220.ico b/reactos/base/shell/shell32/res/icons/220.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/220.ico rename to reactos/base/shell/shell32/res/icons/220.ico diff --git a/reactos/dll/win32/shell32/res/icons/221.ico b/reactos/base/shell/shell32/res/icons/221.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/221.ico rename to reactos/base/shell/shell32/res/icons/221.ico diff --git a/reactos/dll/win32/shell32/res/icons/222.ico b/reactos/base/shell/shell32/res/icons/222.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/222.ico rename to reactos/base/shell/shell32/res/icons/222.ico diff --git a/reactos/dll/win32/shell32/res/icons/224.ico b/reactos/base/shell/shell32/res/icons/224.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/224.ico rename to reactos/base/shell/shell32/res/icons/224.ico diff --git a/reactos/dll/win32/shell32/res/icons/225.ico b/reactos/base/shell/shell32/res/icons/225.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/225.ico rename to reactos/base/shell/shell32/res/icons/225.ico diff --git a/reactos/dll/win32/shell32/res/icons/226.ico b/reactos/base/shell/shell32/res/icons/226.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/226.ico rename to reactos/base/shell/shell32/res/icons/226.ico diff --git a/reactos/dll/win32/shell32/res/icons/228.ico b/reactos/base/shell/shell32/res/icons/228.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/228.ico rename to reactos/base/shell/shell32/res/icons/228.ico diff --git a/reactos/dll/win32/shell32/res/icons/23.ico b/reactos/base/shell/shell32/res/icons/23.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/23.ico rename to reactos/base/shell/shell32/res/icons/23.ico diff --git a/reactos/dll/win32/shell32/res/icons/233.ico b/reactos/base/shell/shell32/res/icons/233.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/233.ico rename to reactos/base/shell/shell32/res/icons/233.ico diff --git a/reactos/dll/win32/shell32/res/icons/235.ico b/reactos/base/shell/shell32/res/icons/235.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/235.ico rename to reactos/base/shell/shell32/res/icons/235.ico diff --git a/reactos/dll/win32/shell32/res/icons/236.ico b/reactos/base/shell/shell32/res/icons/236.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/236.ico rename to reactos/base/shell/shell32/res/icons/236.ico diff --git a/reactos/dll/win32/shell32/res/icons/237.ico b/reactos/base/shell/shell32/res/icons/237.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/237.ico rename to reactos/base/shell/shell32/res/icons/237.ico diff --git a/reactos/dll/win32/shell32/res/icons/238.ico b/reactos/base/shell/shell32/res/icons/238.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/238.ico rename to reactos/base/shell/shell32/res/icons/238.ico diff --git a/reactos/dll/win32/shell32/res/icons/24.ico b/reactos/base/shell/shell32/res/icons/24.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/24.ico rename to reactos/base/shell/shell32/res/icons/24.ico diff --git a/reactos/dll/win32/shell32/res/icons/240.ico b/reactos/base/shell/shell32/res/icons/240.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/240.ico rename to reactos/base/shell/shell32/res/icons/240.ico diff --git a/reactos/dll/win32/shell32/res/icons/245.ico b/reactos/base/shell/shell32/res/icons/245.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/245.ico rename to reactos/base/shell/shell32/res/icons/245.ico diff --git a/reactos/dll/win32/shell32/res/icons/246.ico b/reactos/base/shell/shell32/res/icons/246.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/246.ico rename to reactos/base/shell/shell32/res/icons/246.ico diff --git a/reactos/dll/win32/shell32/res/icons/248.ico b/reactos/base/shell/shell32/res/icons/248.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/248.ico rename to reactos/base/shell/shell32/res/icons/248.ico diff --git a/reactos/dll/win32/shell32/res/icons/249.ico b/reactos/base/shell/shell32/res/icons/249.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/249.ico rename to reactos/base/shell/shell32/res/icons/249.ico diff --git a/reactos/dll/win32/shell32/res/icons/25.ico b/reactos/base/shell/shell32/res/icons/25.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/25.ico rename to reactos/base/shell/shell32/res/icons/25.ico diff --git a/reactos/dll/win32/shell32/res/icons/250.ico b/reactos/base/shell/shell32/res/icons/250.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/250.ico rename to reactos/base/shell/shell32/res/icons/250.ico diff --git a/reactos/dll/win32/shell32/res/icons/252.ico b/reactos/base/shell/shell32/res/icons/252.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/252.ico rename to reactos/base/shell/shell32/res/icons/252.ico diff --git a/reactos/dll/win32/shell32/res/icons/254.ico b/reactos/base/shell/shell32/res/icons/254.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/254.ico rename to reactos/base/shell/shell32/res/icons/254.ico diff --git a/reactos/dll/win32/shell32/res/icons/255.ico b/reactos/base/shell/shell32/res/icons/255.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/255.ico rename to reactos/base/shell/shell32/res/icons/255.ico diff --git a/reactos/dll/win32/shell32/res/icons/263.ico b/reactos/base/shell/shell32/res/icons/263.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/263.ico rename to reactos/base/shell/shell32/res/icons/263.ico diff --git a/reactos/dll/win32/shell32/res/icons/265.ico b/reactos/base/shell/shell32/res/icons/265.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/265.ico rename to reactos/base/shell/shell32/res/icons/265.ico diff --git a/reactos/dll/win32/shell32/res/icons/268.ico b/reactos/base/shell/shell32/res/icons/268.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/268.ico rename to reactos/base/shell/shell32/res/icons/268.ico diff --git a/reactos/dll/win32/shell32/res/icons/269.ico b/reactos/base/shell/shell32/res/icons/269.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/269.ico rename to reactos/base/shell/shell32/res/icons/269.ico diff --git a/reactos/dll/win32/shell32/res/icons/270.ico b/reactos/base/shell/shell32/res/icons/270.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/270.ico rename to reactos/base/shell/shell32/res/icons/270.ico diff --git a/reactos/dll/win32/shell32/res/icons/271.ico b/reactos/base/shell/shell32/res/icons/271.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/271.ico rename to reactos/base/shell/shell32/res/icons/271.ico diff --git a/reactos/dll/win32/shell32/res/icons/277.ico b/reactos/base/shell/shell32/res/icons/277.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/277.ico rename to reactos/base/shell/shell32/res/icons/277.ico diff --git a/reactos/dll/win32/shell32/res/icons/279.ico b/reactos/base/shell/shell32/res/icons/279.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/279.ico rename to reactos/base/shell/shell32/res/icons/279.ico diff --git a/reactos/dll/win32/shell32/res/icons/28.ico b/reactos/base/shell/shell32/res/icons/28.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/28.ico rename to reactos/base/shell/shell32/res/icons/28.ico diff --git a/reactos/dll/win32/shell32/res/icons/289.ico b/reactos/base/shell/shell32/res/icons/289.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/289.ico rename to reactos/base/shell/shell32/res/icons/289.ico diff --git a/reactos/dll/win32/shell32/res/icons/29.ico b/reactos/base/shell/shell32/res/icons/29.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/29.ico rename to reactos/base/shell/shell32/res/icons/29.ico diff --git a/reactos/dll/win32/shell32/res/icons/290.ico b/reactos/base/shell/shell32/res/icons/290.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/290.ico rename to reactos/base/shell/shell32/res/icons/290.ico diff --git a/reactos/dll/win32/shell32/res/icons/291.ico b/reactos/base/shell/shell32/res/icons/291.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/291.ico rename to reactos/base/shell/shell32/res/icons/291.ico diff --git a/reactos/dll/win32/shell32/res/icons/292.ico b/reactos/base/shell/shell32/res/icons/292.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/292.ico rename to reactos/base/shell/shell32/res/icons/292.ico diff --git a/reactos/dll/win32/shell32/res/icons/293.ico b/reactos/base/shell/shell32/res/icons/293.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/293.ico rename to reactos/base/shell/shell32/res/icons/293.ico diff --git a/reactos/dll/win32/shell32/res/icons/294.ico b/reactos/base/shell/shell32/res/icons/294.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/294.ico rename to reactos/base/shell/shell32/res/icons/294.ico diff --git a/reactos/dll/win32/shell32/res/icons/295.ico b/reactos/base/shell/shell32/res/icons/295.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/295.ico rename to reactos/base/shell/shell32/res/icons/295.ico diff --git a/reactos/dll/win32/shell32/res/icons/296.ico b/reactos/base/shell/shell32/res/icons/296.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/296.ico rename to reactos/base/shell/shell32/res/icons/296.ico diff --git a/reactos/dll/win32/shell32/res/icons/297.ico b/reactos/base/shell/shell32/res/icons/297.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/297.ico rename to reactos/base/shell/shell32/res/icons/297.ico diff --git a/reactos/dll/win32/shell32/res/icons/298.ico b/reactos/base/shell/shell32/res/icons/298.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/298.ico rename to reactos/base/shell/shell32/res/icons/298.ico diff --git a/reactos/dll/win32/shell32/res/icons/299.ico b/reactos/base/shell/shell32/res/icons/299.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/299.ico rename to reactos/base/shell/shell32/res/icons/299.ico diff --git a/reactos/dll/win32/shell32/res/icons/3.ico b/reactos/base/shell/shell32/res/icons/3.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/3.ico rename to reactos/base/shell/shell32/res/icons/3.ico diff --git a/reactos/dll/win32/shell32/res/icons/30.ico b/reactos/base/shell/shell32/res/icons/30.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/30.ico rename to reactos/base/shell/shell32/res/icons/30.ico diff --git a/reactos/dll/win32/shell32/res/icons/302.ico b/reactos/base/shell/shell32/res/icons/302.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/302.ico rename to reactos/base/shell/shell32/res/icons/302.ico diff --git a/reactos/dll/win32/shell32/res/icons/304.ico b/reactos/base/shell/shell32/res/icons/304.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/304.ico rename to reactos/base/shell/shell32/res/icons/304.ico diff --git a/reactos/dll/win32/shell32/res/icons/305.ico b/reactos/base/shell/shell32/res/icons/305.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/305.ico rename to reactos/base/shell/shell32/res/icons/305.ico diff --git a/reactos/dll/win32/shell32/res/icons/309.ico b/reactos/base/shell/shell32/res/icons/309.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/309.ico rename to reactos/base/shell/shell32/res/icons/309.ico diff --git a/reactos/dll/win32/shell32/res/icons/315.ico b/reactos/base/shell/shell32/res/icons/315.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/315.ico rename to reactos/base/shell/shell32/res/icons/315.ico diff --git a/reactos/dll/win32/shell32/res/icons/317.ico b/reactos/base/shell/shell32/res/icons/317.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/317.ico rename to reactos/base/shell/shell32/res/icons/317.ico diff --git a/reactos/dll/win32/shell32/res/icons/318.ico b/reactos/base/shell/shell32/res/icons/318.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/318.ico rename to reactos/base/shell/shell32/res/icons/318.ico diff --git a/reactos/dll/win32/shell32/res/icons/319.ico b/reactos/base/shell/shell32/res/icons/319.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/319.ico rename to reactos/base/shell/shell32/res/icons/319.ico diff --git a/reactos/dll/win32/shell32/res/icons/32.ico b/reactos/base/shell/shell32/res/icons/32.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/32.ico rename to reactos/base/shell/shell32/res/icons/32.ico diff --git a/reactos/dll/win32/shell32/res/icons/322.ico b/reactos/base/shell/shell32/res/icons/322.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/322.ico rename to reactos/base/shell/shell32/res/icons/322.ico diff --git a/reactos/dll/win32/shell32/res/icons/323.ico b/reactos/base/shell/shell32/res/icons/323.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/323.ico rename to reactos/base/shell/shell32/res/icons/323.ico diff --git a/reactos/dll/win32/shell32/res/icons/324.ico b/reactos/base/shell/shell32/res/icons/324.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/324.ico rename to reactos/base/shell/shell32/res/icons/324.ico diff --git a/reactos/dll/win32/shell32/res/icons/325.ico b/reactos/base/shell/shell32/res/icons/325.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/325.ico rename to reactos/base/shell/shell32/res/icons/325.ico diff --git a/reactos/dll/win32/shell32/res/icons/326.ico b/reactos/base/shell/shell32/res/icons/326.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/326.ico rename to reactos/base/shell/shell32/res/icons/326.ico diff --git a/reactos/dll/win32/shell32/res/icons/327.ico b/reactos/base/shell/shell32/res/icons/327.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/327.ico rename to reactos/base/shell/shell32/res/icons/327.ico diff --git a/reactos/dll/win32/shell32/res/icons/328.ico b/reactos/base/shell/shell32/res/icons/328.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/328.ico rename to reactos/base/shell/shell32/res/icons/328.ico diff --git a/reactos/dll/win32/shell32/res/icons/329.ico b/reactos/base/shell/shell32/res/icons/329.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/329.ico rename to reactos/base/shell/shell32/res/icons/329.ico diff --git a/reactos/dll/win32/shell32/res/icons/33.ico b/reactos/base/shell/shell32/res/icons/33.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/33.ico rename to reactos/base/shell/shell32/res/icons/33.ico diff --git a/reactos/dll/win32/shell32/res/icons/330.ico b/reactos/base/shell/shell32/res/icons/330.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/330.ico rename to reactos/base/shell/shell32/res/icons/330.ico diff --git a/reactos/dll/win32/shell32/res/icons/35.ico b/reactos/base/shell/shell32/res/icons/35.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/35.ico rename to reactos/base/shell/shell32/res/icons/35.ico diff --git a/reactos/dll/win32/shell32/res/icons/36.ico b/reactos/base/shell/shell32/res/icons/36.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/36.ico rename to reactos/base/shell/shell32/res/icons/36.ico diff --git a/reactos/dll/win32/shell32/res/icons/37.ico b/reactos/base/shell/shell32/res/icons/37.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/37.ico rename to reactos/base/shell/shell32/res/icons/37.ico diff --git a/reactos/dll/win32/shell32/res/icons/38.ico b/reactos/base/shell/shell32/res/icons/38.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/38.ico rename to reactos/base/shell/shell32/res/icons/38.ico diff --git a/reactos/dll/win32/shell32/res/icons/39.ico b/reactos/base/shell/shell32/res/icons/39.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/39.ico rename to reactos/base/shell/shell32/res/icons/39.ico diff --git a/reactos/dll/win32/shell32/res/icons/4.ico b/reactos/base/shell/shell32/res/icons/4.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/4.ico rename to reactos/base/shell/shell32/res/icons/4.ico diff --git a/reactos/dll/win32/shell32/res/icons/40.ico b/reactos/base/shell/shell32/res/icons/40.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/40.ico rename to reactos/base/shell/shell32/res/icons/40.ico diff --git a/reactos/dll/win32/shell32/res/icons/41.ico b/reactos/base/shell/shell32/res/icons/41.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/41.ico rename to reactos/base/shell/shell32/res/icons/41.ico diff --git a/reactos/dll/win32/shell32/res/icons/44.ico b/reactos/base/shell/shell32/res/icons/44.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/44.ico rename to reactos/base/shell/shell32/res/icons/44.ico diff --git a/reactos/dll/win32/shell32/res/icons/45.ico b/reactos/base/shell/shell32/res/icons/45.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/45.ico rename to reactos/base/shell/shell32/res/icons/45.ico diff --git a/reactos/dll/win32/shell32/res/icons/46.ico b/reactos/base/shell/shell32/res/icons/46.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/46.ico rename to reactos/base/shell/shell32/res/icons/46.ico diff --git a/reactos/dll/win32/shell32/res/icons/47.ico b/reactos/base/shell/shell32/res/icons/47.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/47.ico rename to reactos/base/shell/shell32/res/icons/47.ico diff --git a/reactos/dll/win32/shell32/res/icons/48.ico b/reactos/base/shell/shell32/res/icons/48.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/48.ico rename to reactos/base/shell/shell32/res/icons/48.ico diff --git a/reactos/dll/win32/shell32/res/icons/5.ico b/reactos/base/shell/shell32/res/icons/5.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/5.ico rename to reactos/base/shell/shell32/res/icons/5.ico diff --git a/reactos/dll/win32/shell32/res/icons/54.ico b/reactos/base/shell/shell32/res/icons/54.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/54.ico rename to reactos/base/shell/shell32/res/icons/54.ico diff --git a/reactos/dll/win32/shell32/res/icons/6.ico b/reactos/base/shell/shell32/res/icons/6.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/6.ico rename to reactos/base/shell/shell32/res/icons/6.ico diff --git a/reactos/dll/win32/shell32/res/icons/7.ico b/reactos/base/shell/shell32/res/icons/7.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/7.ico rename to reactos/base/shell/shell32/res/icons/7.ico diff --git a/reactos/dll/win32/shell32/res/icons/8.ico b/reactos/base/shell/shell32/res/icons/8.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/8.ico rename to reactos/base/shell/shell32/res/icons/8.ico diff --git a/reactos/dll/win32/shell32/res/icons/8240.ico b/reactos/base/shell/shell32/res/icons/8240.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/8240.ico rename to reactos/base/shell/shell32/res/icons/8240.ico diff --git a/reactos/dll/win32/shell32/res/icons/9.ico b/reactos/base/shell/shell32/res/icons/9.ico similarity index 100% rename from reactos/dll/win32/shell32/res/icons/9.ico rename to reactos/base/shell/shell32/res/icons/9.ico diff --git a/reactos/dll/win32/shell32/res/icons/Icon_Licence/COPYING b/reactos/base/shell/shell32/res/icons/Icon_Licence/COPYING similarity index 100% rename from reactos/dll/win32/shell32/res/icons/Icon_Licence/COPYING rename to reactos/base/shell/shell32/res/icons/Icon_Licence/COPYING diff --git a/reactos/dll/win32/shell32/res/icons/Icon_Licence/Tango.txt b/reactos/base/shell/shell32/res/icons/Icon_Licence/Tango.txt similarity index 100% rename from reactos/dll/win32/shell32/res/icons/Icon_Licence/Tango.txt rename to reactos/base/shell/shell32/res/icons/Icon_Licence/Tango.txt diff --git a/reactos/dll/win32/shell32/res/rgs/adminfoldershortcut.rgs b/reactos/base/shell/shell32/res/rgs/adminfoldershortcut.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/adminfoldershortcut.rgs rename to reactos/base/shell/shell32/res/rgs/adminfoldershortcut.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/controlpanel.rgs b/reactos/base/shell/shell32/res/rgs/controlpanel.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/controlpanel.rgs rename to reactos/base/shell/shell32/res/rgs/controlpanel.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/dragdrophelper.rgs b/reactos/base/shell/shell32/res/rgs/dragdrophelper.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/dragdrophelper.rgs rename to reactos/base/shell/shell32/res/rgs/dragdrophelper.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/exedrophandler.rgs b/reactos/base/shell/shell32/res/rgs/exedrophandler.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/exedrophandler.rgs rename to reactos/base/shell/shell32/res/rgs/exedrophandler.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/folderoptions.rgs b/reactos/base/shell/shell32/res/rgs/folderoptions.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/folderoptions.rgs rename to reactos/base/shell/shell32/res/rgs/folderoptions.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/foldershortcut.rgs b/reactos/base/shell/shell32/res/rgs/foldershortcut.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/foldershortcut.rgs rename to reactos/base/shell/shell32/res/rgs/foldershortcut.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/fontsfoldershortcut.rgs b/reactos/base/shell/shell32/res/rgs/fontsfoldershortcut.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/fontsfoldershortcut.rgs rename to reactos/base/shell/shell32/res/rgs/fontsfoldershortcut.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/menuband.rgs b/reactos/base/shell/shell32/res/rgs/menuband.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/menuband.rgs rename to reactos/base/shell/shell32/res/rgs/menuband.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/menubandsite.rgs b/reactos/base/shell/shell32/res/rgs/menubandsite.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/menubandsite.rgs rename to reactos/base/shell/shell32/res/rgs/menubandsite.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/menudeskbar.rgs b/reactos/base/shell/shell32/res/rgs/menudeskbar.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/menudeskbar.rgs rename to reactos/base/shell/shell32/res/rgs/menudeskbar.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/mycomputer.rgs b/reactos/base/shell/shell32/res/rgs/mycomputer.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/mycomputer.rgs rename to reactos/base/shell/shell32/res/rgs/mycomputer.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/mydocuments.rgs b/reactos/base/shell/shell32/res/rgs/mydocuments.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/mydocuments.rgs rename to reactos/base/shell/shell32/res/rgs/mydocuments.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/networkplaces.rgs b/reactos/base/shell/shell32/res/rgs/networkplaces.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/networkplaces.rgs rename to reactos/base/shell/shell32/res/rgs/networkplaces.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/newmenu.rgs b/reactos/base/shell/shell32/res/rgs/newmenu.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/newmenu.rgs rename to reactos/base/shell/shell32/res/rgs/newmenu.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/openwithmenu.rgs b/reactos/base/shell/shell32/res/rgs/openwithmenu.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/openwithmenu.rgs rename to reactos/base/shell/shell32/res/rgs/openwithmenu.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/printers.rgs b/reactos/base/shell/shell32/res/rgs/printers.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/printers.rgs rename to reactos/base/shell/shell32/res/rgs/printers.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/recyclebin.rgs b/reactos/base/shell/shell32/res/rgs/recyclebin.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/recyclebin.rgs rename to reactos/base/shell/shell32/res/rgs/recyclebin.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/shelldesktop.rgs b/reactos/base/shell/shell32/res/rgs/shelldesktop.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/shelldesktop.rgs rename to reactos/base/shell/shell32/res/rgs/shelldesktop.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/shelldrvdefext.rgs b/reactos/base/shell/shell32/res/rgs/shelldrvdefext.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/shelldrvdefext.rgs rename to reactos/base/shell/shell32/res/rgs/shelldrvdefext.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/shellfiledefext.rgs b/reactos/base/shell/shell32/res/rgs/shellfiledefext.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/shellfiledefext.rgs rename to reactos/base/shell/shell32/res/rgs/shellfiledefext.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/shellfsfolder.rgs b/reactos/base/shell/shell32/res/rgs/shellfsfolder.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/shellfsfolder.rgs rename to reactos/base/shell/shell32/res/rgs/shellfsfolder.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/shelllink.rgs b/reactos/base/shell/shell32/res/rgs/shelllink.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/shelllink.rgs rename to reactos/base/shell/shell32/res/rgs/shelllink.rgs diff --git a/reactos/dll/win32/shell32/res/rgs/startmenu.rgs b/reactos/base/shell/shell32/res/rgs/startmenu.rgs similarity index 100% rename from reactos/dll/win32/shell32/res/rgs/startmenu.rgs rename to reactos/base/shell/shell32/res/rgs/startmenu.rgs diff --git a/reactos/dll/win32/shell32/rgs_res.rc b/reactos/base/shell/shell32/rgs_res.rc similarity index 100% rename from reactos/dll/win32/shell32/rgs_res.rc rename to reactos/base/shell/shell32/rgs_res.rc diff --git a/reactos/dll/win32/shell32/shell32.cpp b/reactos/base/shell/shell32/shell32.cpp similarity index 100% rename from reactos/dll/win32/shell32/shell32.cpp rename to reactos/base/shell/shell32/shell32.cpp diff --git a/reactos/dll/win32/shell32/shell32.rc b/reactos/base/shell/shell32/shell32.rc similarity index 100% rename from reactos/dll/win32/shell32/shell32.rc rename to reactos/base/shell/shell32/shell32.rc diff --git a/reactos/dll/win32/shell32/shell32.spec b/reactos/base/shell/shell32/shell32.spec similarity index 100% rename from reactos/dll/win32/shell32/shell32.spec rename to reactos/base/shell/shell32/shell32.spec diff --git a/reactos/dll/win32/shell32/shell32_version.h b/reactos/base/shell/shell32/shell32_version.h similarity index 100% rename from reactos/dll/win32/shell32/shell32_version.h rename to reactos/base/shell/shell32/shell32_version.h diff --git a/reactos/dll/win32/shell32/shell32_version.rc b/reactos/base/shell/shell32/shell32_version.rc similarity index 100% rename from reactos/dll/win32/shell32/shell32_version.rc rename to reactos/base/shell/shell32/shell32_version.rc diff --git a/reactos/dll/win32/shell32/shellfolder.h b/reactos/base/shell/shell32/shellfolder.h similarity index 100% rename from reactos/dll/win32/shell32/shellfolder.h rename to reactos/base/shell/shell32/shellfolder.h diff --git a/reactos/dll/win32/shell32/shfldr.h b/reactos/base/shell/shell32/shfldr.h similarity index 100% rename from reactos/dll/win32/shell32/shfldr.h rename to reactos/base/shell/shell32/shfldr.h diff --git a/reactos/dll/win32/shell32/shlexec.cpp b/reactos/base/shell/shell32/shlexec.cpp similarity index 100% rename from reactos/dll/win32/shell32/shlexec.cpp rename to reactos/base/shell/shell32/shlexec.cpp diff --git a/reactos/dll/win32/shell32/shlfileop.cpp b/reactos/base/shell/shell32/shlfileop.cpp similarity index 100% rename from reactos/dll/win32/shell32/shlfileop.cpp rename to reactos/base/shell/shell32/shlfileop.cpp diff --git a/reactos/dll/win32/shell32/shlfolder.cpp b/reactos/base/shell/shell32/shlfolder.cpp similarity index 100% rename from reactos/dll/win32/shell32/shlfolder.cpp rename to reactos/base/shell/shell32/shlfolder.cpp diff --git a/reactos/dll/win32/shell32/shobjidl_local.idl b/reactos/base/shell/shell32/shobjidl_local.idl similarity index 100% rename from reactos/dll/win32/shell32/shobjidl_local.idl rename to reactos/base/shell/shell32/shobjidl_local.idl diff --git a/reactos/dll/win32/shell32/shresdef.h b/reactos/base/shell/shell32/shresdef.h similarity index 100% rename from reactos/dll/win32/shell32/shresdef.h rename to reactos/base/shell/shell32/shresdef.h diff --git a/reactos/dll/win32/shell32/stubs.cpp b/reactos/base/shell/shell32/stubs.cpp similarity index 100% rename from reactos/dll/win32/shell32/stubs.cpp rename to reactos/base/shell/shell32/stubs.cpp diff --git a/reactos/dll/win32/shell32/systray.cpp b/reactos/base/shell/shell32/systray.cpp similarity index 100% rename from reactos/dll/win32/shell32/systray.cpp rename to reactos/base/shell/shell32/systray.cpp diff --git a/reactos/dll/win32/shell32/vista.c b/reactos/base/shell/shell32/vista.c similarity index 100% rename from reactos/dll/win32/shell32/vista.c rename to reactos/base/shell/shell32/vista.c diff --git a/reactos/dll/win32/shell32/wine/brsfolder.c b/reactos/base/shell/shell32/wine/brsfolder.c similarity index 100% rename from reactos/dll/win32/shell32/wine/brsfolder.c rename to reactos/base/shell/shell32/wine/brsfolder.c diff --git a/reactos/dll/win32/shell32/wine/changenotify.c b/reactos/base/shell/shell32/wine/changenotify.c similarity index 100% rename from reactos/dll/win32/shell32/wine/changenotify.c rename to reactos/base/shell/shell32/wine/changenotify.c diff --git a/reactos/dll/win32/shell32/wine/classes.c b/reactos/base/shell/shell32/wine/classes.c similarity index 100% rename from reactos/dll/win32/shell32/wine/classes.c rename to reactos/base/shell/shell32/wine/classes.c diff --git a/reactos/dll/win32/shell32/wine/clipboard.c b/reactos/base/shell/shell32/wine/clipboard.c similarity index 100% rename from reactos/dll/win32/shell32/wine/clipboard.c rename to reactos/base/shell/shell32/wine/clipboard.c diff --git a/reactos/dll/win32/shell32/wine/control.c b/reactos/base/shell/shell32/wine/control.c similarity index 100% rename from reactos/dll/win32/shell32/wine/control.c rename to reactos/base/shell/shell32/wine/control.c diff --git a/reactos/dll/win32/shell32/wine/pidl.c b/reactos/base/shell/shell32/wine/pidl.c similarity index 100% rename from reactos/dll/win32/shell32/wine/pidl.c rename to reactos/base/shell/shell32/wine/pidl.c diff --git a/reactos/dll/win32/shell32/wine/pidl.h b/reactos/base/shell/shell32/wine/pidl.h similarity index 100% rename from reactos/dll/win32/shell32/wine/pidl.h rename to reactos/base/shell/shell32/wine/pidl.h diff --git a/reactos/dll/win32/shell32/wine/shell32_main.c b/reactos/base/shell/shell32/wine/shell32_main.c similarity index 100% rename from reactos/dll/win32/shell32/wine/shell32_main.c rename to reactos/base/shell/shell32/wine/shell32_main.c diff --git a/reactos/dll/win32/shell32/wine/shell32_main.h b/reactos/base/shell/shell32/wine/shell32_main.h similarity index 100% rename from reactos/dll/win32/shell32/wine/shell32_main.h rename to reactos/base/shell/shell32/wine/shell32_main.h diff --git a/reactos/dll/win32/shell32/wine/shellole.c b/reactos/base/shell/shell32/wine/shellole.c similarity index 100% rename from reactos/dll/win32/shell32/wine/shellole.c rename to reactos/base/shell/shell32/wine/shellole.c diff --git a/reactos/dll/win32/shell32/wine/shellord.c b/reactos/base/shell/shell32/wine/shellord.c similarity index 100% rename from reactos/dll/win32/shell32/wine/shellord.c rename to reactos/base/shell/shell32/wine/shellord.c diff --git a/reactos/dll/win32/shell32/wine/shellpath.c b/reactos/base/shell/shell32/wine/shellpath.c similarity index 100% rename from reactos/dll/win32/shell32/wine/shellpath.c rename to reactos/base/shell/shell32/wine/shellpath.c diff --git a/reactos/dll/win32/shell32/wine/shellreg.c b/reactos/base/shell/shell32/wine/shellreg.c similarity index 100% rename from reactos/dll/win32/shell32/wine/shellreg.c rename to reactos/base/shell/shell32/wine/shellreg.c diff --git a/reactos/dll/win32/shell32/wine/shellstring.c b/reactos/base/shell/shell32/wine/shellstring.c similarity index 100% rename from reactos/dll/win32/shell32/wine/shellstring.c rename to reactos/base/shell/shell32/wine/shellstring.c diff --git a/reactos/dll/win32/shell32/wine/shlmenu.c b/reactos/base/shell/shell32/wine/shlmenu.c similarity index 100% rename from reactos/dll/win32/shell32/wine/shlmenu.c rename to reactos/base/shell/shell32/wine/shlmenu.c diff --git a/reactos/dll/win32/shell32/wine/shpolicy.c b/reactos/base/shell/shell32/wine/shpolicy.c similarity index 100% rename from reactos/dll/win32/shell32/wine/shpolicy.c rename to reactos/base/shell/shell32/wine/shpolicy.c diff --git a/reactos/dll/win32/shfolder/CMakeLists.txt b/reactos/base/shell/shfolder/CMakeLists.txt similarity index 100% rename from reactos/dll/win32/shfolder/CMakeLists.txt rename to reactos/base/shell/shfolder/CMakeLists.txt diff --git a/reactos/dll/win32/shfolder/shfolder.spec b/reactos/base/shell/shfolder/shfolder.spec similarity index 100% rename from reactos/dll/win32/shfolder/shfolder.spec rename to reactos/base/shell/shfolder/shfolder.spec diff --git a/reactos/dll/win32/shfolder/version.rc b/reactos/base/shell/shfolder/version.rc similarity index 100% rename from reactos/dll/win32/shfolder/version.rc rename to reactos/base/shell/shfolder/version.rc diff --git a/reactos/dll/win32/shimgvw/CMakeLists.txt b/reactos/base/shell/shimgvw/CMakeLists.txt similarity index 100% rename from reactos/dll/win32/shimgvw/CMakeLists.txt rename to reactos/base/shell/shimgvw/CMakeLists.txt diff --git a/reactos/dll/win32/shimgvw/comsup.c b/reactos/base/shell/shimgvw/comsup.c similarity index 100% rename from reactos/dll/win32/shimgvw/comsup.c rename to reactos/base/shell/shimgvw/comsup.c diff --git a/reactos/dll/win32/shimgvw/comsup.h b/reactos/base/shell/shimgvw/comsup.h similarity index 100% rename from reactos/dll/win32/shimgvw/comsup.h rename to reactos/base/shell/shimgvw/comsup.h diff --git a/reactos/dll/win32/shimgvw/lang/bg-BG.rc b/reactos/base/shell/shimgvw/lang/bg-BG.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/bg-BG.rc rename to reactos/base/shell/shimgvw/lang/bg-BG.rc diff --git a/reactos/dll/win32/shimgvw/lang/cs-CZ.rc b/reactos/base/shell/shimgvw/lang/cs-CZ.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/cs-CZ.rc rename to reactos/base/shell/shimgvw/lang/cs-CZ.rc diff --git a/reactos/dll/win32/shimgvw/lang/de-DE.rc b/reactos/base/shell/shimgvw/lang/de-DE.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/de-DE.rc rename to reactos/base/shell/shimgvw/lang/de-DE.rc diff --git a/reactos/dll/win32/shimgvw/lang/en-US.rc b/reactos/base/shell/shimgvw/lang/en-US.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/en-US.rc rename to reactos/base/shell/shimgvw/lang/en-US.rc diff --git a/reactos/dll/win32/shimgvw/lang/es-ES.rc b/reactos/base/shell/shimgvw/lang/es-ES.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/es-ES.rc rename to reactos/base/shell/shimgvw/lang/es-ES.rc diff --git a/reactos/dll/win32/shimgvw/lang/fr-FR.rc b/reactos/base/shell/shimgvw/lang/fr-FR.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/fr-FR.rc rename to reactos/base/shell/shimgvw/lang/fr-FR.rc diff --git a/reactos/dll/win32/shimgvw/lang/he-IL.rc b/reactos/base/shell/shimgvw/lang/he-IL.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/he-IL.rc rename to reactos/base/shell/shimgvw/lang/he-IL.rc diff --git a/reactos/dll/win32/shimgvw/lang/it-IT.rc b/reactos/base/shell/shimgvw/lang/it-IT.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/it-IT.rc rename to reactos/base/shell/shimgvw/lang/it-IT.rc diff --git a/reactos/dll/win32/shimgvw/lang/lt-LT.rc b/reactos/base/shell/shimgvw/lang/lt-LT.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/lt-LT.rc rename to reactos/base/shell/shimgvw/lang/lt-LT.rc diff --git a/reactos/dll/win32/shimgvw/lang/no-NO.rc b/reactos/base/shell/shimgvw/lang/no-NO.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/no-NO.rc rename to reactos/base/shell/shimgvw/lang/no-NO.rc diff --git a/reactos/dll/win32/shimgvw/lang/pl-PL.rc b/reactos/base/shell/shimgvw/lang/pl-PL.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/pl-PL.rc rename to reactos/base/shell/shimgvw/lang/pl-PL.rc diff --git a/reactos/dll/win32/shimgvw/lang/ro-RO.rc b/reactos/base/shell/shimgvw/lang/ro-RO.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/ro-RO.rc rename to reactos/base/shell/shimgvw/lang/ro-RO.rc diff --git a/reactos/dll/win32/shimgvw/lang/ru-RU.rc b/reactos/base/shell/shimgvw/lang/ru-RU.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/ru-RU.rc rename to reactos/base/shell/shimgvw/lang/ru-RU.rc diff --git a/reactos/dll/win32/shimgvw/lang/sk-SK.rc b/reactos/base/shell/shimgvw/lang/sk-SK.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/sk-SK.rc rename to reactos/base/shell/shimgvw/lang/sk-SK.rc diff --git a/reactos/dll/win32/shimgvw/lang/sq-AL.rc b/reactos/base/shell/shimgvw/lang/sq-AL.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/sq-AL.rc rename to reactos/base/shell/shimgvw/lang/sq-AL.rc diff --git a/reactos/dll/win32/shimgvw/lang/tr-TR.rc b/reactos/base/shell/shimgvw/lang/tr-TR.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/tr-TR.rc rename to reactos/base/shell/shimgvw/lang/tr-TR.rc diff --git a/reactos/dll/win32/shimgvw/lang/uk-UA.rc b/reactos/base/shell/shimgvw/lang/uk-UA.rc similarity index 100% rename from reactos/dll/win32/shimgvw/lang/uk-UA.rc rename to reactos/base/shell/shimgvw/lang/uk-UA.rc diff --git a/reactos/dll/win32/shimgvw/res/main.ico b/reactos/base/shell/shimgvw/res/main.ico similarity index 100% rename from reactos/dll/win32/shimgvw/res/main.ico rename to reactos/base/shell/shimgvw/res/main.ico diff --git a/reactos/dll/win32/shimgvw/res/next.bmp b/reactos/base/shell/shimgvw/res/next.bmp similarity index 100% rename from reactos/dll/win32/shimgvw/res/next.bmp rename to reactos/base/shell/shimgvw/res/next.bmp diff --git a/reactos/dll/win32/shimgvw/res/prev.bmp b/reactos/base/shell/shimgvw/res/prev.bmp similarity index 100% rename from reactos/dll/win32/shimgvw/res/prev.bmp rename to reactos/base/shell/shimgvw/res/prev.bmp diff --git a/reactos/dll/win32/shimgvw/res/print.bmp b/reactos/base/shell/shimgvw/res/print.bmp similarity index 100% rename from reactos/dll/win32/shimgvw/res/print.bmp rename to reactos/base/shell/shimgvw/res/print.bmp diff --git a/reactos/dll/win32/shimgvw/res/rot1.bmp b/reactos/base/shell/shimgvw/res/rot1.bmp similarity index 100% rename from reactos/dll/win32/shimgvw/res/rot1.bmp rename to reactos/base/shell/shimgvw/res/rot1.bmp diff --git a/reactos/dll/win32/shimgvw/res/rot2.bmp b/reactos/base/shell/shimgvw/res/rot2.bmp similarity index 100% rename from reactos/dll/win32/shimgvw/res/rot2.bmp rename to reactos/base/shell/shimgvw/res/rot2.bmp diff --git a/reactos/dll/win32/shimgvw/res/save.bmp b/reactos/base/shell/shimgvw/res/save.bmp similarity index 100% rename from reactos/dll/win32/shimgvw/res/save.bmp rename to reactos/base/shell/shimgvw/res/save.bmp diff --git a/reactos/dll/win32/shimgvw/res/zoomm.bmp b/reactos/base/shell/shimgvw/res/zoomm.bmp similarity index 100% rename from reactos/dll/win32/shimgvw/res/zoomm.bmp rename to reactos/base/shell/shimgvw/res/zoomm.bmp diff --git a/reactos/dll/win32/shimgvw/res/zoomp.bmp b/reactos/base/shell/shimgvw/res/zoomp.bmp similarity index 100% rename from reactos/dll/win32/shimgvw/res/zoomp.bmp rename to reactos/base/shell/shimgvw/res/zoomp.bmp diff --git a/reactos/dll/win32/shimgvw/resource.h b/reactos/base/shell/shimgvw/resource.h similarity index 100% rename from reactos/dll/win32/shimgvw/resource.h rename to reactos/base/shell/shimgvw/resource.h diff --git a/reactos/dll/win32/shimgvw/shimgvw.c b/reactos/base/shell/shimgvw/shimgvw.c similarity index 100% rename from reactos/dll/win32/shimgvw/shimgvw.c rename to reactos/base/shell/shimgvw/shimgvw.c diff --git a/reactos/dll/win32/shimgvw/shimgvw.h b/reactos/base/shell/shimgvw/shimgvw.h similarity index 100% rename from reactos/dll/win32/shimgvw/shimgvw.h rename to reactos/base/shell/shimgvw/shimgvw.h diff --git a/reactos/dll/win32/shimgvw/shimgvw.rc b/reactos/base/shell/shimgvw/shimgvw.rc similarity index 100% rename from reactos/dll/win32/shimgvw/shimgvw.rc rename to reactos/base/shell/shimgvw/shimgvw.rc diff --git a/reactos/dll/win32/shimgvw/shimgvw.spec b/reactos/base/shell/shimgvw/shimgvw.spec similarity index 100% rename from reactos/dll/win32/shimgvw/shimgvw.spec rename to reactos/base/shell/shimgvw/shimgvw.spec diff --git a/reactos/dll/win32/shlwapi/CMakeLists.txt b/reactos/base/shell/shlwapi/CMakeLists.txt similarity index 100% rename from reactos/dll/win32/shlwapi/CMakeLists.txt rename to reactos/base/shell/shlwapi/CMakeLists.txt diff --git a/reactos/dll/win32/shlwapi/assoc.c b/reactos/base/shell/shlwapi/assoc.c similarity index 100% rename from reactos/dll/win32/shlwapi/assoc.c rename to reactos/base/shell/shlwapi/assoc.c diff --git a/reactos/dll/win32/shlwapi/clist.c b/reactos/base/shell/shlwapi/clist.c similarity index 100% rename from reactos/dll/win32/shlwapi/clist.c rename to reactos/base/shell/shlwapi/clist.c diff --git a/reactos/dll/win32/shlwapi/istream.c b/reactos/base/shell/shlwapi/istream.c similarity index 100% rename from reactos/dll/win32/shlwapi/istream.c rename to reactos/base/shell/shlwapi/istream.c diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Da.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Da.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Da.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Da.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_De.rc b/reactos/base/shell/shlwapi/lang/shlwapi_De.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_De.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_De.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_En.rc b/reactos/base/shell/shlwapi/lang/shlwapi_En.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_En.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_En.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Es.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Es.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Es.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Es.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Fi.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Fi.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Fi.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Fi.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Fr.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Fr.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Fr.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Fr.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_He.rc b/reactos/base/shell/shlwapi/lang/shlwapi_He.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_He.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_He.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Hu.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Hu.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Hu.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Hu.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_It.rc b/reactos/base/shell/shlwapi/lang/shlwapi_It.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_It.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_It.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Ja.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Ja.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Ja.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Ja.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Ko.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Ko.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Ko.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Ko.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Lt.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Lt.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Lt.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Lt.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Nl.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Nl.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Nl.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Nl.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_No.rc b/reactos/base/shell/shlwapi/lang/shlwapi_No.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_No.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_No.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Pl.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Pl.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Pl.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Pl.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Pt.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Pt.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Pt.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Pt.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Ro.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Ro.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Ro.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Ro.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Ru.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Ru.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Ru.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Ru.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Si.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Si.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Si.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Si.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Sk.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Sk.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Sk.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Sk.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Sq.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Sq.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Sq.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Sq.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Sv.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Sv.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Sv.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Sv.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Tr.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Tr.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Tr.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Tr.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Uk.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Uk.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Uk.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Uk.rc diff --git a/reactos/dll/win32/shlwapi/lang/shlwapi_Zh.rc b/reactos/base/shell/shlwapi/lang/shlwapi_Zh.rc similarity index 100% rename from reactos/dll/win32/shlwapi/lang/shlwapi_Zh.rc rename to reactos/base/shell/shlwapi/lang/shlwapi_Zh.rc diff --git a/reactos/dll/win32/shlwapi/msgbox.c b/reactos/base/shell/shlwapi/msgbox.c similarity index 100% rename from reactos/dll/win32/shlwapi/msgbox.c rename to reactos/base/shell/shlwapi/msgbox.c diff --git a/reactos/dll/win32/shlwapi/ordinal.c b/reactos/base/shell/shlwapi/ordinal.c similarity index 100% rename from reactos/dll/win32/shlwapi/ordinal.c rename to reactos/base/shell/shlwapi/ordinal.c diff --git a/reactos/dll/win32/shlwapi/path.c b/reactos/base/shell/shlwapi/path.c similarity index 100% rename from reactos/dll/win32/shlwapi/path.c rename to reactos/base/shell/shlwapi/path.c diff --git a/reactos/dll/win32/shlwapi/precomp.h b/reactos/base/shell/shlwapi/precomp.h similarity index 100% rename from reactos/dll/win32/shlwapi/precomp.h rename to reactos/base/shell/shlwapi/precomp.h diff --git a/reactos/dll/win32/shlwapi/reg.c b/reactos/base/shell/shlwapi/reg.c similarity index 100% rename from reactos/dll/win32/shlwapi/reg.c rename to reactos/base/shell/shlwapi/reg.c diff --git a/reactos/dll/win32/shlwapi/regstream.c b/reactos/base/shell/shlwapi/regstream.c similarity index 100% rename from reactos/dll/win32/shlwapi/regstream.c rename to reactos/base/shell/shlwapi/regstream.c diff --git a/reactos/dll/win32/shlwapi/resource.h b/reactos/base/shell/shlwapi/resource.h similarity index 100% rename from reactos/dll/win32/shlwapi/resource.h rename to reactos/base/shell/shlwapi/resource.h diff --git a/reactos/dll/win32/shlwapi/shlwapi.rc b/reactos/base/shell/shlwapi/shlwapi.rc similarity index 100% rename from reactos/dll/win32/shlwapi/shlwapi.rc rename to reactos/base/shell/shlwapi/shlwapi.rc diff --git a/reactos/dll/win32/shlwapi/shlwapi.spec b/reactos/base/shell/shlwapi/shlwapi.spec similarity index 100% rename from reactos/dll/win32/shlwapi/shlwapi.spec rename to reactos/base/shell/shlwapi/shlwapi.spec diff --git a/reactos/dll/win32/shlwapi/shlwapi_main.c b/reactos/base/shell/shlwapi/shlwapi_main.c similarity index 100% rename from reactos/dll/win32/shlwapi/shlwapi_main.c rename to reactos/base/shell/shlwapi/shlwapi_main.c diff --git a/reactos/dll/win32/shlwapi/shlwapi_ros.diff b/reactos/base/shell/shlwapi/shlwapi_ros.diff similarity index 100% rename from reactos/dll/win32/shlwapi/shlwapi_ros.diff rename to reactos/base/shell/shlwapi/shlwapi_ros.diff diff --git a/reactos/dll/win32/shlwapi/stopwatch.c b/reactos/base/shell/shlwapi/stopwatch.c similarity index 100% rename from reactos/dll/win32/shlwapi/stopwatch.c rename to reactos/base/shell/shlwapi/stopwatch.c diff --git a/reactos/dll/win32/shlwapi/string.c b/reactos/base/shell/shlwapi/string.c similarity index 100% rename from reactos/dll/win32/shlwapi/string.c rename to reactos/base/shell/shlwapi/string.c diff --git a/reactos/dll/win32/shlwapi/thread.c b/reactos/base/shell/shlwapi/thread.c similarity index 100% rename from reactos/dll/win32/shlwapi/thread.c rename to reactos/base/shell/shlwapi/thread.c diff --git a/reactos/dll/win32/shlwapi/url.c b/reactos/base/shell/shlwapi/url.c similarity index 100% rename from reactos/dll/win32/shlwapi/url.c rename to reactos/base/shell/shlwapi/url.c diff --git a/reactos/dll/win32/shlwapi/version.rc b/reactos/base/shell/shlwapi/version.rc similarity index 100% rename from reactos/dll/win32/shlwapi/version.rc rename to reactos/base/shell/shlwapi/version.rc diff --git a/reactos/dll/win32/shlwapi/wsprintf.c b/reactos/base/shell/shlwapi/wsprintf.c similarity index 100% rename from reactos/dll/win32/shlwapi/wsprintf.c rename to reactos/base/shell/shlwapi/wsprintf.c diff --git a/reactos/dll/win32/CMakeLists.txt b/reactos/dll/win32/CMakeLists.txt index 8bbbc3240c0..acce4e41d14 100644 --- a/reactos/dll/win32/CMakeLists.txt +++ b/reactos/dll/win32/CMakeLists.txt @@ -173,10 +173,6 @@ add_subdirectory(serialui) add_subdirectory(setupapi) add_subdirectory(sfc) add_subdirectory(sfc_os) -add_subdirectory(shell32) -add_subdirectory(shfolder) -add_subdirectory(shimgvw) -add_subdirectory(shlwapi) add_subdirectory(slbcsp) add_subdirectory(smdll) add_subdirectory(sndblst) diff --git a/reactos/dll/win32/shell32/authors.c b/reactos/dll/win32/shell32/authors.c deleted file mode 100644 index 3101d764863..00000000000 --- a/reactos/dll/win32/shell32/authors.c +++ /dev/null @@ -1,3 +0,0 @@ -#include - -const char * const SHELL_Authors[] = { "Copyright 1993-" COPYRIGHT_YEAR " WINE team", "Copyright 1998-" COPYRIGHT_YEAR " ReactOS Team", 0 }; diff --git a/reactos/dll/win32/shell32/autocomplete.c b/reactos/dll/win32/shell32/autocomplete.c deleted file mode 100644 index b05fd67641b..00000000000 --- a/reactos/dll/win32/shell32/autocomplete.c +++ /dev/null @@ -1,629 +0,0 @@ -/* - * AutoComplete interfaces implementation. - * - * Copyright 2004 Maxime Bellengé - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/* - Implemented: - - ACO_AUTOAPPEND style - - ACO_AUTOSUGGEST style - - ACO_UPDOWNKEYDROPSLIST style - - - Handle pwzsRegKeyPath and pwszQuickComplete in Init - - TODO: - - implement ACO_SEARCH style - - implement ACO_FILTERPREFIXES style - - implement ACO_USETAB style - - implement ACO_RTLREADING style - - */ - -#include - - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -typedef struct -{ - const IAutoCompleteVtbl *lpVtbl; - const IAutoComplete2Vtbl *lpvtblAutoComplete2; - LONG ref; - BOOL enabled; - HWND hwndEdit; - HWND hwndListBox; - WNDPROC wpOrigEditProc; - WNDPROC wpOrigLBoxProc; - WCHAR *txtbackup; - WCHAR *quickComplete; - IEnumString *enumstr; - AUTOCOMPLETEOPTIONS options; -} IAutoCompleteImpl; - -static const IAutoCompleteVtbl acvt; -static const IAutoComplete2Vtbl ac2vt; - -static IAutoCompleteImpl * impl_from_IAutoComplete2( IAutoComplete2 *iface ) -{ - return (IAutoCompleteImpl *)((char*)iface - FIELD_OFFSET(IAutoCompleteImpl, lpvtblAutoComplete2)); -} - - -/* - converts This to an interface pointer -*/ -#define _IUnknown_(This) (IUnknown*)&(This->lpVtbl) -#define _IAutoComplete2_(This) (IAutoComplete2*)&(This->lpvtblAutoComplete2) - -static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - -/************************************************************************** - * IAutoComplete_Constructor - */ -HRESULT WINAPI IAutoComplete_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) -{ - IAutoCompleteImpl *lpac; - - if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown)) - return CLASS_E_NOAGGREGATION; - - lpac = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAutoCompleteImpl)); - if (!lpac) - return E_OUTOFMEMORY; - - lpac->ref = 1; - lpac->lpVtbl = &acvt; - lpac->lpvtblAutoComplete2 = &ac2vt; - lpac->enabled = TRUE; - lpac->enumstr = NULL; - lpac->options = ACO_AUTOAPPEND; - lpac->wpOrigEditProc = NULL; - lpac->hwndListBox = NULL; - lpac->txtbackup = NULL; - lpac->quickComplete = NULL; - - if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (lpac), riid, ppv))) { - IUnknown_Release (_IUnknown_ (lpac)); - return E_NOINTERFACE; - } - - TRACE("-- (%p)->\n",lpac); - - return S_OK; -} - -/************************************************************************** - * AutoComplete_QueryInterface - */ -static HRESULT WINAPI IAutoComplete_fnQueryInterface( - IAutoComplete * iface, - REFIID riid, - LPVOID *ppvObj) -{ - IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface; - - TRACE("(%p)->(\n\tIID:\t%s,%p)\n", This, shdebugstr_guid(riid), ppvObj); - *ppvObj = NULL; - - if(IsEqualIID(riid, &IID_IUnknown)) - { - *ppvObj = This; - } - else if(IsEqualIID(riid, &IID_IAutoComplete)) - { - *ppvObj = (IAutoComplete*)This; - } - else if(IsEqualIID(riid, &IID_IAutoComplete2)) - { - *ppvObj = _IAutoComplete2_ (This); - } - - if (*ppvObj) - { - IAutoComplete_AddRef((IAutoComplete*)*ppvObj); - TRACE("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj); - return S_OK; - } - TRACE("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -/****************************************************************************** - * IAutoComplete_fnAddRef - */ -static ULONG WINAPI IAutoComplete_fnAddRef( - IAutoComplete * iface) -{ - IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE("(%p)->(%u)\n", This, refCount - 1); - - return refCount; -} - -/****************************************************************************** - * IAutoComplete_fnRelease - */ -static ULONG WINAPI IAutoComplete_fnRelease( - IAutoComplete * iface) -{ - IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(%u)\n", This, refCount + 1); - - if (!refCount) { - TRACE(" destroying IAutoComplete(%p)\n",This); - HeapFree(GetProcessHeap(), 0, This->quickComplete); - HeapFree(GetProcessHeap(), 0, This->txtbackup); - if (This->hwndListBox) - DestroyWindow(This->hwndListBox); - if (This->enumstr) - IEnumString_Release(This->enumstr); - HeapFree(GetProcessHeap(), 0, This); - } - return refCount; -} - -/****************************************************************************** - * IAutoComplete_fnEnable - */ -static HRESULT WINAPI IAutoComplete_fnEnable( - IAutoComplete * iface, - BOOL fEnable) -{ - IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface; - - HRESULT hr = S_OK; - - TRACE("(%p)->(%s)\n", This, (fEnable)?"true":"false"); - - This->enabled = fEnable; - - return hr; -} - -/****************************************************************************** - * IAutoComplete_fnInit - */ -static HRESULT WINAPI IAutoComplete_fnInit( - IAutoComplete * iface, - HWND hwndEdit, - IUnknown *punkACL, - LPCOLESTR pwzsRegKeyPath, - LPCOLESTR pwszQuickComplete) -{ - IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface; - static const WCHAR lbName[] = {'L','i','s','t','B','o','x',0}; - - TRACE("(%p)->(0x%08lx, %p, %s, %s)\n", - This, hwndEdit, punkACL, debugstr_w(pwzsRegKeyPath), debugstr_w(pwszQuickComplete)); - - if (This->options & ACO_AUTOSUGGEST) TRACE(" ACO_AUTOSUGGEST\n"); - if (This->options & ACO_AUTOAPPEND) TRACE(" ACO_AUTOAPPEND\n"); - if (This->options & ACO_SEARCH) FIXME(" ACO_SEARCH not supported\n"); - if (This->options & ACO_FILTERPREFIXES) FIXME(" ACO_FILTERPREFIXES not supported\n"); - if (This->options & ACO_USETAB) FIXME(" ACO_USETAB not supported\n"); - if (This->options & ACO_UPDOWNKEYDROPSLIST) TRACE(" ACO_UPDOWNKEYDROPSLIST\n"); - if (This->options & ACO_RTLREADING) FIXME(" ACO_RTLREADING not supported\n"); - - This->hwndEdit = hwndEdit; - - if (!SUCCEEDED (IUnknown_QueryInterface (punkACL, &IID_IEnumString, (LPVOID*)&This->enumstr))) { - TRACE("No IEnumString interface\n"); - return E_NOINTERFACE; - } - - This->wpOrigEditProc = (WNDPROC) SetWindowLongPtrW( hwndEdit, GWLP_WNDPROC, (LONG_PTR) ACEditSubclassProc); - SetWindowLongPtrW( hwndEdit, GWLP_USERDATA, (LONG_PTR)This); - - if (This->options & ACO_AUTOSUGGEST) { - HWND hwndParent; - - hwndParent = GetParent(This->hwndEdit); - - /* FIXME : The listbox should be resizable with the mouse. WS_THICKFRAME looks ugly */ - This->hwndListBox = CreateWindowExW(0, lbName, NULL, - WS_BORDER | WS_CHILD | WS_VSCROLL | LBS_HASSTRINGS | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - hwndParent, NULL, - (HINSTANCE)GetWindowLongPtrW( hwndParent, GWLP_HINSTANCE ), NULL); - - if (This->hwndListBox) { - This->wpOrigLBoxProc = (WNDPROC) SetWindowLongPtrW( This->hwndListBox, GWLP_WNDPROC, (LONG_PTR) ACLBoxSubclassProc); - SetWindowLongPtrW( This->hwndListBox, GWLP_USERDATA, (LONG_PTR)This); - } - } - - if (pwzsRegKeyPath) { - WCHAR *key; - WCHAR result[MAX_PATH]; - WCHAR *value; - HKEY hKey = 0; - LONG res; - LONG len; - - /* pwszRegKeyPath contains the key as well as the value, so we split */ - key = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (wcslen(pwzsRegKeyPath)+1)*sizeof(WCHAR)); - wcscpy(key, pwzsRegKeyPath); - value = strrchrW(key, '\\'); - *value = 0; - value++; - /* Now value contains the value and buffer the key */ - res = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hKey); - if (res != ERROR_SUCCESS) { - /* if the key is not found, MSDN states we must seek in HKEY_LOCAL_MACHINE */ - res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hKey); - } - if (res == ERROR_SUCCESS) { - res = RegQueryValueW(hKey, value, result, &len); - if (res == ERROR_SUCCESS) { - This->quickComplete = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len*sizeof(WCHAR)); - wcscpy(This->quickComplete, result); - } - RegCloseKey(hKey); - } - HeapFree(GetProcessHeap(), 0, key); - } - - if ((pwszQuickComplete) && (!This->quickComplete)) { - This->quickComplete = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (wcslen(pwszQuickComplete)+1)*sizeof(WCHAR)); - wcscpy(This->quickComplete, pwszQuickComplete); - } - - return S_OK; -} - -/************************************************************************** - * IAutoComplete_fnVTable - */ -static const IAutoCompleteVtbl acvt = -{ - IAutoComplete_fnQueryInterface, - IAutoComplete_fnAddRef, - IAutoComplete_fnRelease, - IAutoComplete_fnInit, - IAutoComplete_fnEnable, -}; - -/************************************************************************** - * AutoComplete2_QueryInterface - */ -static HRESULT WINAPI IAutoComplete2_fnQueryInterface( - IAutoComplete2 * iface, - REFIID riid, - LPVOID *ppvObj) -{ - IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface); - - TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj); - - return IAutoComplete_QueryInterface((IAutoComplete*)This, riid, ppvObj); -} - -/****************************************************************************** - * IAutoComplete2_fnAddRef - */ -static ULONG WINAPI IAutoComplete2_fnAddRef( - IAutoComplete2 * iface) -{ - IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return IAutoComplete2_AddRef((IAutoComplete*)This); -} - -/****************************************************************************** - * IAutoComplete2_fnRelease - */ -static ULONG WINAPI IAutoComplete2_fnRelease( - IAutoComplete2 * iface) -{ - IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return IAutoComplete_Release((IAutoComplete*)This); -} - -/****************************************************************************** - * IAutoComplete2_fnEnable - */ -static HRESULT WINAPI IAutoComplete2_fnEnable( - IAutoComplete2 * iface, - BOOL fEnable) -{ - IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface); - - TRACE ("(%p)->(%s)\n", This, (fEnable)?"true":"false"); - - return IAutoComplete_Enable((IAutoComplete*)This, fEnable); -} - -/****************************************************************************** - * IAutoComplete2_fnInit - */ -static HRESULT WINAPI IAutoComplete2_fnInit( - IAutoComplete2 * iface, - HWND hwndEdit, - IUnknown *punkACL, - LPCOLESTR pwzsRegKeyPath, - LPCOLESTR pwszQuickComplete) -{ - IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface); - - TRACE("(%p)\n", This); - - return IAutoComplete_Init((IAutoComplete*)This, hwndEdit, punkACL, pwzsRegKeyPath, pwszQuickComplete); -} - -/************************************************************************** - * IAutoComplete_fnGetOptions - */ -static HRESULT WINAPI IAutoComplete2_fnGetOptions( - IAutoComplete2 * iface, - DWORD *pdwFlag) -{ - HRESULT hr = S_OK; - - IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface); - - TRACE("(%p) -> (%p)\n", This, pdwFlag); - - *pdwFlag = This->options; - - return hr; -} - -/************************************************************************** - * IAutoComplete_fnSetOptions - */ -static HRESULT WINAPI IAutoComplete2_fnSetOptions( - IAutoComplete2 * iface, - DWORD dwFlag) -{ - HRESULT hr = S_OK; - - IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface); - - TRACE("(%p) -> (0x%x)\n", This, dwFlag); - - This->options = dwFlag; - - return hr; -} - -/************************************************************************** - * IAutoComplete2_fnVTable - */ -static const IAutoComplete2Vtbl ac2vt = -{ - IAutoComplete2_fnQueryInterface, - IAutoComplete2_fnAddRef, - IAutoComplete2_fnRelease, - IAutoComplete2_fnInit, - IAutoComplete2_fnEnable, - /* IAutoComplete2 */ - IAutoComplete2_fnSetOptions, - IAutoComplete2_fnGetOptions, -}; - -/* - Window procedure for autocompletion - */ -static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - IAutoCompleteImpl *This = (IAutoCompleteImpl *)GetWindowLongPtrW(hwnd, GWLP_USERDATA); - LPOLESTR strs; - HRESULT hr; - WCHAR hwndText[255]; - WCHAR *hwndQCText; - RECT r; - BOOL control, filled, displayall = FALSE; - int cpt, height, sel; - - if (!This->enabled) return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam); - - switch (uMsg) - { - case CB_SHOWDROPDOWN: - ShowWindow(This->hwndListBox, SW_HIDE); - break; - case WM_KILLFOCUS: - if ((This->options & ACO_AUTOSUGGEST) && - ((HWND)wParam != This->hwndListBox)) - { - ShowWindow(This->hwndListBox, SW_HIDE); - } - break; - case WM_KEYUP: - - GetWindowTextW( hwnd, (LPWSTR)hwndText, 255); - - switch(wParam) { - case VK_RETURN: - /* If quickComplete is set and control is pressed, replace the string */ - control = GetKeyState(VK_CONTROL) & 0x8000; - if (control && This->quickComplete) { - hwndQCText = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - (wcslen(This->quickComplete)+wcslen(hwndText))*sizeof(WCHAR)); - sel = swprintf(hwndQCText, This->quickComplete, hwndText); - SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)hwndQCText); - SendMessageW(hwnd, EM_SETSEL, 0, sel); - HeapFree(GetProcessHeap(), 0, hwndQCText); - } - - ShowWindow(This->hwndListBox, SW_HIDE); - return 0; - case VK_LEFT: - case VK_RIGHT: - return 0; - case VK_UP: - case VK_DOWN: - /* Two cases here : - - if the listbox is not visible, displays it - with all the entries if the style ACO_UPDOWNKEYDROPSLIST - is present but does not select anything. - - if the listbox is visible, change the selection - */ - if ( (This->options & (ACO_AUTOSUGGEST | ACO_UPDOWNKEYDROPSLIST)) - && (!IsWindowVisible(This->hwndListBox) && (! *hwndText)) ) - { - /* We must display all the entries */ - displayall = TRUE; - } else { - if (IsWindowVisible(This->hwndListBox)) { - int count; - - count = SendMessageW(This->hwndListBox, LB_GETCOUNT, 0, 0); - /* Change the selection */ - sel = SendMessageW(This->hwndListBox, LB_GETCURSEL, 0, 0); - if (wParam == VK_UP) - sel = ((sel-1)<0)?count-1:sel-1; - else - sel = ((sel+1)>= count)?-1:sel+1; - SendMessageW(This->hwndListBox, LB_SETCURSEL, sel, 0); - if (sel != -1) { - WCHAR *msg; - int len; - - len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, (LPARAM)NULL); - msg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len+1)*sizeof(WCHAR)); - SendMessageW(This->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg); - SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)msg); - SendMessageW(hwnd, EM_SETSEL, wcslen(msg), wcslen(msg)); - HeapFree(GetProcessHeap(), 0, msg); - } else { - SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)This->txtbackup); - SendMessageW(hwnd, EM_SETSEL, wcslen(This->txtbackup), wcslen(This->txtbackup)); - } - } - return 0; - } - break; - case VK_BACK: - case VK_DELETE: - if ((! *hwndText) && (This->options & ACO_AUTOSUGGEST)) { - ShowWindow(This->hwndListBox, SW_HIDE); - return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam); - } - if (This->options & ACO_AUTOAPPEND) { - DWORD b; - SendMessageW(hwnd, EM_GETSEL, (WPARAM)&b, (LPARAM)NULL); - if (b>1) { - hwndText[b-1] = '\0'; - } else { - hwndText[0] = '\0'; - SetWindowTextW(hwnd, hwndText); - } - } - break; - default: - ; - } - - SendMessageW(This->hwndListBox, LB_RESETCONTENT, 0, 0); - - HeapFree(GetProcessHeap(), 0, This->txtbackup); - This->txtbackup = HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, (wcslen(hwndText)+1)*sizeof(WCHAR)); - wcscpy(This->txtbackup, hwndText); - - /* Returns if there is no text to search and we doesn't want to display all the entries */ - if ((!displayall) && (! *hwndText) ) - break; - - IEnumString_Reset(This->enumstr); - filled = FALSE; - for(cpt = 0;;) { - hr = IEnumString_Next(This->enumstr, 1, &strs, NULL); - if (hr != S_OK) - break; - - if ((LPWSTR)strstrW(strs, hwndText) == strs) { - - if (This->options & ACO_AUTOAPPEND) { - SetWindowTextW(hwnd, strs); - SendMessageW(hwnd, EM_SETSEL, wcslen(hwndText), wcslen(strs)); - break; - } - - if (This->options & ACO_AUTOSUGGEST) { - SendMessageW(This->hwndListBox, LB_ADDSTRING, 0, (LPARAM)strs); - filled = TRUE; - cpt++; - } - } - } - - if (This->options & ACO_AUTOSUGGEST) { - if (filled) { - height = SendMessageW(This->hwndListBox, LB_GETITEMHEIGHT, 0, 0); - SendMessageW(This->hwndListBox, LB_CARETOFF, 0, 0); - GetWindowRect(hwnd, &r); - SetParent(This->hwndListBox, HWND_DESKTOP); - /* It seems that Windows XP displays 7 lines at most - and otherwise displays a vertical scroll bar */ - SetWindowPos(This->hwndListBox, HWND_TOP, - r.left, r.bottom + 1, r.right - r.left, min(height * 7, height*(cpt+1)), - SWP_SHOWWINDOW ); - } else { - ShowWindow(This->hwndListBox, SW_HIDE); - } - } - - break; - default: - return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam); - - } - - return 0; -} - -static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - IAutoCompleteImpl *This = (IAutoCompleteImpl *)GetWindowLongPtrW(hwnd, GWLP_USERDATA); - WCHAR *msg; - int sel, len; - - switch (uMsg) { - case WM_MOUSEMOVE: - sel = SendMessageW(hwnd, LB_ITEMFROMPOINT, 0, lParam); - SendMessageW(hwnd, LB_SETCURSEL, (WPARAM)sel, (LPARAM)0); - break; - case WM_LBUTTONDOWN: - sel = SendMessageW(hwnd, LB_GETCURSEL, 0, 0); - if (sel < 0) - break; - len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0); - msg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len+1)*sizeof(WCHAR)); - SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg); - SendMessageW(This->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg); - SendMessageW(This->hwndEdit, EM_SETSEL, 0, wcslen(msg)); - ShowWindow(hwnd, SW_HIDE); - HeapFree(GetProcessHeap(), 0, msg); - break; - default: - return CallWindowProcW(This->wpOrigLBoxProc, hwnd, uMsg, wParam, lParam); - } - return 0; -} diff --git a/reactos/dll/win32/shell32/brsfolder.c b/reactos/dll/win32/shell32/brsfolder.c deleted file mode 100644 index 8409a3e5512..00000000000 --- a/reactos/dll/win32/shell32/brsfolder.c +++ /dev/null @@ -1,816 +0,0 @@ -/* - * Copyright 1999 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - * - * FIXME: - * - many memory leaks - * - many flags unimplemented - * - implement new dialog style "make new folder" button - * - implement editbox - * - implement new dialog style resizing - */ - -#include - - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -typedef struct tagbrowse_info -{ - HWND hWnd; - HWND hwndTreeView; - LPBROWSEINFOW lpBrowseInfo; - LPITEMIDLIST pidlRet; -} browse_info; - -typedef struct tagTV_ITEMDATA -{ - LPSHELLFOLDER lpsfParent; /* IShellFolder of the parent */ - LPITEMIDLIST lpi; /* PIDL relative to parent */ - LPITEMIDLIST lpifq; /* Fully qualified PIDL */ - IEnumIDList* pEnumIL; /* Children iterator */ -} TV_ITEMDATA, *LPTV_ITEMDATA; - -#define SUPPORTEDFLAGS (BIF_STATUSTEXT | \ - BIF_BROWSEFORCOMPUTER | \ - BIF_RETURNFSANCESTORS | \ - BIF_RETURNONLYFSDIRS | \ - BIF_NONEWFOLDERBUTTON | \ - BIF_NEWDIALOGSTYLE | \ - BIF_BROWSEINCLUDEFILES) - -static void FillTreeView(browse_info*, LPSHELLFOLDER, - LPITEMIDLIST, HTREEITEM, IEnumIDList*); -static HTREEITEM InsertTreeViewItem( browse_info*, IShellFolder *, - LPCITEMIDLIST, LPCITEMIDLIST, IEnumIDList*, HTREEITEM); - -static const WCHAR szBrowseFolderInfo[] = { - '_','_','W','I','N','E','_', - 'B','R','S','F','O','L','D','E','R','D','L','G','_', - 'I','N','F','O',0 -}; - -static DWORD __inline BrowseFlagsToSHCONTF(UINT ulFlags) -{ - return SHCONTF_FOLDERS | (ulFlags & BIF_BROWSEINCLUDEFILES ? SHCONTF_NONFOLDERS : 0); -} - -static void browsefolder_callback( LPBROWSEINFOW lpBrowseInfo, HWND hWnd, - UINT msg, LPARAM param ) -{ - if (!lpBrowseInfo->lpfn) - return; - lpBrowseInfo->lpfn( hWnd, msg, param, lpBrowseInfo->lParam ); -} - -/****************************************************************************** - * InitializeTreeView [Internal] - * - * Called from WM_INITDIALOG handler. - * - * PARAMS - * hwndParent [I] The BrowseForFolder dialog - * root [I] ITEMIDLIST of the root shell folder - */ -static void InitializeTreeView( browse_info *info ) -{ - LPITEMIDLIST pidlParent, pidlChild; - HIMAGELIST hImageList; - HRESULT hr; - IShellFolder *lpsfParent, *lpsfRoot; - IEnumIDList * pEnumChildren = NULL; - HTREEITEM item; - DWORD flags; - LPCITEMIDLIST root = info->lpBrowseInfo->pidlRoot; - - TRACE("%p\n", info ); - - Shell_GetImageLists(NULL, &hImageList); - - if (hImageList) - SendMessageW( info->hwndTreeView, TVM_SETIMAGELIST, 0, (LPARAM)hImageList ); - - /* We want to call InsertTreeViewItem down the code, in order to insert - * the root item of the treeview. Due to InsertTreeViewItem's signature, - * we need the following to do this: - * - * + An ITEMIDLIST corresponding to _the parent_ of root. - * + An ITEMIDLIST, which is a relative path from root's parent to root - * (containing a single SHITEMID). - * + An IShellFolder interface pointer of root's parent folder. - * - * If root is 'Desktop', then root's parent is also 'Desktop'. - */ - - pidlParent = ILClone(root); - ILRemoveLastID(pidlParent); - pidlChild = ILClone(ILFindLastID(root)); - - if (_ILIsDesktop(pidlParent)) { - hr = SHGetDesktopFolder(&lpsfParent); - } else { - IShellFolder *lpsfDesktop; - hr = SHGetDesktopFolder(&lpsfDesktop); - if (!SUCCEEDED(hr)) { - WARN("SHGetDesktopFolder failed! hr = %08x\n", hr); - return; - } - hr = IShellFolder_BindToObject(lpsfDesktop, pidlParent, 0, &IID_IShellFolder, (LPVOID*)&lpsfParent); - IShellFolder_Release(lpsfDesktop); - } - - if (!SUCCEEDED(hr)) { - WARN("Could not bind to parent shell folder! hr = %08x\n", hr); - return; - } - - if (pidlChild && pidlChild->mkid.cb) { - hr = IShellFolder_BindToObject(lpsfParent, pidlChild, 0, &IID_IShellFolder, (LPVOID*)&lpsfRoot); - } else { - lpsfRoot = lpsfParent; - hr = IShellFolder_AddRef(lpsfParent); - } - - if (!SUCCEEDED(hr)) { - WARN("Could not bind to root shell folder! hr = %08x\n", hr); - IShellFolder_Release(lpsfParent); - return; - } - - flags = BrowseFlagsToSHCONTF( info->lpBrowseInfo->ulFlags ); - hr = IShellFolder_EnumObjects( lpsfRoot, info->hWnd, flags, &pEnumChildren ); - if (!SUCCEEDED(hr)) { - WARN("Could not get child iterator! hr = %08x\n", hr); - IShellFolder_Release(lpsfParent); - IShellFolder_Release(lpsfRoot); - return; - } - - SendMessageW( info->hwndTreeView, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT ); - item = InsertTreeViewItem( info, lpsfParent, pidlChild, - pidlParent, pEnumChildren, TVI_ROOT ); - SendMessageW( info->hwndTreeView, TVM_EXPAND, TVE_EXPAND, (LPARAM)item ); - - IShellFolder_Release(lpsfRoot); - IShellFolder_Release(lpsfParent); -} - -static int GetIcon(LPCITEMIDLIST lpi, UINT uFlags) -{ - SHFILEINFOW sfi; - SHGetFileInfoW((LPCWSTR)lpi, 0 ,&sfi, sizeof(SHFILEINFOW), uFlags); - return sfi.iIcon; -} - -static void GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, LPTVITEMW lpTV_ITEM) -{ - LPITEMIDLIST pidlDesktop = NULL; - DWORD flags; - - TRACE("%p %p\n",lpifq, lpTV_ITEM); - - if (!lpifq) - { - pidlDesktop = _ILCreateDesktop(); - lpifq = pidlDesktop; - } - - flags = SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON; - lpTV_ITEM->iImage = GetIcon( lpifq, flags ); - - flags = SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_OPENICON; - lpTV_ITEM->iSelectedImage = GetIcon( lpifq, flags ); - - if (pidlDesktop) - ILFree( pidlDesktop ); -} - -/****************************************************************************** - * GetName [Internal] - * - * Query a shell folder for the display name of one of it's children - * - * PARAMS - * lpsf [I] IShellFolder interface of the folder to be queried. - * lpi [I] ITEMIDLIST of the child, relative to parent - * dwFlags [I] as in IShellFolder::GetDisplayNameOf - * lpFriendlyName [O] The desired display name in unicode - * - * RETURNS - * Success: TRUE - * Failure: FALSE - */ -static BOOL GetName(LPSHELLFOLDER lpsf, LPCITEMIDLIST lpi, DWORD dwFlags, LPWSTR lpFriendlyName) -{ - BOOL bSuccess=TRUE; - STRRET str; - - TRACE("%p %p %x %p\n", lpsf, lpi, dwFlags, lpFriendlyName); - if (SUCCEEDED(IShellFolder_GetDisplayNameOf(lpsf, lpi, dwFlags, &str))) - bSuccess = StrRetToStrNW(lpFriendlyName, MAX_PATH, &str, lpi); - else - bSuccess = FALSE; - - TRACE("-- %s\n", debugstr_w(lpFriendlyName)); - return bSuccess; -} - -/****************************************************************************** - * InsertTreeViewItem [Internal] - * - * PARAMS - * info [I] data for the dialog - * lpsf [I] IShellFolder interface of the item's parent shell folder - * pidl [I] ITEMIDLIST of the child to insert, relative to parent - * pidlParent [I] ITEMIDLIST of the parent shell folder - * pEnumIL [I] Iterator for the children of the item to be inserted - * hParent [I] The treeview-item that represents the parent shell folder - * - * RETURNS - * Success: Handle to the created and inserted treeview-item - * Failure: NULL - */ -static HTREEITEM InsertTreeViewItem( browse_info *info, IShellFolder * lpsf, - LPCITEMIDLIST pidl, LPCITEMIDLIST pidlParent, IEnumIDList* pEnumIL, - HTREEITEM hParent) -{ - TVITEMW tvi; - TVINSERTSTRUCTW tvins; - WCHAR szBuff[MAX_PATH]; - LPTV_ITEMDATA lptvid=0; - - tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; - - tvi.cChildren= pEnumIL ? 1 : 0; - tvi.mask |= TVIF_CHILDREN; - - lptvid = SHAlloc( sizeof(TV_ITEMDATA) ); - if (!lptvid) - return NULL; - - if (!GetName(lpsf, pidl, SHGDN_NORMAL, szBuff)) - return NULL; - - tvi.pszText = szBuff; - tvi.cchTextMax = MAX_PATH; - tvi.lParam = (LPARAM)lptvid; - - IShellFolder_AddRef(lpsf); - lptvid->lpsfParent = lpsf; - lptvid->lpi = ILClone(pidl); - lptvid->lpifq = pidlParent ? ILCombine(pidlParent, pidl) : ILClone(pidl); - lptvid->pEnumIL = pEnumIL; - GetNormalAndSelectedIcons(lptvid->lpifq, &tvi); - - tvins.u.item = tvi; - tvins.hInsertAfter = NULL; - tvins.hParent = hParent; - - return (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_INSERTITEM, 0, (LPARAM)&tvins ); -} - -/****************************************************************************** - * FillTreeView [Internal] - * - * For each child (given by lpe) of the parent shell folder, which is given by - * lpsf and whose PIDL is pidl, insert a treeview-item right under hParent - * - * PARAMS - * info [I] data for the dialog - * lpsf [I] IShellFolder interface of the parent shell folder - * pidl [I] ITEMIDLIST of the parent shell folder - * hParent [I] The treeview item that represents the parent shell folder - * lpe [I] An iterator for the children of the parent shell folder - */ -static void FillTreeView( browse_info *info, IShellFolder * lpsf, - LPITEMIDLIST pidl, HTREEITEM hParent, IEnumIDList* lpe) -{ - HTREEITEM hPrev = 0; - LPITEMIDLIST pidlTemp = 0; - ULONG ulFetched; - HRESULT hr; - HWND hwnd = GetParent( info->hwndTreeView ); - - TRACE("%p %p %p %p\n",lpsf, pidl, hParent, lpe); - - /* No IEnumIDList -> No children */ - if (!lpe) return; - - SetCapture( hwnd ); - SetCursor( LoadCursorA( 0, (LPSTR)IDC_WAIT ) ); - - while (NOERROR == IEnumIDList_Next(lpe,1,&pidlTemp,&ulFetched)) - { - ULONG ulAttrs = SFGAO_HASSUBFOLDER | SFGAO_FOLDER; - IEnumIDList* pEnumIL = NULL; - IShellFolder* pSFChild = NULL; - IShellFolder_GetAttributesOf(lpsf, 1, (LPCITEMIDLIST*)&pidlTemp, &ulAttrs); - if (ulAttrs & SFGAO_FOLDER) - { - hr = IShellFolder_BindToObject(lpsf,pidlTemp,NULL,&IID_IShellFolder,(LPVOID*)&pSFChild); - if (SUCCEEDED(hr)) - { - DWORD flags = BrowseFlagsToSHCONTF(info->lpBrowseInfo->ulFlags); - hr = IShellFolder_EnumObjects(pSFChild, hwnd, flags, &pEnumIL); - if (hr == S_OK) - { - if ((IEnumIDList_Skip(pEnumIL, 1) != S_OK) || - FAILED(IEnumIDList_Reset(pEnumIL))) - { - IEnumIDList_Release(pEnumIL); - pEnumIL = NULL; - } - } - IShellFolder_Release(pSFChild); - } - } - - if (!(hPrev = InsertTreeViewItem(info, lpsf, pidlTemp, pidl, pEnumIL, hParent))) - goto done; - SHFree(pidlTemp); /* Finally, free the pidl that the shell gave us... */ - pidlTemp=NULL; - } - -done: - ReleaseCapture(); - SetCursor(LoadCursorW(0, (LPWSTR)IDC_ARROW)); - SHFree(pidlTemp); -} - -static BOOL __inline PIDLIsType(LPCITEMIDLIST pidl, PIDLTYPE type) -{ - LPPIDLDATA data = _ILGetDataPointer(pidl); - if (!data) - return FALSE; - return (data->type == type); -} - -static void BrsFolder_CheckValidSelection( browse_info *info, LPTV_ITEMDATA lptvid ) -{ - LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo; - LPCITEMIDLIST pidl = lptvid->lpi; - BOOL bEnabled = TRUE; - DWORD dwAttributes; - HRESULT r; - - if ((lpBrowseInfo->ulFlags & BIF_BROWSEFORCOMPUTER) && - !PIDLIsType(pidl, PT_COMP)) - bEnabled = FALSE; - if (lpBrowseInfo->ulFlags & BIF_RETURNFSANCESTORS) - { - dwAttributes = SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM; - r = IShellFolder_GetAttributesOf(lptvid->lpsfParent, 1, - (LPCITEMIDLIST*)&lptvid->lpi, &dwAttributes); - if (FAILED(r) || !(dwAttributes & (SFGAO_FILESYSANCESTOR|SFGAO_FILESYSTEM))) - bEnabled = FALSE; - } - if (lpBrowseInfo->ulFlags & BIF_RETURNONLYFSDIRS) - { - dwAttributes = SFGAO_FOLDER | SFGAO_FILESYSTEM; - r = IShellFolder_GetAttributesOf(lptvid->lpsfParent, 1, - (LPCITEMIDLIST*)&lptvid->lpi, &dwAttributes); - if (FAILED(r) || - ((dwAttributes & (SFGAO_FOLDER|SFGAO_FILESYSTEM)) != (SFGAO_FOLDER|SFGAO_FILESYSTEM))) - { - bEnabled = FALSE; - } - } - SendMessageW(info->hWnd, BFFM_ENABLEOK, 0, (LPARAM)bEnabled); -} - -static LRESULT BrsFolder_Treeview_Delete( browse_info *info, NMTREEVIEWW *pnmtv ) -{ - LPTV_ITEMDATA lptvid = (LPTV_ITEMDATA)pnmtv->itemOld.lParam; - - TRACE("TVN_DELETEITEMA/W %p\n", lptvid); - - IShellFolder_Release(lptvid->lpsfParent); - if (lptvid->pEnumIL) - IEnumIDList_Release(lptvid->pEnumIL); - SHFree(lptvid->lpi); - SHFree(lptvid->lpifq); - SHFree(lptvid); - return 0; -} - -static LRESULT BrsFolder_Treeview_Expand( browse_info *info, NMTREEVIEWW *pnmtv ) -{ - IShellFolder *lpsf2 = NULL; - LPTV_ITEMDATA lptvid = (LPTV_ITEMDATA) pnmtv->itemNew.lParam; - HRESULT r; - - TRACE("TVN_ITEMEXPANDINGA/W\n"); - - if ((pnmtv->itemNew.state & TVIS_EXPANDEDONCE)) - return 0; - - if (lptvid->lpi && lptvid->lpi->mkid.cb) { - r = IShellFolder_BindToObject( lptvid->lpsfParent, lptvid->lpi, 0, - (REFIID)&IID_IShellFolder, (LPVOID *)&lpsf2 ); - } else { - lpsf2 = lptvid->lpsfParent; - r = IShellFolder_AddRef(lpsf2); - } - - if (SUCCEEDED(r)) - FillTreeView( info, lpsf2, lptvid->lpifq, pnmtv->itemNew.hItem, lptvid->pEnumIL); - - /* My Computer is already sorted and trying to do a simple text - * sort will only mess things up */ - if (!_ILIsMyComputer(lptvid->lpi)) - SendMessageW( info->hwndTreeView, TVM_SORTCHILDREN, - FALSE, (LPARAM)pnmtv->itemNew.hItem ); - - return 0; -} - -static HRESULT BrsFolder_Treeview_Changed( browse_info *info, NMTREEVIEWW *pnmtv ) -{ - LPTV_ITEMDATA lptvid = (LPTV_ITEMDATA) pnmtv->itemNew.lParam; - - lptvid = (LPTV_ITEMDATA) pnmtv->itemNew.lParam; - info->pidlRet = lptvid->lpifq; - browsefolder_callback( info->lpBrowseInfo, info->hWnd, BFFM_SELCHANGED, - (LPARAM)info->pidlRet ); - BrsFolder_CheckValidSelection( info, lptvid ); - return 0; -} - -static LRESULT BrsFolder_OnNotify( browse_info *info, UINT CtlID, LPNMHDR lpnmh ) -{ - NMTREEVIEWW *pnmtv = (NMTREEVIEWW *)lpnmh; - - TRACE("%p %x %p msg=%x\n", info, CtlID, lpnmh, pnmtv->hdr.code); - - if (pnmtv->hdr.idFrom != IDD_TREEVIEW) - return 0; - - switch (pnmtv->hdr.code) - { - case TVN_DELETEITEMA: - case TVN_DELETEITEMW: - return BrsFolder_Treeview_Delete( info, pnmtv ); - - case TVN_ITEMEXPANDINGA: - case TVN_ITEMEXPANDINGW: - return BrsFolder_Treeview_Expand( info, pnmtv ); - - case TVN_SELCHANGEDA: - case TVN_SELCHANGEDW: - return BrsFolder_Treeview_Changed( info, pnmtv ); - - default: - WARN("unhandled (%d)\n", pnmtv->hdr.code); - break; - } - - return 0; -} - - -static BOOL BrsFolder_OnCreate( HWND hWnd, browse_info *info ) -{ - LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo; - - info->hWnd = hWnd; - SetPropW( hWnd, szBrowseFolderInfo, info ); - - if (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE) - FIXME("flags BIF_NEWDIALOGSTYLE partially implemented\n"); - if (lpBrowseInfo->ulFlags & ~SUPPORTEDFLAGS) - FIXME("flags %x not implemented\n", lpBrowseInfo->ulFlags & ~SUPPORTEDFLAGS); - - if (lpBrowseInfo->lpszTitle) - SetWindowTextW( GetDlgItem(hWnd, IDD_TITLE), lpBrowseInfo->lpszTitle ); - else - ShowWindow( GetDlgItem(hWnd, IDD_TITLE), SW_HIDE ); - - if (!(lpBrowseInfo->ulFlags & BIF_STATUSTEXT) - || (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)) - ShowWindow( GetDlgItem(hWnd, IDD_STATUS), SW_HIDE ); - - /* Hide "Make New Folder" Button? */ - if ((lpBrowseInfo->ulFlags & BIF_NONEWFOLDERBUTTON) - || !(lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)) - ShowWindow( GetDlgItem(hWnd, IDD_MAKENEWFOLDER), SW_HIDE ); - - /* Hide the editbox? */ - if (!(lpBrowseInfo->ulFlags & BIF_EDITBOX)) - { - ShowWindow( GetDlgItem(hWnd, IDD_FOLDER), SW_HIDE ); - ShowWindow( GetDlgItem(hWnd, IDD_FOLDERTEXT), SW_HIDE ); - } - - info->hwndTreeView = GetDlgItem( hWnd, IDD_TREEVIEW ); - if (info->hwndTreeView) - { - InitializeTreeView( info ); - - /* Resize the treeview if there's not editbox */ - if ((lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE) - && !(lpBrowseInfo->ulFlags & BIF_EDITBOX)) - { - RECT rc; - GetClientRect(info->hwndTreeView, &rc); - SetWindowPos(info->hwndTreeView, HWND_TOP, 0, 0, - rc.right, rc.bottom + 40, SWP_NOMOVE); - } - } - else - ERR("treeview control missing!\n"); - - browsefolder_callback( info->lpBrowseInfo, hWnd, BFFM_INITIALIZED, 0 ); - - return TRUE; -} - -static BOOL BrsFolder_OnCommand( browse_info *info, UINT id ) -{ - LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo; - - switch (id) - { - case IDOK: - /* The original pidl is owned by the treeview and will be free'd. */ - info->pidlRet = ILClone(info->pidlRet); - if (info->pidlRet == NULL) /* A null pidl would mean a cancel */ - info->pidlRet = _ILCreateDesktop(); - pdump( info->pidlRet ); - if (lpBrowseInfo->pszDisplayName) - SHGetPathFromIDListW( info->pidlRet, lpBrowseInfo->pszDisplayName ); - EndDialog( info->hWnd, 1 ); - return TRUE; - - case IDCANCEL: - EndDialog( info->hWnd, 0 ); - return TRUE; - - case IDD_MAKENEWFOLDER: - FIXME("make new folder not implemented\n"); - return TRUE; - } - return FALSE; -} - -static BOOL BrsFolder_OnSetExpanded(browse_info *info, LPVOID selection, - BOOL is_str, HTREEITEM *pItem) -{ - LPITEMIDLIST pidlSelection = (LPITEMIDLIST)selection; - LPCITEMIDLIST pidlCurrent, pidlRoot; - TVITEMEXW item; - BOOL bResult = FALSE; - - /* If 'selection' is a string, convert to a Shell ID List. */ - if (is_str) { - IShellFolder *psfDesktop; - HRESULT hr; - - hr = SHGetDesktopFolder(&psfDesktop); - if (FAILED(hr)) - goto done; - - hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, - (LPOLESTR)selection, NULL, &pidlSelection, NULL); - IShellFolder_Release(psfDesktop); - if (FAILED(hr)) - goto done; - } - - /* Move pidlCurrent behind the SHITEMIDs in pidlSelection, which are the root of - * the sub-tree currently displayed. */ - pidlRoot = info->lpBrowseInfo->pidlRoot; - pidlCurrent = pidlSelection; - while (!_ILIsEmpty(pidlRoot) && _ILIsEqualSimple(pidlRoot, pidlCurrent)) { - pidlRoot = ILGetNext(pidlRoot); - pidlCurrent = ILGetNext(pidlCurrent); - } - - /* The given ID List is not part of the SHBrowseForFolder's current sub-tree. */ - if (!_ILIsEmpty(pidlRoot)) - goto done; - - /* Initialize item to point to the first child of the root folder. */ - memset(&item, 0, sizeof(item)); - item.mask = TVIF_PARAM; - item.hItem = TreeView_GetRoot(info->hwndTreeView); - if (item.hItem) - item.hItem = TreeView_GetChild(info->hwndTreeView, item.hItem); - - /* Walk the tree along the nodes corresponding to the remaining ITEMIDLIST */ - while (item.hItem && !_ILIsEmpty(pidlCurrent)) { - LPTV_ITEMDATA pItemData; - - SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item); - pItemData = (LPTV_ITEMDATA)item.lParam; - - if (_ILIsEqualSimple(pItemData->lpi, pidlCurrent)) { - pidlCurrent = ILGetNext(pidlCurrent); - if (!_ILIsEmpty(pidlCurrent)) { - /* Only expand current node and move on to it's first child, - * if we didn't already reach the last SHITEMID */ - SendMessageW(info->hwndTreeView, TVM_EXPAND, TVE_EXPAND, (LPARAM)item.hItem); - item.hItem = TreeView_GetChild(info->hwndTreeView, item.hItem); - } - } else { - item.hItem = TreeView_GetNextSibling(info->hwndTreeView, item.hItem); - } - } - - if (_ILIsEmpty(pidlCurrent) && item.hItem) - bResult = TRUE; - -done: - if (pidlSelection && pidlSelection != (LPITEMIDLIST)selection) - ILFree(pidlSelection); - - if (pItem) - *pItem = item.hItem; - - return bResult; -} - -static BOOL BrsFolder_OnSetSelectionW(browse_info *info, LPVOID selection, BOOL is_str) { - HTREEITEM hItem; - BOOL bResult; - - bResult = BrsFolder_OnSetExpanded(info, selection, is_str, &hItem); - if (bResult) - SendMessageW(info->hwndTreeView, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItem ); - return bResult; -} - -static BOOL BrsFolder_OnSetSelectionA(browse_info *info, LPVOID selection, BOOL is_str) { - LPWSTR selectionW = NULL; - BOOL result = FALSE; - int length; - - if (!is_str) - return BrsFolder_OnSetSelectionW(info, selection, is_str); - - if ((length = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)selection, -1, NULL, 0)) && - (selectionW = HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR))) && - MultiByteToWideChar(CP_ACP, 0, (LPCSTR)selection, -1, selectionW, length)) - { - result = BrsFolder_OnSetSelectionW(info, selectionW, is_str); - } - - HeapFree(GetProcessHeap(), 0, selectionW); - return result; -} - -/************************************************************************* - * BrsFolderDlgProc32 (not an exported API function) - */ -static INT_PTR CALLBACK BrsFolderDlgProc( HWND hWnd, UINT msg, WPARAM wParam, - LPARAM lParam ) -{ - browse_info *info; - - TRACE("hwnd=%p msg=%04x 0x%08lx 0x%08lx\n", hWnd, msg, wParam, lParam ); - - if (msg == WM_INITDIALOG) - return BrsFolder_OnCreate( hWnd, (browse_info*) lParam ); - - info = (browse_info*) GetPropW( hWnd, szBrowseFolderInfo ); - - switch (msg) - { - case WM_NOTIFY: - return BrsFolder_OnNotify( info, (UINT)wParam, (LPNMHDR)lParam); - - case WM_COMMAND: - return BrsFolder_OnCommand( info, wParam ); - - case BFFM_SETSTATUSTEXTA: - TRACE("Set status %s\n", debugstr_a((LPSTR)lParam)); - SetWindowTextA(GetDlgItem(hWnd, IDD_STATUS), (LPSTR)lParam); - break; - - case BFFM_SETSTATUSTEXTW: - TRACE("Set status %s\n", debugstr_w((LPWSTR)lParam)); - SetWindowTextW(GetDlgItem(hWnd, IDD_STATUS), (LPWSTR)lParam); - break; - - case BFFM_ENABLEOK: - TRACE("Enable %ld\n", lParam); - EnableWindow(GetDlgItem(hWnd, 1), (lParam)?TRUE:FALSE); - break; - - case BFFM_SETOKTEXT: /* unicode only */ - TRACE("Set OK text %s\n", debugstr_w((LPWSTR)wParam)); - SetWindowTextW(GetDlgItem(hWnd, 1), (LPWSTR)wParam); - break; - - case BFFM_SETSELECTIONA: - return BrsFolder_OnSetSelectionA(info, (LPVOID)lParam, (BOOL)wParam); - - case BFFM_SETSELECTIONW: - return BrsFolder_OnSetSelectionW(info, (LPVOID)lParam, (BOOL)wParam); - - case BFFM_SETEXPANDED: /* unicode only */ - return BrsFolder_OnSetExpanded(info, (LPVOID)lParam, (BOOL)wParam, NULL); - } - return FALSE; -} - -static const WCHAR swBrowseTemplateName[] = { - 'S','H','B','R','S','F','O','R','F','O','L','D','E','R','_','M','S','G','B','O','X',0}; -static const WCHAR swNewBrowseTemplateName[] = { - 'S','H','N','E','W','B','R','S','F','O','R','F','O','L','D','E','R','_','M','S','G','B','O','X',0}; - -/************************************************************************* - * SHBrowseForFolderA [SHELL32.@] - * SHBrowseForFolder [SHELL32.@] - */ -LPITEMIDLIST WINAPI SHBrowseForFolderA (LPBROWSEINFOA lpbi) -{ - BROWSEINFOW bi; - LPITEMIDLIST lpid; - INT len; - LPWSTR title; - - TRACE("%p\n", lpbi); - - bi.hwndOwner = lpbi->hwndOwner; - bi.pidlRoot = lpbi->pidlRoot; - if (lpbi->pszDisplayName) - { - bi.pszDisplayName = HeapAlloc( GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR) ); - MultiByteToWideChar( CP_ACP, 0, lpbi->pszDisplayName, -1, bi.pszDisplayName, MAX_PATH ); - } - else - bi.pszDisplayName = NULL; - - if (lpbi->lpszTitle) - { - len = MultiByteToWideChar( CP_ACP, 0, lpbi->lpszTitle, -1, NULL, 0 ); - title = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); - MultiByteToWideChar( CP_ACP, 0, lpbi->lpszTitle, -1, title, len ); - } - else - title = NULL; - - bi.lpszTitle = title; - bi.ulFlags = lpbi->ulFlags; - bi.lpfn = lpbi->lpfn; - bi.lParam = lpbi->lParam; - bi.iImage = lpbi->iImage; - lpid = SHBrowseForFolderW( &bi ); - if (bi.pszDisplayName) - { - WideCharToMultiByte( CP_ACP, 0, bi.pszDisplayName, -1, - lpbi->pszDisplayName, MAX_PATH, 0, NULL); - HeapFree( GetProcessHeap(), 0, bi.pszDisplayName ); - } - HeapFree(GetProcessHeap(), 0, title); - lpbi->iImage = bi.iImage; - return lpid; -} - - -/************************************************************************* - * SHBrowseForFolderW [SHELL32.@] - * - * NOTES - * crashes when passed a null pointer - */ -LPITEMIDLIST WINAPI SHBrowseForFolderW (LPBROWSEINFOW lpbi) -{ - browse_info info; - DWORD r; - HRESULT hr; - const WCHAR * templateName; - - info.hWnd = 0; - info.pidlRet = NULL; - info.lpBrowseInfo = lpbi; - info.hwndTreeView = NULL; - - hr = OleInitialize(NULL); - - if (lpbi->ulFlags & BIF_NEWDIALOGSTYLE) - templateName = swNewBrowseTemplateName; - else - templateName = swBrowseTemplateName; - r = DialogBoxParamW( shell32_hInstance, templateName, lpbi->hwndOwner, - BrsFolderDlgProc, (LPARAM)&info ); - if (SUCCEEDED(hr)) - OleUninitialize(); - if (!r) - return NULL; - - return info.pidlRet; -} diff --git a/reactos/dll/win32/shell32/changenotify.c b/reactos/dll/win32/shell32/changenotify.c deleted file mode 100644 index 08a4637e946..00000000000 --- a/reactos/dll/win32/shell32/changenotify.c +++ /dev/null @@ -1,473 +0,0 @@ -/* - * shell change notification - * - * Copyright 2000 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -static CRITICAL_SECTION SHELL32_ChangenotifyCS; -static CRITICAL_SECTION_DEBUG critsect_debug = -{ - 0, 0, &SHELL32_ChangenotifyCS, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": SHELL32_ChangenotifyCS") } -}; -static CRITICAL_SECTION SHELL32_ChangenotifyCS = { &critsect_debug, -1, 0, 0, 0, 0 }; - -typedef SHChangeNotifyEntry *LPNOTIFYREGISTER; - -/* internal list of notification clients (internal) */ -typedef struct _NOTIFICATIONLIST -{ - struct _NOTIFICATIONLIST *next; - struct _NOTIFICATIONLIST *prev; - HWND hwnd; /* window to notify */ - DWORD uMsg; /* message to send */ - LPNOTIFYREGISTER apidl; /* array of entries to watch*/ - UINT cidl; /* number of pidls in array */ - LONG wEventMask; /* subscribed events */ - LONG wSignalledEvent; /* event that occurred */ - DWORD dwFlags; /* client flags */ - LPCITEMIDLIST pidlSignaled; /*pidl of the path that caused the signal*/ - -} NOTIFICATIONLIST, *LPNOTIFICATIONLIST; - -static NOTIFICATIONLIST *head, *tail; - -#define SHCNE_NOITEMEVENTS ( \ - SHCNE_ASSOCCHANGED ) - -#define SHCNE_ONEITEMEVENTS ( \ - SHCNE_ATTRIBUTES | SHCNE_CREATE | SHCNE_DELETE | SHCNE_DRIVEADD | \ - SHCNE_DRIVEADDGUI | SHCNE_DRIVEREMOVED | SHCNE_FREESPACE | \ - SHCNE_MEDIAINSERTED | SHCNE_MEDIAREMOVED | SHCNE_MKDIR | \ - SHCNE_NETSHARE | SHCNE_NETUNSHARE | SHCNE_RMDIR | \ - SHCNE_SERVERDISCONNECT | SHCNE_UPDATEDIR | SHCNE_UPDATEIMAGE ) - -#define SHCNE_TWOITEMEVENTS ( \ - SHCNE_RENAMEFOLDER | SHCNE_RENAMEITEM | SHCNE_UPDATEITEM ) - -/* for dumping events */ -static const char * DumpEvent( LONG event ) -{ - if( event == SHCNE_ALLEVENTS ) - return "SHCNE_ALLEVENTS"; -#define DUMPEV(x) ,( event & SHCNE_##x )? #x " " : "" - return wine_dbg_sprintf( "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s" - DUMPEV(RENAMEITEM) - DUMPEV(CREATE) - DUMPEV(DELETE) - DUMPEV(MKDIR) - DUMPEV(RMDIR) - DUMPEV(MEDIAINSERTED) - DUMPEV(MEDIAREMOVED) - DUMPEV(DRIVEREMOVED) - DUMPEV(DRIVEADD) - DUMPEV(NETSHARE) - DUMPEV(NETUNSHARE) - DUMPEV(ATTRIBUTES) - DUMPEV(UPDATEDIR) - DUMPEV(UPDATEITEM) - DUMPEV(SERVERDISCONNECT) - DUMPEV(UPDATEIMAGE) - DUMPEV(DRIVEADDGUI) - DUMPEV(RENAMEFOLDER) - DUMPEV(FREESPACE) - DUMPEV(EXTENDED_EVENT) - DUMPEV(ASSOCCHANGED) - DUMPEV(INTERRUPT) - ); -#undef DUMPEV -} - -static const char * NodeName(const NOTIFICATIONLIST *item) -{ - const char *str; - WCHAR path[MAX_PATH]; - - if(SHGetPathFromIDListW(item->apidl[0].pidl, path )) - str = wine_dbg_sprintf("%s", debugstr_w(path)); - else - str = wine_dbg_sprintf("" ); - return str; -} - -static void AddNode(LPNOTIFICATIONLIST item) -{ - TRACE("item %p\n", item ); - - /* link items */ - item->prev = tail; - item->next = NULL; - if( tail ) - tail->next = item; - else - head = item; - tail = item; -} - -static LPNOTIFICATIONLIST FindNode( HANDLE hitem ) -{ - LPNOTIFICATIONLIST ptr; - for( ptr = head; ptr; ptr = ptr->next ) - if( ptr == (LPNOTIFICATIONLIST) hitem ) - return ptr; - return NULL; -} - -static void DeleteNode(LPNOTIFICATIONLIST item) -{ - UINT i; - - TRACE("item=%p prev=%p next=%p\n", item, item->prev, item->next); - - /* remove item from list */ - if( item->prev ) - item->prev->next = item->next; - else - head = item->next; - if( item->next ) - item->next->prev = item->prev; - else - tail = item->prev; - - /* free the item */ - for (i=0; icidl; i++) - SHFree((LPITEMIDLIST)item->apidl[i].pidl); - SHFree(item->apidl); - SHFree(item); -} - -void InitChangeNotifications(void) -{ -} - -void FreeChangeNotifications(void) -{ - TRACE("\n"); - - EnterCriticalSection(&SHELL32_ChangenotifyCS); - - while( head ) - DeleteNode( head ); - - LeaveCriticalSection(&SHELL32_ChangenotifyCS); - - // DeleteCriticalSection(&SHELL32_ChangenotifyCS); // static -} - -/************************************************************************* - * SHChangeNotifyRegister [SHELL32.2] - * - */ -ULONG WINAPI -SHChangeNotifyRegister( - HWND hwnd, - int fSources, - LONG wEventMask, - UINT uMsg, - int cItems, - const SHChangeNotifyEntry *lpItems) -{ - LPNOTIFICATIONLIST item; - int i; - - item = SHAlloc(sizeof(NOTIFICATIONLIST)); - - TRACE("(%p,0x%08x,0x%08x,0x%08x,%d,%p) item=%p\n", - hwnd, fSources, wEventMask, uMsg, cItems, lpItems, item); - - item->next = NULL; - item->prev = NULL; - item->cidl = cItems; - item->apidl = SHAlloc(sizeof(SHChangeNotifyEntry) * cItems); - for(i=0;iapidl[i].pidl = ILClone(lpItems[i].pidl); - item->apidl[i].fRecursive = lpItems[i].fRecursive; - } - item->hwnd = hwnd; - item->uMsg = uMsg; - item->wEventMask = wEventMask; - item->wSignalledEvent = 0; - item->dwFlags = fSources; - - TRACE("new node: %s\n", NodeName( item )); - - EnterCriticalSection(&SHELL32_ChangenotifyCS); - - AddNode(item); - - LeaveCriticalSection(&SHELL32_ChangenotifyCS); - - return (ULONG)item; -} - -/************************************************************************* - * SHChangeNotifyDeregister [SHELL32.4] - */ -BOOL WINAPI SHChangeNotifyDeregister(ULONG hNotify) -{ - LPNOTIFICATIONLIST node; - - TRACE("(0x%08x)\n", hNotify); - - EnterCriticalSection(&SHELL32_ChangenotifyCS); - - node = FindNode((HANDLE)hNotify); - if( node ) - DeleteNode(node); - - LeaveCriticalSection(&SHELL32_ChangenotifyCS); - - return node?TRUE:FALSE; -} - -/************************************************************************* - * SHChangeNotifyUpdateEntryList [SHELL32.5] - */ -BOOL WINAPI SHChangeNotifyUpdateEntryList(DWORD unknown1, DWORD unknown2, - DWORD unknown3, DWORD unknown4) -{ - FIXME("(0x%08x, 0x%08x, 0x%08x, 0x%08x)\n", - unknown1, unknown2, unknown3, unknown4); - - return -1; -} - -static BOOL should_notify( LPCITEMIDLIST changed, LPCITEMIDLIST watched, BOOL sub ) -{ - TRACE("%p %p %d\n", changed, watched, sub ); - if ( !watched ) - return FALSE; - if (ILIsEqual( watched, changed ) ) - return TRUE; - if( sub && ILIsParent( watched, changed, TRUE ) ) - return TRUE; - return FALSE; -} - -/************************************************************************* - * SHChangeNotify [SHELL32.@] - */ -void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2) -{ - LPCITEMIDLIST Pidls[2]; - LPNOTIFICATIONLIST ptr; - UINT typeFlag = uFlags & SHCNF_TYPE; - - Pidls[0] = NULL; - Pidls[1] = NULL; - - TRACE("(0x%08x,0x%08x,%p,%p):stub.\n", wEventId, uFlags, dwItem1, dwItem2); - - if( ( wEventId & SHCNE_NOITEMEVENTS ) && ( dwItem1 || dwItem2 ) ) - { - TRACE("dwItem1 and dwItem2 are not zero, but should be\n"); - dwItem1 = 0; - dwItem2 = 0; - return; - } - else if( ( wEventId & SHCNE_ONEITEMEVENTS ) && dwItem2 ) - { - TRACE("dwItem2 is not zero, but should be\n"); - dwItem2 = 0; - return; - } - - if( ( ( wEventId & SHCNE_NOITEMEVENTS ) && - ( wEventId & ~SHCNE_NOITEMEVENTS ) ) || - ( ( wEventId & SHCNE_ONEITEMEVENTS ) && - ( wEventId & ~SHCNE_ONEITEMEVENTS ) ) || - ( ( wEventId & SHCNE_TWOITEMEVENTS ) && - ( wEventId & ~SHCNE_TWOITEMEVENTS ) ) ) - { - WARN("mutually incompatible events listed\n"); - return; - } - - /* convert paths in IDLists*/ - switch (typeFlag) - { - case SHCNF_PATHA: - if (dwItem1) Pidls[0] = SHSimpleIDListFromPathA((LPCSTR)dwItem1); //FIXME - if (dwItem2) Pidls[1] = SHSimpleIDListFromPathA((LPCSTR)dwItem2); //FIXME - break; - case SHCNF_PATHW: - if (dwItem1) Pidls[0] = SHSimpleIDListFromPathW((LPCWSTR)dwItem1); - if (dwItem2) Pidls[1] = SHSimpleIDListFromPathW((LPCWSTR)dwItem2); - break; - case SHCNF_IDLIST: - Pidls[0] = (LPCITEMIDLIST)dwItem1; - Pidls[1] = (LPCITEMIDLIST)dwItem2; - break; - case SHCNF_PRINTERA: - case SHCNF_PRINTERW: - FIXME("SHChangeNotify with (uFlags & SHCNF_PRINTER)\n"); - return; - case SHCNF_DWORD: - default: - FIXME("unknown type %08x\n",typeFlag); - return; - } - - { - WCHAR path[MAX_PATH]; - - if( Pidls[0] && SHGetPathFromIDListW(Pidls[0], path )) - TRACE("notify %08x on item1 = %s\n", wEventId, debugstr_w(path)); - - if( Pidls[1] && SHGetPathFromIDListW(Pidls[1], path )) - TRACE("notify %08x on item2 = %s\n", wEventId, debugstr_w(path)); - } - - EnterCriticalSection(&SHELL32_ChangenotifyCS); - - /* loop through the list */ - for( ptr = head; ptr; ptr = ptr->next ) - { - BOOL notify; - DWORD i; - - notify = FALSE; - - TRACE("trying %p\n", ptr); - - for( i=0; (icidl) && !notify ; i++ ) - { - LPCITEMIDLIST pidl = ptr->apidl[i].pidl; - BOOL subtree = ptr->apidl[i].fRecursive; - - if (wEventId & ptr->wEventMask) - { - if( !pidl ) /* all ? */ - notify = TRUE; - else if( wEventId & SHCNE_NOITEMEVENTS ) - notify = TRUE; - else if( wEventId & ( SHCNE_ONEITEMEVENTS | SHCNE_TWOITEMEVENTS ) ) - notify = should_notify( Pidls[0], pidl, subtree ); - else if( wEventId & SHCNE_TWOITEMEVENTS ) - notify = should_notify( Pidls[1], pidl, subtree ); - } - } - - if( !notify ) - continue; - - ptr->pidlSignaled = ILClone(Pidls[0]); - - TRACE("notifying %s, event %s(%x) before\n", NodeName( ptr ), DumpEvent( - wEventId ),wEventId ); - - ptr->wSignalledEvent |= wEventId; - - if (ptr->dwFlags & SHCNRF_NewDelivery) - SendMessageW(ptr->hwnd, ptr->uMsg, (WPARAM) ptr, (LPARAM) GetCurrentProcessId()); - else - SendMessageW(ptr->hwnd, ptr->uMsg, (WPARAM)Pidls, wEventId); - - TRACE("notifying %s, event %s(%x) after\n", NodeName( ptr ), DumpEvent( - wEventId ),wEventId ); - - } - TRACE("notify Done\n"); - LeaveCriticalSection(&SHELL32_ChangenotifyCS); - - /* if we allocated it, free it. The ANSI flag is also set in its Unicode sibling. */ - if ((typeFlag & SHCNF_PATHA) || (typeFlag & SHCNF_PRINTERA)) - { - SHFree((LPITEMIDLIST)Pidls[0]); - SHFree((LPITEMIDLIST)Pidls[1]); - } -} - -/************************************************************************* - * NTSHChangeNotifyRegister [SHELL32.640] - * NOTES - * Idlist is an array of structures and Count specifies how many items in the array. - * count should always be one when calling SHChangeNotifyRegister, or - * SHChangeNotifyDeregister will not work properly. - */ -ULONG WINAPI NTSHChangeNotifyRegister( - HWND hwnd, - int fSources, - LONG fEvents, - UINT msg, - int count, - SHChangeNotifyEntry *idlist) -{ - return SHChangeNotifyRegister(hwnd, fSources | SHCNRF_NewDelivery, - fEvents, msg, count, idlist); -} - -/************************************************************************* - * SHChangeNotification_Lock [SHELL32.644] - */ -HANDLE WINAPI SHChangeNotification_Lock( - HANDLE hChange, - DWORD dwProcessId, - LPITEMIDLIST **lppidls, - LPLONG lpwEventId) -{ - DWORD i; - LPNOTIFICATIONLIST node; - LPCITEMIDLIST *idlist; - - TRACE("%p %08x %p %p\n", hChange, dwProcessId, lppidls, lpwEventId); - - /* EnterCriticalSection(&SHELL32_ChangenotifyCS); */ - - node = FindNode( hChange ); - if( node ) - { - idlist = SHAlloc( sizeof(LPCITEMIDLIST *) * node->cidl ); - for(i=0; icidl; i++) - idlist[i] = (LPCITEMIDLIST)node->pidlSignaled; - *lpwEventId = node->wSignalledEvent; - *lppidls = (LPITEMIDLIST*)idlist; - node->wSignalledEvent = 0; - } - else - ERR("Couldn't find %p\n", hChange ); - - /* LeaveCriticalSection(&SHELL32_ChangenotifyCS); */ - - return (HANDLE) node; -} - -/************************************************************************* - * SHChangeNotification_Unlock [SHELL32.645] - */ -BOOL WINAPI SHChangeNotification_Unlock ( HANDLE hLock) -{ - TRACE("\n"); - return 1; -} - -/************************************************************************* - * NTSHChangeNotifyDeregister [SHELL32.641] - */ -DWORD WINAPI NTSHChangeNotifyDeregister(ULONG x1) -{ - FIXME("(0x%08x):semi stub.\n",x1); - - return SHChangeNotifyDeregister( x1 ); -} diff --git a/reactos/dll/win32/shell32/classes.c b/reactos/dll/win32/shell32/classes.c deleted file mode 100644 index edc1eacf5c9..00000000000 --- a/reactos/dll/win32/shell32/classes.c +++ /dev/null @@ -1,507 +0,0 @@ -/* - * file type mapping - * (HKEY_CLASSES_ROOT - Stuff) - * - * Copyright 1998, 1999, 2000 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -#define MAX_EXTENSION_LENGTH 20 - -BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, LONG len, BOOL bPrependDot) -{ - HKEY hkey; - WCHAR szTemp[MAX_EXTENSION_LENGTH + 2]; - - TRACE("%s %p\n", debugstr_w(szExtension), debugstr_w(szFileType)); - - /* added because we do not want to have double dots */ - if (szExtension[0] == '.') - bPrependDot = 0; - - if (bPrependDot) - szTemp[0] = '.'; - - lstrcpynW(szTemp + (bPrependDot?1:0), szExtension, MAX_EXTENSION_LENGTH); - - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szTemp, 0, KEY_READ, &hkey)) - { - return FALSE; - } - - if (RegQueryValueW(hkey, NULL, szFileType, &len)) - { - RegCloseKey(hkey); - return FALSE; - } - - RegCloseKey(hkey); - - TRACE("--UE;\n} %s\n", debugstr_w(szFileType)); - - return TRUE; -} - -BOOL HCR_MapTypeToValueA(LPCSTR szExtension, LPSTR szFileType, LONG len, BOOL bPrependDot) -{ - HKEY hkey; - char szTemp[MAX_EXTENSION_LENGTH + 2]; - - TRACE("%s %p\n", szExtension, szFileType); - - /* added because we do not want to have double dots */ - if (szExtension[0] == '.') - bPrependDot = 0; - - if (bPrependDot) - szTemp[0] = '.'; - - lstrcpynA(szTemp + (bPrependDot?1:0), szExtension, MAX_EXTENSION_LENGTH); - - if (RegOpenKeyExA(HKEY_CLASSES_ROOT, szTemp, 0, KEY_READ, &hkey)) - { - return FALSE; - } - - if (RegLoadMUIStringA(hkey, "FriendlyTypeName", szFileType, len, NULL, 0, NULL) == ERROR_SUCCESS) - { - RegCloseKey(hkey); - return TRUE; - } - - if (RegQueryValueA(hkey, NULL, szFileType, &len)) - { - RegCloseKey(hkey); - return FALSE; - } - - RegCloseKey(hkey); - - TRACE("--UE;\n} %s\n", szFileType); - - return TRUE; -} - -static const WCHAR swShell[] = {'s','h','e','l','l','\\',0}; -static const WCHAR swOpen[] = {'o','p','e','n',0}; -static const WCHAR swCommand[] = {'\\','c','o','m','m','a','n','d',0}; - -BOOL HCR_GetDefaultVerbW( HKEY hkeyClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len ) -{ - WCHAR sTemp[MAX_PATH]; - LONG size; - HKEY hkey; - - TRACE("%p %s %p\n", hkeyClass, debugstr_w(szVerb), szDest); - - if (szVerb) - { - lstrcpynW(szDest, szVerb, len); - return TRUE; - } - - size=len; - *szDest='\0'; - if (!RegQueryValueW(hkeyClass, L"shell", szDest, &size) && *szDest) - { - /* The MSDN says to first try the default verb */ - wcscpy(sTemp, swShell); - wcscat(sTemp, szDest); - wcscat(sTemp, swCommand); - if (!RegOpenKeyExW(hkeyClass, sTemp, 0, KEY_READ, &hkey)) - { - RegCloseKey(hkey); - TRACE("default verb=%s\n", debugstr_w(szDest)); - return TRUE; - } - } - - /* then fallback to 'open' */ - wcscpy(sTemp, swShell); - wcscat(sTemp, swOpen); - wcscat(sTemp, swCommand); - if (!RegOpenKeyExW(hkeyClass, sTemp, 0, KEY_READ, &hkey)) - { - RegCloseKey(hkey); - lstrcpynW(szDest, swOpen, len); - TRACE("default verb=open\n"); - return TRUE; - } - - /* and then just use the first verb on Windows >= 2000 */ - if (!RegOpenKeyExW(hkeyClass, L"shell", 0, KEY_READ, &hkey)) - { - if (!RegEnumKeyW(hkey, 0, szDest, len) && *szDest) - { - TRACE("default verb=first verb=%s\n", debugstr_w(szDest)); - RegCloseKey(hkey); - return TRUE; - } - RegCloseKey(hkey); - } - - - TRACE("no default verb!\n"); - return FALSE; -} - -BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len ) -{ - WCHAR sTempVerb[MAX_PATH]; - BOOL ret; - - TRACE("%p %s %s %p\n", hkeyClass, debugstr_w(szClass), debugstr_w(szVerb), szDest); - - if (szClass) - RegOpenKeyExW(HKEY_CLASSES_ROOT, szClass, 0, KEY_READ, &hkeyClass); - if (!hkeyClass) - return FALSE; - ret = FALSE; - - if (HCR_GetDefaultVerbW(hkeyClass, szVerb, sTempVerb, sizeof(sTempVerb))) - { - WCHAR sTemp[MAX_PATH]; - wcscpy(sTemp, swShell); - wcscat(sTemp, sTempVerb); - wcscat(sTemp, swCommand); - ret = (ERROR_SUCCESS == SHGetValueW(hkeyClass, sTemp, NULL, NULL, szDest, &len)); - } - if (szClass) - RegCloseKey(hkeyClass); - - TRACE("-- %s\n", debugstr_w(szDest) ); - return ret; -} - -/*************************************************************************************** -* HCR_GetDefaultIcon [internal] -* -* Gets the icon for a filetype -*/ -static BOOL HCR_RegOpenClassIDKey(REFIID riid, HKEY *hkey) -{ - WCHAR xriid[50]; - swprintf( xriid, L"CLSID\\{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", - riid->Data1, riid->Data2, riid->Data3, - riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3], - riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] ); - - TRACE("%S\n",xriid ); - - return !RegOpenKeyExW(HKEY_CLASSES_ROOT, xriid, 0, KEY_READ, hkey); -} - -static BOOL HCR_RegGetDefaultIconW(HKEY hkey, LPWSTR szDest, DWORD len, int* picon_idx) -{ - DWORD dwType; - WCHAR sTemp[MAX_PATH]; - WCHAR sNum[5]; - - if (!RegQueryValueExW(hkey, NULL, 0, &dwType, (LPBYTE)szDest, &len)) - { - if (dwType == REG_EXPAND_SZ) - { - ExpandEnvironmentStringsW(szDest, sTemp, MAX_PATH); - lstrcpynW(szDest, sTemp, len); - } - if (ParseFieldW (szDest, 2, sNum, 5)) - *picon_idx = atoiW(sNum); - else - *picon_idx=0; /* sometimes the icon number is missing */ - ParseFieldW (szDest, 1, szDest, len); - PathUnquoteSpacesW(szDest); - return TRUE; - } - return FALSE; -} - -static BOOL HCR_RegGetDefaultIconA(HKEY hkey, LPSTR szDest, DWORD len, int* picon_idx) -{ - DWORD dwType; - char sTemp[MAX_PATH]; - char sNum[5]; - - if (!RegQueryValueExA(hkey, NULL, 0, &dwType, (LPBYTE)szDest, &len)) - { - if (dwType == REG_EXPAND_SZ) - { - ExpandEnvironmentStringsA(szDest, sTemp, MAX_PATH); - lstrcpynA(szDest, sTemp, len); - } - if (ParseFieldA (szDest, 2, sNum, 5)) - *picon_idx=atoi(sNum); - else - *picon_idx=0; /* sometimes the icon number is missing */ - ParseFieldA (szDest, 1, szDest, len); - PathUnquoteSpacesA(szDest); - return TRUE; - } - return FALSE; -} - -BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, int* picon_idx) -{ - static const WCHAR swDefaultIcon[] = {'\\','D','e','f','a','u','l','t','I','c','o','n',0}; - HKEY hkey; - WCHAR sTemp[MAX_PATH]; - BOOL ret = FALSE; - - TRACE("%s\n",debugstr_w(szClass) ); - - lstrcpynW(sTemp, szClass, MAX_PATH); - wcscat(sTemp, swDefaultIcon); - - if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, sTemp, 0, KEY_READ, &hkey)) - { - ret = HCR_RegGetDefaultIconW(hkey, szDest, len, picon_idx); - RegCloseKey(hkey); - } - - if(ret) - TRACE("-- %s %i\n", debugstr_w(szDest), *picon_idx); - else - TRACE("-- not found\n"); - - return ret; -} - -BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, int* picon_idx) -{ - HKEY hkey; - char sTemp[MAX_PATH]; - BOOL ret = FALSE; - - TRACE("%s\n",szClass ); - - sprintf(sTemp, "%s\\DefaultIcon",szClass); - - if (!RegOpenKeyExA(HKEY_CLASSES_ROOT, sTemp, 0, KEY_READ, &hkey)) - { - ret = HCR_RegGetDefaultIconA(hkey, szDest, len, picon_idx); - RegCloseKey(hkey); - } - TRACE("-- %s %i\n", szDest, *picon_idx); - return ret; -} - -BOOL HCR_GetDefaultIconFromGUIDW(REFIID riid, LPWSTR szDest, DWORD len, int* picon_idx) -{ - HKEY hkey; - BOOL ret = FALSE; - - if (HCR_RegOpenClassIDKey(riid, &hkey)) - { - ret = HCR_RegGetDefaultIconW(hkey, szDest, len, picon_idx); - RegCloseKey(hkey); - } - TRACE("-- %s %i\n", debugstr_w(szDest), *picon_idx); - return ret; -} - -/*************************************************************************************** -* HCR_GetClassName [internal] -* -* Gets the name of a registered class -*/ -static const WCHAR swEmpty[] = {0}; - -BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len) -{ - HKEY hkey; - BOOL ret = FALSE; - DWORD buflen = len; - WCHAR szName[100]; - LPOLESTR pStr; - - szDest[0] = 0; - - if (StringFromCLSID(riid, &pStr) == S_OK) - { - DWORD dwLen = buflen * sizeof(WCHAR); - swprintf(szName, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\%s", pStr); - if (RegGetValueW(HKEY_CURRENT_USER, szName, NULL, RRF_RT_REG_SZ, NULL, (PVOID)szDest, &dwLen) == ERROR_SUCCESS) - { - ret = TRUE; - } - CoTaskMemFree(pStr); - } - if (!ret && HCR_RegOpenClassIDKey(riid, &hkey)) - { - static const WCHAR wszLocalizedString[] = - { 'L','o','c','a','l','i','z','e','d','S','t','r','i','n','g', 0 }; - if (!RegLoadMUIStringW(hkey, wszLocalizedString, szDest, len, NULL, 0, NULL) || - !RegQueryValueExW(hkey, swEmpty, 0, NULL, (LPBYTE)szDest, &len)) - { - ret = TRUE; - } - RegCloseKey(hkey); - } - - if (!ret || !szDest[0]) - { - if(IsEqualIID(riid, &CLSID_ShellDesktop)) - { - if (LoadStringW(shell32_hInstance, IDS_DESKTOP, szDest, buflen)) - ret = TRUE; - } - else if (IsEqualIID(riid, &CLSID_MyComputer)) - { - if(LoadStringW(shell32_hInstance, IDS_MYCOMPUTER, szDest, buflen)) - ret = TRUE; - } - else if (IsEqualIID(riid, &CLSID_MyDocuments)) - { - if(LoadStringW(shell32_hInstance, IDS_PERSONAL, szDest, buflen)) - ret = TRUE; - } - else if (IsEqualIID(riid, &CLSID_RecycleBin)) - { - if(LoadStringW(shell32_hInstance, IDS_RECYCLEBIN_FOLDER_NAME, szDest, buflen)) - ret = TRUE; - } - else if (IsEqualIID(riid, &CLSID_ControlPanel)) - { - if(LoadStringW(shell32_hInstance, IDS_CONTROLPANEL, szDest, buflen)) - ret = TRUE; - } - else if (IsEqualIID(riid, &CLSID_AdminFolderShortcut)) - { - if(LoadStringW(shell32_hInstance, IDS_ADMINISTRATIVETOOLS, szDest, buflen)) - ret = TRUE; - } - - } - TRACE("-- %s\n", debugstr_w(szDest)); - return ret; -} - -BOOL HCR_GetClassNameA(REFIID riid, LPSTR szDest, DWORD len) -{ HKEY hkey; - BOOL ret = FALSE; - DWORD buflen = len; - - szDest[0] = 0; - if (HCR_RegOpenClassIDKey(riid, &hkey)) - { - if (!RegLoadMUIStringA(hkey,"LocalizedString",szDest,len,NULL,0,NULL) || - !RegQueryValueExA(hkey,"",0,NULL,(LPBYTE)szDest,&len)) - { - ret = TRUE; - } - RegCloseKey(hkey); - } - - if (!ret || !szDest[0]) - { - if(IsEqualIID(riid, &CLSID_ShellDesktop)) - { - if (LoadStringA(shell32_hInstance, IDS_DESKTOP, szDest, buflen)) - ret = TRUE; - } - else if (IsEqualIID(riid, &CLSID_MyComputer)) - { - if(LoadStringA(shell32_hInstance, IDS_MYCOMPUTER, szDest, buflen)) - ret = TRUE; - } - } - - TRACE("-- %s\n", szDest); - - return ret; -} - -/****************************************************************************** - * HCR_GetFolderAttributes [Internal] - * - * Query the registry for a shell folders' attributes - * - * PARAMS - * pidlFolder [I] A simple pidl of type PT_GUID. - * pdwAttributes [IO] In: Attributes to be queried, OUT: Resulting attributes. - * - * RETURNS - * TRUE: Found information for the attributes in the registry - * FALSE: No attribute information found - * - * NOTES - * If queried for an attribute, which is set in the CallForAttributes registry - * value, the function binds to the shellfolder objects and queries it. - */ -BOOL HCR_GetFolderAttributes(LPCITEMIDLIST pidlFolder, LPDWORD pdwAttributes) -{ - HKEY hSFKey; - LPOLESTR pwszCLSID; - LONG lResult; - DWORD dwTemp, dwLen; - static const WCHAR wszAttributes[] = { 'A','t','t','r','i','b','u','t','e','s',0 }; - static const WCHAR wszCallForAttributes[] = { - 'C','a','l','l','F','o','r','A','t','t','r','i','b','u','t','e','s',0 }; - WCHAR wszShellFolderKey[] = { 'C','L','S','I','D','\\','{','0','0','0','2','1','4','0','0','-', - '0','0','0','0','-','0','0','0','0','-','C','0','0','0','-','0','0','0','0','0','0','0', - '0','0','0','4','6','}','\\','S','h','e','l','l','F','o','l','d','e','r',0 }; - - TRACE("(pidlFolder=%p, pdwAttributes=%p)\n", pidlFolder, pdwAttributes); - - if (!_ILIsPidlSimple(pidlFolder)) { - ERR("should be called for simple PIDL's only!\n"); - return FALSE; - } - - if (!_ILIsDesktop(pidlFolder)) { - if (FAILED(StringFromCLSID(_ILGetGUIDPointer(pidlFolder), &pwszCLSID))) return FALSE; - memcpy(&wszShellFolderKey[6], pwszCLSID, 38 * sizeof(WCHAR)); - CoTaskMemFree(pwszCLSID); - } - - lResult = RegOpenKeyExW(HKEY_CLASSES_ROOT, wszShellFolderKey, 0, KEY_READ, &hSFKey); - if (lResult != ERROR_SUCCESS) return FALSE; - - dwLen = sizeof(DWORD); - lResult = RegQueryValueExW(hSFKey, wszCallForAttributes, 0, NULL, (LPBYTE)&dwTemp, &dwLen); - if ((lResult == ERROR_SUCCESS) && (dwTemp & *pdwAttributes)) { - LPSHELLFOLDER psfDesktop, psfFolder; - HRESULT hr; - - RegCloseKey(hSFKey); - hr = SHGetDesktopFolder(&psfDesktop); - if (SUCCEEDED(hr)) { - hr = IShellFolder_BindToObject(psfDesktop, pidlFolder, NULL, &IID_IShellFolder, - (LPVOID*)&psfFolder); - if (SUCCEEDED(hr)) { - hr = IShellFolder_GetAttributesOf(psfFolder, 0, NULL, pdwAttributes); - IShellFolder_Release(psfFolder); - } - IShellFolder_Release(psfDesktop); - } - if (FAILED(hr)) return FALSE; - } else { - lResult = RegQueryValueExW(hSFKey, wszAttributes, 0, NULL, (LPBYTE)&dwTemp, &dwLen); - RegCloseKey(hSFKey); - if (lResult == ERROR_SUCCESS) { - *pdwAttributes &= dwTemp; - } else { - return FALSE; - } - } - - TRACE("-- *pdwAttributes == 0x%08x\n", *pdwAttributes); - - return TRUE; -} diff --git a/reactos/dll/win32/shell32/clipboard.c b/reactos/dll/win32/shell32/clipboard.c deleted file mode 100644 index 24fd0d0f514..00000000000 --- a/reactos/dll/win32/shell32/clipboard.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - * clipboard helper functions - * - * Copyright 2000 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - * - * NOTES: - * - * For copy & paste functions within contextmenus does the shell use - * the OLE clipboard functions in combination with dataobjects. - * The OLE32.DLL gets loaded with LoadLibrary - * - * - a right mousebutton-copy sets the following formats: - * classic: - * Shell IDList Array - * Preferred Drop Effect - * Shell Object Offsets - * HDROP - * FileName - * ole: - * OlePrivateData (ClipboardDataObjectInterface) - * - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -/************************************************************************** - * RenderHDROP - * - * creates a CF_HDROP structure - */ -HGLOBAL RenderHDROP(LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) -{ - UINT i; - int size = 0; - WCHAR wszFileName[MAX_PATH]; - HGLOBAL hGlobal = NULL; - DROPFILES *pDropFiles; - int offset; - LPITEMIDLIST *pidls; - - TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl); - - pidls = HeapAlloc(GetProcessHeap(), 0, cidl * sizeof(*pidls)); - if (!pidls) - goto cleanup; - - /* get the size needed */ - size = sizeof(DROPFILES); - - for (i=0; ipFiles = offset * sizeof(WCHAR); - pDropFiles->fWide = TRUE; - - for (i=0; icidl = cidl; - - /* root pidl */ - offset = sizeof(CIDA) + sizeof (UINT)*(cidl); - pcida->aoffset[0] = offset; /* first element */ - sizePidl = ILGetSize (pidlRoot); - memcpy(((LPBYTE)pcida)+offset, pidlRoot, sizePidl); - offset += sizePidl; - - for(i=0; iaoffset[i+1] = offset; - sizePidl = ILGetSize(apidl[i]); - memcpy(((LPBYTE)pcida)+offset, apidl[i], sizePidl); - offset += sizePidl; - } - - GlobalUnlock(hGlobal); - return hGlobal; -} - -HGLOBAL RenderSHELLIDLISTOFFSET (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) -{ - FIXME("\n"); - return 0; -} - -HGLOBAL RenderFILECONTENTS (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) -{ - FIXME("\n"); - return 0; -} - -HGLOBAL RenderFILEDESCRIPTOR (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) -{ - FIXME("\n"); - return 0; -} - -HGLOBAL RenderFILENAMEA (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) -{ - int size = 0; - char szTemp[MAX_PATH], *szFileName; - LPITEMIDLIST pidl; - HGLOBAL hGlobal; - BOOL bSuccess; - - TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl); - - /* get path of combined pidl */ - pidl = ILCombine(pidlRoot, apidl[0]); - if (!pidl) - return 0; - - bSuccess = SHGetPathFromIDListA(pidl, szTemp); - SHFree(pidl); - if (!bSuccess) - return 0; - - size = strlen(szTemp) + 1; - - /* fill the structure */ - hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size); - if(!hGlobal) return hGlobal; - szFileName = (char *)GlobalLock(hGlobal); - memcpy(szFileName, szTemp, size); - GlobalUnlock(hGlobal); - - return hGlobal; -} - -HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) -{ - int size = 0; - WCHAR szTemp[MAX_PATH], *szFileName; - LPITEMIDLIST pidl; - HGLOBAL hGlobal; - BOOL bSuccess; - - TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl); - - /* get path of combined pidl */ - pidl = ILCombine(pidlRoot, apidl[0]); - if (!pidl) - return 0; - - bSuccess = SHGetPathFromIDListW(pidl, szTemp); - SHFree(pidl); - if (!bSuccess) - return 0; - - size = (wcslen(szTemp)+1) * sizeof(WCHAR); - - /* fill the structure */ - hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size); - if(!hGlobal) return hGlobal; - szFileName = (WCHAR *)GlobalLock(hGlobal); - memcpy(szFileName, szTemp, size); - GlobalUnlock(hGlobal); - - return hGlobal; -} - -HGLOBAL RenderPREFEREDDROPEFFECT (DWORD dwFlags) -{ - DWORD * pdwFlag; - HGLOBAL hGlobal; - - TRACE("(0x%08x)\n", dwFlags); - - hGlobal = GlobalAlloc(GHND|GMEM_SHARE, sizeof(DWORD)); - if(!hGlobal) return hGlobal; - pdwFlag = (DWORD*)GlobalLock(hGlobal); - *pdwFlag = dwFlags; - GlobalUnlock(hGlobal); - return hGlobal; -} diff --git a/reactos/dll/win32/shell32/control.c b/reactos/dll/win32/shell32/control.c deleted file mode 100644 index 9b39b4ed642..00000000000 --- a/reactos/dll/win32/shell32/control.c +++ /dev/null @@ -1,522 +0,0 @@ -/* Control Panel management - * - * Copyright 2001 Eric Pouech - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shlctrl); - -CPlApplet* Control_UnloadApplet(CPlApplet* applet) -{ - unsigned i; - CPlApplet* next; - - for (i = 0; i < applet->count; i++) { - if (!applet->info[i].dwSize) continue; - applet->proc(applet->hWnd, CPL_STOP, i, applet->info[i].lData); - } - if (applet->proc) applet->proc(applet->hWnd, CPL_EXIT, 0L, 0L); - FreeLibrary(applet->hModule); - next = applet->next; - HeapFree(GetProcessHeap(), 0, applet); - return next; -} - -CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel) -{ - CPlApplet* applet; - unsigned i; - CPLINFO info; - NEWCPLINFOW newinfo; - - if (!(applet = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*applet)))) - return applet; - - applet->hWnd = hWnd; - - if (!(applet->hModule = LoadLibraryW(cmd))) { - WARN("Cannot load control panel applet %s\n", debugstr_w(cmd)); - goto theError; - } - if (!(applet->proc = (APPLET_PROC)GetProcAddress(applet->hModule, "CPlApplet"))) { - WARN("Not a valid control panel applet %s\n", debugstr_w(cmd)); - goto theError; - } - if (!applet->proc(hWnd, CPL_INIT, 0L, 0L)) { - WARN("Init of applet has failed\n"); - goto theError; - } - if ((applet->count = applet->proc(hWnd, CPL_GETCOUNT, 0L, 0L)) == 0) { - WARN("No subprogram in applet\n"); - goto theError; - } - - applet = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, applet, - sizeof(*applet) + (applet->count - 1) * sizeof(NEWCPLINFOW)); - - for (i = 0; i < applet->count; i++) { - ZeroMemory(&newinfo, sizeof(newinfo)); - newinfo.dwSize = sizeof(NEWCPLINFOW); - applet->info[i].dwSize = sizeof(NEWCPLINFOW); - /* proc is supposed to return a null value upon success for - * CPL_INQUIRE and CPL_NEWINQUIRE - * However, real drivers don't seem to behave like this - * So, use introspection rather than return value - */ - applet->proc(hWnd, CPL_NEWINQUIRE, i, (LPARAM)&newinfo); - if (newinfo.hIcon == 0) { - applet->proc(hWnd, CPL_INQUIRE, i, (LPARAM)&info); - if (info.idIcon == 0 || info.idName == 0) { - WARN("Couldn't get info from sp %u\n", i); - applet->info[i].dwSize = 0; - } else { - /* convert the old data into the new structure */ - applet->info[i].dwFlags = 0; - applet->info[i].dwHelpContext = 0; - applet->info[i].lData = info.lData; - applet->info[i].hIcon = LoadIconW(applet->hModule, - MAKEINTRESOURCEW(info.idIcon)); - LoadStringW(applet->hModule, info.idName, - applet->info[i].szName, sizeof(applet->info[i].szName) / sizeof(WCHAR)); - LoadStringW(applet->hModule, info.idInfo, - applet->info[i].szInfo, sizeof(applet->info[i].szInfo) / sizeof(WCHAR)); - applet->info[i].szHelpFile[0] = '\0'; - } - } - else - { - CopyMemory(&applet->info[i], &newinfo, newinfo.dwSize); - if (newinfo.dwSize != sizeof(NEWCPLINFOW)) - { - applet->info[i].dwSize = sizeof(NEWCPLINFOW); - lstrcpyW(applet->info[i].szName, newinfo.szName); - lstrcpyW(applet->info[i].szInfo, newinfo.szInfo); - lstrcpyW(applet->info[i].szHelpFile, newinfo.szHelpFile); - } - } - } - - applet->next = panel->first; - panel->first = applet; - - return applet; - - theError: - Control_UnloadApplet(applet); - return NULL; -} - -static void Control_WndProc_Create(HWND hWnd, const CREATESTRUCTW* cs) -{ - CPanel* panel = (CPanel*)cs->lpCreateParams; - - SetWindowLongPtrW(hWnd, 0, (LONG_PTR)panel); - panel->status = 0; - panel->hWnd = hWnd; -} - -#define XICON 32 -#define XSTEP 128 -#define YICON 32 -#define YSTEP 64 - -static BOOL Control_Localize(const CPanel* panel, int cx, int cy, - CPlApplet** papplet, unsigned* psp) -{ - unsigned i, x = (XSTEP-XICON)/2, y = 0; - CPlApplet* applet; - RECT rc; - - GetClientRect(panel->hWnd, &rc); - for (applet = panel->first; applet; applet = applet->next) { - for (i = 0; i < applet->count; i++) { - if (!applet->info[i].dwSize) continue; - if (x + XSTEP >= rc.right - rc.left) { - x = (XSTEP-XICON)/2; - y += YSTEP; - } - if (cx >= x && cx < x + XICON && cy >= y && cy < y + YSTEP) { - *papplet = applet; - *psp = i; - return TRUE; - } - x += XSTEP; - } - } - return FALSE; -} - -static LRESULT Control_WndProc_Paint(const CPanel* panel, WPARAM wParam) -{ - HDC hdc; - PAINTSTRUCT ps; - RECT rc, txtRect; - unsigned i, x = 0, y = 0; - CPlApplet* applet; - HGDIOBJ hOldFont; - - hdc = (wParam) ? (HDC)wParam : BeginPaint(panel->hWnd, &ps); - hOldFont = SelectObject(hdc, GetStockObject(ANSI_VAR_FONT)); - GetClientRect(panel->hWnd, &rc); - for (applet = panel->first; applet; applet = applet->next) { - for (i = 0; i < applet->count; i++) { - if (x + XSTEP >= rc.right - rc.left) { - x = 0; - y += YSTEP; - } - if (!applet->info[i].dwSize) continue; - DrawIcon(hdc, x + (XSTEP-XICON)/2, y, applet->info[i].hIcon); - txtRect.left = x; - txtRect.right = x + XSTEP; - txtRect.top = y + YICON; - txtRect.bottom = y + YSTEP; - DrawTextW(hdc, applet->info[i].szName, -1, &txtRect, - DT_CENTER | DT_VCENTER); - x += XSTEP; - } - } - SelectObject(hdc, hOldFont); - if (!wParam) EndPaint(panel->hWnd, &ps); - return 0; -} - -static LRESULT Control_WndProc_LButton(CPanel* panel, LPARAM lParam, BOOL up) -{ - unsigned i; - CPlApplet* applet; - - if (Control_Localize(panel, (short)LOWORD(lParam), (short)HIWORD(lParam), &applet, &i)) { - if (up) { - if (panel->clkApplet == applet && panel->clkSP == i) { - applet->proc(applet->hWnd, CPL_DBLCLK, i, applet->info[i].lData); - } - } else { - panel->clkApplet = applet; - panel->clkSP = i; - } - } - return 0; -} - -static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg, - WPARAM lParam1, LPARAM lParam2) -{ - CPanel* panel = (CPanel*)GetWindowLongPtrW(hWnd, 0); - - if (panel || wMsg == WM_CREATE) { - switch (wMsg) { - case WM_CREATE: - Control_WndProc_Create(hWnd, (CREATESTRUCTW*)lParam2); - return 0; - case WM_DESTROY: - { - CPlApplet* applet = panel->first; - while (applet) - applet = Control_UnloadApplet(applet); - } - PostQuitMessage(0); - break; - case WM_PAINT: - return Control_WndProc_Paint(panel, lParam1); - case WM_LBUTTONUP: - return Control_WndProc_LButton(panel, lParam2, TRUE); - case WM_LBUTTONDOWN: - return Control_WndProc_LButton(panel, lParam2, FALSE); -/* EPP case WM_COMMAND: */ -/* EPP return Control_WndProc_Command(mwi, lParam1, lParam2); */ - } - } - - return DefWindowProcW(hWnd, wMsg, lParam1, lParam2); -} - -static void Control_DoInterface(CPanel* panel, HWND hWnd, HINSTANCE hInst) -{ - WNDCLASSW wc; - MSG msg; - const WCHAR* appName = L"ReactOS Control Panel"; - wc.style = CS_HREDRAW|CS_VREDRAW; - wc.lpfnWndProc = Control_WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = sizeof(CPlApplet*); - wc.hInstance = hInst; - wc.hIcon = 0; - wc.hCursor = 0; - wc.hbrBackground = GetStockObject(WHITE_BRUSH); - wc.lpszMenuName = NULL; - wc.lpszClassName = L"Shell_Control_WndClass"; - - if (!RegisterClassW(&wc)) return; - - CreateWindowExW(0, wc.lpszClassName, appName, - WS_OVERLAPPEDWINDOW | WS_VISIBLE, - CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, CW_USEDEFAULT, - hWnd, NULL, hInst, panel); - if (!panel->hWnd) return; - - if (!panel->first) { - /* FIXME appName & message should be localized */ - MessageBoxW(panel->hWnd, L"Cannot load any applets", appName, MB_OK); - return; - } - - while (GetMessageW(&msg, panel->hWnd, 0, 0)) { - TranslateMessage(&msg); - DispatchMessageW(&msg); - } -} - -static void Control_DoWindow(CPanel* panel, HWND hWnd, HINSTANCE hInst) -{ - HANDLE h; - WIN32_FIND_DATAW fd; - WCHAR buffer[MAX_PATH]; - static const WCHAR wszAllCpl[] = {'*','.','c','p','l',0}; - WCHAR *p; - - GetSystemDirectoryW( buffer, MAX_PATH ); - p = buffer + wcslen(buffer); - *p++ = '\\'; - wcscpy(p, wszAllCpl); - - if ((h = FindFirstFileW(buffer, &fd)) != INVALID_HANDLE_VALUE) { - do { - wcscpy(p, fd.cFileName); - Control_LoadApplet(hWnd, buffer, panel); - } while (FindNextFileW(h, &fd)); - FindClose(h); - } - - Control_DoInterface(panel, hWnd, hInst); -} - -static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd) - /* forms to parse: - * foo.cpl,@sp,str - * foo.cpl,@sp - * foo.cpl,,str - * foo.cpl @sp - * foo.cpl str - * "a path\foo.cpl" - */ -{ - LPWSTR buffer; - LPWSTR beg = NULL; - LPWSTR end; - WCHAR ch; - LPCWSTR ptr, ptr2; - WCHAR szName[MAX_PATH]; - unsigned sp = 0; - LPWSTR extraPmts = NULL; - int quoted = 0; - BOOL spSet = FALSE; - HANDLE hMutex; - UINT Length; - - ptr = wcsrchr(wszCmd, L'\\'); - ptr2 = wcsrchr(wszCmd, L','); - if (!ptr2) - { - ptr2 = wszCmd + wcslen(wszCmd) + 1; - } - - if (ptr) - ptr++; - else - ptr = wszCmd; - - Length = (ptr2 - ptr); - if (Length >= MAX_PATH) - return; - - memcpy(szName, (LPVOID)ptr, Length * sizeof(WCHAR)); - szName[Length] = L'\0'; - hMutex = CreateMutexW(NULL, TRUE, szName); - - if ((!hMutex) || (GetLastError() == ERROR_ALREADY_EXISTS)) - return; - buffer = HeapAlloc(GetProcessHeap(), 0, (wcslen(wszCmd) + 1) * sizeof(*wszCmd)); - if (!buffer) - { - CloseHandle(hMutex); - return; - } - end = wcscpy(buffer, wszCmd); - for (;;) { - ch = *end; - if (ch == '"') quoted = !quoted; - if (!quoted && (ch == ' ' || ch == ',' || ch == '\0')) { - *end = '\0'; - if (beg) { - if (*beg == '@') { - sp = atoiW(beg + 1); - spSet = TRUE; - } else if (*beg == '\0') { - sp = 0; - spSet = TRUE; - } else { - extraPmts = beg; - } - } - if (ch == '\0') break; - beg = end + 1; - if (ch == ' ') while (end[1] == ' ') end++; - } - end++; - } - while ((ptr = StrChrW(buffer, '"'))) - memmove((LPVOID)ptr, ptr+1, wcslen(ptr)*sizeof(WCHAR)); - - while ((ptr = StrChrW(extraPmts, '"'))) - memmove((LPVOID)ptr, ptr+1, wcslen(ptr)*sizeof(WCHAR)); - - TRACE("cmd %s, extra %s, sp %d\n", debugstr_w(buffer), debugstr_w(extraPmts), sp); - - Control_LoadApplet(hWnd, buffer, panel); - - if (panel->first) { - CPlApplet* applet = panel->first; - - assert(applet && applet->next == NULL); - if (sp >= applet->count) { - WARN("Out of bounds (%u >= %u), setting to 0\n", sp, applet->count); - sp = 0; - } - - if ((extraPmts) && extraPmts[0] &&(!spSet)) - { - while ((lstrcmpiW(extraPmts, applet->info[sp].szName)) && (sp < applet->count)) - sp++; - - if (sp >= applet->count) - { - ReleaseMutex(hMutex); - CloseHandle(hMutex); - Control_UnloadApplet(applet); - HeapFree(GetProcessHeap(), 0, buffer); - return; - } - } - if (applet->info[sp].dwSize) { - if (!applet->proc(applet->hWnd, CPL_DBLCLK, sp, applet->info[sp].lData)) - applet->proc(applet->hWnd, CPL_STARTWPARMSA, sp, (LPARAM)extraPmts); - } - Control_UnloadApplet(applet); - } - ReleaseMutex(hMutex); - CloseHandle(hMutex); - HeapFree(GetProcessHeap(), 0, buffer); -} - -/************************************************************************* - * Control_RunDLLW [SHELL32.@] - * - */ -void WINAPI Control_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow) -{ - CPanel panel; - - TRACE("(%p, %p, %s, 0x%08x)\n", - hWnd, hInst, debugstr_w(cmd), nCmdShow); - - memset(&panel, 0, sizeof(panel)); - - if (!cmd || !*cmd) { - Control_DoWindow(&panel, hWnd, hInst); - } else { - Control_DoLaunch(&panel, hWnd, cmd); - } -} - -/************************************************************************* - * Control_RunDLLA [SHELL32.@] - * - */ -void WINAPI Control_RunDLLA(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow) -{ - DWORD len = MultiByteToWideChar(CP_ACP, 0, cmd, -1, NULL, 0 ); - LPWSTR wszCmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - if (wszCmd && MultiByteToWideChar(CP_ACP, 0, cmd, -1, wszCmd, len )) - { - Control_RunDLLW(hWnd, hInst, wszCmd, nCmdShow); - } - HeapFree(GetProcessHeap(), 0, wszCmd); -} - -/************************************************************************* - * Control_FillCache_RunDLLW [SHELL32.@] - * - */ -HRESULT WINAPI Control_FillCache_RunDLLW(HWND hWnd, HANDLE hModule, DWORD w, DWORD x) -{ - FIXME("%p %p 0x%08x 0x%08x stub\n", hWnd, hModule, w, x); - return 0; -} - -/************************************************************************* - * Control_FillCache_RunDLLA [SHELL32.@] - * - */ -HRESULT WINAPI Control_FillCache_RunDLLA(HWND hWnd, HANDLE hModule, DWORD w, DWORD x) -{ - return Control_FillCache_RunDLLW(hWnd, hModule, w, x); -} - - -/************************************************************************* - * RunDLL_CallEntry16 [SHELL32.122] - * the name is probably wrong - */ -void WINAPI RunDLL_CallEntry16( DWORD proc, HWND hwnd, HINSTANCE inst, - LPCSTR cmdline, INT cmdshow ) -{ -#if !defined(__CYGWIN__) && !defined (__MINGW32__) && !defined(_MSC_VER) - WORD args[5]; - SEGPTR cmdline_seg; - - TRACE( "proc %x hwnd %p inst %p cmdline %s cmdshow %d\n", - proc, hwnd, inst, debugstr_a(cmdline), cmdshow ); - - cmdline_seg = MapLS( cmdline ); - args[4] = HWND_16(hwnd); - args[3] = MapHModuleLS(inst); - args[2] = SELECTOROF(cmdline_seg); - args[1] = OFFSETOF(cmdline_seg); - args[0] = cmdshow; - WOWCallback16Ex( proc, WCB16_PASCAL, sizeof(args), args, NULL ); - UnMapLS( cmdline_seg ); -#else - FIXME( "proc %lx hwnd %p inst %p cmdline %s cmdshow %d\n", - proc, hwnd, inst, debugstr_a(cmdline), cmdshow ); -#endif -} - -/************************************************************************* - * CallCPLEntry16 [SHELL32.166] - * - * called by desk.cpl on "Advanced" with: - * hMod("DeskCp16.Dll"), pFunc("CplApplet"), 0, 1, 0xc, 0 - * - */ -DWORD WINAPI CallCPLEntry16(HMODULE hMod, FARPROC pFunc, DWORD dw3, DWORD dw4, DWORD dw5, DWORD dw6) -{ - FIXME("(%p, %p, %08x, %08x, %08x, %08x): stub.\n", hMod, pFunc, dw3, dw4, dw5, dw6); - return 0x0deadbee; -} diff --git a/reactos/dll/win32/shell32/dataobject.c b/reactos/dll/win32/shell32/dataobject.c deleted file mode 100644 index 6da709528c8..00000000000 --- a/reactos/dll/win32/shell32/dataobject.c +++ /dev/null @@ -1,456 +0,0 @@ -/* - * IEnumFORMATETC, IDataObject - * - * selecting and droping objects within the shell and/or common dialogs - * - * Copyright 1998, 1999 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -/*********************************************************************** -* IEnumFORMATETC implementation -*/ - -typedef struct -{ - /* IUnknown fields */ - const IEnumFORMATETCVtbl *lpVtbl; - LONG ref; - /* IEnumFORMATETC fields */ - UINT posFmt; - UINT countFmt; - LPFORMATETC pFmt; -} IEnumFORMATETCImpl; - -static HRESULT WINAPI IEnumFORMATETC_fnQueryInterface( - LPENUMFORMATETC iface, REFIID riid, LPVOID* ppvObj) -{ - IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface; - TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj); - - *ppvObj = NULL; - - if(IsEqualIID(riid, &IID_IUnknown)) - { - *ppvObj = This; - } - else if(IsEqualIID(riid, &IID_IEnumFORMATETC)) - { - *ppvObj = (IEnumFORMATETC*)This; - } - - if(*ppvObj) - { - IUnknown_AddRef((IUnknown*)(*ppvObj)); - TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj); - return S_OK; - } - TRACE("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -static ULONG WINAPI IEnumFORMATETC_fnAddRef(LPENUMFORMATETC iface) -{ - IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE("(%p)->(count=%u)\n", This, refCount - 1); - - return refCount; -} - -static ULONG WINAPI IEnumFORMATETC_fnRelease(LPENUMFORMATETC iface) -{ - IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(%u)\n", This, refCount + 1); - - if (!refCount) - { - TRACE(" destroying IEnumFORMATETC(%p)\n",This); - SHFree (This->pFmt); - HeapFree(GetProcessHeap(),0,This); - return 0; - } - return refCount; -} - -static HRESULT WINAPI IEnumFORMATETC_fnNext(LPENUMFORMATETC iface, ULONG celt, FORMATETC *rgelt, ULONG *pceltFethed) -{ - IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface; - UINT i; - - TRACE("(%p)->(%u,%p)\n", This, celt, rgelt); - - if(!This->pFmt)return S_FALSE; - if(!rgelt) return E_INVALIDARG; - if (pceltFethed) *pceltFethed = 0; - - for(i = 0; This->posFmt < This->countFmt && celt > i; i++) - { - *rgelt++ = This->pFmt[This->posFmt++]; - } - - if (pceltFethed) *pceltFethed = i; - - return ((i == celt) ? S_OK : S_FALSE); -} - -static HRESULT WINAPI IEnumFORMATETC_fnSkip(LPENUMFORMATETC iface, ULONG celt) -{ - IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface; - TRACE("(%p)->(num=%u)\n", This, celt); - - if((This->posFmt + celt) >= This->countFmt) return S_FALSE; - This->posFmt += celt; - return S_OK; -} - -static HRESULT WINAPI IEnumFORMATETC_fnReset(LPENUMFORMATETC iface) -{ - IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface; - TRACE("(%p)->()\n", This); - - This->posFmt = 0; - return S_OK; -} - -static HRESULT WINAPI IEnumFORMATETC_fnClone(LPENUMFORMATETC iface, LPENUMFORMATETC* ppenum) -{ - IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface; - TRACE("(%p)->(ppenum=%p)\n", This, ppenum); - - if (!ppenum) return E_INVALIDARG; - *ppenum = IEnumFORMATETC_Constructor(This->countFmt, This->pFmt); - if(*ppenum) - IEnumFORMATETC_fnSkip(*ppenum, This->posFmt); - return S_OK; -} - -static const IEnumFORMATETCVtbl efvt = -{ - IEnumFORMATETC_fnQueryInterface, - IEnumFORMATETC_fnAddRef, - IEnumFORMATETC_fnRelease, - IEnumFORMATETC_fnNext, - IEnumFORMATETC_fnSkip, - IEnumFORMATETC_fnReset, - IEnumFORMATETC_fnClone -}; - -LPENUMFORMATETC IEnumFORMATETC_Constructor(UINT cfmt, const FORMATETC afmt[]) -{ - IEnumFORMATETCImpl* ef; - DWORD size=cfmt * sizeof(FORMATETC); - - ef = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumFORMATETCImpl)); - - if(ef) - { - ef->ref=1; - ef->lpVtbl=&efvt; - - ef->countFmt = cfmt; - ef->pFmt = SHAlloc (size); - - if (ef->pFmt) - memcpy(ef->pFmt, afmt, size); - } - - TRACE("(%p)->(%u,%p)\n",ef, cfmt, afmt); - return (LPENUMFORMATETC)ef; -} - - -/*********************************************************************** -* IDataObject implementation -*/ - -/* number of supported formats */ -#define MAX_FORMATS 4 - -typedef struct -{ - /* IUnknown fields */ - const IDataObjectVtbl *lpVtbl; - LONG ref; - - /* IDataObject fields */ - LPITEMIDLIST pidl; - LPITEMIDLIST * apidl; - UINT cidl; - - FORMATETC pFormatEtc[MAX_FORMATS]; - UINT cfShellIDList; - UINT cfFileNameA; - UINT cfFileNameW; - -} IDataObjectImpl; - -/*************************************************************************** -* IDataObject_QueryInterface -*/ -static HRESULT WINAPI IDataObject_fnQueryInterface(LPDATAOBJECT iface, REFIID riid, LPVOID * ppvObj) -{ - IDataObjectImpl *This = (IDataObjectImpl *)iface; - TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj); - - *ppvObj = NULL; - - if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/ - { - *ppvObj = This; - } - else if(IsEqualIID(riid, &IID_IDataObject)) /*IDataObject*/ - { - *ppvObj = (IDataObject*)This; - } - - if(*ppvObj) - { - IUnknown_AddRef((IUnknown*)*ppvObj); - TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj); - return S_OK; - } - TRACE("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -/************************************************************************** -* IDataObject_AddRef -*/ -static ULONG WINAPI IDataObject_fnAddRef(LPDATAOBJECT iface) -{ - IDataObjectImpl *This = (IDataObjectImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE("(%p)->(count=%u)\n", This, refCount - 1); - - return refCount; -} - -/************************************************************************** -* IDataObject_Release -*/ -static ULONG WINAPI IDataObject_fnRelease(LPDATAOBJECT iface) -{ - IDataObjectImpl *This = (IDataObjectImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(%u)\n", This, refCount + 1); - - if (!refCount) - { - TRACE(" destroying IDataObject(%p)\n",This); - _ILFreeaPidl(This->apidl, This->cidl); - ILFree(This->pidl), - HeapFree(GetProcessHeap(),0,This); - } - return refCount; -} - -/************************************************************************** -* IDataObject_fnGetData -*/ -static HRESULT WINAPI IDataObject_fnGetData(LPDATAOBJECT iface, LPFORMATETC pformatetcIn, STGMEDIUM *pmedium) -{ - IDataObjectImpl *This = (IDataObjectImpl *)iface; - - char szTemp[256]; - - szTemp[0]=0; - GetClipboardFormatNameA (pformatetcIn->cfFormat, szTemp, 256); - TRACE("(%p)->(%p %p format=%s)\n", This, pformatetcIn, pmedium, szTemp); - - if (pformatetcIn->cfFormat == This->cfShellIDList) - { - if (This->cidl < 1) return(E_UNEXPECTED); - pmedium->u.hGlobal = RenderSHELLIDLIST(This->pidl, This->apidl, This->cidl); - } - else if (pformatetcIn->cfFormat == CF_HDROP) - { - if (This->cidl < 1) return(E_UNEXPECTED); - pmedium->u.hGlobal = RenderHDROP(This->pidl, This->apidl, This->cidl); - } - else if (pformatetcIn->cfFormat == This->cfFileNameA) - { - if (This->cidl < 1) return(E_UNEXPECTED); - pmedium->u.hGlobal = RenderFILENAMEA(This->pidl, This->apidl, This->cidl); - } - else if (pformatetcIn->cfFormat == This->cfFileNameW) - { - if (This->cidl < 1) return(E_UNEXPECTED); - pmedium->u.hGlobal = RenderFILENAMEW(This->pidl, This->apidl, This->cidl); - } - else - { - FIXME("-- expected clipformat not implemented\n"); - return (E_INVALIDARG); - } - if (pmedium->u.hGlobal) - { - pmedium->tymed = TYMED_HGLOBAL; - pmedium->pUnkForRelease = NULL; - return S_OK; - } - return E_OUTOFMEMORY; -} - -static HRESULT WINAPI IDataObject_fnGetDataHere(LPDATAOBJECT iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium) -{ - IDataObjectImpl *This = (IDataObjectImpl *)iface; - FIXME("(%p)->()\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI IDataObject_fnQueryGetData(LPDATAOBJECT iface, LPFORMATETC pformatetc) -{ - IDataObjectImpl *This = (IDataObjectImpl *)iface; - UINT i; - - TRACE("(%p)->(fmt=0x%08x tym=0x%08x)\n", This, pformatetc->cfFormat, pformatetc->tymed); - - if(!(DVASPECT_CONTENT & pformatetc->dwAspect)) - return DV_E_DVASPECT; - - /* check our formats table what we have */ - for (i=0; ipFormatEtc[i].cfFormat == pformatetc->cfFormat) - && (This->pFormatEtc[i].tymed == pformatetc->tymed)) - { - return S_OK; - } - } - - return DV_E_TYMED; -} - -static HRESULT WINAPI IDataObject_fnGetCanonicalFormatEtc(LPDATAOBJECT iface, LPFORMATETC pformatectIn, LPFORMATETC pformatetcOut) -{ - IDataObjectImpl *This = (IDataObjectImpl *)iface; - FIXME("(%p)->()\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI IDataObject_fnSetData(LPDATAOBJECT iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium, BOOL fRelease) -{ - IDataObjectImpl *This = (IDataObjectImpl *)iface; - FIXME("(%p)->()\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI IDataObject_fnEnumFormatEtc(LPDATAOBJECT iface, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc) -{ - IDataObjectImpl *This = (IDataObjectImpl *)iface; - - TRACE("(%p)->()\n", This); - *ppenumFormatEtc=NULL; - - /* only get data */ - if (DATADIR_GET == dwDirection) - { - *ppenumFormatEtc = IEnumFORMATETC_Constructor(MAX_FORMATS, This->pFormatEtc); - return (*ppenumFormatEtc) ? S_OK : E_FAIL; - } - - return E_NOTIMPL; -} - -static HRESULT WINAPI IDataObject_fnDAdvise(LPDATAOBJECT iface, FORMATETC *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection) -{ - IDataObjectImpl *This = (IDataObjectImpl *)iface; - FIXME("(%p)->()\n", This); - return E_NOTIMPL; -} -static HRESULT WINAPI IDataObject_fnDUnadvise(LPDATAOBJECT iface, DWORD dwConnection) -{ - IDataObjectImpl *This = (IDataObjectImpl *)iface; - FIXME("(%p)->()\n", This); - return E_NOTIMPL; -} -static HRESULT WINAPI IDataObject_fnEnumDAdvise(LPDATAOBJECT iface, IEnumSTATDATA **ppenumAdvise) -{ - IDataObjectImpl *This = (IDataObjectImpl *)iface; - FIXME("(%p)->()\n", This); - return E_NOTIMPL; -} - -static const IDataObjectVtbl dtovt = -{ - IDataObject_fnQueryInterface, - IDataObject_fnAddRef, - IDataObject_fnRelease, - IDataObject_fnGetData, - IDataObject_fnGetDataHere, - IDataObject_fnQueryGetData, - IDataObject_fnGetCanonicalFormatEtc, - IDataObject_fnSetData, - IDataObject_fnEnumFormatEtc, - IDataObject_fnDAdvise, - IDataObject_fnDUnadvise, - IDataObject_fnEnumDAdvise -}; - -/************************************************************************** -* IDataObject_Constructor -*/ -LPDATAOBJECT IDataObject_Constructor(HWND hwndOwner, - LPCITEMIDLIST pMyPidl, LPCITEMIDLIST * apidl, UINT cidl) -{ - IDataObjectImpl* dto; - - dto = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDataObjectImpl)); - - if (dto) - { - dto->ref = 1; - dto->lpVtbl = &dtovt; - dto->pidl = ILClone(pMyPidl); - dto->apidl = _ILCopyaPidl(apidl, cidl); - dto->cidl = cidl; - - dto->cfShellIDList = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); - dto->cfFileNameA = RegisterClipboardFormatA(CFSTR_FILENAMEA); - dto->cfFileNameW = RegisterClipboardFormatW(CFSTR_FILENAMEW); - InitFormatEtc(dto->pFormatEtc[0], dto->cfShellIDList, TYMED_HGLOBAL); - InitFormatEtc(dto->pFormatEtc[1], CF_HDROP, TYMED_HGLOBAL); - InitFormatEtc(dto->pFormatEtc[2], dto->cfFileNameA, TYMED_HGLOBAL); - InitFormatEtc(dto->pFormatEtc[3], dto->cfFileNameW, TYMED_HGLOBAL); - } - - TRACE("(%p)->(apidl=%p cidl=%u)\n",dto, apidl, cidl); - return (LPDATAOBJECT)dto; -} - -/************************************************************************* - * SHCreateDataObject [SHELL32.@] - * - */ - -HRESULT WINAPI SHCreateDataObject(LPCITEMIDLIST pidlFolder, UINT cidl, LPCITEMIDLIST* apidl, IDataObject *pdtInner, REFIID riid, void **ppv) -{ - if (IsEqualIID(riid, &IID_IDataObject)) - { - return CIDLData_CreateFromIDArray(pidlFolder, cidl, apidl, (IDataObject**)ppv); - } - return E_FAIL; -} diff --git a/reactos/dll/win32/shell32/dde.c b/reactos/dll/win32/shell32/dde.c deleted file mode 100644 index e2d1458b972..00000000000 --- a/reactos/dll/win32/shell32/dde.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Shell DDE Handling - * - * Copyright 2004 Robert Shearman - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -/* String handles */ -static HSZ hszProgmanTopic; -static HSZ hszProgmanService; -static HSZ hszAsterisk; -static HSZ hszShell; -static HSZ hszAppProperties; -static HSZ hszFolders; -/* DDE Instance ID */ -static DWORD dwDDEInst; - - -static BOOL __inline Dde_OnConnect(HSZ hszTopic, HSZ hszService) -{ - if ((hszTopic == hszProgmanTopic) && (hszService == hszProgmanService)) - return TRUE; - if ((hszTopic == hszProgmanTopic) && (hszService == hszAppProperties)) - return TRUE; - if ((hszTopic == hszShell) && (hszService == hszFolders)) - return TRUE; - if ((hszTopic == hszShell) && (hszService == hszAppProperties)) - return TRUE; - return FALSE; -} - -static void __inline Dde_OnConnectConfirm(HCONV hconv, HSZ hszTopic, HSZ hszService) -{ - FIXME("stub\n"); -} - -static BOOL __inline Dde_OnWildConnect(HSZ hszTopic, HSZ hszService) -{ - FIXME("stub\n"); - return FALSE; -} - -static HDDEDATA __inline Dde_OnRequest(UINT uFmt, HCONV hconv, HSZ hszTopic, - HSZ hszItem) -{ - FIXME("stub\n"); - return NULL; -} - -static DWORD __inline Dde_OnExecute(HCONV hconv, HSZ hszTopic, HDDEDATA hdata) -{ - BYTE * pszCommand; - - pszCommand = DdeAccessData(hdata, NULL); - if (!pszCommand) - return DDE_FNOTPROCESSED; - - FIXME("stub: %s\n", pszCommand); - - DdeUnaccessData(hdata); - - return DDE_FNOTPROCESSED; -} - -static void __inline Dde_OnDisconnect(HCONV hconv) -{ - FIXME("stub\n"); -} - -static HDDEDATA CALLBACK DdeCallback( - UINT uType, - UINT uFmt, - HCONV hconv, - HSZ hsz1, - HSZ hsz2, - HDDEDATA hdata, - ULONG_PTR dwData1, - ULONG_PTR dwData2) -{ - switch (uType) - { - case XTYP_CONNECT: - return (HDDEDATA)(DWORD_PTR)Dde_OnConnect(hsz1, hsz2); - case XTYP_CONNECT_CONFIRM: - Dde_OnConnectConfirm(hconv, hsz1, hsz2); - return NULL; - case XTYP_WILDCONNECT: - return (HDDEDATA)(DWORD_PTR)Dde_OnWildConnect(hsz1, hsz2); - case XTYP_REQUEST: - return Dde_OnRequest(uFmt, hconv, hsz1, hsz2); - case XTYP_EXECUTE: - return (HDDEDATA)(DWORD_PTR)Dde_OnExecute(hconv, hsz1, hdata); - case XTYP_DISCONNECT: - Dde_OnDisconnect(hconv); - return NULL; - default: - return NULL; - } -} - -/************************************************************************* - * ShellDDEInit (SHELL32.@) - * - * Registers the Shell DDE services with the system so that applications - * can use them. - * - * PARAMS - * bInit [I] TRUE to initialize the services, FALSE to uninitalize. - * - * RETURNS - * Nothing. - */ -void WINAPI ShellDDEInit(BOOL bInit) -{ - TRACE("bInit = %s\n", bInit ? "TRUE" : "FALSE"); - - if (bInit) - { - static const WCHAR wszProgman[] = {'P','r','o','g','m','a','n',0}; - static const WCHAR wszAsterisk[] = {'*',0}; - static const WCHAR wszShell[] = {'S','h','e','l','l',0}; - static const WCHAR wszAppProperties[] = - {'A','p','p','P','r','o','p','e','r','t','i','e','s',0}; - static const WCHAR wszFolders[] = {'F','o','l','d','e','r','s',0}; - - DdeInitializeW(&dwDDEInst, DdeCallback, CBF_FAIL_ADVISES | CBF_FAIL_POKES, 0); - - hszProgmanTopic = DdeCreateStringHandleW(dwDDEInst, wszProgman, CP_WINUNICODE); - hszProgmanService = DdeCreateStringHandleW(dwDDEInst, wszProgman, CP_WINUNICODE); - hszAsterisk = DdeCreateStringHandleW(dwDDEInst, wszAsterisk, CP_WINUNICODE); - hszShell = DdeCreateStringHandleW(dwDDEInst, wszShell, CP_WINUNICODE); - hszAppProperties = DdeCreateStringHandleW(dwDDEInst, wszAppProperties, CP_WINUNICODE); - hszFolders = DdeCreateStringHandleW(dwDDEInst, wszFolders, CP_WINUNICODE); - - DdeNameService(dwDDEInst, hszFolders, 0, DNS_REGISTER); - DdeNameService(dwDDEInst, hszProgmanService, 0, DNS_REGISTER); - DdeNameService(dwDDEInst, hszShell, 0, DNS_REGISTER); - } - else - { - /* unregister all services */ - DdeNameService(dwDDEInst, 0, 0, DNS_UNREGISTER); - - DdeFreeStringHandle(dwDDEInst, hszFolders); - DdeFreeStringHandle(dwDDEInst, hszAppProperties); - DdeFreeStringHandle(dwDDEInst, hszShell); - DdeFreeStringHandle(dwDDEInst, hszAsterisk); - DdeFreeStringHandle(dwDDEInst, hszProgmanService); - DdeFreeStringHandle(dwDDEInst, hszProgmanTopic); - - DdeUninitialize(dwDDEInst); - } -} diff --git a/reactos/dll/win32/shell32/debughlp.c b/reactos/dll/win32/shell32/debughlp.c deleted file mode 100644 index 8a2ad756f9c..00000000000 --- a/reactos/dll/win32/shell32/debughlp.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - * Helper functions for debugging - * - * Copyright 1998, 2002 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(pidl); - -static -LPITEMIDLIST _dbg_ILGetNext(LPCITEMIDLIST pidl) -{ - WORD len; - - if(pidl) - { - len = pidl->mkid.cb; - if (len) - { - return (LPITEMIDLIST) (((LPBYTE)pidl)+len); - } - } - return NULL; -} - -static -BOOL _dbg_ILIsDesktop(LPCITEMIDLIST pidl) -{ - return ( !pidl || (pidl && pidl->mkid.cb == 0x00) ); -} - -static -LPPIDLDATA _dbg_ILGetDataPointer(LPCITEMIDLIST pidl) -{ - if(pidl && pidl->mkid.cb != 0x00) - return (LPPIDLDATA) &(pidl->mkid.abID); - return NULL; -} - -static -LPSTR _dbg_ILGetTextPointer(LPCITEMIDLIST pidl) -{ - LPPIDLDATA pdata =_dbg_ILGetDataPointer(pidl); - - if (pdata) - { - switch (pdata->type) - { - case PT_GUID: - case PT_SHELLEXT: - case PT_YAGUID: - return NULL; - - case PT_DRIVE: - case PT_DRIVE1: - case PT_DRIVE2: - case PT_DRIVE3: - return (LPSTR)&(pdata->u.drive.szDriveName); - - case PT_FOLDER: - case PT_FOLDER1: - case PT_VALUE: - case PT_IESPECIAL1: - case PT_IESPECIAL2: - return (LPSTR)&(pdata->u.file.szNames); - - case PT_WORKGRP: - case PT_COMP: - case PT_NETWORK: - case PT_NETPROVIDER: - case PT_SHARE: - return (LPSTR)&(pdata->u.network.szNames); - } - } - return NULL; -} - -static -LPWSTR _dbg_ILGetTextPointerW(LPCITEMIDLIST pidl) -{ - LPPIDLDATA pdata =_dbg_ILGetDataPointer(pidl); - - if (pdata) - { - switch (pdata->type) - { - case PT_GUID: - case PT_SHELLEXT: - case PT_YAGUID: - return NULL; - - case PT_DRIVE: - case PT_DRIVE1: - case PT_DRIVE2: - case PT_DRIVE3: - /* return (LPSTR)&(pdata->u.drive.szDriveName);*/ - return NULL; - - case PT_FOLDER: - case PT_FOLDER1: - case PT_VALUE: - case PT_IESPECIAL1: - case PT_IESPECIAL2: - /* return (LPSTR)&(pdata->u.file.szNames); */ - return NULL; - - case PT_WORKGRP: - case PT_COMP: - case PT_NETWORK: - case PT_NETPROVIDER: - case PT_SHARE: - /* return (LPSTR)&(pdata->u.network.szNames); */ - return NULL; - - case PT_VALUEW: - return (LPWSTR)&(pdata->u.file.szNames); - } - } - return NULL; -} - - -static -LPSTR _dbg_ILGetSTextPointer(LPCITEMIDLIST pidl) -{ - LPPIDLDATA pdata =_dbg_ILGetDataPointer(pidl); - - if (pdata) - { - switch (pdata->type) - { - case PT_FOLDER: - case PT_VALUE: - case PT_IESPECIAL1: - case PT_IESPECIAL2: - return (LPSTR)(pdata->u.file.szNames + strlen (pdata->u.file.szNames) + 1); - - case PT_WORKGRP: - return (LPSTR)(pdata->u.network.szNames + strlen (pdata->u.network.szNames) + 1); - } - } - return NULL; -} - -static -LPWSTR _dbg_ILGetSTextPointerW(LPCITEMIDLIST pidl) -{ - LPPIDLDATA pdata =_dbg_ILGetDataPointer(pidl); - - if (pdata) - { - switch (pdata->type) - { - case PT_FOLDER: - case PT_VALUE: - case PT_IESPECIAL1: - case PT_IESPECIAL2: - /*return (LPSTR)(pdata->u.file.szNames + strlen (pdata->u.file.szNames) + 1); */ - return NULL; - - case PT_WORKGRP: - /* return (LPSTR)(pdata->u.network.szNames + strlen (pdata->u.network.szNames) + 1); */ - return NULL; - - case PT_VALUEW: - return (LPWSTR)(pdata->u.file.szNames + wcslen ((LPWSTR)pdata->u.file.szNames) + 1); - } - } - return NULL; -} - - -static -IID* _dbg_ILGetGUIDPointer(LPCITEMIDLIST pidl) -{ - LPPIDLDATA pdata =_ILGetDataPointer(pidl); - - if (pdata) - { - switch (pdata->type) - { - case PT_SHELLEXT: - case PT_GUID: - case PT_YAGUID: - return &(pdata->u.guid.guid); - } - } - return NULL; -} - -static -void _dbg_ILSimpleGetText (LPCITEMIDLIST pidl, LPSTR szOut, UINT uOutSize) -{ - LPSTR szSrc; - LPWSTR szSrcW; - GUID const * riid; - - if (!pidl) return; - - if (szOut) - *szOut = 0; - - if (_dbg_ILIsDesktop(pidl)) - { - /* desktop */ - if (szOut) lstrcpynA(szOut, "Desktop", uOutSize); - } - else if (( szSrc = _dbg_ILGetTextPointer(pidl) )) - { - /* filesystem */ - if (szOut) lstrcpynA(szOut, szSrc, uOutSize); - } - else if (( szSrcW = _dbg_ILGetTextPointerW(pidl) )) - { - CHAR tmp[MAX_PATH]; - /* unicode filesystem */ - WideCharToMultiByte(CP_ACP,0,szSrcW, -1, tmp, MAX_PATH, NULL, NULL); - if (szOut) lstrcpynA(szOut, tmp, uOutSize); - } - else if (( riid = _dbg_ILGetGUIDPointer(pidl) )) - { - if (szOut) - sprintf( szOut, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", - riid->Data1, riid->Data2, riid->Data3, - riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3], - riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] ); - } -} - - - - -void pdump (LPCITEMIDLIST pidl) -{ - LPCITEMIDLIST pidltemp = pidl; - - if (!TRACE_ON(pidl)) return; - - if (! pidltemp) - { - MESSAGE ("-------- pidl=NULL (Desktop)\n"); - } - else - { - MESSAGE ("-------- pidl=%p\n", pidl); - if (pidltemp->mkid.cb) - { - do - { - if (_ILIsUnicode(pidltemp)) - { - DWORD dwAttrib = 0; - LPPIDLDATA pData = _dbg_ILGetDataPointer(pidltemp); - DWORD type = pData ? pData->type : 0; - LPWSTR szLongName = _dbg_ILGetTextPointerW(pidltemp); - LPWSTR szShortName = _dbg_ILGetSTextPointerW(pidltemp); - char szName[MAX_PATH]; - - _dbg_ILSimpleGetText(pidltemp, szName, MAX_PATH); - if ( pData && (PT_FOLDER == type || PT_VALUE == type) ) - dwAttrib = pData->u.file.uFileAttribs; - - MESSAGE ("[%p] size=%04u type=%x attr=0x%08x name=%s (%s,%s)\n", - pidltemp, pidltemp->mkid.cb, type, dwAttrib, - debugstr_a(szName), debugstr_w(szLongName), debugstr_w(szShortName)); - } - else - { - DWORD dwAttrib = 0; - LPPIDLDATA pData = _dbg_ILGetDataPointer(pidltemp); - DWORD type = pData ? pData->type : 0; - LPSTR szLongName = _dbg_ILGetTextPointer(pidltemp); - LPSTR szShortName = _dbg_ILGetSTextPointer(pidltemp); - char szName[MAX_PATH]; - - _dbg_ILSimpleGetText(pidltemp, szName, MAX_PATH); - if ( pData && (PT_FOLDER == type || PT_VALUE == type) ) - dwAttrib = pData->u.file.uFileAttribs; - - MESSAGE ("[%p] size=%04u type=%x attr=0x%08x name=%s (%s,%s)\n", - pidltemp, pidltemp->mkid.cb, type, dwAttrib, - debugstr_a(szName), debugstr_a(szLongName), debugstr_a(szShortName)); - } - - pidltemp = _dbg_ILGetNext(pidltemp); - - } while (pidltemp && pidltemp->mkid.cb); - } - else - { - MESSAGE ("empty pidl (Desktop)\n"); - } - pcheck(pidl); - } -} - -static void dump_pidl_hex( LPCITEMIDLIST pidl ) -{ - const unsigned char *p = (const unsigned char *)pidl; - const int max_bytes = 0x80; -#define max_line 0x10 - char szHex[max_line*3+1], szAscii[max_line+1]; - int i, n; - - n = pidl->mkid.cb; - if( n>max_bytes ) - n = max_bytes; - for( i=0; imkid.cb ) - { - type = _dbg_ILGetDataPointer(pidltemp)->type; - switch( type ) - { - case PT_CPLAPPLET: - case PT_GUID: - case PT_SHELLEXT: - case PT_DRIVE: - case PT_DRIVE1: - case PT_DRIVE2: - case PT_DRIVE3: - case PT_FOLDER: - case PT_VALUE: - case PT_VALUEW: - case PT_FOLDER1: - case PT_WORKGRP: - case PT_COMP: - case PT_NETPROVIDER: - case PT_NETWORK: - case PT_IESPECIAL1: - case PT_YAGUID: - case PT_IESPECIAL2: - case PT_SHARE: - break; - default: - ERR("unknown IDLIST %p [%p] size=%u type=%x\n", - pidl, pidltemp, pidltemp->mkid.cb,type ); - dump_pidl_hex( pidltemp ); - return FALSE; - } - pidltemp = _dbg_ILGetNext(pidltemp); - } - return TRUE; -} - -static const struct { - REFIID riid; - const char *name; -} InterfaceDesc[] = { - {&IID_IUnknown, "IID_IUnknown"}, - {&IID_IClassFactory, "IID_IClassFactory"}, - {&IID_IShellView, "IID_IShellView"}, - {&IID_IOleCommandTarget, "IID_IOleCommandTarget"}, - {&IID_IDropTarget, "IID_IDropTarget"}, - {&IID_IDropSource, "IID_IDropSource"}, - {&IID_IViewObject, "IID_IViewObject"}, - {&IID_IContextMenu, "IID_IContextMenu"}, - {&IID_IShellExtInit, "IID_IShellExtInit"}, - {&IID_IShellFolder, "IID_IShellFolder"}, - {&IID_IShellFolder2, "IID_IShellFolder2"}, - {&IID_IPersist, "IID_IPersist"}, - {&IID_IPersistFolder, "IID_IPersistFolder"}, - {&IID_IPersistFolder2, "IID_IPersistFolder2"}, - {&IID_IPersistFolder3, "IID_IPersistFolder3"}, - {&IID_IExtractIconA, "IID_IExtractIconA"}, - {&IID_IExtractIconW, "IID_IExtractIconW"}, - {&IID_IDataObject, "IID_IDataObject"}, - {&IID_IAutoComplete, "IID_IAutoComplete"}, - {&IID_IAutoComplete2, "IID_IAutoComplete2"}, - {&IID_IShellLinkA, "IID_IShellLinkA"}, - {&IID_IShellLinkW, "IID_IShellLinkW"}, - {NULL,NULL}}; - -const char * shdebugstr_guid( const struct _GUID *id ) -{ - int i; - const char* name = NULL; - char clsidbuf[100]; - - if (!id) return "(null)"; - - for (i=0;InterfaceDesc[i].riid && !name;i++) { - if (IsEqualIID(InterfaceDesc[i].riid, id)) name = InterfaceDesc[i].name; - } - if (!name) { - if (HCR_GetClassNameA(id, clsidbuf, 100)) - name = clsidbuf; - } - - return wine_dbg_sprintf( "\n\t{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x} (%s)", - id->Data1, id->Data2, id->Data3, - id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3], - id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7], name ? name : "unknown" ); -} diff --git a/reactos/dll/win32/shell32/desktop.c b/reactos/dll/win32/shell32/desktop.c deleted file mode 100644 index cd21bcbae2a..00000000000 --- a/reactos/dll/win32/shell32/desktop.c +++ /dev/null @@ -1,779 +0,0 @@ -/* - * Shell Desktop - * - * Copyright 2008 Thomas Bluemel - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(desktop); - -BOOL WINAPI SetShellWindowEx(HWND, HWND); - -#define SHDESK_TAG 0x4b534544 - -static const WCHAR szProgmanClassName[] = {'P','r','o','g','m','a','n'}; -static const WCHAR szProgmanWindowName[] = { - 'P','r','o','g','r','a','m',' ','M','a','n','a','g','e','r' -}; - -static const IShellBrowserVtbl SHDESK_Vtbl; -static const ICommDlgBrowserVtbl SHDESK_ICommDlgBrowser_Vtbl; -static const IServiceProviderVtbl SHDESK_IServiceProvider_Vtbl; - -typedef struct _SHDESK -{ - DWORD Tag; - const IShellBrowserVtbl *lpVtbl; - const ICommDlgBrowserVtbl *lpVtblCommDlgBrowser; - const IServiceProviderVtbl *lpVtblServiceProvider; - LONG Ref; - HWND hWnd; - HWND hWndShellView; - HWND hWndDesktopListView; - IShellDesktopTray *ShellDesk; - IShellView *DesktopView; - IShellBrowser *DefaultShellBrowser; - LPITEMIDLIST pidlDesktopDirectory; - LPITEMIDLIST pidlDesktop; -} SHDESK, *PSHDESK; - -static IUnknown * -IUnknown_from_impl(SHDESK *This) -{ - return (IUnknown *)&This->lpVtbl; -} - -static IShellBrowser * -IShellBrowser_from_impl(SHDESK *This) -{ - return (IShellBrowser *)&This->lpVtbl; -} - -static IOleWindow * -IOleWindow_from_impl(SHDESK *This) -{ - return (IOleWindow *)&This->lpVtbl; -} - -static ICommDlgBrowser * -ICommDlgBrowser_from_impl(SHDESK *This) -{ - return (ICommDlgBrowser *)&This->lpVtblCommDlgBrowser; -} - -static IServiceProvider * -IServiceProvider_from_impl(SHDESK *This) -{ - return (IServiceProvider *)&This->lpVtblServiceProvider; -} - -static SHDESK * -impl_from_IShellBrowser(IShellBrowser *iface) -{ - return (SHDESK *)((ULONG_PTR)iface - FIELD_OFFSET(SHDESK, lpVtbl)); -} - -static SHDESK * -impl_from_ICommDlgBrowser(ICommDlgBrowser *iface) -{ - return (SHDESK *)((ULONG_PTR)iface - FIELD_OFFSET(SHDESK, lpVtblCommDlgBrowser)); -} - -static SHDESK * -impl_from_IServiceProvider(IServiceProvider *iface) -{ - return (SHDESK *)((ULONG_PTR)iface - FIELD_OFFSET(SHDESK, lpVtblServiceProvider)); -} - -static void -SHDESK_Free(SHDESK *This) -{ - if (This->ShellDesk != NULL) - IShellDesktopTray_Release(This->ShellDesk); - - if (This->DesktopView != NULL) - { - if (This->hWndShellView != NULL) - IShellView_DestroyViewWindow(This->DesktopView); - - IShellView_Release(This->DesktopView); - This->DesktopView = NULL; - This->hWndShellView = NULL; - This->hWndDesktopListView = NULL; - } - - if (This->pidlDesktopDirectory != NULL) - { - ILFree(This->pidlDesktopDirectory); - This->pidlDesktopDirectory = NULL; - } - - if (This->pidlDesktop != NULL) - { - ILFree(This->pidlDesktop); - This->pidlDesktop = NULL; - } - - ZeroMemory(This, sizeof(SHDESK)); - LocalFree((HLOCAL)This); -} - -static ULONG STDMETHODCALLTYPE -SHDESK_Release(IShellBrowser *iface) -{ - SHDESK *This = impl_from_IShellBrowser(iface); - ULONG Ret; - - Ret = InterlockedDecrement(&This->Ref); - if (Ret == 0) - SHDESK_Free(This); - - return Ret; -} - -static ULONG STDMETHODCALLTYPE -SHDESK_AddRef(IShellBrowser *iface) -{ - SHDESK *This = impl_from_IShellBrowser(iface); - - return InterlockedIncrement(&This->Ref); -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_QueryInterface(IShellBrowser *iface, REFIID riid, LPVOID *ppvObj) -{ - SHDESK *This; - - if (ppvObj == NULL) - return E_POINTER; - - This = impl_from_IShellBrowser(iface); - - if (IsEqualIID(riid, &IID_IUnknown)) - { - *ppvObj = IUnknown_from_impl(This); - } - else if (This->DefaultShellBrowser != NULL) - { - return IShellBrowser_QueryInterface(This->DefaultShellBrowser, riid, ppvObj); - } - else if (IsEqualIID(riid, &IID_IOleWindow)) - { - *ppvObj = IOleWindow_from_impl(This); - } - else if (IsEqualIID(riid, &IID_IShellBrowser)) - { - *ppvObj = IShellBrowser_from_impl(This); - } - else if (IsEqualIID(riid, &IID_ICommDlgBrowser)) - { - *ppvObj = ICommDlgBrowser_from_impl(This); - } - else if (IsEqualIID(riid, &IID_IServiceProvider)) - { - *ppvObj = IServiceProvider_from_impl(This); - } - else - { - *ppvObj = NULL; - return E_NOINTERFACE; - } - - SHDESK_AddRef(iface); - return S_OK; -} - -static PSHDESK -SHDESK_Create(HWND hWnd, LPCREATESTRUCT lpCreateStruct) -{ - IShellFolder *psfDesktopFolder; - IShellDesktopTray *ShellDesk; - CSFV csfv; - SHDESK *This; - HRESULT hRet; - - ShellDesk = (IShellDesktopTray *)lpCreateStruct->lpCreateParams; - if (ShellDesk == NULL) - { - WARN("No IShellDesk interface provided!"); - return NULL; - } - - This = (PSHDESK)LocalAlloc(LMEM_FIXED, sizeof(SHDESK)); - if (This == NULL) - return NULL; - - ZeroMemory(This, sizeof(SHDESK)); - This->Tag = SHDESK_TAG; - This->lpVtbl = &SHDESK_Vtbl; - This->lpVtblCommDlgBrowser = &SHDESK_ICommDlgBrowser_Vtbl; - This->lpVtblServiceProvider = &SHDESK_IServiceProvider_Vtbl; - This->Ref = 1; - This->hWnd = hWnd; - This->ShellDesk = ShellDesk; - IShellDesktopTray_AddRef(ShellDesk); - - This->pidlDesktopDirectory = SHCloneSpecialIDList(This->hWnd, CSIDL_DESKTOPDIRECTORY, FALSE); - hRet = SHGetSpecialFolderLocation(This->hWnd, CSIDL_DESKTOP, &This->pidlDesktop); - if (!SUCCEEDED(hRet)) - goto Fail; - - hRet = SHGetDesktopFolder(&psfDesktopFolder); - if (!SUCCEEDED(hRet)) - goto Fail; - - ZeroMemory(&csfv, sizeof(csfv)); - csfv.cbSize = sizeof(csfv); - csfv.pshf = psfDesktopFolder; - csfv.psvOuter = NULL; - - hRet = SHCreateShellFolderViewEx(&csfv, &This->DesktopView); - IShellFolder_Release(psfDesktopFolder); - - if (!SUCCEEDED(hRet)) - { -Fail: - SHDESK_Release(IShellBrowser_from_impl(This)); - return NULL; - } - - return This; -} - -static HWND -SHDESK_FindDesktopListView (SHDESK *This) -{ - return FindWindowExW(This->hWndShellView, - NULL, - WC_LISTVIEW, - NULL); -} - -static BOOL -SHDESK_CreateDeskWnd(SHDESK *This) -{ - IShellBrowser *ShellBrowser; - FOLDERSETTINGS fs; - RECT rcClient; - HRESULT hRet; - - if (!GetClientRect(This->hWnd, - &rcClient)) - { - return FALSE; - } - - ShellBrowser = IShellBrowser_from_impl(This); - - fs.ViewMode = FVM_ICON; - fs.fFlags = FWF_DESKTOP | FWF_NOCLIENTEDGE | FWF_NOSCROLL | FWF_TRANSPARENT; - hRet = IShellView_CreateViewWindow(This->DesktopView, NULL, &fs, ShellBrowser, &rcClient, &This->hWndShellView); - if (!SUCCEEDED(hRet)) - return FALSE; - - SetShellWindowEx (This->hWnd, - SHDESK_FindDesktopListView (This)); - - return TRUE; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_GetWindow(IShellBrowser *iface, HWND *phwnd) -{ - SHDESK *This = impl_from_IShellBrowser(iface); - - if (This->hWnd != NULL) - { - *phwnd = This->hWnd; - return S_OK; - } - - *phwnd = NULL; - return E_UNEXPECTED; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_ContextSensitiveHelp(IShellBrowser *iface, BOOL fEnterMode) -{ - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_InsertMenusSB(IShellBrowser *iface, HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths) -{ - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_SetMenuSB(IShellBrowser *iface, HMENU hmenuShared, HOLEMENU holemenuRes, HWND hwndActiveObject) -{ - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_RemoveMenusSB(IShellBrowser *iface, HMENU hmenuShared) -{ - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_SetStatusTextSB(IShellBrowser *iface, LPCOLESTR lpszStatusText) -{ - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_EnableModelessSB(IShellBrowser *iface, BOOL fEnable) -{ - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_TranslateAcceleratorSB(IShellBrowser *iface, LPMSG lpmsg, WORD wID) -{ - return S_FALSE; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_BrowseObject(IShellBrowser *iface, LPCITEMIDLIST pidl, UINT wFlags) -{ - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_GetViewStateStream(IShellBrowser *iface, DWORD grfMode, IStream **ppStrm) -{ - return E_NOTIMPL; -} - -static HWND -DesktopGetWindowControl(IN SHDESK *This, - IN UINT id) -{ - switch (id) - { - case FCW_TOOLBAR: - case FCW_STATUS: - case FCW_TREE: - case FCW_PROGRESS: - return NULL; - - default: - return NULL; - } - -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_GetControlWindow(IShellBrowser *iface, UINT id, HWND *lphwnd) -{ - SHDESK *This = impl_from_IShellBrowser(iface); - HWND hWnd; - - hWnd = DesktopGetWindowControl(This, - id); - if (hWnd != NULL) - { - *lphwnd = hWnd; - return S_OK; - } - - *lphwnd = NULL; - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_SendControlMsg(IShellBrowser *iface, UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pret) -{ - SHDESK *This = impl_from_IShellBrowser(iface); - HWND hWnd; - - if (pret == NULL) - return E_POINTER; - - hWnd = DesktopGetWindowControl(This, - id); - if (hWnd != NULL) - { - *pret = SendMessageW(hWnd, - uMsg, - wParam, - lParam); - return S_OK; - } - - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_QueryActiveShellView(IShellBrowser *iface, IShellView **ppshv) -{ - IShellView *ActiveView; - SHDESK *This = impl_from_IShellBrowser(iface); - - ActiveView = This->DesktopView; - SHDESK_AddRef(iface); - *ppshv = ActiveView; - - return S_OK; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_OnViewWindowActive(IShellBrowser *iface, IShellView *ppshv) -{ - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_SetToolbarItems(IShellBrowser *iface, LPTBBUTTON lpButtons, UINT nButtons, UINT uFlags) -{ - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_ICommDlgBrowser_QueryInterface(ICommDlgBrowser *iface, REFIID riid, LPVOID *ppvObj) -{ - SHDESK *This = impl_from_ICommDlgBrowser(iface); - IShellBrowser *ShellBrowser = IShellBrowser_from_impl(This); - - return SHDESK_QueryInterface(ShellBrowser, riid, ppvObj); -} - -static ULONG STDMETHODCALLTYPE -SHDESK_ICommDlgBrowser_Release(ICommDlgBrowser *iface) -{ - SHDESK *This = impl_from_ICommDlgBrowser(iface); - IShellBrowser *ShellBrowser = IShellBrowser_from_impl(This); - - return SHDESK_Release(ShellBrowser); -} - -static ULONG STDMETHODCALLTYPE -SHDESK_ICommDlgBrowser_AddRef(ICommDlgBrowser *iface) -{ - SHDESK *This = impl_from_ICommDlgBrowser(iface); - IShellBrowser *ShellBrowser = IShellBrowser_from_impl(This); - - return SHDESK_AddRef(ShellBrowser); -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface, IShellView *ppshv) -{ - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface, IShellView *ppshv, ULONG uChange) -{ - return S_OK; -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface, IShellView *ppshv, LPCITEMIDLIST pidl) -{ - return S_OK; -} - -static const ICommDlgBrowserVtbl SHDESK_ICommDlgBrowser_Vtbl = -{ - /* IUnknown */ - SHDESK_ICommDlgBrowser_QueryInterface, - SHDESK_ICommDlgBrowser_AddRef, - SHDESK_ICommDlgBrowser_Release, - /* ICommDlgBrowser */ - SHDESK_ICommDlgBrowser_OnDefaultCommand, - SHDESK_ICommDlgBrowser_OnStateChange, - SHDESK_ICommDlgBrowser_IncludeObject -}; - -static HRESULT STDMETHODCALLTYPE -SHDESK_IServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, LPVOID *ppvObj) -{ - SHDESK *This = impl_from_IServiceProvider(iface); - IShellBrowser *ShellBrowser = IShellBrowser_from_impl(This); - - return SHDESK_QueryInterface(ShellBrowser, riid, ppvObj); -} - -static ULONG STDMETHODCALLTYPE -SHDESK_IServiceProvider_Release(IServiceProvider *iface) -{ - SHDESK *This = impl_from_IServiceProvider(iface); - IShellBrowser *ShellBrowser = IShellBrowser_from_impl(This); - - return SHDESK_Release(ShellBrowser); -} - -static ULONG STDMETHODCALLTYPE -SHDESK_IServiceProvider_AddRef(IServiceProvider *iface) -{ - SHDESK *This = impl_from_IServiceProvider(iface); - IShellBrowser *ShellBrowser = IShellBrowser_from_impl(This); - - return SHDESK_AddRef(ShellBrowser); -} - -static HRESULT STDMETHODCALLTYPE -SHDESK_IServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService, REFIID riid, PVOID *ppv) -{ - /* FIXME - handle guidService */ - return SHDESK_IServiceProvider_QueryInterface(iface, riid, ppv); -} - -static const IServiceProviderVtbl SHDESK_IServiceProvider_Vtbl = -{ - /* IUnknown */ - SHDESK_IServiceProvider_QueryInterface, - SHDESK_IServiceProvider_AddRef, - SHDESK_IServiceProvider_Release, - /* IServiceProvider */ - SHDESK_IServiceProvider_QueryService -}; - -static BOOL -SHDESK_MessageLoop(SHDESK *This) -{ - MSG Msg; - BOOL bRet; - - while ((bRet = GetMessageW(&Msg, NULL, 0, 0)) != 0) - { - if (bRet != -1) - { - TranslateMessage(&Msg); - DispatchMessageW(&Msg); - } - } - - return TRUE; -} - -static LRESULT CALLBACK -ProgmanWindowProc(IN HWND hwnd, - IN UINT uMsg, - IN WPARAM wParam, - IN LPARAM lParam) -{ - SHDESK *This = NULL; - LRESULT Ret = FALSE; - - if (uMsg != WM_NCCREATE) - { - This = (SHDESK*)GetWindowLongPtrW(hwnd, - 0); - if (This == NULL) - goto DefMsgHandler; - } - - if (This != NULL || uMsg == WM_NCCREATE) - { - switch (uMsg) - { - case WM_ERASEBKGND: - return (LRESULT)PaintDesktop((HDC)wParam); - - case WM_GETISHELLBROWSER: - Ret = (LRESULT)IShellBrowser_from_impl(This); - break; - - case WM_SIZE: - if (wParam == SIZE_MINIMIZED) - { - /* Hey, we're the desktop!!! */ - ShowWindow(hwnd, - SW_RESTORE); - } - else - { - RECT rcDesktop; - - rcDesktop.left = GetSystemMetrics(SM_XVIRTUALSCREEN); - rcDesktop.top = GetSystemMetrics(SM_YVIRTUALSCREEN); - rcDesktop.right = GetSystemMetrics(SM_CXVIRTUALSCREEN); - rcDesktop.bottom = GetSystemMetrics(SM_CYVIRTUALSCREEN); - - /* FIXME: Update work area */ - } - break; - - case WM_SYSCOLORCHANGE: - { - InvalidateRect(This->hWnd, - NULL, - TRUE); - - if (This->hWndShellView != NULL) - { - /* Forward the message */ - SendMessageW(This->hWndShellView, - WM_SYSCOLORCHANGE, - wParam, - lParam); - } - break; - } - - case WM_CREATE: - { - IShellDesktopTray_RegisterDesktopWindow(This->ShellDesk, - This->hWnd); - - if (!SHDESK_CreateDeskWnd(This)) - WARN("Could not create the desktop view control!\n"); - break; - } - - case WM_NCCREATE: - { - LPCREATESTRUCT CreateStruct = (LPCREATESTRUCT)lParam; - This = SHDESK_Create(hwnd, CreateStruct); - if (This == NULL) - { - WARN("Failed to create desktop structure\n"); - break; - } - - SetWindowLongPtrW(hwnd, - 0, - (LONG_PTR)This); - Ret = TRUE; - break; - } - - case WM_NCDESTROY: - { - SHDESK_Free(This); - break; - } - - default: -DefMsgHandler: - Ret = DefWindowProcW(hwnd, uMsg, wParam, lParam); - break; - } - } - - return Ret; -} - -static BOOL -RegisterProgmanWindowClass(VOID) -{ - WNDCLASSW wcProgman; - - wcProgman.style = CS_DBLCLKS; - wcProgman.lpfnWndProc = ProgmanWindowProc; - wcProgman.cbClsExtra = 0; - wcProgman.cbWndExtra = sizeof(PSHDESK); - wcProgman.hInstance = shell32_hInstance; - wcProgman.hIcon = NULL; - wcProgman.hCursor = LoadCursorW(NULL, - IDC_ARROW); - wcProgman.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1); - wcProgman.lpszMenuName = NULL; - wcProgman.lpszClassName = szProgmanClassName; - - return RegisterClassW(&wcProgman) != 0; -} - - -/************************************************************************* - * SHCreateDesktop [SHELL32.200] - * - */ -HANDLE WINAPI SHCreateDesktop(IShellDesktopTray *ShellDesk) -{ - HWND hWndDesk; - RECT rcDesk; - - if (ShellDesk == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - if (RegisterProgmanWindowClass() == 0) - { - WARN("Failed to register the Progman window class!\n"); - return NULL; - } - - rcDesk.left = GetSystemMetrics(SM_XVIRTUALSCREEN); - rcDesk.top = GetSystemMetrics(SM_YVIRTUALSCREEN); - rcDesk.right = rcDesk.left + GetSystemMetrics(SM_CXVIRTUALSCREEN); - rcDesk.bottom = rcDesk.top + GetSystemMetrics(SM_CYVIRTUALSCREEN); - - if (IsRectEmpty(&rcDesk)) - { - rcDesk.left = rcDesk.top = 0; - rcDesk.right = GetSystemMetrics(SM_CXSCREEN); - rcDesk.bottom = GetSystemMetrics(SM_CYSCREEN); - } - - hWndDesk = CreateWindowExW(0, szProgmanClassName, szProgmanWindowName, - WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, - rcDesk.left, rcDesk.top, rcDesk.right, rcDesk.bottom, - NULL, NULL, shell32_hInstance, (LPVOID)ShellDesk); - if (hWndDesk != NULL) - return (HANDLE)GetWindowLongPtrW(hWndDesk, 0); - - return NULL; -} - -/************************************************************************* - * SHCreateDesktop [SHELL32.201] - * - */ -BOOL WINAPI SHDesktopMessageLoop(HANDLE hDesktop) -{ - PSHDESK Desk = (PSHDESK)hDesktop; - - if (Desk == NULL || Desk->Tag != SHDESK_TAG) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - return SHDESK_MessageLoop(Desk); -} - -static const IShellBrowserVtbl SHDESK_Vtbl = -{ - /* IUnknown */ - SHDESK_QueryInterface, - SHDESK_AddRef, - SHDESK_Release, - /* IOleWindow */ - SHDESK_GetWindow, - SHDESK_ContextSensitiveHelp, - /* IShellBrowser */ - SHDESK_InsertMenusSB, - SHDESK_SetMenuSB, - SHDESK_RemoveMenusSB, - SHDESK_SetStatusTextSB, - SHDESK_EnableModelessSB, - SHDESK_TranslateAcceleratorSB, - SHDESK_BrowseObject, - SHDESK_GetViewStateStream, - SHDESK_GetControlWindow, - SHDESK_SendControlMsg, - SHDESK_QueryActiveShellView, - SHDESK_OnViewWindowActive, - SHDESK_SetToolbarItems -}; diff --git a/reactos/dll/win32/shell32/dialogs.c b/reactos/dll/win32/shell32/dialogs.c deleted file mode 100644 index 4ea9418bba6..00000000000 --- a/reactos/dll/win32/shell32/dialogs.c +++ /dev/null @@ -1,712 +0,0 @@ -/* - * common shell dialogs - * - * Copyright 2000 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - - -typedef struct - { - HWND hwndOwner ; - HICON hIcon ; - LPCWSTR lpstrDirectory ; - LPCWSTR lpstrTitle ; - LPCWSTR lpstrDescription ; - UINT uFlags ; - } RUNFILEDLGPARAMS ; - -typedef BOOL (WINAPI * LPFNOFN) (OPENFILENAMEW *) ; - -WINE_DEFAULT_DEBUG_CHANNEL(shell); -static INT_PTR CALLBACK RunDlgProc (HWND, UINT, WPARAM, LPARAM) ; -static void FillList (HWND, char *, BOOL) ; - - -/************************************************************************* - * PickIconDlg [SHELL32.62] - * - */ - -typedef struct -{ - HMODULE hLibrary; - HWND hDlgCtrl; - WCHAR szName[MAX_PATH]; - INT Index; -}PICK_ICON_CONTEXT, *PPICK_ICON_CONTEXT; - -BOOL CALLBACK EnumPickIconResourceProc(HMODULE hModule, - LPCWSTR lpszType, - LPWSTR lpszName, - LONG_PTR lParam -) -{ - WCHAR szName[100]; - int index; - HICON hIcon; - PPICK_ICON_CONTEXT pIconContext = (PPICK_ICON_CONTEXT)lParam; - - if (IS_INTRESOURCE(lpszName)) - swprintf(szName, L"%u", lpszName); - else - wcscpy(szName, (WCHAR*)lpszName); - - - hIcon = LoadIconW(pIconContext->hLibrary, (LPCWSTR)lpszName); - if (hIcon == NULL) - return TRUE; - - index = SendMessageW(pIconContext->hDlgCtrl, LB_ADDSTRING, 0, (LPARAM)szName); - if (index != LB_ERR) - SendMessageW(pIconContext->hDlgCtrl, LB_SETITEMDATA, index, (LPARAM)hIcon); - - return TRUE; -} - -void -DestroyIconList(HWND hDlgCtrl) -{ - int count; - int index; - - count = SendMessage(hDlgCtrl, LB_GETCOUNT, 0, 0); - if (count == LB_ERR) - return; - - for(index = 0; index < count; index++) - { - HICON hIcon = (HICON)SendMessageW(hDlgCtrl, LB_GETITEMDATA, index, 0); - DestroyIcon(hIcon); - } -} - -INT_PTR CALLBACK PickIconProc(HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam -) -{ - LPMEASUREITEMSTRUCT lpmis; - LPDRAWITEMSTRUCT lpdis; - HICON hIcon; - INT index, count; - WCHAR szText[MAX_PATH], szTitle[100], szFilter[100]; - OPENFILENAMEW ofn = {0}; - - PPICK_ICON_CONTEXT pIconContext = (PPICK_ICON_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER); - - switch(uMsg) - { - case WM_INITDIALOG: - pIconContext = (PPICK_ICON_CONTEXT)lParam; - SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG)pIconContext); - pIconContext->hDlgCtrl = GetDlgItem(hwndDlg, IDC_PICKICON_LIST); - EnumResourceNamesW(pIconContext->hLibrary, RT_ICON, EnumPickIconResourceProc, (LPARAM)pIconContext); - if (PathUnExpandEnvStringsW(pIconContext->szName, szText, MAX_PATH)) - SendDlgItemMessageW(hwndDlg, IDC_EDIT_PATH, WM_SETTEXT, 0, (LPARAM)szText); - else - SendDlgItemMessageW(hwndDlg, IDC_EDIT_PATH, WM_SETTEXT, 0, (LPARAM)pIconContext->szName); - - count = SendMessage(pIconContext->hDlgCtrl, LB_GETCOUNT, 0, 0); - if (count != LB_ERR) - { - if (count > pIconContext->Index) - SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, pIconContext->Index, 0); - else - SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, 0, 0); - } - return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDOK: - index = SendMessageW(pIconContext->hDlgCtrl, LB_GETCURSEL, 0, 0); - pIconContext->Index = index; - SendDlgItemMessageW(hwndDlg, IDC_EDIT_PATH, WM_GETTEXT, MAX_PATH, (LPARAM)pIconContext->szName); - DestroyIconList(pIconContext->hDlgCtrl); - EndDialog(hwndDlg, 1); - break; - case IDCANCEL: - DestroyIconList(pIconContext->hDlgCtrl); - EndDialog(hwndDlg, 0); - break; - case IDC_PICKICON_LIST: - if (HIWORD(wParam) == LBN_SELCHANGE) - InvalidateRect((HWND)lParam, NULL, TRUE); // FIXME USE UPDATE RECT - break; - case IDC_BUTTON_PATH: - szText[0] = 0; - szTitle[0] = 0; - szFilter[0] = 0; - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwndDlg; - ofn.lpstrFile = szText; - ofn.nMaxFile = MAX_PATH; - LoadStringW(shell32_hInstance, IDS_PICK_ICON_TITLE, szTitle, sizeof(szTitle) / sizeof(WCHAR)); - ofn.lpstrTitle = szTitle; - LoadStringW(shell32_hInstance, IDS_PICK_ICON_FILTER, szFilter, sizeof(szFilter) / sizeof(WCHAR)); - ofn.lpstrFilter = szFilter; - if (GetOpenFileNameW(&ofn)) - { - HMODULE hLibrary; - - if (!wcsicmp(pIconContext->szName, szText)) - break; - - DestroyIconList(pIconContext->hDlgCtrl); - - hLibrary = LoadLibraryExW(szText, NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE); - if (hLibrary == NULL) - break; - FreeLibrary(pIconContext->hLibrary); - pIconContext->hLibrary = hLibrary; - wcscpy(pIconContext->szName, szText); - EnumResourceNamesW(pIconContext->hLibrary, RT_ICON, EnumPickIconResourceProc, (LPARAM)pIconContext); - if (PathUnExpandEnvStringsW(pIconContext->szName, szText, MAX_PATH)) - SendDlgItemMessageW(hwndDlg, IDC_EDIT_PATH, WM_SETTEXT, 0, (LPARAM)szText); - else - SendDlgItemMessageW(hwndDlg, IDC_EDIT_PATH, WM_SETTEXT, 0, (LPARAM)pIconContext->szName); - - SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, 0, 0); - } - break; - } - break; - case WM_MEASUREITEM: - lpmis = (LPMEASUREITEMSTRUCT) lParam; - lpmis->itemHeight = 32; - lpmis->itemWidth = 64; - return TRUE; - case WM_DRAWITEM: - lpdis = (LPDRAWITEMSTRUCT) lParam; - if (lpdis->itemID == -1) - { - break; - } - switch (lpdis->itemAction) - { - case ODA_SELECT: - case ODA_DRAWENTIRE: - index = SendMessageW(pIconContext->hDlgCtrl, LB_GETCURSEL, 0, 0); - hIcon =(HICON)SendMessage(lpdis->hwndItem, LB_GETITEMDATA, lpdis->itemID, (LPARAM) 0); - - if (lpdis->itemID == index) - { - HBRUSH hBrush; - hBrush = CreateSolidBrush(RGB(0, 0, 255)); - FillRect(lpdis->hDC, &lpdis->rcItem, hBrush); - DeleteObject(hBrush); - } - else - { - HBRUSH hBrush; - hBrush = CreateSolidBrush(RGB(255, 255, 255)); - FillRect(lpdis->hDC, &lpdis->rcItem, hBrush); - DeleteObject(hBrush); - } - DrawIconEx(lpdis->hDC, lpdis->rcItem.left,lpdis->rcItem.top, hIcon, - 0, - 0, - 0, - NULL, - DI_NORMAL); - break; - } - break; - } - - return FALSE; -} - -BOOL WINAPI PickIconDlg( - HWND hwndOwner, - LPWSTR lpstrFile, - UINT nMaxFile, - INT* lpdwIconIndex) -{ - HMODULE hLibrary; - int res; - PICK_ICON_CONTEXT IconContext; - - hLibrary = LoadLibraryExW(lpstrFile, NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE); - IconContext.hLibrary = hLibrary; - IconContext.Index = *lpdwIconIndex; - wcscpy(IconContext.szName, lpstrFile); - - res = DialogBoxParamW(shell32_hInstance, MAKEINTRESOURCEW(IDD_PICK_ICON_DIALOG), hwndOwner, PickIconProc, (LPARAM)&IconContext); - if (res) - { - wcscpy(lpstrFile, IconContext.szName); - *lpdwIconIndex = IconContext.Index; - } - - FreeLibrary(hLibrary); - return res; -} - -/************************************************************************* - * RunFileDlg [internal] - * - * The Unicode function that is available as ordinal 61 on Windows NT/2000/XP/... - */ -void WINAPI RunFileDlg( - HWND hwndOwner, - HICON hIcon, - LPCWSTR lpstrDirectory, - LPCWSTR lpstrTitle, - LPCWSTR lpstrDescription, - UINT uFlags) -{ - static const WCHAR resnameW[] = {'S','H','E','L','L','_','R','U','N','_','D','L','G',0}; - RUNFILEDLGPARAMS rfdp; - HRSRC hRes; - LPVOID template; - TRACE("\n"); - - rfdp.hwndOwner = hwndOwner; - rfdp.hIcon = hIcon; - rfdp.lpstrDirectory = lpstrDirectory; - rfdp.lpstrTitle = lpstrTitle; - rfdp.lpstrDescription = lpstrDescription; - rfdp.uFlags = uFlags; - - if (!(hRes = FindResourceW(shell32_hInstance, resnameW, (LPWSTR)RT_DIALOG)) || - !(template = LoadResource(shell32_hInstance, hRes))) - { - ERR("Couldn't load SHELL_RUN_DLG resource\n"); - ShellMessageBoxW(shell32_hInstance, hwndOwner, MAKEINTRESOURCEW(IDS_RUNDLG_ERROR), NULL, MB_OK | MB_ICONERROR); - return; - } - - DialogBoxIndirectParamW(shell32_hInstance, - template, hwndOwner, RunDlgProc, (LPARAM)&rfdp); - -} - -/* find the directory that contains the file being run */ -static LPWSTR RunDlg_GetParentDir(LPCWSTR cmdline) -{ - const WCHAR *src; - WCHAR *dest, *result, *result_end=NULL; - static const WCHAR dotexeW[] = {'.','e','x','e',0}; - - result = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(strlenW(cmdline)+5)); - - src = cmdline; - dest = result; - - if (*src == '"') - { - src++; - while (*src && *src != '"') - { - if (*src == '\\') - result_end = dest; - *dest++ = *src++; - } - } - else { - while (*src) - { - if (isspaceW(*src)) - { - *dest = 0; - if (INVALID_FILE_ATTRIBUTES != GetFileAttributesW(result)) - break; - strcatW(dest, dotexeW); - if (INVALID_FILE_ATTRIBUTES != GetFileAttributesW(result)) - break; - } - else if (*src == '\\') - result_end = dest; - *dest++ = *src++; - } - } - - if (result_end) - { - *result_end = 0; - return result; - } - else - { - HeapFree(GetProcessHeap(), 0, result); - return NULL; - } -} - -/* Dialog procedure for RunFileDlg */ -static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) - { - RUNFILEDLGPARAMS *prfdp = (RUNFILEDLGPARAMS *)GetWindowLongPtrW(hwnd, DWLP_USER); - - switch (message) - { - case WM_INITDIALOG : - prfdp = (RUNFILEDLGPARAMS *)lParam ; - SetWindowLongPtrW(hwnd, DWLP_USER, (LONG_PTR)prfdp); - - if (prfdp->lpstrTitle) - SetWindowTextW(hwnd, prfdp->lpstrTitle); - if (prfdp->lpstrDescription) - SetWindowTextW(GetDlgItem(hwnd, IDC_RUNDLG_DESCRIPTION), prfdp->lpstrDescription); - if (prfdp->uFlags & RFF_NOBROWSE) - { - HWND browse = GetDlgItem(hwnd, IDC_RUNDLG_BROWSE); - ShowWindow(browse, SW_HIDE); - EnableWindow(browse, FALSE); - } - if (prfdp->uFlags & RFF_NOLABEL) - ShowWindow(GetDlgItem(hwnd, IDC_RUNDLG_LABEL), SW_HIDE); - if (prfdp->uFlags & RFF_CALCDIRECTORY) - FIXME("RFF_CALCDIRECTORY not supported\n"); - - if (prfdp->hIcon == NULL) - prfdp->hIcon = LoadIconW(NULL, (LPCWSTR)IDI_WINLOGO); - SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM)prfdp->hIcon); - SendMessageW(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)prfdp->hIcon); - SendMessageW(GetDlgItem(hwnd, IDC_RUNDLG_ICON), STM_SETICON, (WPARAM)prfdp->hIcon, 0); - - FillList (GetDlgItem (hwnd, IDC_RUNDLG_EDITPATH), NULL, (prfdp->uFlags & RFF_NODEFAULT) == 0) ; - SetFocus (GetDlgItem (hwnd, IDC_RUNDLG_EDITPATH)) ; - return TRUE ; - - case WM_COMMAND : - switch (LOWORD (wParam)) - { - case IDOK : - { - int ic ; - HWND htxt = GetDlgItem (hwnd, IDC_RUNDLG_EDITPATH); - if ((ic = GetWindowTextLengthW (htxt))) - { - WCHAR *psz, *parent=NULL ; - SHELLEXECUTEINFOW sei ; - - ZeroMemory (&sei, sizeof(sei)) ; - sei.cbSize = sizeof(sei) ; - psz = HeapAlloc( GetProcessHeap(), 0, (ic + 1)*sizeof(WCHAR) ); - GetWindowTextW (htxt, psz, ic + 1) ; - - /* according to http://www.codeproject.com/KB/shell/runfiledlg.aspx we should send a - * WM_NOTIFY before execution */ - - sei.hwnd = hwnd; - sei.nShow = SW_SHOWNORMAL; - sei.lpFile = psz; - - if (prfdp->lpstrDirectory) - sei.lpDirectory = prfdp->lpstrDirectory; - else - sei.lpDirectory = parent = RunDlg_GetParentDir(sei.lpFile); - - if (!ShellExecuteExW( &sei )) - { - HeapFree(GetProcessHeap(), 0, psz); - HeapFree(GetProcessHeap(), 0, parent); - SendMessageA (htxt, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ; - return TRUE ; - } - - /* FillList is still ANSI */ - GetWindowTextA (htxt, (LPSTR)psz, ic + 1) ; - FillList (htxt, (LPSTR)psz, FALSE) ; - - HeapFree(GetProcessHeap(), 0, psz); - HeapFree(GetProcessHeap(), 0, parent); - EndDialog (hwnd, 0); - } - } - - case IDCANCEL : - EndDialog (hwnd, 0) ; - return TRUE ; - - case IDC_RUNDLG_BROWSE : - { - HMODULE hComdlg = NULL ; - LPFNOFN ofnProc = NULL ; - static const WCHAR comdlg32W[] = {'c','o','m','d','l','g','3','2',0}; - WCHAR szFName[1024] = {0}; - WCHAR filter[MAX_PATH], szCaption[MAX_PATH]; - OPENFILENAMEW ofn; - - LoadStringW(shell32_hInstance, IDS_RUNDLG_BROWSE_FILTER, filter, MAX_PATH); - LoadStringW(shell32_hInstance, IDS_RUNDLG_BROWSE_CAPTION, szCaption, MAX_PATH); - - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(OPENFILENAMEW); - ofn.hwndOwner = hwnd; - ofn.lpstrFilter = filter; - ofn.lpstrFile = szFName; - ofn.nMaxFile = 1023; - ofn.lpstrTitle = szCaption; - ofn.Flags = OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; - ofn.lpstrInitialDir = prfdp->lpstrDirectory; - - if (NULL == (hComdlg = LoadLibraryExW (comdlg32W, NULL, 0)) || - NULL == (ofnProc = (LPFNOFN)GetProcAddress (hComdlg, "GetOpenFileNameW"))) - { - ERR("Couldn't get GetOpenFileName function entry (lib=%p, proc=%p)\n", hComdlg, ofnProc); - ShellMessageBoxW(shell32_hInstance, hwnd, MAKEINTRESOURCEW(IDS_RUNDLG_BROWSE_ERROR), NULL, MB_OK | MB_ICONERROR); - return TRUE ; - } - - if (ofnProc(&ofn)) - { - SetFocus (GetDlgItem (hwnd, IDOK)) ; - SetWindowTextW (GetDlgItem (hwnd, IDC_RUNDLG_EDITPATH), szFName) ; - SendMessageW (GetDlgItem (hwnd, IDC_RUNDLG_EDITPATH), CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ; - SetFocus (GetDlgItem (hwnd, IDOK)) ; - } - - FreeLibrary (hComdlg) ; - - return TRUE ; - } - } - return TRUE ; - } - return FALSE ; - } - -/* This grabs the MRU list from the registry and fills the combo for the "Run" dialog above */ -/* fShowDefault ignored if pszLatest != NULL */ -static void FillList (HWND hCb, char *pszLatest, BOOL fShowDefault) - { - HKEY hkey ; -/* char szDbgMsg[256] = "" ; */ - char *pszList = NULL, *pszCmd = NULL, cMatch = 0, cMax = 0x60, szIndex[2] = "-" ; - DWORD icList = 0, icCmd = 0 ; - UINT Nix ; - - SendMessageA (hCb, CB_RESETCONTENT, 0, 0) ; - - if (ERROR_SUCCESS != RegCreateKeyExA ( - HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU", - 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL)) - MessageBoxA (hCb, "Unable to open registry key !", "Nix", MB_OK) ; - - RegQueryValueExA (hkey, "MRUList", NULL, NULL, NULL, &icList) ; - - if (icList > 0) - { - pszList = HeapAlloc( GetProcessHeap(), 0, icList) ; - if (ERROR_SUCCESS != RegQueryValueExA (hkey, "MRUList", NULL, NULL, (LPBYTE)pszList, &icList)) - MessageBoxA (hCb, "Unable to grab MRUList !", "Nix", MB_OK) ; - } - else - { - icList = 1 ; - pszList = HeapAlloc( GetProcessHeap(), 0, icList) ; - pszList[0] = 0 ; - } - - for (Nix = 0 ; Nix < icList - 1 ; Nix++) - { - if (pszList[Nix] > cMax) - cMax = pszList[Nix] ; - - szIndex[0] = pszList[Nix] ; - - if (ERROR_SUCCESS != RegQueryValueExA (hkey, szIndex, NULL, NULL, NULL, &icCmd)) - MessageBoxA (hCb, "Unable to grab size of index", "Nix", MB_OK) ; - if( pszCmd ) - pszCmd = HeapReAlloc(GetProcessHeap(), 0, pszCmd, icCmd) ; - else - pszCmd = HeapAlloc(GetProcessHeap(), 0, icCmd) ; - if (ERROR_SUCCESS != RegQueryValueExA (hkey, szIndex, NULL, NULL, (LPBYTE)pszCmd, &icCmd)) - MessageBoxA (hCb, "Unable to grab index", "Nix", MB_OK) ; - - if (NULL != pszLatest) - { - if (!lstrcmpiA(pszCmd, pszLatest)) - { - /* - sprintf (szDbgMsg, "Found existing (%d).\n", Nix) ; - MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ; - */ - SendMessageA (hCb, CB_INSERTSTRING, 0, (LPARAM)pszCmd) ; - SetWindowTextA (hCb, pszCmd) ; - SendMessageA (hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ; - - cMatch = pszList[Nix] ; - memmove (&pszList[1], pszList, Nix) ; - pszList[0] = cMatch ; - continue ; - } - } - - if (26 != icList - 1 || icList - 2 != Nix || cMatch || NULL == pszLatest) - { - /* - sprintf (szDbgMsg, "Happily appending (%d).\n", Nix) ; - MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ; - */ - SendMessageA (hCb, CB_ADDSTRING, 0, (LPARAM)pszCmd) ; - if (!Nix && fShowDefault) - { - SetWindowTextA (hCb, pszCmd) ; - SendMessageA (hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ; - } - - } - else - { - /* - sprintf (szDbgMsg, "Doing loop thing.\n") ; - MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ; - */ - SendMessageA (hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest) ; - SetWindowTextA (hCb, pszLatest) ; - SendMessageA (hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ; - - cMatch = pszList[Nix] ; - memmove (&pszList[1], pszList, Nix) ; - pszList[0] = cMatch ; - szIndex[0] = cMatch ; - RegSetValueExA (hkey, szIndex, 0, REG_SZ, (LPBYTE)pszLatest, strlen (pszLatest) + 1) ; - } - } - - if (!cMatch && NULL != pszLatest) - { - /* - sprintf (szDbgMsg, "Simply inserting (increasing list).\n") ; - MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ; - */ - SendMessageA (hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest) ; - SetWindowTextA (hCb, pszLatest) ; - SendMessageA (hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ; - - cMatch = ++cMax ; - if( pszList ) - pszList = HeapReAlloc(GetProcessHeap(), 0, pszList, ++icList) ; - else - pszList = HeapAlloc(GetProcessHeap(), 0, ++icList) ; - memmove (&pszList[1], pszList, icList - 1) ; - pszList[0] = cMatch ; - szIndex[0] = cMatch ; - RegSetValueExA (hkey, szIndex, 0, REG_SZ, (LPBYTE)pszLatest, strlen (pszLatest) + 1) ; - } - - RegSetValueExA (hkey, "MRUList", 0, REG_SZ, (LPBYTE)pszList, strlen (pszList) + 1) ; - - HeapFree( GetProcessHeap(), 0, pszCmd) ; - HeapFree( GetProcessHeap(), 0, pszList) ; - } - - -/************************************************************************* - * ConfirmDialog [internal] - * - * Put up a confirm box, return TRUE if the user confirmed - */ -static BOOL ConfirmDialog(HWND hWndOwner, UINT PromptId, UINT TitleId) -{ - WCHAR Prompt[256]; - WCHAR Title[256]; - - LoadStringW(shell32_hInstance, PromptId, Prompt, sizeof(Prompt) / sizeof(WCHAR)); - LoadStringW(shell32_hInstance, TitleId, Title, sizeof(Title) / sizeof(WCHAR)); - return MessageBoxW(hWndOwner, Prompt, Title, MB_YESNO|MB_ICONQUESTION) == IDYES; -} - - -/************************************************************************* - * RestartDialogEx [SHELL32.730] - */ - -int WINAPI RestartDialogEx(HWND hWndOwner, LPCWSTR lpwstrReason, DWORD uFlags, DWORD uReason) -{ - TRACE("(%p)\n", hWndOwner); - - /* FIXME: use lpwstrReason */ - if (ConfirmDialog(hWndOwner, IDS_RESTART_PROMPT, IDS_RESTART_TITLE)) - { - HANDLE hToken; - TOKEN_PRIVILEGES npr; - - /* enable the shutdown privilege for the current process */ - if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken)) - { - LookupPrivilegeValueA(0, "SeShutdownPrivilege", &npr.Privileges[0].Luid); - npr.PrivilegeCount = 1; - npr.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - AdjustTokenPrivileges(hToken, FALSE, &npr, 0, 0, 0); - CloseHandle(hToken); - } - ExitWindowsEx(EWX_REBOOT, uReason); - } - - return 0; -} - - -/************************************************************************* - * LogoffWindowsDialog [SHELL32.54] - */ - -int WINAPI LogoffWindowsDialog(HWND hWndOwner) -{ - if (ConfirmDialog(hWndOwner, IDS_LOGOFF_PROMPT, IDS_LOGOFF_TITLE)) - { - ExitWindowsEx(EWX_LOGOFF, 0); - } - return 0; -} - - -/************************************************************************* - * RestartDialog [SHELL32.59] - */ - -int WINAPI RestartDialog(HWND hWndOwner, LPCWSTR lpstrReason, DWORD uFlags) -{ - return RestartDialogEx(hWndOwner, lpstrReason, uFlags, 0); -} - - -/************************************************************************* - * ExitWindowsDialog [SHELL32.60] - * - * NOTES - * exported by ordinal - */ -void WINAPI ExitWindowsDialog (HWND hWndOwner) -{ - TRACE("(%p)\n", hWndOwner); - - if (ConfirmDialog(hWndOwner, IDS_SHUTDOWN_PROMPT, IDS_SHUTDOWN_TITLE)) - { - HANDLE hToken; - TOKEN_PRIVILEGES npr; - - /* enable shutdown privilege for current process */ - if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken)) - { - LookupPrivilegeValueA(0, "SeShutdownPrivilege", &npr.Privileges[0].Luid); - npr.PrivilegeCount = 1; - npr.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - AdjustTokenPrivileges(hToken, FALSE, &npr, 0, 0, 0); - CloseHandle(hToken); - } - ExitWindowsEx(EWX_SHUTDOWN, 0); - } -} diff --git a/reactos/dll/win32/shell32/dragdrophelper.c b/reactos/dll/win32/shell32/dragdrophelper.c deleted file mode 100644 index ebd39a3be37..00000000000 --- a/reactos/dll/win32/shell32/dragdrophelper.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * file system folder - * - * Copyright 1997 Marcus Meissner - * Copyright 1998, 1999, 2002 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL (shell); - -/*********************************************************************** -* IDropTargetHelper implementation -*/ - -typedef struct { - const IDropTargetHelperVtbl *lpVtbl; - LONG ref; -} IDropTargetHelperImpl; - -static const IDropTargetHelperVtbl vt_IDropTargetHelper; - -#define _IUnknown_(This) (IUnknown*)&(This->lpVtbl) -#define _IDropTargetHelper_(This) (IDropTargetHelper*)&(This->lpVtbl) - -/************************************************************************** -* IDropTargetHelper_Constructor -*/ -HRESULT WINAPI IDropTargetHelper_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) -{ - IDropTargetHelperImpl *dth; - - TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid)); - - if (!ppv) - return E_POINTER; - if (pUnkOuter) - return CLASS_E_NOAGGREGATION; - - dth = (IDropTargetHelperImpl *) LocalAlloc (LMEM_ZEROINIT, sizeof (IDropTargetHelperImpl)); - if (!dth) return E_OUTOFMEMORY; - - dth->ref = 0; - dth->lpVtbl = &vt_IDropTargetHelper; - - if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (dth), riid, ppv))) { - IUnknown_Release (_IUnknown_ (dth)); - return E_NOINTERFACE; - } - - TRACE ("--(%p)\n", dth); - return S_OK; -} - -/************************************************************************** - * IDropTargetHelper_fnQueryInterface - */ -static HRESULT WINAPI IDropTargetHelper_fnQueryInterface (IDropTargetHelper * iface, REFIID riid, LPVOID * ppvObj) -{ - IDropTargetHelperImpl *This = (IDropTargetHelperImpl *)iface; - - TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj); - - *ppvObj = NULL; - - if (IsEqualIID (riid, &IID_IUnknown) || IsEqualIID (riid, &IID_IDropTargetHelper)) { - *ppvObj = This; - } - - if (*ppvObj) { - IUnknown_AddRef ((IUnknown *) (*ppvObj)); - TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj); - return S_OK; - } - FIXME ("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -static ULONG WINAPI IDropTargetHelper_fnAddRef (IDropTargetHelper * iface) -{ - IDropTargetHelperImpl *This = (IDropTargetHelperImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE ("(%p)->(count=%u)\n", This, refCount - 1); - - return refCount; -} - -static ULONG WINAPI IDropTargetHelper_fnRelease (IDropTargetHelper * iface) -{ - IDropTargetHelperImpl *This = (IDropTargetHelperImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE ("(%p)->(count=%u)\n", This, refCount + 1); - - if (!refCount) { - TRACE("-- destroying (%p)\n", This); - LocalFree ((HLOCAL) This); - return 0; - } - return refCount; -} - -static HRESULT WINAPI IDropTargetHelper_fnDragEnter ( - IDropTargetHelper * iface, - HWND hwndTarget, - IDataObject* pDataObject, - POINT* ppt, - DWORD dwEffect) -{ - IDropTargetHelperImpl *This = (IDropTargetHelperImpl *)iface; - FIXME ("(%p)->(%p %p %p 0x%08x)\n", This,hwndTarget, pDataObject, ppt, dwEffect); - return E_NOTIMPL; -} - -static HRESULT WINAPI IDropTargetHelper_fnDragLeave (IDropTargetHelper * iface) -{ - IDropTargetHelperImpl *This = (IDropTargetHelperImpl *)iface; - FIXME ("(%p)->()\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI IDropTargetHelper_fnDragOver (IDropTargetHelper * iface, POINT* ppt, DWORD dwEffect) -{ - IDropTargetHelperImpl *This = (IDropTargetHelperImpl *)iface; - FIXME ("(%p)->(%p 0x%08x)\n", This, ppt, dwEffect); - return E_NOTIMPL; -} - -static HRESULT WINAPI IDropTargetHelper_fnDrop (IDropTargetHelper * iface, IDataObject* pDataObject, POINT* ppt, DWORD dwEffect) -{ - IDropTargetHelperImpl *This = (IDropTargetHelperImpl *)iface; - FIXME ("(%p)->(%p %p 0x%08x)\n", This, pDataObject, ppt, dwEffect); - return E_NOTIMPL; -} - -static HRESULT WINAPI IDropTargetHelper_fnShow (IDropTargetHelper * iface, BOOL fShow) -{ - IDropTargetHelperImpl *This = (IDropTargetHelperImpl *)iface; - FIXME ("(%p)->(%u)\n", This, fShow); - return E_NOTIMPL; -} - -static const IDropTargetHelperVtbl vt_IDropTargetHelper = -{ - IDropTargetHelper_fnQueryInterface, - IDropTargetHelper_fnAddRef, - IDropTargetHelper_fnRelease, - IDropTargetHelper_fnDragEnter, - IDropTargetHelper_fnDragLeave, - IDropTargetHelper_fnDragOver, - IDropTargetHelper_fnDrop, - IDropTargetHelper_fnShow -}; diff --git a/reactos/dll/win32/shell32/drive.c b/reactos/dll/win32/shell32/drive.c deleted file mode 100644 index 240739c6c73..00000000000 --- a/reactos/dll/win32/shell32/drive.c +++ /dev/null @@ -1,1290 +0,0 @@ -/* - * Shell Library Functions - * - * Copyright 2005 Johannes Anderwald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#define MAX_PROPERTY_SHEET_PAGE 32 - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -typedef enum -{ - HWPD_STANDARDLIST = 0, - HWPD_LARGELIST, - HWPD_MAX = HWPD_LARGELIST -} HWPAGE_DISPLAYMODE, *PHWPAGE_DISPLAYMODE; - -typedef -BOOLEAN -(NTAPI *INITIALIZE_FMIFS)( - IN PVOID hinstDll, - IN DWORD dwReason, - IN PVOID reserved -); -typedef -BOOLEAN -(NTAPI *QUERY_AVAILABLEFSFORMAT)( - IN DWORD Index, - IN OUT PWCHAR FileSystem, - OUT UCHAR* Major, - OUT UCHAR* Minor, - OUT BOOLEAN* LastestVersion -); -typedef -BOOLEAN -(NTAPI *ENABLEVOLUMECOMPRESSION)( - IN PWCHAR DriveRoot, - IN USHORT Compression -); - -typedef -VOID -(NTAPI *FORMAT_EX)( - IN PWCHAR DriveRoot, - IN FMIFS_MEDIA_FLAG MediaFlag, - IN PWCHAR Format, - IN PWCHAR Label, - IN BOOLEAN QuickFormat, - IN ULONG ClusterSize, - IN PFMIFSCALLBACK Callback -); - -typedef -VOID -(NTAPI *CHKDSK)( - IN PWCHAR DriveRoot, - IN PWCHAR Format, - IN BOOLEAN CorrectErrors, - IN BOOLEAN Verbose, - IN BOOLEAN CheckOnlyIfDirty, - IN BOOLEAN ScanDrive, - IN PVOID Unused2, - IN PVOID Unused3, - IN PFMIFSCALLBACK Callback -); - - -typedef struct -{ - WCHAR Drive; - UINT Options; - HMODULE hLibrary; - QUERY_AVAILABLEFSFORMAT QueryAvailableFileSystemFormat; - FORMAT_EX FormatEx; - ENABLEVOLUMECOMPRESSION EnableVolumeCompression; - CHKDSK Chkdsk; - UINT Result; -}FORMAT_DRIVE_CONTEXT, *PFORMAT_DRIVE_CONTEXT; - -BOOL InitializeFmifsLibrary(PFORMAT_DRIVE_CONTEXT pContext); -BOOL GetDefaultClusterSize(LPWSTR szFs, PDWORD pClusterSize, PULARGE_INTEGER TotalNumberOfBytes); -HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj); -HWND WINAPI -DeviceCreateHardwarePageEx(HWND hWndParent, - LPGUID lpGuids, - UINT uNumberOfGuids, - HWPAGE_DISPLAYMODE DisplayMode); - -HPROPSHEETPAGE SH_CreatePropertySheetPage(LPSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle); - -#define DRIVE_PROPERTY_PAGES (3) - -static const GUID GUID_DEVCLASS_DISKDRIVE = {0x4d36e967L, 0xe325, 0x11ce, {0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18}}; - - -VOID -GetDriveNameWithLetter(LPWSTR szText, UINT Length, WCHAR Drive) -{ - WCHAR szDrive[] = {'C',':','\\', 0}; - DWORD dwMaxComp, dwFileSys, TempLength = 0; - - szDrive[0] = Drive; - if (GetVolumeInformationW(szDrive, szText, Length, NULL, &dwMaxComp, &dwFileSys, NULL, 0)) - { - szText[Length-1] = L'\0'; - TempLength = wcslen(szText); - if (!TempLength) - { - /* load default volume label */ - TempLength = LoadStringW(shell32_hInstance, IDS_DRIVE_FIXED, &szText[Length+1], (sizeof(szText)/sizeof(WCHAR))- Length - 2); - } - } - if (TempLength + 4 < Length) - { - szText[TempLength] = L' '; - szText[TempLength+1] = L'('; - szText[TempLength+2] = szDrive[0]; - szText[TempLength+3] = L')'; - TempLength +=4; - } - - if (TempLength < Length) - szText[TempLength] = L'\0'; - else - szText[Length-1] = L'\0'; -} - - -VOID -InitializeChkDskDialog(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext) -{ - WCHAR szText[100]; - UINT Length; - SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pContext); - - Length = GetWindowTextW(hwndDlg, szText, sizeof(szText)/sizeof(WCHAR)); - - GetDriveNameWithLetter(&szText[Length +1], (sizeof(szText)/sizeof(WCHAR))-Length-1, pContext->Drive); - szText[Length] = L' '; - szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0'; - SetWindowText(hwndDlg, szText); -} - -HWND ChkdskDrvDialog = NULL; -BOOLEAN bChkdskSuccess = FALSE; - -BOOLEAN -NTAPI -ChkdskCallback( - IN CALLBACKCOMMAND Command, - IN ULONG SubAction, - IN PVOID ActionInfo) -{ - PDWORD Progress; - PBOOLEAN pSuccess; - switch(Command) - { - case PROGRESS: - Progress = (PDWORD)ActionInfo; - SendDlgItemMessageW(ChkdskDrvDialog, 14002, PBM_SETPOS, (WPARAM)*Progress, 0); - break; - case DONE: - pSuccess = (PBOOLEAN)ActionInfo; - bChkdskSuccess = (*pSuccess); - break; - - case VOLUMEINUSE: - case INSUFFICIENTRIGHTS: - case FSNOTSUPPORTED: - case CLUSTERSIZETOOSMALL: - bChkdskSuccess = FALSE; - FIXME("\n"); - break; - - default: - break; - } - - return TRUE; -} - -VOID -ChkDskNow(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext) -{ - DWORD ClusterSize = 0, dwMaxComponentLength, FileSystemFlags; - WCHAR szFs[30]; - WCHAR szDrive[] = {'C',':','\\', 0}; - WCHAR szVolumeLabel[40]; - ULARGE_INTEGER TotalNumberOfFreeBytes, FreeBytesAvailableUser; - BOOLEAN bCorrectErrors = FALSE, bScanDrive = FALSE; - - szDrive[0] = pContext->Drive; - if(!GetVolumeInformationW(szDrive, szVolumeLabel, sizeof(szVolumeLabel)/sizeof(WCHAR), NULL, &dwMaxComponentLength, &FileSystemFlags, szFs, sizeof(szFs)/sizeof(WCHAR))) - { - FIXME("failed to get drive fs type\n"); - return; - } - - if (!GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailableUser, &TotalNumberOfFreeBytes, NULL)) - { - FIXME("failed to get drive space type\n"); - return; - } - - if (!GetDefaultClusterSize(szFs, &ClusterSize, &TotalNumberOfFreeBytes)) - { - FIXME("invalid cluster size\n"); - return; - } - - if (SendDlgItemMessageW(hwndDlg, 14000, BM_GETCHECK, 0, 0) == BST_CHECKED) - bCorrectErrors = TRUE; - - if (SendDlgItemMessageW(hwndDlg, 14001, BM_GETCHECK, 0, 0) == BST_CHECKED) - bScanDrive = TRUE; - - ChkdskDrvDialog = hwndDlg; - bChkdskSuccess = FALSE; - SendDlgItemMessageW(hwndDlg, 14002, PBM_SETRANGE, 0, MAKELPARAM(0, 100)); - pContext->Chkdsk(szDrive, szFs, bCorrectErrors, TRUE, FALSE, bScanDrive, NULL, NULL, ChkdskCallback); - - ChkdskDrvDialog = NULL; - pContext->Result = bChkdskSuccess; - bChkdskSuccess = FALSE; - -} - -INT_PTR -CALLBACK -ChkDskDlg( - HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam -) -{ - PFORMAT_DRIVE_CONTEXT pContext; - switch(uMsg) - { - case WM_INITDIALOG: - SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)lParam); - InitializeChkDskDialog(hwndDlg, (PFORMAT_DRIVE_CONTEXT)lParam); - return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDCANCEL: - EndDialog(hwndDlg, 0); - break; - case IDOK: - pContext = (PFORMAT_DRIVE_CONTEXT) GetWindowLongPtr(hwndDlg, DWLP_USER); - ChkDskNow(hwndDlg, pContext); - break; - } - break; - } - - return FALSE; -} - - -static -ULONGLONG -GetFreeBytesShare(ULONGLONG TotalNumberOfFreeBytes, ULONGLONG TotalNumberOfBytes) -{ - ULONGLONG Temp; - - if (TotalNumberOfFreeBytes == 0LL) - { - return 0; - } - - Temp = TotalNumberOfBytes / 100; - if (Temp >= TotalNumberOfFreeBytes) - { - return 1; - } - else - { - return TotalNumberOfFreeBytes / Temp; - } -} - -static -void -PaintStaticControls(HWND hwndDlg, LPDRAWITEMSTRUCT drawItem) -{ - HBRUSH hBrush; - - if (drawItem->CtlID == 14013) - { - hBrush = CreateSolidBrush(RGB(0, 0, 255)); - if (hBrush) - { - FillRect(drawItem->hDC, &drawItem->rcItem, hBrush); - DeleteObject((HGDIOBJ)hBrush); - } - } - else if (drawItem->CtlID == 14014) - { - hBrush = CreateSolidBrush(RGB(255, 0, 255)); - if (hBrush) - { - FillRect(drawItem->hDC, &drawItem->rcItem, hBrush); - DeleteObject((HGDIOBJ)hBrush); - } - } - else if (drawItem->CtlID == 14015) - { - HBRUSH hBlueBrush; - HBRUSH hMagBrush; - RECT rect; - LONG horzsize; - LONGLONG Result; - WCHAR szBuffer[20]; - - hBlueBrush = CreateSolidBrush(RGB(0, 0, 255)); - hMagBrush = CreateSolidBrush(RGB(255, 0, 255)); - - SendDlgItemMessageW(hwndDlg, 14006, WM_GETTEXT, 20, (LPARAM)szBuffer); - Result = _wtoi(szBuffer); - - CopyRect(&rect, &drawItem->rcItem); - horzsize = rect.right - rect.left; - Result = (Result * horzsize) / 100; - - rect.right = drawItem->rcItem.right - Result; - FillRect(drawItem->hDC, &rect, hBlueBrush); - rect.left = rect.right; - rect.right = drawItem->rcItem.right; - FillRect(drawItem->hDC, &rect, hMagBrush); - DeleteObject(hBlueBrush); - DeleteObject(hMagBrush); - } -} - -static -void -InitializeGeneralDriveDialog(HWND hwndDlg, WCHAR * szDrive) -{ - WCHAR szVolumeName[MAX_PATH+1] = {0}; - DWORD MaxComponentLength = 0; - DWORD FileSystemFlags = 0; - WCHAR FileSystemName[MAX_PATH+1] = {0}; - WCHAR szFormat[50]; - WCHAR szBuffer[128]; - BOOL ret; - UINT DriveType; - ULARGE_INTEGER FreeBytesAvailable; - LARGE_INTEGER TotalNumberOfFreeBytes; - LARGE_INTEGER TotalNumberOfBytes; - - ret = GetVolumeInformationW(szDrive, szVolumeName, MAX_PATH+1, NULL, &MaxComponentLength, &FileSystemFlags, FileSystemName, MAX_PATH+1); - if (ret) - { - /* set volume label */ - SendDlgItemMessageW(hwndDlg, 14000, WM_SETTEXT, (WPARAM)NULL, (LPARAM)szVolumeName); - - /* set filesystem type */ - SendDlgItemMessageW(hwndDlg, 14002, WM_SETTEXT, (WPARAM)NULL, (LPARAM)FileSystemName); - - } - - DriveType = GetDriveTypeW(szDrive); - if (DriveType == DRIVE_FIXED || DriveType == DRIVE_CDROM) - { - - if(GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailable, (PULARGE_INTEGER)&TotalNumberOfBytes, (PULARGE_INTEGER)&TotalNumberOfFreeBytes)) - { - WCHAR szResult[128]; - LONGLONG Result; - HANDLE hVolume; - DWORD BytesReturned = 0; - - swprintf(szResult, L"\\\\.\\%c:", towupper(szDrive[0])); - hVolume = CreateFileW(szResult, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); - if (hVolume != INVALID_HANDLE_VALUE) - { - ret = DeviceIoControl(hVolume, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, (LPVOID)&TotalNumberOfBytes, sizeof(ULARGE_INTEGER), &BytesReturned, NULL); - if (ret && StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, szResult, sizeof(szResult) / sizeof(WCHAR))) - SendDlgItemMessageW(hwndDlg, 14007, WM_SETTEXT, (WPARAM)NULL, (LPARAM)szResult); - - CloseHandle(hVolume); - } - - TRACE("szResult %s hVOlume %p ret %d LengthInformation %ul Bytesreturned %d\n", debugstr_w(szResult), hVolume, ret, TotalNumberOfBytes.QuadPart, BytesReturned); - - if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart - FreeBytesAvailable.QuadPart, szResult, sizeof(szResult) / sizeof(WCHAR))) - SendDlgItemMessageW(hwndDlg, 14003, WM_SETTEXT, (WPARAM)NULL, (LPARAM)szResult); - - if (StrFormatByteSizeW(FreeBytesAvailable.QuadPart, szResult, sizeof(szResult) / sizeof(WCHAR))) - SendDlgItemMessageW(hwndDlg, 14005, WM_SETTEXT, (WPARAM)NULL, (LPARAM)szResult); - - Result = GetFreeBytesShare(TotalNumberOfFreeBytes.QuadPart, TotalNumberOfBytes.QuadPart); - /* set free bytes percentage */ - swprintf(szResult, L"%02d%%", Result); - SendDlgItemMessageW(hwndDlg, 14006, WM_SETTEXT, (WPARAM)0, (LPARAM)szResult); - /* store used share amount */ - Result = 100 - Result; - swprintf(szResult, L"%02d%%", Result); - SendDlgItemMessageW(hwndDlg, 14004, WM_SETTEXT, (WPARAM)0, (LPARAM)szResult); - if (DriveType == DRIVE_FIXED) - { - if (LoadStringW(shell32_hInstance, IDS_DRIVE_FIXED, szBuffer, sizeof(szBuffer) / sizeof(WCHAR))) - SendDlgItemMessageW(hwndDlg, 14001, WM_SETTEXT, (WPARAM)0, (LPARAM)szBuffer); - } - else /* DriveType == DRIVE_CDROM) */ - { - if (LoadStringW(shell32_hInstance, IDS_DRIVE_CDROM, szBuffer, sizeof(szBuffer) / sizeof(WCHAR))) - SendDlgItemMessageW(hwndDlg, 14001, WM_SETTEXT, (WPARAM)0, (LPARAM)szBuffer); - } - } - } - /* set drive description */ - SendDlgItemMessageW(hwndDlg, 14009, WM_GETTEXT, (WPARAM)50, (LPARAM)szFormat); - swprintf(szBuffer, szFormat, szDrive); - SendDlgItemMessageW(hwndDlg, 14009, WM_SETTEXT, (WPARAM)NULL, (LPARAM)szBuffer); -} - - -INT_PTR -CALLBACK -DriveGeneralDlg( - HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam -) -{ - LPPROPSHEETPAGEW ppsp; - LPDRAWITEMSTRUCT drawItem; - STARTUPINFOW si; - PROCESS_INFORMATION pi; - WCHAR * lpstr; - WCHAR szPath[MAX_PATH]; - UINT length; - LPPSHNOTIFY lppsn; - - switch(uMsg) - { - case WM_INITDIALOG: - ppsp = (LPPROPSHEETPAGEW)lParam; - if (ppsp == NULL) - break; - lpstr = (WCHAR *)ppsp->lParam; - SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)lpstr); - InitializeGeneralDriveDialog(hwndDlg, lpstr); - return TRUE; - case WM_DRAWITEM: - drawItem = (LPDRAWITEMSTRUCT)lParam; - if (drawItem->CtlID >= 14013 && drawItem->CtlID <= 14015) - { - PaintStaticControls(hwndDlg, drawItem); - return TRUE; - } - break; - case WM_COMMAND: - if (LOWORD(wParam) == 14010) /* Disk Cleanup */ - { - lpstr = (WCHAR*)GetWindowLongPtr(hwndDlg, DWLP_USER); - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof(si); - ZeroMemory( &pi, sizeof(pi) ); - if (!GetSystemDirectoryW(szPath, MAX_PATH)) - break; - wcscat(szPath, L"\\cleanmgr.exe /D "); - length = wcslen(szPath); - szPath[length] = lpstr[0]; - szPath[length+1] = L'\0'; - if (CreateProcessW(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) - { - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - } - break; - } - case WM_NOTIFY: - lppsn = (LPPSHNOTIFY) lParam; - if (LOWORD(wParam) == 14000) - { - if (HIWORD(wParam) == EN_CHANGE) - { - PropSheet_Changed(GetParent(hwndDlg), hwndDlg); - } - break; - } - if (lppsn->hdr.code == PSN_APPLY) - { - lpstr = (LPWSTR)GetWindowLongPtr(hwndDlg, DWLP_USER); - if (lpstr && SendDlgItemMessageW(hwndDlg, 14000, WM_GETTEXT, sizeof(szPath)/sizeof(WCHAR), (LPARAM)szPath)) - { - szPath[(sizeof(szPath)/sizeof(WCHAR))-1] = L'\0'; - SetVolumeLabelW(lpstr, szPath); - } - SetWindowLongPtr( hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR ); - return TRUE; - } - break; - - default: - break; - } - - - return FALSE; -} - -INT_PTR -CALLBACK -DriveExtraDlg( - HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam -) -{ - STARTUPINFOW si; - PROCESS_INFORMATION pi; - WCHAR szPath[MAX_PATH + 10]; - WCHAR szArg[MAX_PATH]; - WCHAR * szDrive; - LPPROPSHEETPAGEW ppsp; - DWORD dwSize; - FORMAT_DRIVE_CONTEXT Context; - - switch (uMsg) - { - case WM_INITDIALOG: - ppsp = (LPPROPSHEETPAGEW)lParam; - SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)ppsp->lParam); - return TRUE; - case WM_COMMAND: - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof(si); - ZeroMemory( &pi, sizeof(pi) ); - - szDrive = (WCHAR*)GetWindowLongPtr(hwndDlg, DWLP_USER); - switch(LOWORD(wParam)) - { - case 14000: - if (InitializeFmifsLibrary(&Context)) - { - Context.Drive = szDrive[0]; - DialogBoxParamW(shell32_hInstance, L"CHKDSK_DLG", hwndDlg, ChkDskDlg, (LPARAM)&Context); - FreeLibrary(Context.hLibrary); - } - break; - case 14001: - dwSize = sizeof(szPath); - if (RegGetValueW(HKEY_LOCAL_MACHINE, - L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\DefragPath", - NULL, - RRF_RT_REG_EXPAND_SZ, - NULL, - (PVOID)szPath, - &dwSize) == S_OK) - { - swprintf(szArg, szPath, szDrive[0]); - if (!GetSystemDirectoryW(szPath, MAX_PATH)) - break; - szDrive = PathAddBackslashW(szPath); - if (!szDrive) - break; - - wcscat(szDrive, L"mmc.exe"); - if (CreateProcessW(szPath, szArg, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) - { - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - } - } - break; - case 14002: - dwSize = sizeof(szPath); - if (RegGetValueW(HKEY_LOCAL_MACHINE, - L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\BackupPath", - NULL, - RRF_RT_REG_EXPAND_SZ, - NULL, - (PVOID)szPath, - &dwSize) == S_OK) - { - if (CreateProcessW(szPath, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) - { - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - } - } - } - break; - } - return FALSE; -} - -INT_PTR -CALLBACK -DriveHardwareDlg( - HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam -) -{ - GUID Guids[1]; - Guids[0] = GUID_DEVCLASS_DISKDRIVE; - - UNREFERENCED_PARAMETER(lParam); - UNREFERENCED_PARAMETER(wParam); - - switch(uMsg) - { - case WM_INITDIALOG: - /* create the hardware page */ - DeviceCreateHardwarePageEx(hwndDlg, - Guids, - sizeof(Guids) / sizeof(Guids[0]), - 0); - break; - } - - return FALSE; -} - -static -const -struct -{ - LPSTR resname; - DLGPROC dlgproc; - UINT DriveType; -} PropPages[] = -{ - { "DRIVE_GENERAL_DLG", DriveGeneralDlg, -1}, - { "DRIVE_EXTRA_DLG", DriveExtraDlg, DRIVE_FIXED}, - { "DRIVE_HARDWARE_DLG", DriveHardwareDlg, -1}, -}; - -HRESULT -CALLBACK -AddPropSheetPageProc(HPROPSHEETPAGE hpage, LPARAM lParam) -{ - PROPSHEETHEADER *ppsh = (PROPSHEETHEADER *)lParam; - if (ppsh != NULL && ppsh->nPages < MAX_PROPERTY_SHEET_PAGE) - { - ppsh->u3.phpage[ppsh->nPages++] = hpage; - return TRUE; - } - return FALSE; -} - -BOOL -SH_ShowDriveProperties(WCHAR * drive, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST * apidl) -{ - HPSXA hpsx = NULL; - HPROPSHEETPAGE hpsp[MAX_PROPERTY_SHEET_PAGE]; - PROPSHEETHEADERW psh; - BOOL ret; - UINT i; - WCHAR szName[MAX_PATH+6]; - DWORD dwMaxComponent, dwFileSysFlags; - IDataObject * pDataObj = NULL; - UINT DriveType; - - ZeroMemory(&psh, sizeof(PROPSHEETHEADERW)); - psh.dwSize = sizeof(PROPSHEETHEADERW); - //psh.dwFlags = PSH_USECALLBACK | PSH_PROPTITLE; - psh.hwndParent = NULL; - psh.u2.nStartPage = 0; - psh.u3.phpage = hpsp; - - if (GetVolumeInformationW(drive, szName, sizeof(szName)/sizeof(WCHAR), NULL, &dwMaxComponent, - &dwFileSysFlags, NULL, 0)) - { - psh.pszCaption = szName; - psh.dwFlags |= PSH_PROPTITLE; - if (!wcslen(szName)) - { - /* FIXME - * check if disk is a really a local hdd - */ - i = LoadStringW(shell32_hInstance, IDS_DRIVE_FIXED, szName, sizeof(szName)/sizeof(WCHAR)-6); - if (i > 0 && i < (sizeof(szName)/sizeof(WCHAR)) - 6) - { - szName[i] = L' '; - szName[i+1] = L'('; - wcscpy(&szName[i+2], drive); - szName[i+4] = L')'; - szName[i+5] = L'\0'; - } - } - } - - DriveType = GetDriveTypeW(drive); - for (i = 0; i < DRIVE_PROPERTY_PAGES; i++) - { - if (PropPages[i].DriveType == (UINT)-1 || (PropPages[i].DriveType != (UINT)-1 && PropPages[i].DriveType == DriveType)) - { - HPROPSHEETPAGE hprop = SH_CreatePropertySheetPage(PropPages[i].resname, PropPages[i].dlgproc, (LPARAM)drive, NULL); - if (hprop) - { - hpsp[psh.nPages] = hprop; - psh.nPages++; - } - } - } - - if (SHCreateDataObject(pidlFolder, 1, apidl, NULL, &IID_IDataObject, (void**)&pDataObj) == S_OK) - { - hpsx = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, L"Drive", MAX_PROPERTY_SHEET_PAGE-DRIVE_PROPERTY_PAGES, pDataObj); - if (hpsx) - { - SHAddFromPropSheetExtArray(hpsx, (LPFNADDPROPSHEETPAGE)AddPropSheetPageProc, (LPARAM)&psh); - } - } - - ret = PropertySheetW(&psh); - if (pDataObj) - IDataObject_Release(pDataObj); - - if (hpsx) - SHDestroyPropSheetExtArray(hpsx); - - if (ret < 0) - return FALSE; - else - return TRUE; -} - -BOOL -GetDefaultClusterSize(LPWSTR szFs, PDWORD pClusterSize, PULARGE_INTEGER TotalNumberOfBytes) -{ - DWORD ClusterSize; - - if (!wcsicmp(szFs, L"FAT16") || - !wcsicmp(szFs, L"FAT")) //REACTOS HACK - { - if (TotalNumberOfBytes->QuadPart <= (16 * 1024 * 1024)) - ClusterSize = 2048; - else if (TotalNumberOfBytes->QuadPart <= (32 * 1024 * 1024)) - ClusterSize = 512; - else if (TotalNumberOfBytes->QuadPart <= (64 * 1024 * 1024)) - ClusterSize = 1024; - else if (TotalNumberOfBytes->QuadPart <= (128 * 1024 * 1024)) - ClusterSize = 2048; - else if (TotalNumberOfBytes->QuadPart <= (256 * 1024 * 1024)) - ClusterSize = 4096; - else if (TotalNumberOfBytes->QuadPart <= (512 * 1024 * 1024)) - ClusterSize = 8192; - else if (TotalNumberOfBytes->QuadPart <= (1024 * 1024 * 1024)) - ClusterSize = 16384; - else if (TotalNumberOfBytes->QuadPart <= (2048LL * 1024LL * 1024LL)) - ClusterSize = 32768; - else if (TotalNumberOfBytes->QuadPart <= (4096LL * 1024LL * 1024LL)) - ClusterSize = 8192; - else - return FALSE; - } - else if (!wcsicmp(szFs, L"FAT32")) - { - if (TotalNumberOfBytes->QuadPart <=(64 * 1024 * 1024)) - ClusterSize = 512; - else if (TotalNumberOfBytes->QuadPart <= (128 * 1024 * 1024)) - ClusterSize = 1024; - else if (TotalNumberOfBytes->QuadPart <= (256 * 1024 * 1024)) - ClusterSize = 2048; - else if (TotalNumberOfBytes->QuadPart <= (8192LL * 1024LL * 1024LL)) - ClusterSize = 2048; - else if (TotalNumberOfBytes->QuadPart <= (16384LL * 1024LL * 1024LL)) - ClusterSize = 8192; - else if (TotalNumberOfBytes->QuadPart <= (32768LL * 1024LL * 1024LL)) - ClusterSize = 16384; - else - return FALSE; - } - else if (!wcsicmp(szFs, L"NTFS")) - { - if (TotalNumberOfBytes->QuadPart <=(512 * 1024 * 1024)) - ClusterSize = 512; - else if (TotalNumberOfBytes->QuadPart <= (1024 * 1024 * 1024)) - ClusterSize = 1024; - else if (TotalNumberOfBytes->QuadPart <= (2048LL * 1024LL * 1024LL)) - ClusterSize = 2048; - else - ClusterSize = 2048; - } - else - return FALSE; - - *pClusterSize = ClusterSize; - return TRUE; -} - - -VOID -InsertDefaultClusterSizeForFs(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext) -{ - WCHAR szFs[100] = {0}; - WCHAR szDrive[4] = { L'C', ':', '\\', 0 }; - INT iSelIndex; - ULARGE_INTEGER FreeBytesAvailableUser, TotalNumberOfBytes; - DWORD ClusterSize; - LRESULT lIndex; - HWND hDlgCtrl; - - hDlgCtrl = GetDlgItem(hwndDlg, 28677); - iSelIndex = SendMessage(hDlgCtrl, CB_GETCURSEL, 0, 0); - if (iSelIndex == CB_ERR) - return; - - if (SendMessageW(hDlgCtrl, CB_GETLBTEXT, iSelIndex, (LPARAM)szFs) == CB_ERR) - return; - - szFs[(sizeof(szFs)/sizeof(WCHAR))-1] = L'\0'; - szDrive[0] = pContext->Drive + 'A'; - - if (!GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailableUser, &TotalNumberOfBytes, NULL)) - return; - - if (!wcsicmp(szFs, L"FAT16") || - !wcsicmp(szFs, L"FAT")) //REACTOS HACK - { - if (!GetDefaultClusterSize(szFs, &ClusterSize, &TotalNumberOfBytes)) - { - TRACE("FAT16 is not supported on hdd larger than 4G current %lu\n", TotalNumberOfBytes.QuadPart); - SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0); - return; - } - - if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, szFs, sizeof(szFs)/sizeof(WCHAR))) - { - hDlgCtrl = GetDlgItem(hwndDlg, 28680); - szFs[(sizeof(szFs)/sizeof(WCHAR))-1] = L'\0'; - SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0); - lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)szFs); - if (lIndex != CB_ERR) - SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize); - SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0); - } - } - else if (!wcsicmp(szFs, L"FAT32")) - { - if (!GetDefaultClusterSize(szFs, &ClusterSize, &TotalNumberOfBytes)) - { - TRACE("FAT32 is not supported on hdd larger than 32G current %lu\n", TotalNumberOfBytes.QuadPart); - SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0); - return; - } - - if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, szFs, sizeof(szFs)/sizeof(WCHAR))) - { - hDlgCtrl = GetDlgItem(hwndDlg, 28680); - szFs[(sizeof(szFs)/sizeof(WCHAR))-1] = L'\0'; - SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0); - lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)szFs); - if (lIndex != CB_ERR) - SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize); - SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0); - } - } - else if (!wcsicmp(szFs, L"NTFS")) - { - if (!GetDefaultClusterSize(szFs, &ClusterSize, &TotalNumberOfBytes)) - { - TRACE("NTFS is not supported on hdd larger than 2TB current %lu\n", TotalNumberOfBytes.QuadPart); - SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0); - return; - } - - hDlgCtrl = GetDlgItem(hwndDlg, 28680); - if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, szFs, sizeof(szFs)/sizeof(WCHAR))) - { - szFs[(sizeof(szFs)/sizeof(WCHAR))-1] = L'\0'; - SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0); - lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)szFs); - if (lIndex != CB_ERR) - SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize); - SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0); - } - ClusterSize = 512; - for (lIndex = 0; lIndex < 4; lIndex++) - { - TotalNumberOfBytes.QuadPart = ClusterSize; - if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, szFs, sizeof(szFs)/sizeof(WCHAR))) - { - lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)szFs); - if (lIndex != CB_ERR) - SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize); - } - ClusterSize *= 2; - } - } - else - { - FIXME("unknown fs\n"); - SendDlgItemMessageW(hwndDlg, 28680, CB_RESETCONTENT, iSelIndex, 0); - return; - } -} - -VOID -InitializeFormatDriveDlg(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext) -{ - WCHAR szText[120]; - WCHAR szDrive[4] = { L'C', ':', '\\', 0 }; - WCHAR szFs[30] = {0}; - INT Length, TempLength; - DWORD dwSerial, dwMaxComp, dwFileSys; - ULARGE_INTEGER FreeBytesAvailableUser, TotalNumberOfBytes; - DWORD dwIndex, dwDefault; - UCHAR uMinor, uMajor; - BOOLEAN Latest; - HWND hDlgCtrl; - - Length = GetWindowTextW(hwndDlg, szText, sizeof(szText)/sizeof(WCHAR)); - if (Length < 0) - Length = 0; - szDrive[0] = pContext->Drive + L'A'; - if (GetVolumeInformationW(szDrive, &szText[Length+1], (sizeof(szText)/sizeof(WCHAR))- Length - 2, &dwSerial, &dwMaxComp, &dwFileSys, szFs, sizeof(szFs)/sizeof(WCHAR))) - { - szText[Length] = L' '; - szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0'; - TempLength = wcslen(&szText[Length+1]); - if (!TempLength) - { - /* load default volume label */ - TempLength = LoadStringW(shell32_hInstance, IDS_DRIVE_FIXED, &szText[Length+1], (sizeof(szText)/sizeof(WCHAR))- Length - 2); - } - else - { - /* set volume label */ - szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0'; - SendDlgItemMessageW(hwndDlg, 28679, WM_SETTEXT, 0, (LPARAM)&szText[Length+1]); - } - Length += TempLength + 1; - } - - if (Length + 4 < (sizeof(szText)/sizeof(WCHAR))) - { - szText[Length] = L' '; - szText[Length+1] = L'('; - szText[Length+2] = szDrive[0]; - szText[Length+3] = L')'; - Length +=4; - } - - if (Length < (sizeof(szText)/sizeof(WCHAR))) - szText[Length] = L'\0'; - else - szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0'; - - /* set window text */ - SetWindowTextW(hwndDlg, szText); - - if (GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailableUser, &TotalNumberOfBytes, NULL)) - { - if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, szText, sizeof(szText)/sizeof(WCHAR))) - { - /* add drive capacity */ - szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0'; - SendDlgItemMessageW(hwndDlg, 28673, CB_ADDSTRING, 0, (LPARAM)szText); - SendDlgItemMessageW(hwndDlg, 28673, CB_SETCURSEL, 0, (LPARAM)0); - } - } - - if (pContext->Options & SHFMT_OPT_FULL) - { - /* check quick format button */ - SendDlgItemMessageW(hwndDlg, 28674, BM_SETCHECK, BST_CHECKED, 0); - } - - /* enumerate all available filesystems */ - dwIndex = 0; - dwDefault = 0; - hDlgCtrl = GetDlgItem(hwndDlg, 28677); - - while(pContext->QueryAvailableFileSystemFormat(dwIndex, szText, &uMajor, &uMinor, &Latest)) - { - szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0'; - if (!wcsicmp(szText, szFs)) - dwDefault = dwIndex; - - SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)szText); - dwIndex++; - } - - if (!dwIndex) - { - ERR("no filesystem providers\n"); - return; - } - - /* select default filesys */ - SendMessageW(hDlgCtrl, CB_SETCURSEL, dwDefault, 0); - /* setup cluster combo */ - InsertDefaultClusterSizeForFs(hwndDlg, pContext); - /* hide progress control */ - ShowWindow(GetDlgItem(hwndDlg, 28678), SW_HIDE); -} - -HWND FormatDrvDialog = NULL; -BOOLEAN bSuccess = FALSE; - - -BOOLEAN -NTAPI -FormatExCB( - IN CALLBACKCOMMAND Command, - IN ULONG SubAction, - IN PVOID ActionInfo) -{ - PDWORD Progress; - PBOOLEAN pSuccess; - switch(Command) - { - case PROGRESS: - Progress = (PDWORD)ActionInfo; - SendDlgItemMessageW(FormatDrvDialog, 28678, PBM_SETPOS, (WPARAM)*Progress, 0); - break; - case DONE: - pSuccess = (PBOOLEAN)ActionInfo; - bSuccess = (*pSuccess); - break; - - case VOLUMEINUSE: - case INSUFFICIENTRIGHTS: - case FSNOTSUPPORTED: - case CLUSTERSIZETOOSMALL: - bSuccess = FALSE; - FIXME("\n"); - break; - - default: - break; - } - - return TRUE; -} - - - - - -VOID -FormatDrive(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext) -{ - WCHAR szDrive[4] = { L'C', ':', '\\', 0 }; - WCHAR szFileSys[40] = {0}; - WCHAR szLabel[40] = {0}; - INT iSelIndex; - UINT Length; - HWND hDlgCtrl; - BOOL QuickFormat; - DWORD ClusterSize; - - /* set volume path */ - szDrive[0] = pContext->Drive; - - /* get filesystem */ - hDlgCtrl = GetDlgItem(hwndDlg, 28677); - iSelIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0); - if (iSelIndex == CB_ERR) - { - FIXME("\n"); - return; - } - Length = SendMessageW(hDlgCtrl, CB_GETLBTEXTLEN, iSelIndex, 0); - if (Length == CB_ERR || Length + 1> sizeof(szFileSys)/sizeof(WCHAR)) - { - FIXME("\n"); - return; - } - - /* retrieve the file system */ - SendMessageW(hDlgCtrl, CB_GETLBTEXT, iSelIndex, (LPARAM)szFileSys); - szFileSys[(sizeof(szFileSys)/sizeof(WCHAR))-1] = L'\0'; - - /* retrieve the volume label */ - hDlgCtrl = GetWindow(hwndDlg, 28679); - Length = SendMessageW(hDlgCtrl, WM_GETTEXTLENGTH, 0, 0); - if (Length + 1 > sizeof(szLabel)/sizeof(WCHAR)) - { - FIXME("\n"); - return; - } - SendMessageW(hDlgCtrl, WM_GETTEXT, sizeof(szLabel)/sizeof(WCHAR), (LPARAM)szLabel); - szLabel[(sizeof(szLabel)/sizeof(WCHAR))-1] = L'\0'; - - /* check for quickformat */ - if (SendDlgItemMessageW(hwndDlg, 28674, BM_GETCHECK, 0, 0) == BST_CHECKED) - QuickFormat = TRUE; - else - QuickFormat = FALSE; - - /* get the cluster size */ - hDlgCtrl = GetDlgItem(hwndDlg, 28680); - iSelIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0); - if (iSelIndex == CB_ERR) - { - FIXME("\n"); - return; - } - ClusterSize = SendMessageW(hDlgCtrl, CB_GETITEMDATA, iSelIndex, 0); - if (ClusterSize == CB_ERR) - { - FIXME("\n"); - return; - } - - hDlgCtrl = GetDlgItem(hwndDlg, 28680); - ShowWindow(hDlgCtrl, SW_SHOW); - SendMessageW(hDlgCtrl, PBM_SETRANGE, 0, MAKELPARAM(0, 100)); - bSuccess = FALSE; - - /* FIXME - * will cause display problems - * when performing more than one format - */ - FormatDrvDialog = hwndDlg; - - pContext->FormatEx(szDrive, - FMIFS_HARDDISK, /* FIXME */ - szFileSys, - szLabel, - QuickFormat, - ClusterSize, - FormatExCB); - - ShowWindow(hDlgCtrl, SW_HIDE); - FormatDrvDialog = NULL; - if (!bSuccess) - { - pContext->Result = SHFMT_ERROR; - } - else if (QuickFormat) - { - pContext->Result = SHFMT_OPT_FULL; - } - else - { - pContext->Result = FALSE; - } -} - - -BOOL -CALLBACK -FormatDriveDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - PFORMAT_DRIVE_CONTEXT pContext; - - switch(uMsg) - { - case WM_INITDIALOG: - InitializeFormatDriveDlg(hwndDlg, (PFORMAT_DRIVE_CONTEXT)lParam); - SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)lParam); - return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDOK: - pContext = (PFORMAT_DRIVE_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER); - FormatDrive(hwndDlg, pContext); - break; - case IDCANCEL: - pContext = (PFORMAT_DRIVE_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER); - EndDialog(hwndDlg, pContext->Result); - break; - case 28677: // filesystem combo - if (HIWORD(wParam) == CBN_SELENDOK) - { - pContext = (PFORMAT_DRIVE_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER); - InsertDefaultClusterSizeForFs(hwndDlg, pContext); - } - break; - } - } - return FALSE; -} - - -BOOL -InitializeFmifsLibrary(PFORMAT_DRIVE_CONTEXT pContext) -{ - INITIALIZE_FMIFS InitFmifs; - BOOLEAN ret; - HMODULE hLibrary; - - hLibrary = pContext->hLibrary = LoadLibraryW(L"fmifs.dll"); - if(!hLibrary) - { - ERR("failed to load fmifs.dll\n"); - return FALSE; - } - - InitFmifs = (INITIALIZE_FMIFS)GetProcAddress(hLibrary, "InitializeFmIfs"); - if (!InitFmifs) - { - ERR("InitializeFmIfs export is missing\n"); - FreeLibrary(hLibrary); - return FALSE; - } - - ret = (*InitFmifs)(NULL, DLL_PROCESS_ATTACH, NULL); - if (!ret) - { - ERR("fmifs failed to initialize\n"); - FreeLibrary(hLibrary); - return FALSE; - } - - pContext->QueryAvailableFileSystemFormat = (QUERY_AVAILABLEFSFORMAT)GetProcAddress(hLibrary, "QueryAvailableFileSystemFormat"); - if (!pContext->QueryAvailableFileSystemFormat) - { - ERR("QueryAvailableFileSystemFormat export is missing\n"); - FreeLibrary(hLibrary); - return FALSE; - } - - pContext->FormatEx = (FORMAT_EX) GetProcAddress(hLibrary, "FormatEx"); - if (!pContext->FormatEx) - { - ERR("FormatEx export is missing\n"); - FreeLibrary(hLibrary); - return FALSE; - } - - pContext->EnableVolumeCompression = (ENABLEVOLUMECOMPRESSION) GetProcAddress(hLibrary, "EnableVolumeCompression"); - if (!pContext->FormatEx) - { - ERR("EnableVolumeCompression export is missing\n"); - FreeLibrary(hLibrary); - return FALSE; - } - - pContext->Chkdsk = (CHKDSK) GetProcAddress(hLibrary, "Chkdsk"); - if (!pContext->Chkdsk) - { - ERR("Chkdsk export is missing\n"); - FreeLibrary(hLibrary); - return FALSE; - } - - return TRUE; -} - -/************************************************************************* - * SHFormatDrive (SHELL32.@) - */ - -DWORD -WINAPI -SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options) -{ - FORMAT_DRIVE_CONTEXT Context; - int result; - - TRACE("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options); - - if (!InitializeFmifsLibrary(&Context)) - { - ERR("failed to initialize fmifs\n"); - return SHFMT_NOFORMAT; - } - - Context.Drive = drive; - Context.Options = options; - - result = DialogBoxParamW(shell32_hInstance, L"FORMAT_DLG", hwnd, FormatDriveDlg, (LPARAM)&Context); - - FreeLibrary(Context.hLibrary); - return result; -} - - diff --git a/reactos/dll/win32/shell32/enumidlist.c b/reactos/dll/win32/shell32/enumidlist.c deleted file mode 100644 index 22daeaf1720..00000000000 --- a/reactos/dll/win32/shell32/enumidlist.c +++ /dev/null @@ -1,388 +0,0 @@ -/* - * IEnumIDList - * - * Copyright 1998 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -typedef struct tagENUMLIST -{ - struct tagENUMLIST *pNext; - LPITEMIDLIST pidl; - -} ENUMLIST, *LPENUMLIST; - -typedef struct -{ - const IEnumIDListVtbl *lpVtbl; - LONG ref; - LPENUMLIST mpFirst; - LPENUMLIST mpLast; - LPENUMLIST mpCurrent; - -} IEnumIDListImpl; - -static const IEnumIDListVtbl eidlvt; - -/************************************************************************** - * AddToEnumList() - */ -BOOL AddToEnumList( - IEnumIDList * iface, - LPITEMIDLIST pidl) -{ - IEnumIDListImpl *This = (IEnumIDListImpl *)iface; - - LPENUMLIST pNew; - - TRACE("(%p)->(pidl=%p)\n",This,pidl); - - if (!iface || !pidl) - return FALSE; - - pNew = (LPENUMLIST)SHAlloc(sizeof(ENUMLIST)); - if(pNew) - { - /*set the next pointer */ - pNew->pNext = NULL; - pNew->pidl = pidl; - - /*is This the first item in the list? */ - if(!This->mpFirst) - { - This->mpFirst = pNew; - This->mpCurrent = pNew; - } - - if(This->mpLast) - { - /*add the new item to the end of the list */ - This->mpLast->pNext = pNew; - } - - /*update the last item pointer */ - This->mpLast = pNew; - TRACE("-- (%p)->(first=%p, last=%p)\n",This,This->mpFirst,This->mpLast); - return TRUE; - } - return FALSE; -} -/************************************************************************** - * HasItemWithCLSID() - */ -BOOL HasItemWithCLSID(IEnumIDList *iface, LPITEMIDLIST pidl) -{ - IEnumIDListImpl *This = (IEnumIDListImpl *)iface; - LPENUMLIST pCur; - REFIID refid = _ILGetGUIDPointer(pidl); - - pCur = This->mpFirst; - - while(pCur) - { - LPGUID curid = _ILGetGUIDPointer(pCur->pidl); - if (curid && IsEqualGUID(curid, refid)) - { - return TRUE; - } - pCur = pCur->pNext; - } - return FALSE; -} - - -/************************************************************************** - * CreateFolderEnumList() - */ -BOOL CreateFolderEnumList( - IEnumIDList *list, - LPCWSTR lpszPath, - DWORD dwFlags) -{ - LPITEMIDLIST pidl=NULL; - WIN32_FIND_DATAW stffile; - HANDLE hFile; - WCHAR szPath[MAX_PATH]; - BOOL succeeded = TRUE; - static const WCHAR stars[] = { '*','.','*',0 }; - static const WCHAR dot[] = { '.',0 }; - static const WCHAR dotdot[] = { '.','.',0 }; - - TRACE("(%p)->(path=%s flags=0x%08x)\n", list, debugstr_w(lpszPath), dwFlags); - - if(!lpszPath || !lpszPath[0]) return FALSE; - - wcscpy(szPath, lpszPath); - PathAddBackslashW(szPath); - wcscat(szPath,stars); - - hFile = FindFirstFileW(szPath,&stffile); - if ( hFile != INVALID_HANDLE_VALUE ) - { - BOOL findFinished = FALSE; - - do - { - if ( !(stffile.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) - || (dwFlags & SHCONTF_INCLUDEHIDDEN) ) - { - if ( (stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - dwFlags & SHCONTF_FOLDERS && - strcmpW(stffile.cFileName, dot) && strcmpW(stffile.cFileName, dotdot)) - { - pidl = _ILCreateFromFindDataW(&stffile); - succeeded = succeeded && AddToEnumList(list, pidl); - } - else if (!(stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - && dwFlags & SHCONTF_NONFOLDERS) - { - pidl = _ILCreateFromFindDataW(&stffile); - succeeded = succeeded && AddToEnumList(list, pidl); - } - } - if (succeeded) - { - if (!FindNextFileW(hFile, &stffile)) - { - if (GetLastError() == ERROR_NO_MORE_FILES) - findFinished = TRUE; - else - succeeded = FALSE; - } - } - } while (succeeded && !findFinished); - FindClose(hFile); - } - return succeeded; -} - -/************************************************************************** -* DeleteList() -*/ -static BOOL DeleteList( - IEnumIDList * iface) -{ - IEnumIDListImpl *This = (IEnumIDListImpl *)iface; - - LPENUMLIST pDelete; - - TRACE("(%p)->()\n",This); - - while(This->mpFirst) - { pDelete = This->mpFirst; - This->mpFirst = pDelete->pNext; - SHFree(pDelete->pidl); - SHFree(pDelete); - } - This->mpFirst = This->mpLast = This->mpCurrent = NULL; - return TRUE; -} - -/************************************************************************** - * IEnumIDList_Folder_Constructor - * - */ - -IEnumIDList * IEnumIDList_Constructor(void) -{ - IEnumIDListImpl *lpeidl = HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, sizeof(IEnumIDListImpl)); - - if (lpeidl) - { - lpeidl->ref = 1; - lpeidl->lpVtbl = &eidlvt; - } - TRACE("-- (%p)->()\n",lpeidl); - - return (IEnumIDList*)lpeidl; -} - -/************************************************************************** - * EnumIDList_QueryInterface - */ -static HRESULT WINAPI IEnumIDList_fnQueryInterface( - IEnumIDList * iface, - REFIID riid, - LPVOID *ppvObj) -{ - IEnumIDListImpl *This = (IEnumIDListImpl *)iface; - - TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj); - - *ppvObj = NULL; - - if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/ - { *ppvObj = This; - } - else if(IsEqualIID(riid, &IID_IEnumIDList)) /*IEnumIDList*/ - { *ppvObj = (IEnumIDList*)This; - } - - if(*ppvObj) - { IEnumIDList_AddRef((IEnumIDList*)*ppvObj); - TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj); - return S_OK; - } - - TRACE("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -/****************************************************************************** - * IEnumIDList_fnAddRef - */ -static ULONG WINAPI IEnumIDList_fnAddRef( - IEnumIDList * iface) -{ - IEnumIDListImpl *This = (IEnumIDListImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE("(%p)->(%u)\n", This, refCount - 1); - - return refCount; -} -/****************************************************************************** - * IEnumIDList_fnRelease - */ -static ULONG WINAPI IEnumIDList_fnRelease( - IEnumIDList * iface) -{ - IEnumIDListImpl *This = (IEnumIDListImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(%u)\n", This, refCount + 1); - - if (!refCount) { - TRACE(" destroying IEnumIDList(%p)\n",This); - DeleteList((IEnumIDList*)This); - HeapFree(GetProcessHeap(),0,This); - } - return refCount; -} - -/************************************************************************** - * IEnumIDList_fnNext - */ - -static HRESULT WINAPI IEnumIDList_fnNext( - IEnumIDList * iface, - ULONG celt, - LPITEMIDLIST * rgelt, - ULONG *pceltFetched) -{ - IEnumIDListImpl *This = (IEnumIDListImpl *)iface; - - ULONG i; - HRESULT hr = S_OK; - LPITEMIDLIST temp; - - TRACE("(%p)->(%d,%p, %p)\n",This,celt,rgelt,pceltFetched); - -/* It is valid to leave pceltFetched NULL when celt is 1. Some of explorer's - * subsystems actually use it (and so may a third party browser) - */ - if(pceltFetched) - *pceltFetched = 0; - - *rgelt=0; - - if(celt > 1 && !pceltFetched) - { return E_INVALIDARG; - } - - if(celt > 0 && !This->mpCurrent) - { return S_FALSE; - } - - for(i = 0; i < celt; i++) - { if(!(This->mpCurrent)) - break; - - temp = ILClone(This->mpCurrent->pidl); - rgelt[i] = temp; - This->mpCurrent = This->mpCurrent->pNext; - } - if(pceltFetched) - { *pceltFetched = i; - } - - return hr; -} - -/************************************************************************** -* IEnumIDList_fnSkip -*/ -static HRESULT WINAPI IEnumIDList_fnSkip( - IEnumIDList * iface,ULONG celt) -{ - IEnumIDListImpl *This = (IEnumIDListImpl *)iface; - - DWORD dwIndex; - HRESULT hr = S_OK; - - TRACE("(%p)->(%u)\n",This,celt); - - for(dwIndex = 0; dwIndex < celt; dwIndex++) - { if(!This->mpCurrent) - { hr = S_FALSE; - break; - } - This->mpCurrent = This->mpCurrent->pNext; - } - return hr; -} -/************************************************************************** -* IEnumIDList_fnReset -*/ -static HRESULT WINAPI IEnumIDList_fnReset( - IEnumIDList * iface) -{ - IEnumIDListImpl *This = (IEnumIDListImpl *)iface; - - TRACE("(%p)\n",This); - This->mpCurrent = This->mpFirst; - return S_OK; -} -/************************************************************************** -* IEnumIDList_fnClone -*/ -static HRESULT WINAPI IEnumIDList_fnClone( - IEnumIDList * iface,LPENUMIDLIST * ppenum) -{ - IEnumIDListImpl *This = (IEnumIDListImpl *)iface; - - TRACE("(%p)->() to (%p)->() E_NOTIMPL\n",This,ppenum); - return E_NOTIMPL; -} - -/************************************************************************** - * IEnumIDList_fnVTable - */ -static const IEnumIDListVtbl eidlvt = -{ - IEnumIDList_fnQueryInterface, - IEnumIDList_fnAddRef, - IEnumIDList_fnRelease, - IEnumIDList_fnNext, - IEnumIDList_fnSkip, - IEnumIDList_fnReset, - IEnumIDList_fnClone, -}; diff --git a/reactos/dll/win32/shell32/extracticon.c b/reactos/dll/win32/shell32/extracticon.c deleted file mode 100644 index 576d46195b2..00000000000 --- a/reactos/dll/win32/shell32/extracticon.c +++ /dev/null @@ -1,546 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS Registry namespace extension - * FILE: dll/win32/shell32/extracticon.c - * PURPOSE: Icon extraction - * - * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org) - */ - -#include - -#define CONST_VTABLE - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -struct IconLocation -{ - LPWSTR file; - UINT index; -}; - -struct IconExtraction -{ - LONG ref; - IDefaultExtractIconInit defaultExtractIconInitImpl; - IExtractIconW extractIconWImpl; - IExtractIconA extractIconAImpl; - IPersistFile persistFileImpl; - - UINT flags; - struct IconLocation defaultIcon; - struct IconLocation normalIcon; - struct IconLocation openIcon; - struct IconLocation shortcutIcon; -}; - -static VOID -DuplicateString( - LPCWSTR Source, - LPWSTR *Destination) -{ - SIZE_T cb; - - if (*Destination) - CoTaskMemFree(*Destination); - - cb = (wcslen(Source) + 1) * sizeof(WCHAR); - *Destination = CoTaskMemAlloc(cb); - if (!*Destination) - return; - CopyMemory(*Destination, Source, cb); -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_DefaultExtractIconInit_QueryInterface( - IDefaultExtractIconInit *This, - REFIID riid, - void **ppvObject) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, defaultExtractIconInitImpl); - - TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppvObject); - - if (!ppvObject) - return E_POINTER; - - if (IsEqualIID(riid, &IID_IUnknown)) - *ppvObject = &s->defaultExtractIconInitImpl; - else if (IsEqualIID(riid, &IID_IDefaultExtractIconInit)) - *ppvObject = &s->defaultExtractIconInitImpl; - else if (IsEqualIID(riid, &IID_IExtractIconW)) - *ppvObject = &s->extractIconWImpl; - else if (IsEqualIID(riid, &IID_IExtractIconA)) - *ppvObject = &s->extractIconAImpl; - else if (IsEqualIID(riid, &IID_IPersist)) - *ppvObject = &s->persistFileImpl; - else if (IsEqualIID(riid, &IID_IPersistFile)) - *ppvObject = &s->persistFileImpl; - else - { - *ppvObject = NULL; - return E_NOINTERFACE; - } - - IUnknown_AddRef(This); - return S_OK; -} - -static ULONG STDMETHODCALLTYPE -IconExtraction_DefaultExtractIconInit_AddRef( - IDefaultExtractIconInit *This) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, defaultExtractIconInitImpl); - ULONG refCount = InterlockedIncrement(&s->ref); - TRACE("(%p)\n", This); - return refCount; -} - -static ULONG STDMETHODCALLTYPE -IconExtraction_DefaultExtractIconInit_Release( - IDefaultExtractIconInit *This) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, defaultExtractIconInitImpl); - ULONG refCount; - - TRACE("(%p)\n", This); - - refCount = InterlockedDecrement(&s->ref); - if (refCount == 0) - { - if (s->defaultIcon.file) CoTaskMemFree(s->defaultIcon.file); - if (s->normalIcon.file) CoTaskMemFree(s->normalIcon.file); - if (s->openIcon.file) CoTaskMemFree(s->openIcon.file); - if (s->shortcutIcon.file) CoTaskMemFree(s->shortcutIcon.file); - CoTaskMemFree(s); - } - - return refCount; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_DefaultExtractIconInit_SetDefaultIcon( - IDefaultExtractIconInit *This, - LPCWSTR pszFile, - int iIcon) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, defaultExtractIconInitImpl); - - TRACE("(%p, %s, %d)\n", This, debugstr_w(pszFile), iIcon); - - DuplicateString(pszFile, &s->defaultIcon.file); - if (!s->defaultIcon.file) - return E_OUTOFMEMORY; - s->defaultIcon.index = iIcon; - return S_OK; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_DefaultExtractIconInit_SetFlags( - IDefaultExtractIconInit *This, - UINT uFlags) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, defaultExtractIconInitImpl); - - TRACE("(%p, 0x%x)\n", This, uFlags); - - s->flags = uFlags; - return S_OK; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_DefaultExtractIconInit_SetKey( - IDefaultExtractIconInit *This, - HKEY hkey) -{ - FIXME("(%p, %p)\n", This, hkey); - UNIMPLEMENTED; - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_DefaultExtractIconInit_SetNormalIcon( - IDefaultExtractIconInit *This, - LPCWSTR pszFile, - int iIcon) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, defaultExtractIconInitImpl); - - TRACE("(%p, %s, %d)\n", This, debugstr_w(pszFile), iIcon); - - DuplicateString(pszFile, &s->normalIcon.file); - if (!s->normalIcon.file) - return E_OUTOFMEMORY; - s->normalIcon.index = iIcon; - return S_OK; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_DefaultExtractIconInit_SetOpenIcon( - IDefaultExtractIconInit *This, - LPCWSTR pszFile, - int iIcon) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, defaultExtractIconInitImpl); - - TRACE("(%p, %s, %d)\n", This, debugstr_w(pszFile), iIcon); - - DuplicateString(pszFile, &s->openIcon.file); - if (!s->openIcon.file) - return E_OUTOFMEMORY; - s->openIcon.index = iIcon; - return S_OK; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_DefaultExtractIconInit_SetShortcutIcon( - IDefaultExtractIconInit *This, - LPCWSTR pszFile, - int iIcon) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, defaultExtractIconInitImpl); - - TRACE("(%p, %s, %d)\n", This, debugstr_w(pszFile), iIcon); - - DuplicateString(pszFile, &s->shortcutIcon.file); - if (!s->shortcutIcon.file) - return E_OUTOFMEMORY; - s->shortcutIcon.index = iIcon; - return S_OK; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_ExtractIconW_QueryInterface( - IExtractIconW *This, - REFIID riid, - void **ppvObject) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, extractIconWImpl); - return IconExtraction_DefaultExtractIconInit_QueryInterface(&s->defaultExtractIconInitImpl, riid, ppvObject); -} - -static ULONG STDMETHODCALLTYPE -IconExtraction_ExtractIconW_AddRef( - IExtractIconW *This) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, extractIconWImpl); - return IconExtraction_DefaultExtractIconInit_AddRef(&s->defaultExtractIconInitImpl); -} - -static ULONG STDMETHODCALLTYPE -IconExtraction_ExtractIconW_Release( - IExtractIconW *This) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, extractIconWImpl); - return IconExtraction_DefaultExtractIconInit_Release(&s->defaultExtractIconInitImpl); -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_ExtractIconW_GetIconLocation( - IExtractIconW *This, - UINT uFlags, - LPWSTR szIconFile, - UINT cchMax, - int *piIndex, - UINT *pwFlags) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, extractIconWImpl); - const struct IconLocation *icon = NULL; - SIZE_T cb; - - TRACE("(%p, 0x%x, %s, 0x%x, %p, %p)\n", This, uFlags, debugstr_w(szIconFile), cchMax, piIndex, pwFlags); - - if (!piIndex || !pwFlags) - return E_POINTER; - - if (uFlags & GIL_DEFAULTICON) - icon = s->defaultIcon.file ? &s->defaultIcon : &s->normalIcon; - else if (uFlags & GIL_FORSHORTCUT) - icon = s->shortcutIcon.file ? &s->shortcutIcon : &s->normalIcon; - else if (uFlags & GIL_OPENICON) - icon = s->openIcon.file ? &s->openIcon : &s->normalIcon; - else - icon = &s->normalIcon; - - if (!icon->file) - return E_FAIL; - - cb = wcslen(icon->file) + 1; - if (cchMax < (UINT)cb) - return E_FAIL; - CopyMemory(szIconFile, icon->file, cb * sizeof(WCHAR)); - *piIndex = icon->index; - *pwFlags = s->flags; - return S_OK; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_ExtractIconW_Extract( - IExtractIconW *This, - LPCWSTR pszFile, - UINT nIconIndex, - HICON *phiconLarge, - HICON *phiconSmall, - UINT nIconSize) -{ - TRACE("(%p, %s, %u, %p, %p, %u)\n", This, debugstr_w(pszFile), - nIconIndex, phiconLarge, phiconSmall, nIconSize); - - /* Nothing to do, ExtractIconW::GetIconLocation should be enough */ - return S_FALSE; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_ExtractIconA_QueryInterface( - IExtractIconA *This, - REFIID riid, - void **ppvObject) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, extractIconAImpl); - return IconExtraction_DefaultExtractIconInit_QueryInterface(&s->defaultExtractIconInitImpl, riid, ppvObject); -} - -static ULONG STDMETHODCALLTYPE -IconExtraction_ExtractIconA_AddRef( - IExtractIconA *This) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, extractIconAImpl); - return IconExtraction_DefaultExtractIconInit_AddRef(&s->defaultExtractIconInitImpl); -} - -static ULONG STDMETHODCALLTYPE -IconExtraction_ExtractIconA_Release( - IExtractIconA *This) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, extractIconAImpl); - return IconExtraction_DefaultExtractIconInit_Release(&s->defaultExtractIconInitImpl); -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_ExtractIconA_GetIconLocation( - IExtractIconA *This, - UINT uFlags, - LPSTR szIconFile, - UINT cchMax, - int *piIndex, - UINT *pwFlags) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, extractIconAImpl); - LPWSTR szIconFileW = NULL; - HRESULT hr; - - if (cchMax > 0) - { - szIconFileW = CoTaskMemAlloc(cchMax * sizeof(WCHAR)); - if (!szIconFileW) - return E_OUTOFMEMORY; - } - - hr = IconExtraction_ExtractIconW_GetIconLocation( - &s->extractIconWImpl, uFlags, szIconFileW, cchMax, piIndex, pwFlags); - if (SUCCEEDED(hr) && cchMax > 0) - if (0 == WideCharToMultiByte(CP_ACP, 0, szIconFileW, cchMax, szIconFile, cchMax, NULL, NULL)) - hr = E_FAIL; - - if (szIconFileW) - CoTaskMemFree(szIconFileW); - return hr; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_ExtractIconA_Extract( - IExtractIconA *This, - LPCSTR pszFile, - UINT nIconIndex, - HICON *phiconLarge, - HICON *phiconSmall, - UINT nIconSize) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, extractIconAImpl); - LPWSTR pszFileW = NULL; - int nLength; - HRESULT hr; - - if (pszFile) - { - nLength = MultiByteToWideChar(CP_ACP, 0, pszFile, -1, NULL, 0); - if (nLength == 0) - return E_FAIL; - pszFileW = CoTaskMemAlloc(nLength * sizeof(WCHAR)); - if (!pszFileW) - return E_OUTOFMEMORY; - if (!MultiByteToWideChar(CP_ACP, 0, pszFile, nLength, pszFileW, nLength)) - { - CoTaskMemFree(pszFileW); - return E_FAIL; - } - } - - hr = IconExtraction_ExtractIconW_Extract( - &s->extractIconWImpl, pszFileW, nIconIndex, phiconLarge, phiconSmall, nIconSize); - - if (pszFileW) - CoTaskMemFree(pszFileW); - return hr; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_PersistFile_QueryInterface( - IPersistFile *This, - REFIID riid, - void **ppvObject) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, persistFileImpl); - return IconExtraction_DefaultExtractIconInit_QueryInterface(&s->defaultExtractIconInitImpl, riid, ppvObject); -} - -static ULONG STDMETHODCALLTYPE -IconExtraction_PersistFile_AddRef( - IPersistFile *This) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, persistFileImpl); - return IconExtraction_DefaultExtractIconInit_AddRef(&s->defaultExtractIconInitImpl); -} - -static ULONG STDMETHODCALLTYPE -IconExtraction_PersistFile_Release( - IPersistFile *This) -{ - struct IconExtraction *s = CONTAINING_RECORD(This, struct IconExtraction, persistFileImpl); - return IconExtraction_DefaultExtractIconInit_Release(&s->defaultExtractIconInitImpl); -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_PersistFile_GetClassID( - IPersistFile *This, - CLSID *pClassID) -{ - TRACE("(%p, %p)\n", This, pClassID); - - if (!pClassID) - return E_POINTER; - - *pClassID = GUID_NULL; - return S_OK; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_PersistFile_IsDirty( - IPersistFile *This) -{ - FIXME("(%p)\n", This); - UNIMPLEMENTED; - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_PersistFile_Load( - IPersistFile *This, - LPCOLESTR pszFileName, - DWORD dwMode) -{ - FIXME("(%p, %s, %u)\n", This, debugstr_w(pszFileName), dwMode); - UNIMPLEMENTED; - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_PersistFile_Save( - IPersistFile *This, - LPCOLESTR pszFileName, - BOOL fRemember) -{ - FIXME("(%p, %s, %d)\n", This, debugstr_w(pszFileName), fRemember); - UNIMPLEMENTED; - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_PersistFile_SaveCompleted( - IPersistFile *This, - LPCOLESTR pszFileName) -{ - FIXME("(%p, %s)\n", This, debugstr_w(pszFileName)); - UNIMPLEMENTED; - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE -IconExtraction_PersistFile_GetCurFile( - IPersistFile *This, - LPOLESTR *ppszFileName) -{ - FIXME("(%p, %p)\n", This, ppszFileName); - UNIMPLEMENTED; - return E_NOTIMPL; -} - -static const IDefaultExtractIconInitVtbl IconExtractionDefaultExtractIconInitVtbl = -{ - IconExtraction_DefaultExtractIconInit_QueryInterface, - IconExtraction_DefaultExtractIconInit_AddRef, - IconExtraction_DefaultExtractIconInit_Release, - IconExtraction_DefaultExtractIconInit_SetDefaultIcon, - IconExtraction_DefaultExtractIconInit_SetFlags, - IconExtraction_DefaultExtractIconInit_SetKey, - IconExtraction_DefaultExtractIconInit_SetNormalIcon, - IconExtraction_DefaultExtractIconInit_SetOpenIcon, - IconExtraction_DefaultExtractIconInit_SetShortcutIcon, -}; - -static const IExtractIconWVtbl IconExtractionExtractIconWVtbl = -{ - IconExtraction_ExtractIconW_QueryInterface, - IconExtraction_ExtractIconW_AddRef, - IconExtraction_ExtractIconW_Release, - IconExtraction_ExtractIconW_GetIconLocation, - IconExtraction_ExtractIconW_Extract, -}; - -static const IExtractIconAVtbl IconExtractionExtractIconAVtbl = -{ - IconExtraction_ExtractIconA_QueryInterface, - IconExtraction_ExtractIconA_AddRef, - IconExtraction_ExtractIconA_Release, - IconExtraction_ExtractIconA_GetIconLocation, - IconExtraction_ExtractIconA_Extract, -}; - -static const IPersistFileVtbl IconExtractionPersistFileVtbl = -{ - IconExtraction_PersistFile_QueryInterface, - IconExtraction_PersistFile_AddRef, - IconExtraction_PersistFile_Release, - IconExtraction_PersistFile_GetClassID, - IconExtraction_PersistFile_IsDirty, - IconExtraction_PersistFile_Load, - IconExtraction_PersistFile_Save, - IconExtraction_PersistFile_SaveCompleted, - IconExtraction_PersistFile_GetCurFile, -}; - -HRESULT WINAPI -SHCreateDefaultExtractIcon( - REFIID riid, - void **ppv) -{ - struct IconExtraction *s; - - if (!ppv) - return E_POINTER; - - *ppv = NULL; - - s = CoTaskMemAlloc(sizeof(struct IconExtraction)); - if (!s) - return E_OUTOFMEMORY; - memset(s, 0, sizeof(struct IconExtraction)); - s->defaultExtractIconInitImpl.lpVtbl = (IDefaultExtractIconInitVtbl*)&IconExtractionDefaultExtractIconInitVtbl; - s->extractIconAImpl.lpVtbl = (IExtractIconAVtbl*)&IconExtractionExtractIconAVtbl; - s->extractIconWImpl.lpVtbl = (IExtractIconWVtbl*)&IconExtractionExtractIconWVtbl; - s->persistFileImpl.lpVtbl = (IPersistFileVtbl*)&IconExtractionPersistFileVtbl; - s->ref = 1; - *ppv = &s->defaultExtractIconInitImpl; - - return S_OK; -} diff --git a/reactos/dll/win32/shell32/folder_options.c b/reactos/dll/win32/shell32/folder_options.c deleted file mode 100644 index 3d72018dbd3..00000000000 --- a/reactos/dll/win32/shell32/folder_options.c +++ /dev/null @@ -1,829 +0,0 @@ -/* - * Open With Context Menu extension - * - * Copyright 2007 Johannes Anderwald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - - -WINE_DEFAULT_DEBUG_CHANNEL (fprop); -#define MAX_PROPERTY_SHEET_PAGE (32) - -/// Folder Options: -/// CLASSKEY = HKEY_CLASSES_ROOT\CLSID\{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF} -/// DefaultIcon = %SystemRoot%\system32\SHELL32.dll,-210 -/// Verbs: Open / RunAs -/// Cmd: rundll32.exe shell32.dll,Options_RunDLL 0 - -/// ShellFolder Attributes: 0x0 - -typedef struct -{ - DWORD cFiles; - DWORD cFolder; - LARGE_INTEGER bSize; - HWND hwndDlg; - WCHAR szFolderPath[MAX_PATH]; -}FOLDER_PROPERTIES_CONTEXT, *PFOLDER_PROPERTIES_CONTEXT; - -typedef struct -{ - WCHAR FileExtension[30]; - WCHAR FileDescription[100]; - WCHAR ClassKey[MAX_PATH]; -}FOLDER_FILE_TYPE_ENTRY, *PFOLDER_FILE_TYPE_ENTRY; - -typedef struct -{ - LPCWSTR szKeyName; - UINT ResourceID; -}FOLDER_VIEW_ENTRY, PFOLDER_VIEW_ENTRY; -/* -static FOLDER_VIEW_ENTRY s_Options[] = -{ - { L"AlwaysShowMenus", IDS_ALWAYSSHOWMENUS }, - { L"AutoCheckSelect", -1 }, - { L"ClassicViewState", -1 }, - { L"DontPrettyPath", -1 }, - { L"Filter", -1 }, - { L"FolderContentsInfoTip", IDS_FOLDERCONTENTSTIP }, - { L"FriendlyTree", -1 }, - { L"Hidden", -1, }, - { L"HideFileExt", IDS_HIDEFILEEXT }, - { L"HideIcons", -1}, - { L"IconsOnly", -1}, - { L"ListviewAlphaSelect", -1}, - { L"ListviewShadow", -1}, - { L"ListviewWatermark", -1}, - { L"MapNetDrvBtn", -1}, - { L"PersistBrowsers", -1}, - { L"SeperateProcess", IDS_SEPERATEPROCESS}, - { L"ServerAdminUI", -1}, - { L"SharingWizardOn", IDS_USESHAREWIZARD}, - { L"ShowCompColor", IDS_COMPCOLOR}, - { L"ShowInfoTip", IDS_SHOWINFOTIP}, - { L"ShowPreviewHandlers", -1}, - { L"ShowSuperHidden", IDS_HIDEOSFILES}, - { L"ShowTypeOverlay", -1}, - { L"Start_ShowMyGames", -1}, - { L"StartMenuInit", -1}, - { L"SuperHidden", -1}, - { L"TypeAhead", -1}, - { L"Webview", -1}, - { NULL, -1} - -}; -*/ - -HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj); - -INT_PTR -CALLBACK -FolderOptionsGeneralDlg( - HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam -) -{ - - - - return FALSE; -} - -static -VOID -InitializeFolderOptionsListCtrl(HWND hwndDlg) -{ - RECT clientRect; - LVCOLUMNW col; - WCHAR szName[50]; - HWND hDlgCtrl; - - hDlgCtrl = GetDlgItem(hwndDlg, 14003); - - if (!LoadStringW(shell32_hInstance, IDS_COLUMN_EXTENSION, szName, sizeof(szName) / sizeof(WCHAR))) - szName[0] = 0; - szName[(sizeof(szName)/sizeof(WCHAR))-1] = 0; - - GetClientRect(hDlgCtrl, &clientRect); - ZeroMemory(&col, sizeof(LV_COLUMN)); - col.mask = LVCF_SUBITEM | LVCF_WIDTH | LVCF_FMT; - col.iSubItem = 0; - col.pszText = szName; - col.fmt = LVCFMT_LEFT; - col.cx = (clientRect.right - clientRect.left) - GetSystemMetrics(SM_CXVSCROLL); - (void)SendMessageW(hDlgCtrl, LVM_INSERTCOLUMN, 0, (LPARAM)&col); - - - -} - - -INT_PTR -CALLBACK -FolderOptionsViewDlg( - HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam -) -{ - switch(uMsg) - { - case WM_INITDIALOG: - InitializeFolderOptionsListCtrl(hwndDlg); - return TRUE; - } - - return FALSE; - -} - -VOID -InitializeFileTypesListCtrlColumns(HWND hDlgCtrl) -{ - RECT clientRect; - LVCOLUMNW col; - WCHAR szName[50]; - DWORD dwStyle; - int columnSize = 140; - - - if (!LoadStringW(shell32_hInstance, IDS_COLUMN_EXTENSION, szName, sizeof(szName) / sizeof(WCHAR))) - { - /* default to english */ - wcscpy(szName, L"Extensions"); - } - - /* make sure its null terminated */ - szName[(sizeof(szName)/sizeof(WCHAR))-1] = 0; - - GetClientRect(hDlgCtrl, &clientRect); - ZeroMemory(&col, sizeof(LV_COLUMN)); - columnSize = 140; //FIXME - col.iSubItem = 0; - col.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT; - col.fmt = LVCFMT_FIXED_WIDTH; - col.cx = columnSize | LVCFMT_LEFT; - col.cchTextMax = wcslen(szName); - col.pszText = szName; - (void)SendMessageW(hDlgCtrl, LVM_INSERTCOLUMNW, 0, (LPARAM)&col); - - if (!LoadStringW(shell32_hInstance, IDS_FILE_TYPES, szName, sizeof(szName) / sizeof(WCHAR))) - { - /* default to english */ - wcscpy(szName, L"FileTypes"); - } - - col.iSubItem = 1; - col.cx = clientRect.right - clientRect.left - columnSize; - col.cchTextMax = wcslen(szName); - col.pszText = szName; - (void)SendMessageW(hDlgCtrl, LVM_INSERTCOLUMNW, 1, (LPARAM)&col); - - /* set full select style */ - dwStyle = (DWORD) SendMessage(hDlgCtrl, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0); - dwStyle = dwStyle | LVS_EX_FULLROWSELECT; - SendMessage(hDlgCtrl, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dwStyle); - -} - -INT -FindItem(HWND hDlgCtrl, WCHAR * ItemName) -{ - LVFINDINFOW findInfo; - ZeroMemory(&findInfo, sizeof(LVFINDINFOW)); - - findInfo.flags = LVFI_STRING; - findInfo.psz = ItemName; - return ListView_FindItem(hDlgCtrl, 0, &findInfo); -} - -VOID -InsertFileType(HWND hDlgCtrl, WCHAR * szName, PINT iItem, WCHAR * szFile) -{ - PFOLDER_FILE_TYPE_ENTRY Entry; - HKEY hKey; - LVITEMW lvItem; - DWORD dwSize; - - if (szName[0] != L'.') - { - /* FIXME handle URL protocol handlers */ - return; - } - - /* allocate file type entry */ - Entry = (PFOLDER_FILE_TYPE_ENTRY)HeapAlloc(GetProcessHeap(), 0, sizeof(FOLDER_FILE_TYPE_ENTRY)); - - if (!Entry) - return; - - /* open key */ - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szName, 0, KEY_READ, &hKey) != ERROR_SUCCESS) - return; - - /* FIXME check for duplicates */ - - /* query for the default key */ - dwSize = sizeof(Entry->ClassKey); - if (RegQueryValueExW(hKey, NULL, NULL, NULL, (LPBYTE)Entry->ClassKey, &dwSize) != ERROR_SUCCESS) - { - /* no link available */ - Entry->ClassKey[0] = 0; - } - - if (Entry->ClassKey[0]) - { - HKEY hTemp; - /* try open linked key */ - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, Entry->ClassKey, 0, KEY_READ, &hTemp) == ERROR_SUCCESS) - { - /* use linked key */ - RegCloseKey(hKey); - hKey = hTemp; - } - } - - /* read friendly type name */ - if (RegLoadMUIStringW(hKey, L"FriendlyTypeName", Entry->FileDescription, sizeof(Entry->FileDescription), NULL, 0, NULL) != ERROR_SUCCESS) - { - /* read file description */ - dwSize = sizeof(Entry->FileDescription); - Entry->FileDescription[0] = 0; - - /* read default key */ - RegQueryValueExW(hKey, NULL, NULL, NULL, (LPBYTE)Entry->FileDescription, &dwSize); - } - - /* close key */ - RegCloseKey(hKey); - - /* convert extension to upper case */ - wcscpy(Entry->FileExtension, szName); - _wcsupr(Entry->FileExtension); - - if (!Entry->FileDescription[0]) - { - /* construct default 'FileExtensionFile' */ - wcscpy(Entry->FileDescription, &Entry->FileExtension[1]); - wcscat(Entry->FileDescription, L" "); - wcscat(Entry->FileDescription, szFile); - } - - ZeroMemory(&lvItem, sizeof(LVITEMW)); - lvItem.mask = LVIF_TEXT | LVIF_PARAM; - lvItem.iSubItem = 0; - lvItem.pszText = &Entry->FileExtension[1]; - lvItem.iItem = *iItem; - lvItem.lParam = (LPARAM)Entry; - (void)SendMessageW(hDlgCtrl, LVM_INSERTITEMW, 0, (LPARAM)&lvItem); - - ZeroMemory(&lvItem, sizeof(LVITEMW)); - lvItem.mask = LVIF_TEXT; - lvItem.pszText = Entry->FileDescription; - lvItem.iItem = *iItem; - lvItem.iSubItem = 1; - - (void)SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&lvItem); - (*iItem)++; -} - -int -CALLBACK -ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) -{ - PFOLDER_FILE_TYPE_ENTRY Entry1, Entry2; - - Entry1 = (PFOLDER_FILE_TYPE_ENTRY)lParam1; - Entry2 = (PFOLDER_FILE_TYPE_ENTRY)lParam2; - - return wcsicmp(Entry1->FileExtension, Entry2->FileExtension); -} - -BOOL -InitializeFileTypesListCtrl(HWND hwndDlg) -{ - HWND hDlgCtrl; - DWORD dwIndex = 0; - WCHAR szName[50]; - WCHAR szFile[100]; - DWORD dwName; - LVITEMW lvItem; - INT iItem = 0; - - hDlgCtrl = GetDlgItem(hwndDlg, 14000); - InitializeFileTypesListCtrlColumns(hDlgCtrl); - - szFile[0] = 0; - if (!LoadStringW(shell32_hInstance, IDS_SHV_COLUMN1, szFile, sizeof(szFile) / sizeof(WCHAR))) - { - /* default to english */ - wcscpy(szFile, L"File"); - } - szFile[(sizeof(szFile)/sizeof(WCHAR))-1] = 0; - - dwName = sizeof(szName) / sizeof(WCHAR); - - while(RegEnumKeyExW(HKEY_CLASSES_ROOT, dwIndex++, szName, &dwName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) - { - InsertFileType(hDlgCtrl, szName, &iItem, szFile); - dwName = sizeof(szName) / sizeof(WCHAR); - } - - /* sort list */ - ListView_SortItems(hDlgCtrl, ListViewCompareProc, NULL); - - /* select first item */ - ZeroMemory(&lvItem, sizeof(LVITEMW)); - lvItem.mask = LVIF_STATE; - lvItem.stateMask = (UINT)-1; - lvItem.state = LVIS_FOCUSED|LVIS_SELECTED; - lvItem.iItem = 0; - (void)SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&lvItem); - - return TRUE; -} - -PFOLDER_FILE_TYPE_ENTRY -FindSelectedItem( - HWND hDlgCtrl) -{ - UINT Count, Index; - LVITEMW lvItem; - - Count = ListView_GetItemCount(hDlgCtrl); - - for (Index = 0; Index < Count; Index++) - { - ZeroMemory(&lvItem, sizeof(LVITEM)); - lvItem.mask = LVIF_PARAM | LVIF_STATE; - lvItem.iItem = Index; - lvItem.stateMask = (UINT)-1; - - if (ListView_GetItem(hDlgCtrl, &lvItem)) - { - if (lvItem.state & LVIS_SELECTED) - return (PFOLDER_FILE_TYPE_ENTRY)lvItem.lParam; - } - } - - return NULL; -} - - -INT_PTR -CALLBACK -FolderOptionsFileTypesDlg( - HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) -{ - LPNMLISTVIEW lppl; - LVITEMW lvItem; - WCHAR Buffer[255], FormatBuffer[255]; - PFOLDER_FILE_TYPE_ENTRY pItem; - OPENASINFO Info; - - switch(uMsg) - { - case WM_INITDIALOG: - InitializeFileTypesListCtrl(hwndDlg); - return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case 14006: - pItem = FindSelectedItem(GetDlgItem(hwndDlg, 14000)); - if (pItem) - { - Info.oaifInFlags = OAIF_ALLOW_REGISTRATION | OAIF_REGISTER_EXT; - Info.pcszClass = pItem->FileExtension; - SHOpenWithDialog(hwndDlg, &Info); - } - break; - } - - break; - case WM_NOTIFY: - lppl = (LPNMLISTVIEW) lParam; - - if (lppl->hdr.code == LVN_ITEMCHANGING) - { - ZeroMemory(&lvItem, sizeof(LVITEM)); - lvItem.mask = LVIF_PARAM; - lvItem.iItem = lppl->iItem; - if (!SendMessageW(lppl->hdr.hwndFrom, LVM_GETITEMW, 0, (LPARAM)&lvItem)) - return TRUE; - - pItem = (PFOLDER_FILE_TYPE_ENTRY)lvItem.lParam; - if (!pItem) - return TRUE; - - if (!(lppl->uOldState & LVIS_FOCUSED) && (lppl->uNewState & LVIS_FOCUSED)) - { - /* new focused item */ - if (!LoadStringW(shell32_hInstance, IDS_FILE_DETAILS, FormatBuffer, sizeof(FormatBuffer) / sizeof(WCHAR))) - { - /* use default english format string */ - wcscpy(FormatBuffer, L"Details for '%s' extension"); - } - - /* format buffer */ - swprintf(Buffer, FormatBuffer, &pItem->FileExtension[1]); - /* update dialog */ - SendDlgItemMessageW(hwndDlg, 14003, WM_SETTEXT, 0, (LPARAM)Buffer); - - if (!LoadStringW(shell32_hInstance, IDS_FILE_DETAILSADV, FormatBuffer, sizeof(FormatBuffer) / sizeof(WCHAR))) - { - /* use default english format string */ - wcscpy(FormatBuffer, L"Files with extension '%s' are of type '%s'. To change settings that affect all '%s' files, click Advanced."); - } - /* format buffer */ - swprintf(Buffer, FormatBuffer, &pItem->FileExtension[1], &pItem->FileDescription[0], &pItem->FileDescription[0]); - /* update dialog */ - SendDlgItemMessageW(hwndDlg, 14007, WM_SETTEXT, 0, (LPARAM)Buffer); - } - } - break; - } - - return FALSE; -} - - -VOID -ShowFolderOptionsDialog(HWND hWnd, HINSTANCE hInst) -{ - PROPSHEETHEADERW pinfo; - HPROPSHEETPAGE hppages[3]; - HPROPSHEETPAGE hpage; - UINT num_pages = 0; - WCHAR szOptions[100]; - - hpage = SH_CreatePropertySheetPage("FOLDER_OPTIONS_GENERAL_DLG", FolderOptionsGeneralDlg, 0, NULL); - if (hpage) - hppages[num_pages++] = hpage; - - hpage = SH_CreatePropertySheetPage("FOLDER_OPTIONS_VIEW_DLG", FolderOptionsViewDlg, 0, NULL); - if (hpage) - hppages[num_pages++] = hpage; - - hpage = SH_CreatePropertySheetPage("FOLDER_OPTIONS_FILETYPES_DLG", FolderOptionsFileTypesDlg, 0, NULL); - if (hpage) - hppages[num_pages++] = hpage; - - szOptions[0] = L'\0'; - LoadStringW(shell32_hInstance, IDS_FOLDER_OPTIONS, szOptions, sizeof(szOptions) / sizeof(WCHAR)); - szOptions[(sizeof(szOptions)/sizeof(WCHAR))-1] = L'\0'; - - memset(&pinfo, 0x0, sizeof(PROPSHEETHEADERW)); - pinfo.dwSize = sizeof(PROPSHEETHEADERW); - pinfo.dwFlags = PSH_NOCONTEXTHELP; - pinfo.nPages = num_pages; - pinfo.u3.phpage = hppages; - pinfo.pszCaption = szOptions; - - PropertySheetW(&pinfo); -} - -VOID -Options_RunDLLCommon(HWND hWnd, HINSTANCE hInst, int fOptions, DWORD nCmdShow) -{ - switch(fOptions) - { - case 0: - ShowFolderOptionsDialog(hWnd, hInst); - break; - case 1: - // show taskbar options dialog - FIXME("notify explorer to show taskbar options dialog"); - //PostMessage(GetShellWindow(), WM_USER+22, fOptions, 0); - break; - default: - FIXME("unrecognized options id %d\n", fOptions); - } -} - -/************************************************************************* - * Options_RunDLL (SHELL32.@) - */ -VOID WINAPI Options_RunDLL(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow) -{ - Options_RunDLLCommon(hWnd, hInst, StrToIntA(cmd), nCmdShow); -} -/************************************************************************* - * Options_RunDLLA (SHELL32.@) - */ -VOID WINAPI Options_RunDLLA(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow) -{ - Options_RunDLLCommon(hWnd, hInst, StrToIntA(cmd), nCmdShow); -} - -/************************************************************************* - * Options_RunDLLW (SHELL32.@) - */ -VOID WINAPI Options_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow) -{ - Options_RunDLLCommon(hWnd, hInst, StrToIntW(cmd), nCmdShow); -} - -static -DWORD WINAPI -CountFolderAndFiles(LPVOID lParam) -{ - WIN32_FIND_DATAW FindData; - HANDLE hFile; - UINT Length; - LPWSTR pOffset; - BOOL ret; - PFOLDER_PROPERTIES_CONTEXT pContext = (PFOLDER_PROPERTIES_CONTEXT) lParam; - - pOffset = PathAddBackslashW(pContext->szFolderPath); - if (!pOffset) - return 0; - - Length = pOffset - pContext->szFolderPath; - - wcscpy(pOffset, L"*.*"); - hFile = FindFirstFileW(pContext->szFolderPath, &FindData); - if (hFile == INVALID_HANDLE_VALUE) - return 0; - - do - { - ret = FindNextFileW(hFile, &FindData); - if (ret) - { - if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - { - if (FindData.cFileName[0] == L'.' && FindData.cFileName[1] == L'.' && - FindData.cFileName[2] == L'\0') - continue; - - pContext->cFolder++; - wcscpy(pOffset, FindData.cFileName); - CountFolderAndFiles((LPVOID)pContext); - pOffset[0] = L'\0'; - } - else - { - pContext->cFiles++; - pContext->bSize.u.LowPart += FindData.nFileSizeLow; - pContext->bSize.u.HighPart += FindData.nFileSizeHigh; - } - } - else if (GetLastError() == ERROR_NO_MORE_FILES) - { - break; - } - }while(1); - - FindClose(hFile); - return 1; -} - -static -VOID -InitializeFolderGeneralDlg(PFOLDER_PROPERTIES_CONTEXT pContext) -{ - LPWSTR pFolderName; - WIN32_FILE_ATTRIBUTE_DATA FolderAttribute; - FILETIME ft; - SYSTEMTIME dt; - WCHAR szBuffer[MAX_PATH+5]; - WCHAR szFormat[30] = {0}; - - static const WCHAR wFormat[] = {'%','0','2','d','/','%','0','2','d','/','%','0','4','d',' ',' ','%','0','2','d',':','%','0','2','u',0}; - - pFolderName = wcsrchr(pContext->szFolderPath, L'\\'); - if (!pFolderName) - return; - - /* set folder name */ - SendDlgItemMessageW(pContext->hwndDlg, 14001, WM_SETTEXT, 0, (LPARAM) (pFolderName + 1)); - /* set folder location */ - pFolderName[0] = L'\0'; - if (wcslen(pContext->szFolderPath) == 2) - { - /* folder is located at root */ - WCHAR szDrive[4] = {L'C',L':',L'\\',L'\0'}; - szDrive[0] = pContext->szFolderPath[0]; - SendDlgItemMessageW(pContext->hwndDlg, 14007, WM_SETTEXT, 0, (LPARAM) szDrive); - } - else - { - SendDlgItemMessageW(pContext->hwndDlg, 14007, WM_SETTEXT, 0, (LPARAM) pContext->szFolderPath); - } - pFolderName[0] = L'\\'; - /* get folder properties */ - if (GetFileAttributesExW(pContext->szFolderPath, GetFileExInfoStandard, (LPVOID)&FolderAttribute)) - { - if (FolderAttribute.dwFileAttributes & FILE_ATTRIBUTE_READONLY) - { - /* check readonly button */ - SendDlgItemMessage(pContext->hwndDlg, 14021, BM_SETCHECK, BST_CHECKED, 0); - } - - if (FolderAttribute.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) - { - /* check hidden button */ - SendDlgItemMessage(pContext->hwndDlg, 14022, BM_SETCHECK, BST_CHECKED, 0); - } - - if (FileTimeToLocalFileTime(&FolderAttribute.ftCreationTime, &ft)) - { - FileTimeToSystemTime(&ft, &dt); - swprintf (szBuffer, wFormat, dt.wDay, dt.wMonth, dt.wYear, dt.wHour, dt.wMinute); - SendDlgItemMessageW(pContext->hwndDlg, 14015, WM_SETTEXT, 0, (LPARAM) szBuffer); - } - } - /* now enumerate enumerate contents */ - wcscpy(szBuffer, pContext->szFolderPath); - CountFolderAndFiles((LPVOID)pContext); - wcscpy(pContext->szFolderPath, szBuffer); - /* set folder details */ - LoadStringW(shell32_hInstance, IDS_FILE_FOLDER, szFormat, sizeof(szFormat)/sizeof(WCHAR)); - szFormat[(sizeof(szFormat)/sizeof(WCHAR))-1] = L'\0'; - swprintf(szBuffer, szFormat, pContext->cFiles, pContext->cFolder); - SendDlgItemMessageW(pContext->hwndDlg, 14011, WM_SETTEXT, 0, (LPARAM) szBuffer); - - if (StrFormatByteSizeW(pContext->bSize.QuadPart, szBuffer, sizeof(szBuffer)/sizeof(WCHAR))) - { - /* store folder size */ - SendDlgItemMessageW(pContext->hwndDlg, 14009, WM_SETTEXT, 0, (LPARAM) szBuffer); - } -} - - -INT_PTR -CALLBACK -FolderPropertiesGeneralDlg( - HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam -) -{ - LPPROPSHEETPAGEW ppsp; - PFOLDER_PROPERTIES_CONTEXT pContext; - HICON hIcon; - WIN32_FILE_ATTRIBUTE_DATA FolderAttribute; - LONG res; - LPPSHNOTIFY lppsn; - DWORD Attribute; - - switch(uMsg) - { - case WM_INITDIALOG: - ppsp = (LPPROPSHEETPAGEW)lParam; - if (ppsp == NULL) - break; - hIcon = LoadIconW(shell32_hInstance, MAKEINTRESOURCEW(IDI_SHELL_FOLDER_OPEN)); - if (hIcon) - SendDlgItemMessageW(hwndDlg, 14000, STM_SETICON, (WPARAM)hIcon, 0); - - pContext = SHAlloc(sizeof(FOLDER_PROPERTIES_CONTEXT)); - if (pContext) - { - ZeroMemory(pContext, sizeof(FOLDER_PROPERTIES_CONTEXT)); - pContext->hwndDlg = hwndDlg; - wcscpy(pContext->szFolderPath, (LPWSTR)ppsp->lParam); - SetWindowLongPtr(hwndDlg, DWL_USER, (LONG_PTR)pContext); - InitializeFolderGeneralDlg(pContext); - } - return TRUE; - case WM_COMMAND: - if (HIWORD(wParam) == BN_CLICKED) - { - PropSheet_Changed(GetParent(hwndDlg), hwndDlg); - } - break; - case WM_DESTROY: - pContext = (PFOLDER_PROPERTIES_CONTEXT)GetWindowLongPtr(hwndDlg, DWL_USER); - SHFree((LPVOID)pContext); - break; - case WM_NOTIFY: - pContext = (PFOLDER_PROPERTIES_CONTEXT)GetWindowLongPtr(hwndDlg, DWL_USER); - lppsn = (LPPSHNOTIFY) lParam; - if (lppsn->hdr.code == PSN_APPLY) - { - if (GetFileAttributesExW(pContext->szFolderPath, GetFileExInfoStandard, (LPVOID)&FolderAttribute)) - { - res = SendDlgItemMessageW(hwndDlg, 14021, BM_GETCHECK, 0, 0); - if (res == BST_CHECKED) - FolderAttribute.dwFileAttributes |= FILE_ATTRIBUTE_READONLY; - else - FolderAttribute.dwFileAttributes &= (~FILE_ATTRIBUTE_READONLY); - - res = SendDlgItemMessageW(hwndDlg, 14022, BM_GETCHECK, 0, 0); - if (res == BST_CHECKED) - FolderAttribute.dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN; - else - FolderAttribute.dwFileAttributes &= (~FILE_ATTRIBUTE_HIDDEN); - - Attribute = FolderAttribute.dwFileAttributes & -(FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY); - - SetFileAttributesW(pContext->szFolderPath, Attribute); - } - SetWindowLongPtr( hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR ); - return TRUE; - } - break; - } - return FALSE; -} - -static -BOOL -CALLBACK -FolderAddPropSheetPageProc(HPROPSHEETPAGE hpage, LPARAM lParam) -{ - PROPSHEETHEADERW *ppsh = (PROPSHEETHEADERW *)lParam; - if (ppsh != NULL && ppsh->nPages < MAX_PROPERTY_SHEET_PAGE) - { - ppsh->u3.phpage[ppsh->nPages++] = hpage; - return TRUE; - } - return FALSE; -} - -BOOL -SH_ShowFolderProperties(LPWSTR pwszFolder, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST * apidl) -{ - HPROPSHEETPAGE hppages[MAX_PROPERTY_SHEET_PAGE]; - HPROPSHEETPAGE hpage; - PROPSHEETHEADERW psh; - BOOL ret; - WCHAR szName[MAX_PATH] = {0}; - HPSXA hpsx = NULL; - LPWSTR pFolderName; - IDataObject * pDataObj = NULL; - - if (!PathIsDirectoryW(pwszFolder)) - return FALSE; - - pFolderName = wcsrchr(pwszFolder, L'\\'); - if (!pFolderName) - return FALSE; - - wcscpy(szName, pFolderName + 1); - - hpage = SH_CreatePropertySheetPage("SHELL_FOLDER_GENERAL_DLG", FolderPropertiesGeneralDlg, (LPARAM)pwszFolder, NULL); - if (!hpage) - return FALSE; - - ZeroMemory(&psh, sizeof(PROPSHEETHEADERW)); - hppages[psh.nPages] = hpage; - psh.nPages++; - psh.dwSize = sizeof(PROPSHEETHEADERW); - psh.dwFlags = PSH_PROPTITLE; - psh.hwndParent = NULL; - psh.u3.phpage = hppages; - psh.pszCaption = szName; - - - if (SHCreateDataObject(pidlFolder, 1, apidl, NULL, &IID_IDataObject, (void**)&pDataObj) == S_OK) - { - hpsx = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, L"Directory", MAX_PROPERTY_SHEET_PAGE-1, pDataObj); - if (hpsx) - { - SHAddFromPropSheetExtArray(hpsx, - (LPFNADDPROPSHEETPAGE)FolderAddPropSheetPageProc, - (LPARAM)&psh); - } - } - - ret = PropertySheetW(&psh); - if (pDataObj) - IDataObject_Release(pDataObj); - - if (hpsx) - SHDestroyPropSheetExtArray(hpsx); - - if (ret < 0) - return FALSE; - else - return TRUE; -} - - diff --git a/reactos/dll/win32/shell32/folders.c b/reactos/dll/win32/shell32/folders.c deleted file mode 100644 index d1a6c672b51..00000000000 --- a/reactos/dll/win32/shell32/folders.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Copyright 1997 Marcus Meissner - * Copyright 1998 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -WCHAR swShell32Name[MAX_PATH]; - -DWORD NumIconOverlayHandlers = 0; -IShellIconOverlayIdentifier ** Handlers = NULL; - -static HRESULT getIconLocationForFolder(LPCITEMIDLIST pidl, UINT uFlags, - LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags) -{ - int icon_idx; - WCHAR wszPath[MAX_PATH]; - WCHAR wszCLSIDValue[CHARS_IN_GUID]; - static const WCHAR shellClassInfo[] = { '.','S','h','e','l','l','C','l','a','s','s','I','n','f','o',0 }; - static const WCHAR iconFile[] = { 'I','c','o','n','F','i','l','e',0 }; - static const WCHAR clsid[] = { 'C','L','S','I','D',0 }; - static const WCHAR clsid2[] = { 'C','L','S','I','D','2',0 }; - static const WCHAR iconIndex[] = { 'I','c','o','n','I','n','d','e','x',0 }; - - if (SHELL32_GetCustomFolderAttribute(pidl, shellClassInfo, iconFile, - wszPath, MAX_PATH)) - { - WCHAR wszIconIndex[10]; - SHELL32_GetCustomFolderAttribute(pidl, shellClassInfo, iconIndex, - wszIconIndex, 10); - *piIndex = _wtoi(wszIconIndex); - } - else if (SHELL32_GetCustomFolderAttribute(pidl, shellClassInfo, clsid, - wszCLSIDValue, CHARS_IN_GUID) && - HCR_GetDefaultIconW(wszCLSIDValue, szIconFile, cchMax, &icon_idx)) - { - *piIndex = icon_idx; - } - else if (SHELL32_GetCustomFolderAttribute(pidl, shellClassInfo, clsid2, - wszCLSIDValue, CHARS_IN_GUID) && - HCR_GetDefaultIconW(wszCLSIDValue, szIconFile, cchMax, &icon_idx)) - { - *piIndex = icon_idx; - } - else - { - static const WCHAR folder[] = { 'F','o','l','d','e','r',0 }; - - if (!HCR_GetDefaultIconW(folder, szIconFile, cchMax, &icon_idx)) - { - lstrcpynW(szIconFile, swShell32Name, cchMax); - icon_idx = -IDI_SHELL_FOLDER; - } - - if (uFlags & GIL_OPENICON) - *piIndex = icon_idx<0? icon_idx-1: icon_idx+1; - else - *piIndex = icon_idx; - } - - return S_OK; -} - -void InitIconOverlays(void) -{ - HKEY hKey; - DWORD dwIndex, dwResult, dwSize; - WCHAR szName[MAX_PATH]; - WCHAR szValue[100]; - CLSID clsid; - IShellIconOverlayIdentifier * Overlay; - - if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers",0, KEY_READ, &hKey) != ERROR_SUCCESS) - return; - - if (RegQueryInfoKeyW(hKey, NULL, NULL, NULL, &dwResult, NULL, NULL, NULL, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) - { - RegCloseKey(hKey); - return; - } - - Handlers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwResult * sizeof(IShellIconOverlayIdentifier*)); - if (!Handlers) - { - RegCloseKey(hKey); - return; - } - - dwIndex = 0; - - CoInitialize(0); - - do - { - dwSize = sizeof(szName) / sizeof(WCHAR); - dwResult = RegEnumKeyExW(hKey, dwIndex, szName, &dwSize, NULL, NULL, NULL, NULL); - - if (dwResult == ERROR_NO_MORE_ITEMS) - break; - - if (dwResult == ERROR_SUCCESS) - { - dwSize = sizeof(szValue) / sizeof(WCHAR); - if (RegGetValueW(hKey, szName, NULL, RRF_RT_REG_SZ, NULL, szValue, &dwSize) == ERROR_SUCCESS) - { - - CLSIDFromString(szValue, &clsid); - dwResult = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (LPVOID*)&Overlay); - if (dwResult == S_OK) - { - Handlers[NumIconOverlayHandlers] = Overlay; - NumIconOverlayHandlers++; - } - } - } - - dwIndex++; - - }while(1); - - RegCloseKey(hKey); -} - -BOOL -GetIconOverlay(LPCITEMIDLIST pidl, WCHAR * wTemp, int* pIndex) -{ - DWORD Index; - HRESULT hResult; - int Priority; - int HighestPriority; - ULONG IconIndex; - ULONG Flags; - WCHAR szPath[MAX_PATH]; - - if(!SHGetPathFromIDListW(pidl, szPath)) - return FALSE; - - - HighestPriority = 101; - IconIndex = NumIconOverlayHandlers; - for(Index = 0; Index < NumIconOverlayHandlers; Index++) - { - hResult = Handlers[Index]->lpVtbl->IsMemberOf(Handlers[Index], szPath, SFGAO_FILESYSTEM); - if (hResult == S_OK) - { - hResult = Handlers[Index]->lpVtbl->GetPriority(Handlers[Index], &Priority); - if (hResult == S_OK) - { - if (Priority < HighestPriority) - { - HighestPriority = Priority; - IconIndex = Index; - } - } - } - } - - if (IconIndex == NumIconOverlayHandlers) - return FALSE; - - hResult = Handlers[IconIndex]->lpVtbl->GetOverlayInfo(Handlers[IconIndex], wTemp, MAX_PATH, pIndex, &Flags); - - if (hResult == S_OK) - return TRUE; - else - return FALSE; -} - -/************************************************************************** -* IExtractIconW_Constructor -*/ -IExtractIconW* IExtractIconW_Constructor(LPCITEMIDLIST pidl) -{ - IDefaultExtractIconInit *initIcon; - IExtractIconW *extractIcon; - GUID const * riid; - int icon_idx; - UINT flags; - CHAR sTemp[MAX_PATH]; - WCHAR wTemp[MAX_PATH]; - LPITEMIDLIST pSimplePidl = ILFindLastID(pidl); - HRESULT hr; - - hr = SHCreateDefaultExtractIcon(&IID_IDefaultExtractIconInit, (void **)&initIcon); - if (!SUCCEEDED(hr)) - return NULL; - - hr = IDefaultExtractIconInit_QueryInterface(initIcon, &IID_IExtractIconW, (void **)&extractIcon); - IDefaultExtractIconInit_Release(initIcon); - if (!SUCCEEDED(hr)) - return NULL; - - if (_ILIsDesktop(pSimplePidl)) - { - IDefaultExtractIconInit_SetNormalIcon(initIcon, swShell32Name, -IDI_SHELL_DESKTOP); - } - else if ((riid = _ILGetGUIDPointer(pSimplePidl))) - { - /* my computer and other shell extensions */ - static const WCHAR fmt[] = { 'C','L','S','I','D','\\', - '{','%','0','8','l','x','-','%','0','4','x','-','%','0','4','x','-', - '%','0','2','x','%','0','2','x','-','%','0','2','x', '%','0','2','x', - '%','0','2','x','%','0','2','x','%','0','2','x','%','0','2','x','}',0 }; - WCHAR xriid[50]; - - swprintf(xriid, fmt, - riid->Data1, riid->Data2, riid->Data3, - riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3], - riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7]); - - if (HCR_GetDefaultIconW(xriid, wTemp, MAX_PATH, &icon_idx)) - { - IDefaultExtractIconInit_SetNormalIcon(initIcon, wTemp, icon_idx); - } - else - { - if (IsEqualGUID(riid, &CLSID_MyComputer)) - IDefaultExtractIconInit_SetNormalIcon(initIcon, swShell32Name, -IDI_SHELL_MY_COMPUTER); - else if (IsEqualGUID(riid, &CLSID_MyDocuments)) - IDefaultExtractIconInit_SetNormalIcon(initIcon, swShell32Name, -IDI_SHELL_MY_DOCUMENTS); - else if (IsEqualGUID(riid, &CLSID_NetworkPlaces)) - IDefaultExtractIconInit_SetNormalIcon(initIcon, swShell32Name, -IDI_SHELL_MY_NETWORK_PLACES); - else if (IsEqualGUID(riid, &CLSID_UnixFolder) || - IsEqualGUID(riid, &CLSID_UnixDosFolder)) - IDefaultExtractIconInit_SetNormalIcon(initIcon, swShell32Name, -IDI_SHELL_DRIVE); - else - IDefaultExtractIconInit_SetNormalIcon(initIcon, swShell32Name, -IDI_SHELL_FOLDER); - } - } - - else if (_ILIsDrive (pSimplePidl)) - { - static const WCHAR drive[] = { 'D','r','i','v','e',0 }; - int icon_idx = -1; - - if (_ILGetDrive(pSimplePidl, sTemp, MAX_PATH)) - { - switch(GetDriveTypeA(sTemp)) - { - case DRIVE_REMOVABLE: icon_idx = IDI_SHELL_FLOPPY; break; - case DRIVE_CDROM: icon_idx = IDI_SHELL_CDROM; break; - case DRIVE_REMOTE: icon_idx = IDI_SHELL_NETDRIVE; break; - case DRIVE_RAMDISK: icon_idx = IDI_SHELL_RAMDISK; break; - case DRIVE_NO_ROOT_DIR: icon_idx = IDI_SHELL_CDROM; break; - } - } - - if (icon_idx != -1) - { - IDefaultExtractIconInit_SetNormalIcon(initIcon, swShell32Name, -icon_idx); - } - else - { - if (HCR_GetDefaultIconW(drive, wTemp, MAX_PATH, &icon_idx)) - IDefaultExtractIconInit_SetNormalIcon(initIcon, wTemp, icon_idx); - else - IDefaultExtractIconInit_SetNormalIcon(initIcon, swShell32Name, -IDI_SHELL_DRIVE); - } - } - - else if (_ILIsFolder (pSimplePidl)) - { - if (SUCCEEDED(getIconLocationForFolder( - pidl, 0, wTemp, MAX_PATH, - &icon_idx, - &flags))) - { - IDefaultExtractIconInit_SetNormalIcon(initIcon, wTemp, icon_idx); - } - if (SUCCEEDED(getIconLocationForFolder( - pidl, GIL_DEFAULTICON, wTemp, MAX_PATH, - &icon_idx, - &flags))) - { - IDefaultExtractIconInit_SetDefaultIcon(initIcon, wTemp, icon_idx); - } - if (SUCCEEDED(getIconLocationForFolder( - pidl, GIL_FORSHORTCUT, wTemp, MAX_PATH, - &icon_idx, - &flags))) - { - IDefaultExtractIconInit_SetShortcutIcon(initIcon, wTemp, icon_idx); - } - if (SUCCEEDED(getIconLocationForFolder( - pidl, GIL_OPENICON, wTemp, MAX_PATH, - &icon_idx, - &flags))) - { - IDefaultExtractIconInit_SetOpenIcon(initIcon, wTemp, icon_idx); - } - } - else - { - BOOL found = FALSE; - - if (_ILIsCPanelStruct(pSimplePidl)) - { - if (SUCCEEDED(CPanel_GetIconLocationW(pSimplePidl, wTemp, MAX_PATH, &icon_idx))) - found = TRUE; - } - else if (_ILGetExtension(pSimplePidl, sTemp, MAX_PATH)) - { - if (HCR_MapTypeToValueA(sTemp, sTemp, MAX_PATH, TRUE) - && HCR_GetDefaultIconA(sTemp, sTemp, MAX_PATH, &icon_idx)) - { - if (!lstrcmpA("%1", sTemp)) /* icon is in the file */ - { - SHGetPathFromIDListW(pidl, wTemp); - icon_idx = 0; - } - else - { - MultiByteToWideChar(CP_ACP, 0, sTemp, -1, wTemp, MAX_PATH); - } - - found = TRUE; - } - else if (!lstrcmpiA(sTemp, "lnkfile")) - { - /* extract icon from shell shortcut */ - IShellFolder* dsf; - IShellLinkW* psl; - - if (SUCCEEDED(SHGetDesktopFolder(&dsf))) - { - HRESULT hr = IShellFolder_GetUIObjectOf(dsf, NULL, 1, (LPCITEMIDLIST*)&pidl, &IID_IShellLinkW, NULL, (LPVOID*)&psl); - - if (SUCCEEDED(hr)) - { - hr = IShellLinkW_GetIconLocation(psl, wTemp, MAX_PATH, &icon_idx); - - if (SUCCEEDED(hr) && *sTemp) - found = TRUE; - - IShellLinkW_Release(psl); - } - - IShellFolder_Release(dsf); - } - } - } - - if (!found) - /* default icon */ - IDefaultExtractIconInit_SetNormalIcon(initIcon, swShell32Name, 0); - else - IDefaultExtractIconInit_SetNormalIcon(initIcon, wTemp, icon_idx); - } - - return extractIcon; -} - -/************************************************************************** -* IExtractIconA_Constructor -*/ -IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl) -{ - IExtractIconW *extractIconW; - IExtractIconA *extractIconA; - HRESULT hr; - - extractIconW = IExtractIconW_Constructor(pidl); - if (!extractIconW) - return NULL; - - hr = extractIconW->lpVtbl->QueryInterface(extractIconW, &IID_IExtractIconA, (void **)&extractIconA); - extractIconW->lpVtbl->Release(extractIconW); - if (!SUCCEEDED(hr)) - return NULL; - return extractIconA; -} diff --git a/reactos/dll/win32/shell32/fprop.c b/reactos/dll/win32/shell32/fprop.c deleted file mode 100644 index 3e324499808..00000000000 --- a/reactos/dll/win32/shell32/fprop.c +++ /dev/null @@ -1,879 +0,0 @@ -/* - * Shell Library Functions - * - * Copyright 2005 Johannes Anderwald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -#define MAX_PROPERTY_SHEET_PAGE 32 - -typedef struct _LANGANDCODEPAGE_ -{ - WORD lang; - WORD code; -} LANGANDCODEPAGE, *LPLANGANDCODEPAGE; - -HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj); - -/************************************************************************* - * - * SH_CreatePropertySheetPage [Internal] - * - * creates a property sheet page from an resource name - * - */ - -HPROPSHEETPAGE -SH_CreatePropertySheetPage(LPSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle) -{ - HRSRC hRes; - LPVOID lpsztemplate; - PROPSHEETPAGEW ppage; - - if (resname == NULL) - return (HPROPSHEETPAGE)0; - - hRes = FindResourceA(shell32_hInstance, resname, (LPSTR)RT_DIALOG); - - if (hRes == NULL) - { - ERR("failed to find resource name\n"); - return (HPROPSHEETPAGE)0; - } - - lpsztemplate = LoadResource(shell32_hInstance, hRes); - - if (lpsztemplate == NULL) - return (HPROPSHEETPAGE)0; - - memset(&ppage, 0x0, sizeof(PROPSHEETPAGEW)); - ppage.dwSize = sizeof(PROPSHEETPAGEW); - ppage.dwFlags = PSP_DLGINDIRECT; - ppage.u.pResource = lpsztemplate; - ppage.pfnDlgProc = dlgproc; - ppage.lParam = lParam; - ppage.pszTitle = szTitle; - - if (szTitle) - { - ppage.dwFlags |= PSP_USETITLE; - } - - return CreatePropertySheetPageW(&ppage); -} - -/************************************************************************* - * - * SH_FileGeneralFileType [Internal] - * - * retrieves file extension description from registry and sets it in dialog - * - * TODO: retrieve file extension default icon and load it - * find executable name from registry, retrieve description from executable - */ - -BOOL -SH_FileGeneralSetFileType(HWND hwndDlg, WCHAR *filext) -{ - WCHAR name[MAX_PATH]; - WCHAR value[MAX_PATH]; - DWORD lname = MAX_PATH; - DWORD lvalue = MAX_PATH; - HKEY hKey; - LONG result; - HWND hDlgCtrl; - - TRACE("fileext %s\n", debugstr_w(filext)); - - if (filext == NULL) - return FALSE; - - hDlgCtrl = GetDlgItem(hwndDlg, 14005); - - if (hDlgCtrl == NULL) - return FALSE; - - if (RegOpenKeyW(HKEY_CLASSES_ROOT, filext, &hKey) != ERROR_SUCCESS) - { - /* the file extension is unknown, so default to string "FileExtension File" */ - SendMessageW(hDlgCtrl, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)value); - swprintf(name, L"%s %s", &filext[1], value); - SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)name); - return TRUE; - } - - result = RegEnumValueW(hKey, 0, name, &lname, NULL, NULL, (LPBYTE)value, &lvalue); - RegCloseKey(hKey); - - if (result != ERROR_SUCCESS) - return FALSE; - - if (RegOpenKeyW(HKEY_CLASSES_ROOT, value, &hKey) == ERROR_SUCCESS) - { - if (RegLoadMUIStringW(hKey, L"FriendlyTypeName", value, MAX_PATH, NULL, 0, NULL) != ERROR_SUCCESS) - { - lvalue = lname = MAX_PATH; - result = RegEnumValueW(hKey, 0, name, &lname, NULL, NULL, (LPBYTE)value, &lvalue); - } - - lname = MAX_PATH; - - if (RegGetValueW(hKey, L"DefaultIcon", NULL, RRF_RT_REG_SZ, NULL, name, &lname) == ERROR_SUCCESS) - { - UINT IconIndex; - WCHAR szBuffer[MAX_PATH]; - WCHAR *Offset; - HICON hIcon = 0; - HRSRC hResource; - LPVOID pResource = NULL; - HGLOBAL hGlobal; - HANDLE hLibrary; - Offset = wcsrchr(name, L','); - - if (Offset) - { - IconIndex = _wtoi(Offset + 2); - *Offset = L'\0'; - name[MAX_PATH - 1] = L'\0'; - - if (ExpandEnvironmentStringsW(name, szBuffer, MAX_PATH)) - { - szBuffer[MAX_PATH - 1] = L'\0'; - hLibrary = LoadLibraryExW(szBuffer, NULL, LOAD_LIBRARY_AS_DATAFILE); - if (hLibrary) - { - hResource = FindResourceW(hLibrary, MAKEINTRESOURCEW(IconIndex), (LPCWSTR)RT_ICON); - if (hResource) - { - hGlobal = LoadResource(shell32_hInstance, hResource); - if (hGlobal) - { - pResource = LockResource(hGlobal); - if (pResource != NULL) - { - hIcon = CreateIconFromResource(pResource, SizeofResource(shell32_hInstance, hResource), TRUE, 0x00030000); - TRACE("hIcon %p,- szBuffer %s IconIndex %u error %u icon %p hResource %p pResource %p\n", - hIcon, - debugstr_w(szBuffer), - IconIndex, - MAKEINTRESOURCEW(IconIndex), - hResource, - pResource); - SendDlgItemMessageW(hwndDlg, 14000, STM_SETICON, (WPARAM)hIcon, 0); - } - } - } - FreeLibrary(hLibrary); - } - } - } - } - RegCloseKey(hKey); - } - - /* file extension type */ - value[MAX_PATH - 1] = L'\0'; - SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)value); - - return TRUE; -} - -/************************************************************************* - * - * SHFileGeneralGetFileTimeString [Internal] - * - * formats a given LPFILETIME struct into readable user format - */ - -BOOL -SHFileGeneralGetFileTimeString(LPFILETIME lpFileTime, WCHAR *lpResult) -{ - FILETIME ft; - SYSTEMTIME dt; - WORD wYear; - static const WCHAR wFormat[] = { - '%', '0', '2', 'd', '/', '%', '0', '2', 'd', '/', '%', '0', '4', 'd', - ' ', ' ', '%', '0', '2', 'd', ':', '%', '0', '2', 'u', 0 }; - - if (lpFileTime == NULL || lpResult == NULL) - return FALSE; - - if (!FileTimeToLocalFileTime(lpFileTime, &ft)) - return FALSE; - - FileTimeToSystemTime(&ft, &dt); - - wYear = dt.wYear; - - /* ddmmyy */ - swprintf(lpResult, wFormat, dt.wDay, dt.wMonth, wYear, dt.wHour, dt.wMinute); - - TRACE("result %s\n", debugstr_w(lpResult)); - return TRUE; -} - -/************************************************************************* - * - * SH_FileGeneralSetText [Internal] - * - * sets file path string and filename string - * - */ - -BOOL -SH_FileGeneralSetText(HWND hwndDlg, WCHAR *lpstr) -{ - int flength; - int plength; - WCHAR *lpdir; - WCHAR buff[MAX_PATH]; - HWND hDlgCtrl; - - if (lpstr == NULL) - return FALSE; - - lpdir = wcsrchr(lpstr, '\\'); /* find the last occurence of '\\' */ - - plength = wcslen(lpstr); - flength = wcslen(lpdir); - - if (lpdir) - { - /* location text field */ - wcsncpy(buff, lpstr, plength - flength); - buff[plength - flength] = UNICODE_NULL; - hDlgCtrl = GetDlgItem(hwndDlg, 14009); - SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)buff); - } - - if (flength > 1) - { - /* text filename field */ - wcsncpy(buff, &lpdir[1], flength); - hDlgCtrl = GetDlgItem(hwndDlg, 14001); - SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)buff); - } - - return TRUE; -} - -/************************************************************************* - * - * SH_FileGeneralSetFileSizeTime [Internal] - * - * retrieves file information from file and sets in dialog - * - */ - -BOOL -SH_FileGeneralSetFileSizeTime(HWND hwndDlg, WCHAR *lpfilename, PULARGE_INTEGER lpfilesize) -{ - BOOL result; - HANDLE hFile; - FILETIME create_time; - FILETIME accessed_time; - FILETIME write_time; - WCHAR resultstr[MAX_PATH]; - HWND hDlgCtrl; - LARGE_INTEGER file_size; - - if (lpfilename == NULL) - return FALSE; - - hFile = CreateFileW(lpfilename, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - WARN("failed to open file %s\n", debugstr_w(lpfilename)); - return FALSE; - } - - result = GetFileTime(hFile, &create_time, &accessed_time, &write_time); - - if (!result) - { - WARN("GetFileTime failed\n"); - return FALSE; - } - - if (SHFileGeneralGetFileTimeString(&create_time, resultstr)) - { - hDlgCtrl = GetDlgItem(hwndDlg, 14015); - SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)resultstr); - } - - if (SHFileGeneralGetFileTimeString(&accessed_time, resultstr)) - { - hDlgCtrl = GetDlgItem(hwndDlg, 14019); - SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)resultstr); - } - - if (SHFileGeneralGetFileTimeString(&write_time, resultstr)) - { - hDlgCtrl = GetDlgItem(hwndDlg, 14017); - SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)resultstr); - } - - if (!GetFileSizeEx(hFile, &file_size)) - { - WARN("GetFileSize failed\n"); - CloseHandle(hFile); - return FALSE; - } - - CloseHandle(hFile); - - if (!StrFormatByteSizeW(file_size.QuadPart, - resultstr, - sizeof(resultstr) / sizeof(WCHAR))) - return FALSE; - - hDlgCtrl = GetDlgItem(hwndDlg, 14011); - - TRACE("result size %u resultstr %s\n", file_size.QuadPart, debugstr_w(resultstr)); - SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)resultstr); - - if (lpfilesize) - lpfilesize->QuadPart = (ULONGLONG)file_size.QuadPart; - - return TRUE; -} - -/************************************************************************* - * - * SH_SetFileVersionText [Internal] - * - * - */ - -BOOL -SH_FileVersionQuerySetText(HWND hwndDlg, DWORD dlgId, LPVOID pInfo, WCHAR *text, WCHAR **resptr) -{ - UINT reslen; - HWND hDlgCtrl; - - if (hwndDlg == NULL || resptr == NULL || text == NULL) - return FALSE; - - if (VerQueryValueW(pInfo, text, (LPVOID *)resptr, &reslen)) - { - /* file description property */ - hDlgCtrl = GetDlgItem(hwndDlg, dlgId); - TRACE("%s :: %s\n", debugstr_w(text), debugstr_w(*resptr)); - SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)0, (LPARAM)*resptr); - return TRUE; - } - - return FALSE; -} - -/************************************************************************* - * - * SH_FileVersionQuerySetListText [Internal] - * - * retrieves a version string and adds it to listbox - * - */ - -BOOL -SH_FileVersionQuerySetListText(HWND hwndDlg, LPVOID pInfo, const WCHAR *text, WCHAR **resptr, WORD lang, WORD code) -{ - UINT reslen; - HWND hDlgCtrl; - UINT index; - static const WCHAR wFormat[] = { - '\\', 'S', 't', 'r', 'i', 'n', 'g', 'F', 'i', 'l', 'e', 'I', 'n', 'f', 'o', - '\\', '%', '0', '4', 'x', '%', '0', '4', 'x', '\\', '%', 's', 0 }; - WCHAR buff[256]; - - TRACE("text %s, resptr %p hwndDlg %p\n", debugstr_w(text), resptr, hwndDlg); - - if (hwndDlg == NULL || resptr == NULL || text == NULL) - return FALSE; - - swprintf(buff, wFormat, lang, code, text); - - if (VerQueryValueW(pInfo, buff, (LPVOID *)resptr, &reslen)) - { - /* listbox name property */ - hDlgCtrl = GetDlgItem(hwndDlg, 14009); - TRACE("%s :: %s\n", debugstr_w(text), debugstr_w(*resptr)); - index = SendMessageW(hDlgCtrl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)text); - SendMessageW(hDlgCtrl, LB_SETITEMDATA, (WPARAM)index, (LPARAM)(WCHAR *)*resptr); - return TRUE; - } - - return FALSE; -} - -/************************************************************************* - * - * SH_FileVersionInitialize [Internal] - * - * sets all file version properties in dialog - */ - -BOOL -SH_FileVersionInitialize(HWND hwndDlg, WCHAR *lpfilename) -{ - LPVOID pBuf; - DWORD versize; - DWORD handle; - LPVOID info = NULL; - UINT infolen; - WCHAR buff[256]; - HWND hDlgCtrl; - WORD lang = 0; - WORD code = 0; - LPLANGANDCODEPAGE lplangcode; - WCHAR *str; - static const WCHAR wVersionFormat[] = { - '%', 'd', '.', '%', 'd', '.', '%', 'd', '.', '%', 'd', 0 }; - static const WCHAR wFileDescriptionFormat[] = { - '\\', 'S', 't', 'r', 'i', 'n', 'g', 'F', 'i', 'l', 'e', 'I', 'n', 'f', 'o', - '\\', '%', '0', '4', 'x', '%', '0', '4', 'x', - '\\', 'F', 'i', 'l', 'e', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'i', 'o', 'n', 0 }; - static const WCHAR wLegalCopyrightFormat[] = { - '\\', 'S', 't', 'r', 'i', 'n', 'g', 'F', 'i', 'l', 'e', 'I', 'n', 'f', 'o', - '\\', '%', '0', '4', 'x', '%', '0', '4', 'x', - '\\', 'L', 'e', 'g', 'a', 'l', 'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', 0 }; - static const WCHAR wTranslation[] = { - 'V', 'a', 'r', 'F', 'i', 'l', 'e', 'I', 'n', 'f', 'o', - '\\', 'T', 'r', 'a', 'n', 's', 'l', 'a', 't', 'i', 'o', 'n', 0 }; - static const WCHAR wCompanyName[] = { - 'C', 'o', 'm', 'p', 'a', 'n', 'y', 'N', 'a', 'm', 'e', 0 }; - static const WCHAR wFileVersion[] = { - 'F', 'i', 'l', 'e', 'V', 'e', 'r', 's', 'i', 'o', 'n', 0 }; - static const WCHAR wInternalName[] = { - 'I', 'n', 't', 'e', 'r', 'n', 'a', 'l', 'N', 'a', 'm', 'e', 0 }; - static const WCHAR wOriginalFilename[] = { - 'O', 'r', 'i', 'g', 'i', 'n', 'a', 'l', 'F', 'i', 'l', 'e', 'n', 'a', 'm', 'e', 0 }; - static const WCHAR wProductName[] = { - 'P', 'r', 'o', 'd', 'u', 'c', 't', 'N', 'a', 'm', 'e', 0 }; - static const WCHAR wProductVersion[] = { - 'P', 'r', 'o', 'd', 'u', 'c', 't', 'V', 'e', 'r', 's', 'i', 'o', 'n', 0 }; - static const WCHAR wSlash[] = { '\\', 0 }; - - if (lpfilename == 0) - return FALSE; - - if (!(versize = GetFileVersionInfoSizeW(lpfilename, &handle))) - { - WARN("GetFileVersionInfoSize failed\n"); - return FALSE; - } - - if (!(pBuf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, versize))) - { - WARN("HeapAlloc failed bytes %x\n", versize); - return FALSE; - } - - if (!GetFileVersionInfoW(lpfilename, handle, versize, pBuf)) - { - HeapFree(GetProcessHeap(), 0, pBuf); - return FALSE; - } - - if (VerQueryValueW(pBuf, wSlash, &info, &infolen)) - { - VS_FIXEDFILEINFO *inf = (VS_FIXEDFILEINFO *)info; - swprintf(buff, wVersionFormat, HIWORD(inf->dwFileVersionMS), - LOWORD(inf->dwFileVersionMS), - HIWORD(inf->dwFileVersionLS), - LOWORD(inf->dwFileVersionLS)); - hDlgCtrl = GetDlgItem(hwndDlg, 14001); - TRACE("MS %x LS %x res %s \n", inf->dwFileVersionMS, inf->dwFileVersionLS, debugstr_w(buff)); - SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)buff); - } - - if (VerQueryValueW(pBuf, wTranslation, (LPVOID *)&lplangcode, &infolen)) - { - /* FIXME find language from current locale / if not available, - * default to english - * for now default to first available language - */ - lang = lplangcode->lang; - code = lplangcode->code; - } - - swprintf(buff, wFileDescriptionFormat, lang, code); - SH_FileVersionQuerySetText(hwndDlg, 14003, pBuf, buff, &str); - - swprintf(buff, wLegalCopyrightFormat, lang, code); - SH_FileVersionQuerySetText(hwndDlg, 14005, pBuf, buff, &str); - - /* listbox properties */ - SH_FileVersionQuerySetListText(hwndDlg, pBuf, wCompanyName, &str, lang, code); - SH_FileVersionQuerySetListText(hwndDlg, pBuf, wFileVersion, &str, lang, code); - SH_FileVersionQuerySetListText(hwndDlg, pBuf, wInternalName, &str, lang, code); - - /* FIXME insert language identifier */ - - SH_FileVersionQuerySetListText(hwndDlg, pBuf, wOriginalFilename, &str, lang, code); - SH_FileVersionQuerySetListText(hwndDlg, pBuf, wProductName, &str, lang, code); - SH_FileVersionQuerySetListText(hwndDlg, pBuf, wProductVersion, &str, lang, code); - SetWindowLongPtr(hwndDlg, DWL_USER, (LONG_PTR)pBuf); - - /* select first item */ - hDlgCtrl = GetDlgItem(hwndDlg, 14009); - SendMessageW(hDlgCtrl, LB_SETCURSEL, 0, 0); - str = (WCHAR *) SendMessageW(hDlgCtrl, LB_GETITEMDATA, (WPARAM)0, (LPARAM)NULL); - hDlgCtrl = GetDlgItem(hwndDlg, 14010); - SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)str); - - return TRUE; -} - -/************************************************************************* - * - * SH_FileVersionDlgProc - * - * wnd proc of 'Version' property sheet page - */ - -INT_PTR -CALLBACK -SH_FileVersionDlgProc(HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) -{ - LPPROPSHEETPAGE ppsp; - WCHAR *lpstr; - LPVOID *buf; - - switch (uMsg) - { - case WM_INITDIALOG: - ppsp = (LPPROPSHEETPAGE)lParam; - - if (ppsp == NULL) - break; - - TRACE("WM_INITDIALOG hwnd %p lParam %p ppsplParam %x\n", hwndDlg, lParam, ppsp->lParam); - - lpstr = (WCHAR *)ppsp->lParam; - - if (lpstr == NULL) - break; - - return SH_FileVersionInitialize(hwndDlg, lpstr); - - case WM_COMMAND: - if (LOWORD(wParam) == 14009 && HIWORD(wParam) == LBN_DBLCLK) - { - HWND hDlgCtrl; - LRESULT lresult; - WCHAR *str; - - hDlgCtrl = GetDlgItem(hwndDlg, 14009); - lresult = SendMessageW(hDlgCtrl, LB_GETCURSEL, (WPARAM)NULL, (LPARAM)NULL); - - if (lresult == LB_ERR) - break; - - str = (WCHAR *) SendMessageW(hDlgCtrl, LB_GETITEMDATA, (WPARAM)lresult, (LPARAM)NULL); - - if (str == NULL) - break; - - hDlgCtrl = GetDlgItem(hwndDlg, 14010); - TRACE("hDlgCtrl %x string %s \n", hDlgCtrl, debugstr_w(str)); - SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)str); - - return TRUE; - } - break; - - case WM_DESTROY: - buf = (LPVOID) GetWindowLongPtr(hwndDlg, DWL_USER); - HeapFree(GetProcessHeap(), 0, buf); - break; - - default: - break; - } - - return FALSE; -} - -/************************************************************************* - * - * SH_FileGeneralDlgProc - * - * wnd proc of 'General' property sheet page - * - */ - -INT_PTR -CALLBACK -SH_FileGeneralDlgProc(HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) -{ - LPPROPSHEETPAGEW ppsp; - WCHAR *lpstr; - - switch (uMsg) - { - case WM_INITDIALOG: - ppsp = (LPPROPSHEETPAGEW)lParam; - - if (ppsp == NULL) - break; - - TRACE("WM_INITDIALOG hwnd %p lParam %p ppsplParam %S\n", hwndDlg, lParam, ppsp->lParam); - - lpstr = (WCHAR *)ppsp->lParam; - - if (lpstr == NULL) - { - ERR("no filename\n"); - break; - } - - /* set general text properties filename filelocation and icon */ - SH_FileGeneralSetText(hwndDlg, lpstr); - - /* enumerate file extension from registry and application which opens it */ - SH_FileGeneralSetFileType(hwndDlg, wcsrchr(lpstr, '.')); - - /* set file time create/modfied/accessed */ - SH_FileGeneralSetFileSizeTime(hwndDlg, lpstr, NULL); - - return TRUE; - - default: - break; - } - - return FALSE; -} - -BOOL -CALLBACK -AddShellPropSheetExCallback(HPROPSHEETPAGE hPage, - LPARAM lParam) -{ - PROPSHEETHEADERW *pinfo = (PROPSHEETHEADERW *)lParam; - - if (pinfo->nPages < MAX_PROPERTY_SHEET_PAGE) - { - pinfo->u3.phpage[pinfo->nPages++] = hPage; - return TRUE; - } - - return FALSE; -} - -int -EnumPropSheetExt(LPWSTR wFileName, PROPSHEETHEADERW *pinfo, int NumPages, HPSXA *hpsxa, IDataObject *pDataObj) -{ - WCHAR szName[MAX_PATH] = { 0 }; - WCHAR *pOffset; - UINT Length; - DWORD dwName; - int Pages; - CLSID clsid; - - pOffset = wcsrchr(wFileName, L'.'); - - if (!pOffset) - { - Length = wcslen(szName); - - if (Length + 6 > sizeof(szName) / sizeof(szName[0])) - return 0; - - if (CLSIDFromString(wFileName, &clsid) == NOERROR) - { - wcscpy(szName, L"CLSID\\"); - wcscpy(&szName[6], wFileName); - } - else - { - wcscpy(szName, wFileName); - } - } - else - { - Length = wcslen(pOffset); - - if (Length >= sizeof(szName) / sizeof(szName[0])) - return 0; - - wcscpy(szName, pOffset); - } - - TRACE("EnumPropSheetExt szName %s\n", debugstr_w(szName)); - - hpsxa[0] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, szName, NumPages, pDataObj); - Pages = SHAddFromPropSheetExtArray(hpsxa[0], AddShellPropSheetExCallback, (LPARAM)pinfo); - - hpsxa[1] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, L"*", NumPages-Pages, pDataObj); - Pages += SHAddFromPropSheetExtArray(hpsxa[1], AddShellPropSheetExCallback, (LPARAM)pinfo); - - hpsxa[2] = NULL; - - if (pOffset) - { - /* try to load property sheet handlers from prog id key */ - dwName = sizeof(szName); - - if (RegGetValueW(HKEY_CLASSES_ROOT, pOffset, NULL, RRF_RT_REG_SZ, NULL, szName, &dwName) == ERROR_SUCCESS) - { - TRACE("EnumPropSheetExt szName %s, pOffset %s\n", debugstr_w(szName), debugstr_w(pOffset)); - szName[(sizeof(szName) / sizeof(WCHAR)) - 1] = L'\0'; - hpsxa[2] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, szName, NumPages - Pages, pDataObj); - Pages += SHAddFromPropSheetExtArray(hpsxa[2], AddShellPropSheetExCallback, (LPARAM)pinfo); - } - } - - return Pages; -} - -/************************************************************************* - * - * SH_ShowPropertiesDialog - * - * called from ShellExecuteExW32 - * - * lpf contains (quoted) path of folder/file - * - * TODO: provide button change application type if file has registered type - * make filename field editable and apply changes to filename on close - */ - -BOOL -SH_ShowPropertiesDialog(WCHAR *lpf, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST *apidl) -{ - PROPSHEETHEADERW pinfo; - HPROPSHEETPAGE hppages[MAX_PROPERTY_SHEET_PAGE]; - WCHAR wFileName[MAX_PATH]; - DWORD dwHandle = 0; - WCHAR *pFileName; - HPSXA hpsxa[3]; - INT_PTR res; - IDataObject *pDataObj = NULL; - HRESULT hResult; - - TRACE("SH_ShowPropertiesDialog entered filename %s\n", debugstr_w(lpf)); - - if (lpf == NULL) - return FALSE; - - if (!wcslen(lpf)) - return FALSE; - - memset(hppages, 0x0, sizeof(HPROPSHEETPAGE) * MAX_PROPERTY_SHEET_PAGE); - - if (lpf[0] == '"') - { - /* remove quotes from lpf */ - LPCWSTR src = lpf + 1; - LPWSTR dst = wFileName; - - while (*src && *src != '"') - *dst++ = *src++; - - *dst = '\0'; - } - else - { - wcscpy(wFileName, lpf); - } - - if (PathIsDirectoryW(wFileName)) - { - return SH_ShowFolderProperties(wFileName, pidlFolder, apidl); - } - - if (wcslen(wFileName) == 3) - { - return SH_ShowDriveProperties(wFileName, pidlFolder, apidl); - } - - pFileName = wcsrchr(wFileName, '\\'); - - if (!pFileName) - pFileName = wFileName; - else - pFileName++; - - memset(&pinfo, 0x0, sizeof(PROPSHEETHEADERW)); - pinfo.dwSize = sizeof(PROPSHEETHEADERW); - pinfo.dwFlags = PSH_NOCONTEXTHELP | PSH_PROPTITLE; - pinfo.u3.phpage = hppages; - pinfo.pszCaption = pFileName; - - hppages[pinfo.nPages] = - SH_CreatePropertySheetPage("SHELL_FILE_GENERAL_DLG", - SH_FileGeneralDlgProc, - (LPARAM)wFileName, - NULL); - - if (hppages[pinfo.nPages]) - pinfo.nPages++; - - hResult = SHCreateDataObject(pidlFolder, 1, apidl, NULL, &IID_IDataObject, (LPVOID *)&pDataObj); - - if (hResult == S_OK) - { - if (!EnumPropSheetExt(wFileName, &pinfo, MAX_PROPERTY_SHEET_PAGE - 1, hpsxa, pDataObj)) - { - hpsxa[0] = NULL; - hpsxa[1] = NULL; - hpsxa[2] = NULL; - } - } - - if (GetFileVersionInfoSizeW(lpf, &dwHandle)) - { - hppages[pinfo.nPages] = - SH_CreatePropertySheetPage("SHELL_FILE_VERSION_DLG", - SH_FileVersionDlgProc, - (LPARAM)wFileName, - NULL); - if (hppages[pinfo.nPages]) - pinfo.nPages++; - } - - res = PropertySheetW(&pinfo); - - if (hResult == S_OK) - { - SHDestroyPropSheetExtArray(hpsxa[0]); - SHDestroyPropSheetExtArray(hpsxa[1]); - SHDestroyPropSheetExtArray(hpsxa[2]); - IDataObject_Release(pDataObj); - } - - return (res != -1); -} - -/*EOF */ diff --git a/reactos/dll/win32/shell32/iconcache.c b/reactos/dll/win32/shell32/iconcache.c deleted file mode 100644 index 01e84c99e75..00000000000 --- a/reactos/dll/win32/shell32/iconcache.c +++ /dev/null @@ -1,934 +0,0 @@ -/* - * shell icon cache (SIC) - * - * Copyright 1998, 1999 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -/********************** THE ICON CACHE ********************************/ - -#define INVALID_INDEX -1 - -typedef struct -{ - LPWSTR sSourceFile; /* file (not path!) containing the icon */ - DWORD dwSourceIndex; /* index within the file, if it is a resoure ID it will be negated */ - DWORD dwListIndex; /* index within the iconlist */ - DWORD dwFlags; /* GIL_* flags */ - DWORD dwAccessTime; -} SIC_ENTRY, * LPSIC_ENTRY; - -static HDPA sic_hdpa = 0; - -static CRITICAL_SECTION SHELL32_SicCS; -static CRITICAL_SECTION_DEBUG critsect_debug = -{ - 0, 0, &SHELL32_SicCS, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": SHELL32_SicCS") } -}; -static CRITICAL_SECTION SHELL32_SicCS = { &critsect_debug, -1, 0, 0, 0, 0 }; - -/***************************************************************************** - * SIC_CompareEntries - * - * NOTES - * Callback for DPA_Search - */ -static INT CALLBACK SIC_CompareEntries( LPVOID p1, LPVOID p2, LPARAM lparam) -{ LPSIC_ENTRY e1 = (LPSIC_ENTRY)p1, e2 = (LPSIC_ENTRY)p2; - - TRACE("%p %p %8lx\n", p1, p2, lparam); - - /* Icons in the cache are keyed by the name of the file they are - * loaded from, their resource index and the fact if they have a shortcut - * icon overlay or not. - */ - if (e1->dwSourceIndex != e2->dwSourceIndex || /* first the faster one */ - (e1->dwFlags & GIL_FORSHORTCUT) != (e2->dwFlags & GIL_FORSHORTCUT)) - return 1; - - if (wcsicmp(e1->sSourceFile,e2->sSourceFile)) - return 1; - - return 0; -} - -/* declare SIC_LoadOverlayIcon() */ -static int SIC_LoadOverlayIcon(int icon_idx); - -/***************************************************************************** - * SIC_OverlayShortcutImage [internal] - * - * NOTES - * Creates a new icon as a copy of the passed-in icon, overlayed with a - * shortcut image. - */ -static HICON SIC_OverlayShortcutImage(HICON SourceIcon, BOOL large) -{ ICONINFO SourceIconInfo, ShortcutIconInfo, TargetIconInfo; - HICON ShortcutIcon, TargetIcon; - BITMAP SourceBitmapInfo, ShortcutBitmapInfo; - HDC SourceDC = NULL, - ShortcutDC = NULL, - TargetDC = NULL, - ScreenDC = NULL; - HBITMAP OldSourceBitmap = NULL, - OldShortcutBitmap = NULL, - OldTargetBitmap = NULL; - - static int s_imgListIdx = -1; - - /* Get information about the source icon and shortcut overlay */ - if (! GetIconInfo(SourceIcon, &SourceIconInfo) - || 0 == GetObjectW(SourceIconInfo.hbmColor, sizeof(BITMAP), &SourceBitmapInfo)) - { - return NULL; - } - - /* search for the shortcut icon only once */ - if (s_imgListIdx == -1) - s_imgListIdx = SIC_LoadOverlayIcon(- IDI_SHELL_SHORTCUT); - /* FIXME should use icon index 29 instead of the - resource id, but not all icons are present yet - so we can't use icon indices */ - - if (s_imgListIdx != -1) - { - if (large) - ShortcutIcon = ImageList_GetIcon(ShellBigIconList, s_imgListIdx, ILD_TRANSPARENT); - else - ShortcutIcon = ImageList_GetIcon(ShellSmallIconList, s_imgListIdx, ILD_TRANSPARENT); - } else - ShortcutIcon = NULL; - - if (NULL == ShortcutIcon - || ! GetIconInfo(ShortcutIcon, &ShortcutIconInfo) - || 0 == GetObjectW(ShortcutIconInfo.hbmColor, sizeof(BITMAP), &ShortcutBitmapInfo)) - { - return NULL; - } - - TargetIconInfo = SourceIconInfo; - TargetIconInfo.hbmMask = NULL; - TargetIconInfo.hbmColor = NULL; - - /* Setup the source, shortcut and target masks */ - SourceDC = CreateCompatibleDC(NULL); - if (NULL == SourceDC) goto fail; - OldSourceBitmap = SelectObject(SourceDC, SourceIconInfo.hbmMask); - if (NULL == OldSourceBitmap) goto fail; - - ShortcutDC = CreateCompatibleDC(NULL); - if (NULL == ShortcutDC) goto fail; - OldShortcutBitmap = SelectObject(ShortcutDC, ShortcutIconInfo.hbmMask); - if (NULL == OldShortcutBitmap) goto fail; - - TargetDC = CreateCompatibleDC(NULL); - if (NULL == TargetDC) goto fail; - TargetIconInfo.hbmMask = CreateCompatibleBitmap(TargetDC, SourceBitmapInfo.bmWidth, - SourceBitmapInfo.bmHeight); - if (NULL == TargetIconInfo.hbmMask) goto fail; - ScreenDC = GetDC(NULL); - if (NULL == ScreenDC) goto fail; - TargetIconInfo.hbmColor = CreateCompatibleBitmap(ScreenDC, SourceBitmapInfo.bmWidth, - SourceBitmapInfo.bmHeight); - ReleaseDC(NULL, ScreenDC); - if (NULL == TargetIconInfo.hbmColor) goto fail; - OldTargetBitmap = SelectObject(TargetDC, TargetIconInfo.hbmMask); - if (NULL == OldTargetBitmap) goto fail; - - /* Create the target mask by ANDing the source and shortcut masks */ - if (! BitBlt(TargetDC, 0, 0, SourceBitmapInfo.bmWidth, SourceBitmapInfo.bmHeight, - SourceDC, 0, 0, SRCCOPY) || - ! BitBlt(TargetDC, 0, SourceBitmapInfo.bmHeight - ShortcutBitmapInfo.bmHeight, - ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight, - ShortcutDC, 0, 0, SRCAND)) - { - goto fail; - } - - /* Setup the source and target xor bitmap */ - if (NULL == SelectObject(SourceDC, SourceIconInfo.hbmColor) || - NULL == SelectObject(TargetDC, TargetIconInfo.hbmColor)) - { - goto fail; - } - - /* Copy the source color bitmap to the target */ - if (! BitBlt(TargetDC, 0, 0, SourceBitmapInfo.bmWidth, SourceBitmapInfo.bmHeight, - SourceDC, 0, 0, SRCCOPY)) goto fail; - - /* Copy the source xor bitmap to the target and clear out part of it by using - the shortcut mask */ - if (NULL == SelectObject(ShortcutDC, ShortcutIconInfo.hbmColor)) goto fail; - if (!MaskBlt(TargetDC, 0, SourceBitmapInfo.bmHeight - ShortcutBitmapInfo.bmHeight, - ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight, - ShortcutDC, 0, 0, ShortcutIconInfo.hbmMask, 0, 0, - MAKEROP4(0xAA0000, SRCCOPY))) - { - goto fail; - } - - /* Clean up, we're not goto'ing to 'fail' after this so we can be lazy and not set - handles to NULL */ - SelectObject(TargetDC, OldTargetBitmap); - DeleteObject(TargetDC); - SelectObject(ShortcutDC, OldShortcutBitmap); - DeleteObject(ShortcutDC); - SelectObject(SourceDC, OldSourceBitmap); - DeleteObject(SourceDC); - - /* Create the icon using the bitmaps prepared earlier */ - TargetIcon = CreateIconIndirect(&TargetIconInfo); - - /* CreateIconIndirect copies the bitmaps, so we can release our bitmaps now */ - DeleteObject(TargetIconInfo.hbmColor); - DeleteObject(TargetIconInfo.hbmMask); - - return TargetIcon; - -fail: - /* Clean up scratch resources we created */ - if (NULL != OldTargetBitmap) SelectObject(TargetDC, OldTargetBitmap); - if (NULL != TargetIconInfo.hbmColor) DeleteObject(TargetIconInfo.hbmColor); - if (NULL != TargetIconInfo.hbmMask) DeleteObject(TargetIconInfo.hbmMask); - if (NULL != TargetDC) DeleteObject(TargetDC); - if (NULL != OldShortcutBitmap) SelectObject(ShortcutDC, OldShortcutBitmap); - if (NULL != ShortcutDC) DeleteObject(ShortcutDC); - if (NULL != OldSourceBitmap) SelectObject(SourceDC, OldSourceBitmap); - if (NULL != SourceDC) DeleteObject(SourceDC); - - return NULL; -} - -/***************************************************************************** - * SIC_IconAppend [internal] - * - * NOTES - * appends an icon pair to the end of the cache - */ -static INT SIC_IconAppend (LPCWSTR sSourceFile, INT dwSourceIndex, HICON hSmallIcon, HICON hBigIcon, DWORD dwFlags) -{ LPSIC_ENTRY lpsice; - INT ret, index, index1; - WCHAR path[MAX_PATH]; - TRACE("%s %i %p %p\n", debugstr_w(sSourceFile), dwSourceIndex, hSmallIcon ,hBigIcon); - - lpsice = (LPSIC_ENTRY) SHAlloc (sizeof (SIC_ENTRY)); - - GetFullPathNameW(sSourceFile, MAX_PATH, path, NULL); - lpsice->sSourceFile = HeapAlloc( GetProcessHeap(), 0, (wcslen(path)+1)*sizeof(WCHAR) ); - wcscpy( lpsice->sSourceFile, path ); - - lpsice->dwSourceIndex = dwSourceIndex; - lpsice->dwFlags = dwFlags; - - EnterCriticalSection(&SHELL32_SicCS); - - index = DPA_InsertPtr(sic_hdpa, 0x7fff, lpsice); - if ( INVALID_INDEX == index ) - { - HeapFree(GetProcessHeap(), 0, lpsice->sSourceFile); - SHFree(lpsice); - ret = INVALID_INDEX; - } - else - { - index = ImageList_AddIcon (ShellSmallIconList, hSmallIcon); - index1= ImageList_AddIcon (ShellBigIconList, hBigIcon); - - if (index!=index1) - { - FIXME("iconlists out of sync 0x%x 0x%x\n", index, index1); - } - lpsice->dwListIndex = index; - ret = lpsice->dwListIndex; - } - - LeaveCriticalSection(&SHELL32_SicCS); - return ret; -} -/**************************************************************************** - * SIC_LoadIcon [internal] - * - * NOTES - * gets small/big icon by number from a file - */ -static INT SIC_LoadIcon (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags) -{ HICON hiconLarge=0; - HICON hiconSmall=0; - HICON hiconLargeShortcut; - HICON hiconSmallShortcut; - -#if defined(__CYGWIN__) || defined (__MINGW32__) || defined(_MSC_VER) - static UINT (WINAPI*PrivateExtractIconExW)(LPCWSTR,int,HICON*,HICON*,UINT) = NULL; - - if (!PrivateExtractIconExW) { - HMODULE hUser32 = GetModuleHandleA("user32"); - PrivateExtractIconExW = (UINT(WINAPI*)(LPCWSTR,int,HICON*,HICON*,UINT)) GetProcAddress(hUser32, "PrivateExtractIconExW"); - } - - if (PrivateExtractIconExW) - PrivateExtractIconExW(sSourceFile, dwSourceIndex, &hiconLarge, &hiconSmall, 1); - else -#endif - { - PrivateExtractIconsW(sSourceFile, dwSourceIndex, 32, 32, &hiconLarge, NULL, 1, 0); - PrivateExtractIconsW(sSourceFile, dwSourceIndex, 16, 16, &hiconSmall, NULL, 1, 0); - } - - if ( !hiconLarge || !hiconSmall) - { - WARN("failure loading icon %i from %s (%p %p)\n", dwSourceIndex, debugstr_w(sSourceFile), hiconLarge, hiconSmall); - return -1; - } - - if (0 != (dwFlags & GIL_FORSHORTCUT)) - { - hiconLargeShortcut = SIC_OverlayShortcutImage(hiconLarge, TRUE); - hiconSmallShortcut = SIC_OverlayShortcutImage(hiconSmall, FALSE); - if (NULL != hiconLargeShortcut && NULL != hiconSmallShortcut) - { - hiconLarge = hiconLargeShortcut; - hiconSmall = hiconSmallShortcut; - } - else - { - WARN("Failed to create shortcut overlayed icons\n"); - if (NULL != hiconLargeShortcut) DestroyIcon(hiconLargeShortcut); - if (NULL != hiconSmallShortcut) DestroyIcon(hiconSmallShortcut); - dwFlags &= ~ GIL_FORSHORTCUT; - } - } - - return SIC_IconAppend (sSourceFile, dwSourceIndex, hiconSmall, hiconLarge, dwFlags); -} -/***************************************************************************** - * SIC_GetIconIndex [internal] - * - * Parameters - * sSourceFile [IN] filename of file containing the icon - * index [IN] index/resID (negated) in this file - * - * NOTES - * look in the cache for a proper icon. if not available the icon is taken - * from the file and cached - */ -INT SIC_GetIconIndex (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags ) -{ - SIC_ENTRY sice; - INT ret, index = INVALID_INDEX; - WCHAR path[MAX_PATH]; - - TRACE("%s %i\n", debugstr_w(sSourceFile), dwSourceIndex); - - GetFullPathNameW(sSourceFile, MAX_PATH, path, NULL); - sice.sSourceFile = path; - sice.dwSourceIndex = dwSourceIndex; - sice.dwFlags = dwFlags; - - EnterCriticalSection(&SHELL32_SicCS); - - if (NULL != DPA_GetPtr (sic_hdpa, 0)) - { - /* search linear from position 0*/ - index = DPA_Search (sic_hdpa, &sice, 0, SIC_CompareEntries, 0, 0); - } - - if ( INVALID_INDEX == index ) - { - ret = SIC_LoadIcon (sSourceFile, dwSourceIndex, dwFlags); - } - else - { - TRACE("-- found\n"); - ret = ((LPSIC_ENTRY)DPA_GetPtr(sic_hdpa, index))->dwListIndex; - } - - LeaveCriticalSection(&SHELL32_SicCS); - return ret; -} -/***************************************************************************** - * SIC_Initialize [internal] - */ -BOOL SIC_Initialize(void) -{ - HICON hSm = NULL, hLg = NULL; - INT cx_small, cy_small; - INT cx_large, cy_large; - HDC hDC; - INT bpp; - DWORD ilMask; - - TRACE("Entered SIC_Initialize\n"); - - if (sic_hdpa) - { - TRACE("Icon cache already initialized\n"); - return TRUE; - } - - sic_hdpa = DPA_Create(16); - if (!sic_hdpa) - { - return FALSE; - } - - hDC = CreateICW(L"DISPLAY", NULL, NULL, NULL); - if (!hDC) - { - ERR("Failed to create information context (error %d)\n", GetLastError()); - return FALSE; - } - - bpp = GetDeviceCaps(hDC, BITSPIXEL); - ReleaseDC(NULL, hDC); - - if (bpp <= 4) - ilMask = ILC_COLOR4; - else if (bpp <= 8) - ilMask = ILC_COLOR8; - else if (bpp <= 16) - ilMask = ILC_COLOR16; - else if (bpp <= 24) - ilMask = ILC_COLOR24; - else if (bpp <= 32) - ilMask = ILC_COLOR32; - else - ilMask = ILC_COLOR; - - ilMask |= ILC_MASK; - - cx_small = GetSystemMetrics(SM_CXSMICON); - cy_small = GetSystemMetrics(SM_CYSMICON); - cx_large = GetSystemMetrics(SM_CXICON); - cy_large = GetSystemMetrics(SM_CYICON); - - ShellSmallIconList = ImageList_Create(cx_small, - cy_small, - ilMask, - 100, - 100); - - ShellBigIconList = ImageList_Create(cx_large, - cy_large, - ilMask, - 100, - 100); - if (ShellSmallIconList) - { - /* Load the document icon, which is used as the default if an icon isn't found. */ - hSm = (HICON)LoadImageW(shell32_hInstance, - MAKEINTRESOURCEW(IDI_SHELL_DOCUMENT), - IMAGE_ICON, - cx_small, - cy_small, - LR_SHARED | LR_DEFAULTCOLOR); - if (!hSm) - { - ERR("Failed to load IDI_SHELL_DOCUMENT icon1!\n"); - return FALSE; - } - } - else - { - ERR("Failed to load ShellSmallIconList\n"); - return FALSE; - } - - if (ShellBigIconList) - { - hLg = (HICON)LoadImageW(shell32_hInstance, - MAKEINTRESOURCEW(IDI_SHELL_DOCUMENT), - IMAGE_ICON, - cx_large, - cy_large, - LR_SHARED | LR_DEFAULTCOLOR); - if (!hLg) - { - ERR("Failed to load IDI_SHELL_DOCUMENT icon2!\n"); - DestroyIcon(hSm); - return FALSE; - } - } - else - { - ERR("Failed to load ShellBigIconList\n"); - return FALSE; - } - - SIC_IconAppend(swShell32Name, IDI_SHELL_DOCUMENT-1, hSm, hLg, 0); - SIC_IconAppend(swShell32Name, -IDI_SHELL_DOCUMENT, hSm, hLg, 0); - - TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList); - - return TRUE; -} -/************************************************************************* - * SIC_Destroy - * - * frees the cache - */ -static INT CALLBACK sic_free( LPVOID ptr, LPVOID lparam ) -{ - HeapFree(GetProcessHeap(), 0, ((LPSIC_ENTRY)ptr)->sSourceFile); - SHFree(ptr); - return TRUE; -} - -void SIC_Destroy(void) -{ - TRACE("\n"); - - EnterCriticalSection(&SHELL32_SicCS); - - if (sic_hdpa) DPA_DestroyCallback(sic_hdpa, sic_free, NULL ); - - sic_hdpa = NULL; - ImageList_Destroy(ShellSmallIconList); - ShellSmallIconList = 0; - ImageList_Destroy(ShellBigIconList); - ShellBigIconList = 0; - - LeaveCriticalSection(&SHELL32_SicCS); - //DeleteCriticalSection(&SHELL32_SicCS); //static -} - -/***************************************************************************** - * SIC_LoadOverlayIcon [internal] - * - * Load a shell overlay icon and return its icon cache index. - */ -static int SIC_LoadOverlayIcon(int icon_idx) -{ - WCHAR buffer[1024], wszIdx[8]; - HKEY hKeyShellIcons; - LPCWSTR iconPath; - int iconIdx; - - static const WCHAR wszShellIcons[] = { - 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\', - 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', - 'E','x','p','l','o','r','e','r','\\','S','h','e','l','l',' ','I','c','o','n','s',0 - }; - static const WCHAR wszNumFmt[] = {'%','d',0}; - - iconPath = swShell32Name; /* default: load icon from shell32.dll */ - iconIdx = icon_idx; - - if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszShellIcons, 0, KEY_READ, &hKeyShellIcons) == ERROR_SUCCESS) - { - DWORD count = sizeof(buffer); - - swprintf(wszIdx, wszNumFmt, icon_idx); - - /* read icon path and index */ - if (RegQueryValueExW(hKeyShellIcons, wszIdx, NULL, NULL, (LPBYTE)buffer, &count) == ERROR_SUCCESS) - { - LPWSTR p = wcschr(buffer, ','); - - if (p) - *p++ = 0; - - iconPath = buffer; - iconIdx = _wtoi(p); - } - - RegCloseKey(hKeyShellIcons); - } - - return SIC_LoadIcon(iconPath, iconIdx, 0); -} - -/************************************************************************* - * Shell_GetImageLists [SHELL32.71] - * - * PARAMETERS - * imglist[1|2] [OUT] pointer which receives imagelist handles - * - */ -BOOL WINAPI Shell_GetImageLists(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList) -{ TRACE("(%p,%p)\n",lpBigList,lpSmallList); - if (lpBigList) - { *lpBigList = ShellBigIconList; - } - if (lpSmallList) - { *lpSmallList = ShellSmallIconList; - } - - return TRUE; -} -/************************************************************************* - * PidlToSicIndex [INTERNAL] - * - * PARAMETERS - * sh [IN] IShellFolder - * pidl [IN] - * bBigIcon [IN] - * uFlags [IN] GIL_* - * pIndex [OUT] index within the SIC - * - */ -BOOL PidlToSicIndex ( - IShellFolder * sh, - LPCITEMIDLIST pidl, - BOOL bBigIcon, - UINT uFlags, - int * pIndex) -{ - IExtractIconW *ei; - WCHAR szIconFile[MAX_PATH]; /* file containing the icon */ - INT iSourceIndex; /* index or resID(negated) in this file */ - BOOL ret = FALSE; - UINT dwFlags = 0; - int iShortcutDefaultIndex = INVALID_INDEX; - - TRACE("sf=%p pidl=%p %s\n", sh, pidl, bBigIcon?"Big":"Small"); - - if (SUCCEEDED (IShellFolder_GetUIObjectOf(sh, 0, 1, &pidl, &IID_IExtractIconW, 0, (void **)&ei))) - { - if (SUCCEEDED(ei->lpVtbl->GetIconLocation(ei, uFlags, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags))) - { - *pIndex = SIC_GetIconIndex(szIconFile, iSourceIndex, uFlags); - ret = TRUE; - } - ei->lpVtbl->Release(ei); - } - - if (INVALID_INDEX == *pIndex) /* default icon when failed */ - { - if (0 == (uFlags & GIL_FORSHORTCUT)) - { - *pIndex = 0; - } - else - { - if (INVALID_INDEX == iShortcutDefaultIndex) - { - iShortcutDefaultIndex = SIC_LoadIcon(swShell32Name, 0, GIL_FORSHORTCUT); - } - *pIndex = (INVALID_INDEX != iShortcutDefaultIndex ? iShortcutDefaultIndex : 0); - } - } - - return ret; - -} - -/************************************************************************* - * SHMapPIDLToSystemImageListIndex [SHELL32.77] - * - * PARAMETERS - * sh [IN] pointer to an instance of IShellFolder - * pidl [IN] - * pIndex [OUT][OPTIONAL] SIC index for big icon - * - */ -int WINAPI SHMapPIDLToSystemImageListIndex( - IShellFolder *sh, - LPCITEMIDLIST pidl, - int *pIndex) -{ - int Index; - UINT uGilFlags = 0; - - TRACE("(SF=%p,pidl=%p,%p)\n",sh,pidl,pIndex); - pdump(pidl); - - if (SHELL_IsShortcut(pidl)) - uGilFlags |= GIL_FORSHORTCUT; - - if (pIndex) - if (!PidlToSicIndex ( sh, pidl, 1, uGilFlags, pIndex)) - *pIndex = -1; - - if (!PidlToSicIndex ( sh, pidl, 0, uGilFlags, &Index)) - return -1; - - return Index; -} - -/************************************************************************* - * SHMapIDListToImageListIndexAsync [SHELL32.148] - */ -HRESULT WINAPI SHMapIDListToImageListIndexAsync(IUnknown *pts, IShellFolder *psf, - LPCITEMIDLIST pidl, UINT flags, - void *pfn, void *pvData, void *pvHint, - int *piIndex, int *piIndexSel) -{ - FIXME("(%p, %p, %p, 0x%08x, %p, %p, %p, %p, %p)\n", - pts, psf, pidl, flags, pfn, pvData, pvHint, piIndex, piIndexSel); - return E_FAIL; -} - -/************************************************************************* - * Shell_GetCachedImageIndex [SHELL32.72] - * - */ -INT WINAPI Shell_GetCachedImageIndexA(LPCSTR szPath, INT nIndex, UINT bSimulateDoc) -{ - INT ret, len; - LPWSTR szTemp; - - WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_a(szPath), nIndex, bSimulateDoc); - - len = MultiByteToWideChar( CP_ACP, 0, szPath, -1, NULL, 0 ); - szTemp = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); - MultiByteToWideChar( CP_ACP, 0, szPath, -1, szTemp, len ); - - ret = SIC_GetIconIndex( szTemp, nIndex, 0 ); - - HeapFree( GetProcessHeap(), 0, szTemp ); - - return ret; -} - -INT WINAPI Shell_GetCachedImageIndexW(LPCWSTR szPath, INT nIndex, UINT bSimulateDoc) -{ - WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_w(szPath), nIndex, bSimulateDoc); - - return SIC_GetIconIndex(szPath, nIndex, 0); -} - -INT WINAPI Shell_GetCachedImageIndexAW(LPCVOID szPath, INT nIndex, BOOL bSimulateDoc) -{ if( SHELL_OsIsUnicode()) - return Shell_GetCachedImageIndexW(szPath, nIndex, bSimulateDoc); - return Shell_GetCachedImageIndexA(szPath, nIndex, bSimulateDoc); -} - -/************************************************************************* - * ExtractIconExW [SHELL32.@] - * RETURNS - * 0 no icon found - * -1 file is not valid - * or number of icons extracted - */ -UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons) -{ - /* get entry point of undocumented function PrivateExtractIconExW() in user32 */ -#if defined(__CYGWIN__) || defined (__MINGW32__) || defined(_MSC_VER) - static UINT (WINAPI*PrivateExtractIconExW)(LPCWSTR,int,HICON*,HICON*,UINT) = NULL; - - if (!PrivateExtractIconExW) { - HMODULE hUser32 = GetModuleHandleA("user32"); - PrivateExtractIconExW = (UINT(WINAPI*)(LPCWSTR,int,HICON*,HICON*,UINT)) GetProcAddress(hUser32, "PrivateExtractIconExW"); - - if (!PrivateExtractIconExW) - return 0; - } -#endif - - TRACE("%s %i %p %p %i\n", debugstr_w(lpszFile), nIconIndex, phiconLarge, phiconSmall, nIcons); - - return PrivateExtractIconExW(lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons); -} - -/************************************************************************* - * ExtractIconExA [SHELL32.@] - */ -UINT WINAPI ExtractIconExA(LPCSTR lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons) -{ - UINT ret = 0; - INT len = MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, NULL, 0); - LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - - TRACE("%s %i %p %p %i\n", lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons); - - if (lpwstrFile) - { - MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, lpwstrFile, len); - ret = ExtractIconExW(lpwstrFile, nIconIndex, phiconLarge, phiconSmall, nIcons); - HeapFree(GetProcessHeap(), 0, lpwstrFile); - } - return ret; -} - -/************************************************************************* - * ExtractAssociatedIconA (SHELL32.@) - * - * Return icon for given file (either from file itself or from associated - * executable) and patch parameters if needed. - */ -HICON WINAPI ExtractAssociatedIconA(HINSTANCE hInst, LPSTR lpIconPath, LPWORD lpiIcon) -{ - HICON hIcon = NULL; - INT len = MultiByteToWideChar(CP_ACP, 0, lpIconPath, -1, NULL, 0); - /* Note that we need to allocate MAX_PATH, since we are supposed to fill - * the correct executable if there is no icon in lpIconPath directly. - * lpIconPath itself is supposed to be large enough, so make sure lpIconPathW - * is large enough too. Yes, I am puking too. - */ - LPWSTR lpIconPathW = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR)); - - TRACE("%p %s %p\n", hInst, debugstr_a(lpIconPath), lpiIcon); - - if (lpIconPathW) - { - MultiByteToWideChar(CP_ACP, 0, lpIconPath, -1, lpIconPathW, len); - hIcon = ExtractAssociatedIconW(hInst, lpIconPathW, lpiIcon); - WideCharToMultiByte(CP_ACP, 0, lpIconPathW, -1, lpIconPath, MAX_PATH , NULL, NULL); - HeapFree(GetProcessHeap(), 0, lpIconPathW); - } - return hIcon; -} - -/************************************************************************* - * ExtractAssociatedIconW (SHELL32.@) - * - * Return icon for given file (either from file itself or from associated - * executable) and patch parameters if needed. - */ -HICON WINAPI ExtractAssociatedIconW(HINSTANCE hInst, LPWSTR lpIconPath, LPWORD lpiIcon) -{ - HICON hIcon = NULL; - WORD wDummyIcon = 0; - - TRACE("%p %s %p\n", hInst, debugstr_w(lpIconPath), lpiIcon); - - if(lpiIcon == NULL) - lpiIcon = &wDummyIcon; - - hIcon = ExtractIconW(hInst, lpIconPath, *lpiIcon); - - if( hIcon < (HICON)2 ) - { if( hIcon == (HICON)1 ) /* no icons found in given file */ - { WCHAR tempPath[MAX_PATH]; - HINSTANCE uRet = FindExecutableW(lpIconPath,NULL,tempPath); - - if( uRet > (HINSTANCE)32 && tempPath[0] ) - { wcscpy(lpIconPath,tempPath); - hIcon = ExtractIconW(hInst, lpIconPath, *lpiIcon); - if( hIcon > (HICON)2 ) - return hIcon; - } - } - - if( hIcon == (HICON)1 ) - *lpiIcon = 2; /* MSDOS icon - we found .exe but no icons in it */ - else - *lpiIcon = 6; /* generic icon - found nothing */ - - if (GetModuleFileNameW(hInst, lpIconPath, MAX_PATH)) - hIcon = LoadIconW(hInst, MAKEINTRESOURCEW(*lpiIcon)); - } - return hIcon; -} - -/************************************************************************* - * ExtractAssociatedIconExW (SHELL32.@) - * - * Return icon for given file (either from file itself or from associated - * executable) and patch parameters if needed. - */ -HICON WINAPI ExtractAssociatedIconExW(HINSTANCE hInst, LPWSTR lpIconPath, LPWORD lpiIconIdx, LPWORD lpiIconId) -{ - FIXME("%p %s %p %p): stub\n", hInst, debugstr_w(lpIconPath), lpiIconIdx, lpiIconId); - return 0; -} - -/************************************************************************* - * ExtractAssociatedIconExA (SHELL32.@) - * - * Return icon for given file (either from file itself or from associated - * executable) and patch parameters if needed. - */ -HICON WINAPI ExtractAssociatedIconExA(HINSTANCE hInst, LPSTR lpIconPath, LPWORD lpiIconIdx, LPWORD lpiIconId) -{ - HICON ret; - INT len = MultiByteToWideChar( CP_ACP, 0, lpIconPath, -1, NULL, 0 ); - LPWSTR lpwstrFile = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); - - TRACE("%p %s %p %p)\n", hInst, lpIconPath, lpiIconIdx, lpiIconId); - - MultiByteToWideChar( CP_ACP, 0, lpIconPath, -1, lpwstrFile, len ); - ret = ExtractAssociatedIconExW(hInst, lpwstrFile, lpiIconIdx, lpiIconId); - HeapFree(GetProcessHeap(), 0, lpwstrFile); - return ret; -} - - -/**************************************************************************** - * SHDefExtractIconW [SHELL32.@] - */ -HRESULT WINAPI SHDefExtractIconW(LPCWSTR pszIconFile, int iIndex, UINT uFlags, - HICON* phiconLarge, HICON* phiconSmall, UINT nIconSize) -{ - UINT ret; - HICON hIcons[2]; - WARN("%s %d 0x%08x %p %p %d, semi-stub\n", debugstr_w(pszIconFile), iIndex, uFlags, phiconLarge, phiconSmall, nIconSize); - - ret = PrivateExtractIconsW(pszIconFile, iIndex, nIconSize, nIconSize, hIcons, NULL, 2, LR_DEFAULTCOLOR); - /* FIXME: deal with uFlags parameter which contains GIL_ flags */ - if (ret == 0xFFFFFFFF) - return E_FAIL; - if (ret > 0) { - if (phiconLarge) - *phiconLarge = hIcons[0]; - else - DestroyIcon(hIcons[0]); - if (phiconSmall) - *phiconSmall = hIcons[1]; - else - DestroyIcon(hIcons[1]); - return S_OK; - } - return S_FALSE; -} - -/**************************************************************************** - * SHDefExtractIconA [SHELL32.@] - */ -HRESULT WINAPI SHDefExtractIconA(LPCSTR pszIconFile, int iIndex, UINT uFlags, - HICON* phiconLarge, HICON* phiconSmall, UINT nIconSize) -{ - HRESULT ret; - INT len = MultiByteToWideChar(CP_ACP, 0, pszIconFile, -1, NULL, 0); - LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - - TRACE("%s %d 0x%08x %p %p %d\n", pszIconFile, iIndex, uFlags, phiconLarge, phiconSmall, nIconSize); - - MultiByteToWideChar(CP_ACP, 0, pszIconFile, -1, lpwstrFile, len); - ret = SHDefExtractIconW(lpwstrFile, iIndex, uFlags, phiconLarge, phiconSmall, nIconSize); - HeapFree(GetProcessHeap(), 0, lpwstrFile); - return ret; -} - -/**************************************************************************** - * SHGetIconOverlayIndexA [SHELL32.@] - * - * Returns the index of the overlay icon in the system image list. - */ -INT WINAPI SHGetIconOverlayIndexA(LPCSTR pszIconPath, INT iIconIndex) -{ - FIXME("%s, %d\n", debugstr_a(pszIconPath), iIconIndex); - - return -1; -} - -/**************************************************************************** - * SHGetIconOverlayIndexW [SHELL32.@] - * - * Returns the index of the overlay icon in the system image list. - */ -INT WINAPI SHGetIconOverlayIndexW(LPCWSTR pszIconPath, INT iIconIndex) -{ - FIXME("%s, %d\n", debugstr_w(pszIconPath), iIconIndex); - - return -1; -} diff --git a/reactos/dll/win32/shell32/pidl.c b/reactos/dll/win32/shell32/pidl.c deleted file mode 100644 index 59985de032b..00000000000 --- a/reactos/dll/win32/shell32/pidl.c +++ /dev/null @@ -1,2428 +0,0 @@ -/* - * pidl Handling - * - * Copyright 1998 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - * - * NOTES - * a pidl == NULL means desktop and is legal - * - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(pidl); -WINE_DECLARE_DEBUG_CHANNEL(shell); - -/* from comctl32.dll */ -extern LPVOID WINAPI Alloc(INT); -extern BOOL WINAPI Free(LPVOID); - -static LPSTR _ILGetSTextPointer(LPCITEMIDLIST pidl); -static LPWSTR _ILGetTextPointerW(LPCITEMIDLIST pidl); - -/************************************************************************* - * ILGetDisplayNameExA [SHELL32.186] - * - * Retrieves the display name of an ItemIDList - * - * PARAMS - * psf [I] Shell Folder to start with, if NULL the desktop is used - * pidl [I] ItemIDList relative to the psf to get the display name for - * path [O] Filled in with the display name, assumed to be at least MAX_PATH long - * type [I] Type of display name to retrieve - * 0 = SHGDN_FORPARSING | SHGDN_FORADDRESSBAR uses always the desktop as root - * 1 = SHGDN_NORMAL relative to the root folder - * 2 = SHGDN_INFOLDER relative to the root folder, only the last name - * - * RETURNS - * True if the display name could be retrieved successfully, False otherwise - */ -static BOOL ILGetDisplayNameExA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPSTR path, DWORD type) -{ - BOOL ret = FALSE; - WCHAR wPath[MAX_PATH]; - - TRACE("%p %p %p %d\n", psf, pidl, path, type); - - if (!pidl || !path) - return FALSE; - - ret = ILGetDisplayNameExW(psf, pidl, wPath, type); - WideCharToMultiByte(CP_ACP, 0, wPath, -1, path, MAX_PATH, NULL, NULL); - TRACE("%p %p %s\n", psf, pidl, debugstr_a(path)); - - return ret; -} - -BOOL WINAPI ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type) -{ - LPSHELLFOLDER psfParent, lsf = psf; - HRESULT ret = NO_ERROR; - LPCITEMIDLIST pidllast; - STRRET strret; - DWORD flag; - - TRACE("%p %p %p %d\n", psf, pidl, path, type); - - if (!pidl || !path) - return FALSE; - - if (!lsf) - { - ret = SHGetDesktopFolder(&lsf); - if (FAILED(ret)) - return FALSE; - } - - if (type <= 2) - { - switch (type) - { - case ILGDN_FORPARSING: - flag = SHGDN_FORPARSING | SHGDN_FORADDRESSBAR; - break; - case ILGDN_NORMAL: - flag = SHGDN_NORMAL; - break; - case ILGDN_INFOLDER: - flag = SHGDN_INFOLDER; - break; - default: - FIXME("Unknown type parameter = %x\n", type); - flag = SHGDN_FORPARSING | SHGDN_FORADDRESSBAR; - break; - } - if (!*(const WORD*)pidl || type == ILGDN_FORPARSING) - { - ret = IShellFolder_GetDisplayNameOf(lsf, pidl, flag, &strret); - if (SUCCEEDED(ret)) - { - if(!StrRetToStrNW(path, MAX_PATH, &strret, pidl)) - ret = E_FAIL; - } - } - else - { - ret = SHBindToParent(pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidllast); - if (SUCCEEDED(ret)) - { - ret = IShellFolder_GetDisplayNameOf(psfParent, pidllast, flag, &strret); - if (SUCCEEDED(ret)) - { - if(!StrRetToStrNW(path, MAX_PATH, &strret, pidllast)) - ret = E_FAIL; - } - IShellFolder_Release(psfParent); - } - } - } - - TRACE("%p %p %s\n", psf, pidl, debugstr_w(path)); - - if (!psf) - IShellFolder_Release(lsf); - return SUCCEEDED(ret); -} - -/************************************************************************* - * ILGetDisplayNameEx [SHELL32.186] - */ -BOOL WINAPI ILGetDisplayNameEx(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPVOID path, DWORD type) -{ - TRACE_(shell)("%p %p %p %d\n", psf, pidl, path, type); - - if (SHELL_OsIsUnicode()) - return ILGetDisplayNameExW(psf, pidl, path, type); - return ILGetDisplayNameExA(psf, pidl, path, type); -} - -/************************************************************************* - * ILGetDisplayName [SHELL32.15] - */ -BOOL WINAPI ILGetDisplayName(LPCITEMIDLIST pidl, LPVOID path) -{ - TRACE_(shell)("%p %p\n", pidl, path); - - if (SHELL_OsIsUnicode()) - return ILGetDisplayNameExW(NULL, pidl, path, ILGDN_FORPARSING); - return ILGetDisplayNameExA(NULL, pidl, path, ILGDN_FORPARSING); -} - -/************************************************************************* - * ILFindLastID [SHELL32.16] - * - * NOTES - * observed: pidl=Desktop return=pidl - */ -LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl) -{ - LPCITEMIDLIST pidlLast = pidl; - - TRACE("(pidl=%p)\n",pidl); - - if (!pidl) - return NULL; - - while (pidl->mkid.cb) - { - pidlLast = pidl; - pidl = ILGetNext(pidl); - } - return (LPITEMIDLIST)pidlLast; -} - -/************************************************************************* - * ILRemoveLastID [SHELL32.17] - * - * NOTES - * when pidl=Desktop return=FALSE - */ -BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl) -{ - TRACE_(shell)("pidl=%p\n",pidl); - - if (!pidl || !pidl->mkid.cb) - return 0; - ILFindLastID(pidl)->mkid.cb = 0; - return 1; -} - -/************************************************************************* - * ILClone [SHELL32.18] - * - * NOTES - * duplicate an idlist - */ -LPITEMIDLIST WINAPI ILClone (LPCITEMIDLIST pidl) -{ - DWORD len; - LPITEMIDLIST newpidl; - - if (!pidl) - return NULL; - - len = ILGetSize(pidl); - newpidl = SHAlloc(len); - if (newpidl) - memcpy(newpidl,pidl,len); - - TRACE("pidl=%p newpidl=%p\n",pidl, newpidl); - pdump(pidl); - - return newpidl; -} - -/************************************************************************* - * ILCloneFirst [SHELL32.19] - * - * NOTES - * duplicates the first idlist of a complex pidl - */ -LPITEMIDLIST WINAPI ILCloneFirst(LPCITEMIDLIST pidl) -{ - DWORD len; - LPITEMIDLIST pidlNew = NULL; - - TRACE("pidl=%p\n", pidl); - pdump(pidl); - - if (pidl) - { - len = pidl->mkid.cb; - pidlNew = SHAlloc(len+2); - if (pidlNew) - { - memcpy(pidlNew,pidl,len+2); /* 2 -> mind a desktop pidl */ - - if (len) - ILGetNext(pidlNew)->mkid.cb = 0x00; - } - } - TRACE("-- newpidl=%p\n",pidlNew); - - return pidlNew; -} - -/************************************************************************* - * ILLoadFromStream (SHELL32.26) - * - * NOTES - * the first two bytes are the len, the pidl is following then - */ -HRESULT WINAPI ILLoadFromStream (IStream * pStream, LPITEMIDLIST * ppPidl) -{ - WORD wLen = 0; - DWORD dwBytesRead; - HRESULT ret = E_FAIL; - - - TRACE_(shell)("%p %p\n", pStream , ppPidl); - - SHFree(*ppPidl); - *ppPidl = NULL; - - IStream_AddRef (pStream); - - if (SUCCEEDED(IStream_Read(pStream, &wLen, 2, &dwBytesRead))) - { - TRACE("PIDL length is %d\n", wLen); - if (wLen != 0) - { - *ppPidl = SHAlloc (wLen); - if (SUCCEEDED(IStream_Read(pStream, *ppPidl , wLen, &dwBytesRead))) - { - TRACE("Stream read OK\n"); - ret = S_OK; - } - else - { - WARN("reading pidl failed\n"); - SHFree(*ppPidl); - *ppPidl = NULL; - } - } - else - { - *ppPidl = NULL; - ret = S_OK; - } - } - - /* we are not yet fully compatible */ - if (*ppPidl && !pcheck(*ppPidl)) - { - WARN("Check failed\n"); - SHFree(*ppPidl); - *ppPidl = NULL; - } - - IStream_Release (pStream); - TRACE("done\n"); - return ret; -} - -/************************************************************************* - * ILSaveToStream (SHELL32.27) - * - * NOTES - * the first two bytes are the len, the pidl is following then - */ -HRESULT WINAPI ILSaveToStream (IStream * pStream, LPCITEMIDLIST pPidl) -{ - WORD wLen = 0; - HRESULT ret = E_FAIL; - - TRACE_(shell)("%p %p\n", pStream, pPidl); - - IStream_AddRef (pStream); - - wLen = ILGetSize(pPidl); - - if (SUCCEEDED(IStream_Write(pStream, &wLen, 2, NULL))) - { - if (SUCCEEDED(IStream_Write(pStream, pPidl, wLen, NULL))) - ret = S_OK; - } - IStream_Release (pStream); - - return ret; -} - -/************************************************************************* - * SHILCreateFromPath [SHELL32.28] - * - * Create an ItemIDList from a path - * - * PARAMS - * path [I] - * ppidl [O] - * attributes [I/O] requested attributes on call and actual attributes when - * the function returns - * - * RETURNS - * NO_ERROR if successful, or an OLE errer code otherwise - * - * NOTES - * Wrapper for IShellFolder_ParseDisplayName(). - */ -HRESULT WINAPI SHILCreateFromPathA(LPCSTR path, LPITEMIDLIST * ppidl, DWORD * attributes) -{ - WCHAR lpszDisplayName[MAX_PATH]; - - TRACE_(shell)("%s %p 0x%08x\n", path, ppidl, attributes ? *attributes : 0); - - if (!MultiByteToWideChar(CP_ACP, 0, path, -1, lpszDisplayName, MAX_PATH)) - lpszDisplayName[MAX_PATH-1] = 0; - - return SHILCreateFromPathW(lpszDisplayName, ppidl, attributes); -} - -HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST * ppidl, DWORD * attributes) -{ - LPSHELLFOLDER sf; - DWORD pchEaten; - HRESULT ret = E_FAIL; - - TRACE_(shell)("%s %p 0x%08x\n", debugstr_w(path), ppidl, attributes ? *attributes : 0); - - if (SUCCEEDED (SHGetDesktopFolder(&sf))) - { - ret = IShellFolder_ParseDisplayName(sf, 0, NULL, (LPWSTR)path, &pchEaten, ppidl, attributes); - IShellFolder_Release(sf); - } - return ret; -} - -HRESULT WINAPI SHILCreateFromPathAW (LPCVOID path, LPITEMIDLIST * ppidl, DWORD * attributes) -{ - if ( SHELL_OsIsUnicode()) - return SHILCreateFromPathW (path, ppidl, attributes); - return SHILCreateFromPathA (path, ppidl, attributes); -} - -/************************************************************************* - * SHCloneSpecialIDList [SHELL32.89] - * - * Create an ItemIDList to one of the special folders. - - * PARAMS - * hwndOwner [in] - * nFolder [in] CSIDL_xxxxx - * fCreate [in] Create folder if it does not exist - * - * RETURNS - * Success: The newly created pidl - * Failure: NULL, if inputs are invalid. - * - * NOTES - * exported by ordinal. - * Caller is responsible for deallocating the returned ItemIDList with the - * shells IMalloc interface, aka ILFree. - */ -LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate) -{ - LPITEMIDLIST ppidl; - TRACE_(shell)("(hwnd=%p,csidl=0x%x,%s).\n", hwndOwner, nFolder, fCreate ? "T" : "F"); - - if (fCreate) - nFolder |= CSIDL_FLAG_CREATE; - - SHGetSpecialFolderLocation(hwndOwner, nFolder, &ppidl); - return ppidl; -} - -/************************************************************************* - * ILGlobalClone [SHELL32.20] - * - * Clones an ItemIDList using Alloc. - * - * PARAMS - * pidl [I] ItemIDList to clone - * - * RETURNS - * Newly allocated ItemIDList. - * - * NOTES - * exported by ordinal. - */ -LPITEMIDLIST WINAPI ILGlobalClone(LPCITEMIDLIST pidl) -{ - DWORD len; - LPITEMIDLIST newpidl; - - if (!pidl) - return NULL; - - len = ILGetSize(pidl); - newpidl = Alloc(len); - if (newpidl) - memcpy(newpidl,pidl,len); - - TRACE("pidl=%p newpidl=%p\n",pidl, newpidl); - pdump(pidl); - - return newpidl; -} - -/************************************************************************* - * ILIsEqual [SHELL32.21] - * - */ -BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - char szData1[MAX_PATH]; - char szData2[MAX_PATH]; - - LPCITEMIDLIST pidltemp1 = pidl1; - LPCITEMIDLIST pidltemp2 = pidl2; - - TRACE("pidl1=%p pidl2=%p\n",pidl1, pidl2); - - /* - * Explorer reads from registry directly (StreamMRU), - * so we can only check here - */ - if (!pcheck(pidl1) || !pcheck (pidl2)) - return FALSE; - - pdump (pidl1); - pdump (pidl2); - - if (!pidl1 || !pidl2) - return FALSE; - - while (pidltemp1->mkid.cb && pidltemp2->mkid.cb) - { - _ILSimpleGetText(pidltemp1, szData1, MAX_PATH); - _ILSimpleGetText(pidltemp2, szData2, MAX_PATH); - - if (strcmp( szData1, szData2 )) - return FALSE; - - pidltemp1 = ILGetNext(pidltemp1); - pidltemp2 = ILGetNext(pidltemp2); - } - - if (!pidltemp1->mkid.cb && !pidltemp2->mkid.cb) - return TRUE; - - return FALSE; -} - -/************************************************************************* - * ILIsParent [SHELL32.23] - * - * Verifies that pidlParent is indeed the (immediate) parent of pidlChild. - * - * PARAMS - * pidlParent [I] - * pidlChild [I] - * bImmediate [I] only return true if the parent is the direct parent - * of the child - * - * RETURNS - * True if the parent ItemIDlist is a complete part of the child ItemIdList, - * False otherwise. - * - * NOTES - * parent = a/b, child = a/b/c -> true, c is in folder a/b - * child = a/b/c/d -> false if bImmediate is true, d is not in folder a/b - * child = a/b/c/d -> true if bImmediate is false, d is in a subfolder of a/b - */ -BOOL WINAPI ILIsParent(LPCITEMIDLIST pidlParent, LPCITEMIDLIST pidlChild, BOOL bImmediate) -{ - char szData1[MAX_PATH]; - char szData2[MAX_PATH]; - LPCITEMIDLIST pParent = pidlParent; - LPCITEMIDLIST pChild = pidlChild; - - TRACE("%p %p %x\n", pidlParent, pidlChild, bImmediate); - - if (!pParent || !pChild) - return FALSE; - - while (pParent->mkid.cb && pChild->mkid.cb) - { - _ILSimpleGetText(pParent, szData1, MAX_PATH); - _ILSimpleGetText(pChild, szData2, MAX_PATH); - - if (strcmp( szData1, szData2 )) - return FALSE; - - pParent = ILGetNext(pParent); - pChild = ILGetNext(pChild); - } - - /* child shorter or has equal length to parent */ - if (pParent->mkid.cb || !pChild->mkid.cb) - return FALSE; - - /* not immediate descent */ - if ( ILGetNext(pChild)->mkid.cb && bImmediate) - return FALSE; - - return TRUE; -} - -/************************************************************************* - * ILFindChild [SHELL32.24] - * - * Compares elements from pidl1 and pidl2. - * - * PARAMS - * pidl1 [I] - * pidl2 [I] - * - * RETURNS - * pidl1 is desktop pidl2 - * pidl1 shorter pidl2 pointer to first different element of pidl2 - * if there was at least one equal element - * pidl2 shorter pidl1 0 - * pidl2 equal pidl1 pointer to last 0x00-element of pidl2 - * - * NOTES - * exported by ordinal. - */ -LPITEMIDLIST WINAPI ILFindChild(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - char szData1[MAX_PATH]; - char szData2[MAX_PATH]; - - LPCITEMIDLIST pidltemp1 = pidl1; - LPCITEMIDLIST pidltemp2 = pidl2; - LPCITEMIDLIST ret=NULL; - - TRACE("pidl1=%p pidl2=%p\n",pidl1, pidl2); - - /* explorer reads from registry directly (StreamMRU), - so we can only check here */ - if ((!pcheck (pidl1)) || (!pcheck (pidl2))) - return FALSE; - - pdump (pidl1); - pdump (pidl2); - - if (_ILIsDesktop(pidl1)) - { - ret = pidl2; - } - else - { - while (pidltemp1->mkid.cb && pidltemp2->mkid.cb) - { - _ILSimpleGetText(pidltemp1, szData1, MAX_PATH); - _ILSimpleGetText(pidltemp2, szData2, MAX_PATH); - - if (strcmp(szData1,szData2)) - break; - - pidltemp1 = ILGetNext(pidltemp1); - pidltemp2 = ILGetNext(pidltemp2); - ret = pidltemp2; - } - - if (pidltemp1->mkid.cb) - ret = NULL; /* elements of pidl1 left*/ - } - TRACE_(shell)("--- %p\n", ret); - return (LPITEMIDLIST)ret; /* pidl 1 is shorter */ -} - -/************************************************************************* - * ILCombine [SHELL32.25] - * - * Concatenates two complex ItemIDLists. - * - * PARAMS - * pidl1 [I] first complex ItemIDLists - * pidl2 [I] complex ItemIDLists to append - * - * RETURNS - * if both pidl's == NULL NULL - * if pidl1 == NULL cloned pidl2 - * if pidl2 == NULL cloned pidl1 - * otherwise new pidl with pidl2 appended to pidl1 - * - * NOTES - * exported by ordinal. - * Does not destroy the passed in ItemIDLists! - */ -LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - DWORD len1,len2; - LPITEMIDLIST pidlNew; - - TRACE("pidl=%p pidl=%p\n",pidl1,pidl2); - - if (!pidl1 && !pidl2) return NULL; - - pdump (pidl1); - pdump (pidl2); - - if (!pidl1) - { - pidlNew = ILClone(pidl2); - return pidlNew; - } - - if (!pidl2) - { - pidlNew = ILClone(pidl1); - return pidlNew; - } - - len1 = ILGetSize(pidl1)-2; - len2 = ILGetSize(pidl2); - pidlNew = SHAlloc(len1+len2); - - if (pidlNew) - { - memcpy(pidlNew,pidl1,len1); - memcpy(((BYTE *)pidlNew)+len1,pidl2,len2); - } - - /* TRACE(pidl,"--new pidl=%p\n",pidlNew);*/ - return pidlNew; -} - -/************************************************************************* - * SHGetRealIDL [SHELL32.98] - * - * NOTES - */ -HRESULT WINAPI SHGetRealIDL(LPSHELLFOLDER lpsf, LPCITEMIDLIST pidlSimple, LPITEMIDLIST *pidlReal) -{ - IDataObject* pDataObj; - HRESULT hr; - - hr = IShellFolder_GetUIObjectOf(lpsf, 0, 1, &pidlSimple, - &IID_IDataObject, 0, (LPVOID*)&pDataObj); - if (SUCCEEDED(hr)) - { - STGMEDIUM medium; - FORMATETC fmt; - - fmt.cfFormat = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); - fmt.ptd = NULL; - fmt.dwAspect = DVASPECT_CONTENT; - fmt.lindex = -1; - fmt.tymed = TYMED_HGLOBAL; - - hr = IDataObject_GetData(pDataObj, &fmt, &medium); - - IDataObject_Release(pDataObj); - - if (SUCCEEDED(hr)) - { - /*assert(pida->cidl==1);*/ - LPIDA pida = GlobalLock(medium.u.hGlobal); - - LPCITEMIDLIST pidl_folder = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[0]); - LPCITEMIDLIST pidl_child = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[1]); - - *pidlReal = ILCombine(pidl_folder, pidl_child); - - if (!*pidlReal) - hr = E_OUTOFMEMORY; - - GlobalUnlock(medium.u.hGlobal); - GlobalFree(medium.u.hGlobal); - } - } - - return hr; -} - -/************************************************************************* - * SHLogILFromFSIL [SHELL32.95] - * - * NOTES - * pild = CSIDL_DESKTOP ret = 0 - * pild = CSIDL_DRIVES ret = 0 - */ -LPITEMIDLIST WINAPI SHLogILFromFSIL(LPITEMIDLIST pidl) -{ - FIXME("(pidl=%p)\n",pidl); - - pdump(pidl); - - return 0; -} - -/************************************************************************* - * ILGetSize [SHELL32.152] - * - * Gets the byte size of an ItemIDList including zero terminator - * - * PARAMS - * pidl [I] ItemIDList - * - * RETURNS - * size of pidl in bytes - * - * NOTES - * exported by ordinal - */ -UINT WINAPI ILGetSize(LPCITEMIDLIST pidl) -{ - LPCSHITEMID si = &(pidl->mkid); - UINT len=0; - - if (pidl) - { - while (si->cb) - { - len += si->cb; - si = (LPCSHITEMID)(((const BYTE*)si)+si->cb); - } - len += 2; - } - TRACE("pidl=%p size=%u\n",pidl, len); - return len; -} - -/************************************************************************* - * ILGetNext [SHELL32.153] - * - * Gets the next ItemID of an ItemIDList - * - * PARAMS - * pidl [I] ItemIDList - * - * RETURNS - * null -> null - * desktop -> null - * simple pidl -> pointer to 0x0000 element - * - * NOTES - * exported by ordinal. - */ -LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl) -{ - WORD len; - - TRACE("%p\n", pidl); - - if (pidl) - { - len = pidl->mkid.cb; - if (len) - { - pidl = (LPCITEMIDLIST) (((const BYTE*)pidl)+len); - TRACE("-- %p\n", pidl); - return (LPITEMIDLIST)pidl; - } - } - return NULL; -} - -/************************************************************************* - * ILAppend [SHELL32.154] - * - * Adds the single ItemID item to the ItemIDList indicated by pidl. - * If bEnd is FALSE, inserts the item in the front of the list, - * otherwise it adds the item to the end. (???) - * - * PARAMS - * pidl [I] ItemIDList to extend - * item [I] ItemID to prepend/append - * bEnd [I] Indicates if the item should be appended - * - * NOTES - * Destroys the passed in idlist! (???) - */ -LPITEMIDLIST WINAPI ILAppend(LPITEMIDLIST pidl, LPCITEMIDLIST item, BOOL bEnd) -{ - LPITEMIDLIST idlRet; - - WARN("(pidl=%p,pidl=%p,%08u)semi-stub\n",pidl,item,bEnd); - - pdump (pidl); - pdump (item); - - if (_ILIsDesktop(pidl)) - { - idlRet = ILClone(item); - SHFree (pidl); - return idlRet; - } - - if (bEnd) - idlRet = ILCombine(pidl, item); - else - idlRet = ILCombine(item, pidl); - - SHFree(pidl); - return idlRet; -} - -/************************************************************************* - * ILFree [SHELL32.155] - * - * Frees memory (if not NULL) allocated by SHMalloc allocator - * - * PARAMS - * pidl [I] - * - * RETURNS - * Nothing - * - * NOTES - * exported by ordinal - */ -void WINAPI ILFree(LPITEMIDLIST pidl) -{ - TRACE("(pidl=%p)\n",pidl); - SHFree(pidl); -} - -/************************************************************************* - * ILGlobalFree [SHELL32.156] - * - * Frees memory (if not NULL) allocated by Alloc allocator - * - * PARAMS - * pidl [I] - * - * RETURNS - * Nothing - * - * NOTES - * exported by ordinal. - */ -void WINAPI ILGlobalFree( LPITEMIDLIST pidl) -{ - TRACE("%p\n", pidl); - - Free(pidl); -} - -/************************************************************************* - * ILCreateFromPathA [SHELL32.189] - * - * Creates a complex ItemIDList from a path and returns it. - * - * PARAMS - * path [I] - * - * RETURNS - * the newly created complex ItemIDList or NULL if failed - * - * NOTES - * exported by ordinal. - */ -LPITEMIDLIST WINAPI ILCreateFromPathA (LPCSTR path) -{ - LPITEMIDLIST pidlnew = NULL; - - TRACE_(shell)("%s\n", debugstr_a(path)); - - if (SUCCEEDED(SHILCreateFromPathA(path, &pidlnew, NULL))) - return pidlnew; - return NULL; -} - -/************************************************************************* - * ILCreateFromPathW [SHELL32.190] - * - * See ILCreateFromPathA. - */ -LPITEMIDLIST WINAPI ILCreateFromPathW (LPCWSTR path) -{ - LPITEMIDLIST pidlnew = NULL; - - TRACE_(shell)("%s\n", debugstr_w(path)); - - if (SUCCEEDED(SHILCreateFromPathW(path, &pidlnew, NULL))) - return pidlnew; - return NULL; -} - -/************************************************************************* - * ILCreateFromPath [SHELL32.157] - */ -LPITEMIDLIST WINAPI ILCreateFromPathAW (LPCVOID path) -{ - if ( SHELL_OsIsUnicode()) - return ILCreateFromPathW (path); - return ILCreateFromPathA (path); -} - -/************************************************************************* - * _ILParsePathW [internal] - * - * Creates an ItemIDList from a path and returns it. - * - * PARAMS - * path [I] path to parse and convert into an ItemIDList - * lpFindFile [I] pointer to buffer to initialize the FileSystem - * Bind Data object with - * bBindCtx [I] indicates to create a BindContext and assign a - * FileSystem Bind Data object - * ppidl [O] the newly create ItemIDList - * prgfInOut [I/O] requested attributes on input and actual - * attributes on return - * - * RETURNS - * NO_ERROR on success or an OLE error code - * - * NOTES - * If either lpFindFile is non-NULL or bBindCtx is TRUE, this function - * creates a BindContext object and assigns a FileSystem Bind Data object - * to it, passing the BindContext to IShellFolder_ParseDisplayName. Each - * IShellFolder uses that FileSystem Bind Data object of the BindContext - * to pass data about the current path element to the next object. This - * is used to avoid having to verify the current path element on disk, so - * that creating an ItemIDList from a nonexistent path still can work. - */ -static HRESULT _ILParsePathW(LPCWSTR path, LPWIN32_FIND_DATAW lpFindFile, - BOOL bBindCtx, LPITEMIDLIST *ppidl, LPDWORD prgfInOut) -{ - LPSHELLFOLDER pSF = NULL; - LPBC pBC = NULL; - HRESULT ret; - - TRACE("%s %p %d (%p)->%p (%p)->0x%x\n", debugstr_w(path), lpFindFile, bBindCtx, - ppidl, ppidl ? *ppidl : NULL, - prgfInOut, prgfInOut ? *prgfInOut : 0); - - ret = SHGetDesktopFolder(&pSF); - if (FAILED(ret)) - return ret; - - if (lpFindFile || bBindCtx) - ret = IFileSystemBindData_Constructor(lpFindFile, &pBC); - - if (SUCCEEDED(ret)) - { - ret = IShellFolder_ParseDisplayName(pSF, 0, pBC, (LPOLESTR)path, NULL, ppidl, prgfInOut); - } - - if (pBC) - { - IBindCtx_Release(pBC); - pBC = NULL; - } - - IShellFolder_Release(pSF); - - if (FAILED(ret) && ppidl) - *ppidl = NULL; - - TRACE("%s %p 0x%x\n", debugstr_w(path), ppidl ? *ppidl : NULL, prgfInOut ? *prgfInOut : 0); - - return ret; -} - -/************************************************************************* - * SHSimpleIDListFromPath [SHELL32.162] - * - * Creates a simple ItemIDList from a path and returns it. This function - * does not fail on nonexistent paths. - * - * PARAMS - * path [I] path to parse and convert into an ItemIDList - * - * RETURNS - * the newly created simple ItemIDList - * - * NOTES - * Simple in the name does not mean a relative ItemIDList but rather a - * fully qualified list, where only the file name is filled in and the - * directory flag for those ItemID elements this is known about, eg. - * it is not the last element in the ItemIDList or the actual directory - * exists on disk. - * exported by ordinal. - */ -LPITEMIDLIST WINAPI SHSimpleIDListFromPathA(LPCSTR lpszPath) -{ - LPITEMIDLIST pidl = NULL; - LPWSTR wPath = NULL; - int len; - - TRACE("%s\n", debugstr_a(lpszPath)); - - if (lpszPath) - { - len = MultiByteToWideChar(CP_ACP, 0, lpszPath, -1, NULL, 0); - wPath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, lpszPath, -1, wPath, len); - } - - _ILParsePathW(wPath, NULL, TRUE, &pidl, NULL); - - HeapFree(GetProcessHeap(), 0, wPath); - TRACE("%s %p\n", debugstr_a(lpszPath), pidl); - return pidl; -} - -LPITEMIDLIST WINAPI SHSimpleIDListFromPathW(LPCWSTR lpszPath) -{ - LPITEMIDLIST pidl = NULL; - - TRACE("%s\n", debugstr_w(lpszPath)); - - _ILParsePathW(lpszPath, NULL, TRUE, &pidl, NULL); - TRACE("%s %p\n", debugstr_w(lpszPath), pidl); - return pidl; -} - -LPITEMIDLIST WINAPI SHSimpleIDListFromPathAW(LPCVOID lpszPath) -{ - if ( SHELL_OsIsUnicode()) - return SHSimpleIDListFromPathW (lpszPath); - return SHSimpleIDListFromPathA (lpszPath); -} - -/************************************************************************* - * SHGetDataFromIDListA [SHELL32.247] - * - * NOTES - * the pidl can be a simple one. since we can't get the path out of the pidl - * we have to take all data from the pidl - */ -HRESULT WINAPI SHGetDataFromIDListA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, - int nFormat, LPVOID dest, int len) -{ - LPSTR filename, shortname; - WIN32_FIND_DATAA * pfd; - - TRACE_(shell)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf,pidl,nFormat,dest,len); - - pdump(pidl); - if (!psf || !dest) - return E_INVALIDARG; - - switch (nFormat) - { - case SHGDFIL_FINDDATA: - pfd = dest; - - if (_ILIsDrive(pidl) || _ILIsSpecialFolder(pidl)) - return E_INVALIDARG; - - if (len < sizeof(WIN32_FIND_DATAA)) - return E_INVALIDARG; - - ZeroMemory(pfd, sizeof (WIN32_FIND_DATAA)); - _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime)); - pfd->dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0); - pfd->nFileSizeLow = _ILGetFileSize ( pidl, NULL, 0); - - filename = _ILGetTextPointer(pidl); - shortname = _ILGetSTextPointer(pidl); - - if (filename) - lstrcpynA(pfd->cFileName, filename, sizeof(pfd->cFileName)); - else - pfd->cFileName[0] = '\0'; - - if (shortname) - lstrcpynA(pfd->cAlternateFileName, shortname, sizeof(pfd->cAlternateFileName)); - else - pfd->cAlternateFileName[0] = '\0'; - return NOERROR; - - case SHGDFIL_NETRESOURCE: - case SHGDFIL_DESCRIPTIONID: - FIXME_(shell)("SHGDFIL %i stub\n", nFormat); - break; - - default: - ERR_(shell)("Unknown SHGDFIL %i, please report\n", nFormat); - } - - return E_INVALIDARG; -} - -/************************************************************************* - * SHGetDataFromIDListW [SHELL32.248] - * - */ -HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, - int nFormat, LPVOID dest, int len) -{ - LPSTR filename, shortname; - WIN32_FIND_DATAW * pfd = dest; - - TRACE_(shell)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf,pidl,nFormat,dest,len); - - pdump(pidl); - - if (!psf || !dest) - return E_INVALIDARG; - - switch (nFormat) - { - case SHGDFIL_FINDDATA: - pfd = dest; - - if (_ILIsDrive(pidl)) - return E_INVALIDARG; - - if (len < sizeof(WIN32_FIND_DATAW)) - return E_INVALIDARG; - - ZeroMemory(pfd, sizeof (WIN32_FIND_DATAW)); - _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime)); - pfd->dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0); - pfd->nFileSizeLow = _ILGetFileSize ( pidl, NULL, 0); - - filename = _ILGetTextPointer(pidl); - shortname = _ILGetSTextPointer(pidl); - - if (!filename) - pfd->cFileName[0] = '\0'; - else if (!MultiByteToWideChar(CP_ACP, 0, filename, -1, pfd->cFileName, MAX_PATH)) - pfd->cFileName[MAX_PATH-1] = 0; - - if (!shortname) - pfd->cAlternateFileName[0] = '\0'; - else if (!MultiByteToWideChar(CP_ACP, 0, shortname, -1, pfd->cAlternateFileName, 14)) - pfd->cAlternateFileName[13] = 0; - return NOERROR; - - case SHGDFIL_NETRESOURCE: - case SHGDFIL_DESCRIPTIONID: - FIXME_(shell)("SHGDFIL %i stub\n", nFormat); - break; - - default: - ERR_(shell)("Unknown SHGDFIL %i, please report\n", nFormat); - } - - return E_INVALIDARG; -} - -/************************************************************************* - * SHGetPathFromIDListA [SHELL32.@][NT 4.0: SHELL32.220] - * - * PARAMETERS - * pidl, [IN] pidl - * pszPath [OUT] path - * - * RETURNS - * path from a passed PIDL. - * - * NOTES - * NULL returns FALSE - * desktop pidl gives path to desktop directory back - * special pidls returning FALSE - */ -BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath) -{ - WCHAR wszPath[MAX_PATH]; - BOOL bSuccess; - - bSuccess = SHGetPathFromIDListW(pidl, wszPath); - WideCharToMultiByte(CP_ACP, 0, wszPath, -1, pszPath, MAX_PATH, NULL, NULL); - - return bSuccess; -} - -/************************************************************************* - * SHGetPathFromIDListW [SHELL32.@] - * - * See SHGetPathFromIDListA. - */ -BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath) -{ - HRESULT hr; - LPCITEMIDLIST pidlLast; - LPSHELLFOLDER psfFolder; - DWORD dwAttributes; - STRRET strret; - - TRACE_(shell)("(pidl=%p,%p)\n", pidl, pszPath); - pdump(pidl); - - *pszPath = '\0'; - if (!pidl) - return FALSE; - - hr = SHBindToParent(pidl, &IID_IShellFolder, (VOID**)&psfFolder, &pidlLast); - if (FAILED(hr)) return FALSE; - - dwAttributes = SFGAO_FILESYSTEM; - hr = IShellFolder_GetAttributesOf(psfFolder, 1, &pidlLast, &dwAttributes); - if (FAILED(hr) || !(dwAttributes & SFGAO_FILESYSTEM)) { - IShellFolder_Release(psfFolder); - return FALSE; - } - - hr = IShellFolder_GetDisplayNameOf(psfFolder, pidlLast, SHGDN_FORPARSING, &strret); - IShellFolder_Release(psfFolder); - if (FAILED(hr)) return FALSE; - - hr = StrRetToBufW(&strret, pidlLast, pszPath, MAX_PATH); - - TRACE_(shell)("-- %s, 0x%08x\n",debugstr_w(pszPath), hr); - return SUCCEEDED(hr); -} - -/************************************************************************* - * SHBindToParent [shell version 5.0] - */ -HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast) -{ - IShellFolder * psfDesktop; - HRESULT hr=E_FAIL; - - TRACE_(shell)("pidl=%p\n", pidl); - pdump(pidl); - - if (!pidl || !ppv) - return E_INVALIDARG; - - *ppv = NULL; - if (ppidlLast) - *ppidlLast = NULL; - - hr = SHGetDesktopFolder(&psfDesktop); - if (FAILED(hr)) - return hr; - - if (_ILIsPidlSimple(pidl)) - { - /* we are on desktop level */ - hr = IShellFolder_QueryInterface(psfDesktop, riid, ppv); - } - else - { - LPITEMIDLIST pidlParent = ILClone(pidl); - ILRemoveLastID(pidlParent); - hr = IShellFolder_BindToObject(psfDesktop, pidlParent, NULL, riid, ppv); - SHFree (pidlParent); - } - - IShellFolder_Release(psfDesktop); - - if (SUCCEEDED(hr) && ppidlLast) - *ppidlLast = ILFindLastID(pidl); - - TRACE_(shell)("-- psf=%p pidl=%p ret=0x%08x\n", *ppv, (ppidlLast)?*ppidlLast:NULL, hr); - return hr; -} - -/************************************************************************** - * - * internal functions - * - * ### 1. section creating pidls ### - * - ************************************************************************* - */ - -/* Basic PIDL constructor. Allocates size + 5 bytes, where: - * - two bytes are SHITEMID.cb - * - one byte is PIDLDATA.type - * - two bytes are the NULL PIDL terminator - * Sets type of the returned PIDL to type. - */ -static LPITEMIDLIST _ILAlloc(PIDLTYPE type, unsigned int size) -{ - LPITEMIDLIST pidlOut = NULL; - - pidlOut = SHAlloc(size + 5); - if(pidlOut) - { - LPPIDLDATA pData; - LPITEMIDLIST pidlNext; - - ZeroMemory(pidlOut, size + 5); - pidlOut->mkid.cb = size + 3; - - pData = _ILGetDataPointer(pidlOut); - if (pData) - pData->type = type; - - pidlNext = ILGetNext(pidlOut); - if (pidlNext) - pidlNext->mkid.cb = 0x00; - TRACE("-- (pidl=%p, size=%u)\n", pidlOut, size); - } - - return pidlOut; -} - -LPITEMIDLIST _ILCreateDesktop(void) -{ - LPITEMIDLIST ret; - - TRACE("()\n"); - ret = SHAlloc(2); - if (ret) - ret->mkid.cb = 0; - return ret; -} - -LPITEMIDLIST _ILCreateMyComputer(void) -{ - TRACE("()\n"); - return _ILCreateGuid(PT_GUID, &CLSID_MyComputer); -} - -LPITEMIDLIST _ILCreateMyDocuments(void) -{ - TRACE("()\n"); - return _ILCreateGuid(PT_GUID, &CLSID_MyDocuments); -} - -LPITEMIDLIST _ILCreateIExplore(void) -{ - TRACE("()\n"); - return _ILCreateGuid(PT_GUID, &CLSID_Internet); -} - -LPITEMIDLIST _ILCreateControlPanel(void) -{ - LPITEMIDLIST parent = _ILCreateGuid(PT_GUID, &CLSID_MyComputer), ret = NULL; - - TRACE("()\n"); - if (parent) - { - LPITEMIDLIST cpl = _ILCreateGuid(PT_SHELLEXT, &CLSID_ControlPanel); - - if (cpl) - { - ret = ILCombine(parent, cpl); - SHFree(cpl); - } - SHFree(parent); - } - return ret; -} - -LPITEMIDLIST _ILCreatePrinters(void) -{ - LPITEMIDLIST parent = _ILCreateGuid(PT_GUID, &CLSID_MyComputer), ret = NULL; - - TRACE("()\n"); - if (parent) - { - LPITEMIDLIST printers = _ILCreateGuid(PT_YAGUID, &CLSID_Printers); - - if (printers) - { - ret = ILCombine(parent, printers); - SHFree(printers); - } - SHFree(parent); - } - return ret; -} - -LPITEMIDLIST _ILCreateNetwork(void) -{ - TRACE("()\n"); - return _ILCreateGuid(PT_GUID, &CLSID_NetworkPlaces); -} - -LPITEMIDLIST _ILCreateBitBucket(void) -{ - TRACE("()\n"); - return _ILCreateGuid(PT_GUID, &CLSID_RecycleBin); -} - -LPITEMIDLIST _ILCreateAdminTools(void) -{ - TRACE("()\n"); - return _ILCreateGuid(PT_GUID, &CLSID_AdminFolderShortcut); //FIXME -} - -LPITEMIDLIST _ILCreateGuid(PIDLTYPE type, REFIID guid) -{ - LPITEMIDLIST pidlOut; - - if (type == PT_SHELLEXT || type == PT_GUID || type == PT_YAGUID) - { - pidlOut = _ILAlloc(type, sizeof(GUIDStruct)); - if (pidlOut) - { - LPPIDLDATA pData = _ILGetDataPointer(pidlOut); - - pData->u.guid.guid = *guid; - TRACE("-- create GUID-pidl %s\n", - debugstr_guid(&(pData->u.guid.guid))); - } - } - else - { - WARN("%d: invalid type for GUID\n", type); - pidlOut = NULL; - } - return pidlOut; -} - -LPITEMIDLIST _ILCreateGuidFromStrA(LPCSTR szGUID) -{ - IID iid; - - if (FAILED(SHCLSIDFromStringA(szGUID, &iid))) - { - ERR("%s is not a GUID\n", szGUID); - return NULL; - } - return _ILCreateGuid(PT_GUID, &iid); -} - -LPITEMIDLIST _ILCreateGuidFromStrW(LPCWSTR szGUID) -{ - IID iid; - - if (FAILED(CLSIDFromString((LPOLESTR)szGUID, &iid))) - { - ERR("%s is not a GUID\n", debugstr_w(szGUID)); - return NULL; - } - return _ILCreateGuid(PT_GUID, &iid); -} - -LPITEMIDLIST _ILCreateFromFindDataW( const WIN32_FIND_DATAW *wfd ) -{ - char buff[MAX_PATH + 14 +1]; /* see WIN32_FIND_DATA */ - DWORD len, len1, wlen, alen; - LPITEMIDLIST pidl; - PIDLTYPE type; - - if (!wfd) - return NULL; - - TRACE("(%s, %s)\n",debugstr_w(wfd->cAlternateFileName), debugstr_w(wfd->cFileName)); - - /* prepare buffer with both names */ - len = WideCharToMultiByte(CP_ACP,0,wfd->cFileName,-1,buff,MAX_PATH,NULL,NULL); - len1 = WideCharToMultiByte(CP_ACP,0,wfd->cAlternateFileName,-1, buff+len, sizeof(buff)-len, NULL, NULL); - alen = len + len1; - - type = (wfd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? PT_FOLDER : PT_VALUE; - - wlen = wcslen(wfd->cFileName) + 1; - pidl = _ILAlloc(type, FIELD_OFFSET(FileStruct, szNames[alen + (alen & 1)]) + - FIELD_OFFSET(FileStructW, wszName[wlen]) + sizeof(WORD)); - if (pidl) - { - LPPIDLDATA pData = _ILGetDataPointer(pidl); - FileStruct *fs = &pData->u.file; - FileStructW *fsw; - WORD *pOffsetW; - - FileTimeToDosDateTime( &wfd->ftLastWriteTime, &fs->uFileDate, &fs->uFileTime); - fs->dwFileSize = wfd->nFileSizeLow; - fs->uFileAttribs = wfd->dwFileAttributes; - memcpy(fs->szNames, buff, alen); - - fsw = (FileStructW*)(pData->u.file.szNames + alen + (alen & 0x1)); - fsw->cbLen = FIELD_OFFSET(FileStructW, wszName[wlen]) + sizeof(WORD); - FileTimeToDosDateTime( &wfd->ftCreationTime, &fsw->uCreationDate, &fsw->uCreationTime); - FileTimeToDosDateTime( &wfd->ftLastAccessTime, &fsw->uLastAccessDate, &fsw->uLastAccessTime); - memcpy(fsw->wszName, wfd->cFileName, wlen * sizeof(WCHAR)); - - pOffsetW = (WORD*)((LPBYTE)pidl + pidl->mkid.cb - sizeof(WORD)); - *pOffsetW = (LPBYTE)fsw - (LPBYTE)pidl; - TRACE("-- Set Value: %s\n",debugstr_w(fsw->wszName)); - } - return pidl; - -} - -HRESULT _ILCreateFromPathW(LPCWSTR szPath, LPITEMIDLIST* ppidl) -{ - HANDLE hFile; - WIN32_FIND_DATAW stffile; - - if (!ppidl) - return E_INVALIDARG; - - hFile = FindFirstFileW(szPath, &stffile); - if (hFile == INVALID_HANDLE_VALUE) - return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); - - FindClose(hFile); - - *ppidl = _ILCreateFromFindDataW(&stffile); - - return *ppidl ? S_OK : E_OUTOFMEMORY; -} - -LPITEMIDLIST _ILCreateDrive(LPCWSTR lpszNew) -{ - LPITEMIDLIST pidlOut; - - TRACE("(%s)\n",debugstr_w(lpszNew)); - - pidlOut = _ILAlloc(PT_DRIVE, sizeof(DriveStruct)); - if (pidlOut) - { - LPSTR pszDest; - - pszDest = _ILGetTextPointer(pidlOut); - if (pszDest) - { - strcpy(pszDest, "x:\\"); - pszDest[0]=towupper(lpszNew[0]); - TRACE("-- create Drive: %s\n", debugstr_a(pszDest)); - } - } - return pidlOut; -} - -/************************************************************************** - * _ILGetDrive() - * - * Gets the text for the drive eg. 'c:\' - * - * RETURNS - * strlen (lpszText) - */ -DWORD _ILGetDrive(LPCITEMIDLIST pidl,LPSTR pOut, UINT uSize) -{ - TRACE("(%p,%p,%u)\n",pidl,pOut,uSize); - - if(_ILIsMyComputer(pidl)) - pidl = ILGetNext(pidl); - - if (pidl && _ILIsDrive(pidl)) - return _ILSimpleGetText(pidl, pOut, uSize); - - return 0; -} - -/************************************************************************** - * - * ### 2. section testing pidls ### - * - ************************************************************************** - * _ILIsUnicode() - * _ILIsDesktop() - * _ILIsMyComputer() - * _ILIsSpecialFolder() - * _ILIsDrive() - * _ILIsFolder() - * _ILIsValue() - * _ILIsPidlSimple() - */ -BOOL _ILIsUnicode(LPCITEMIDLIST pidl) -{ - LPPIDLDATA lpPData = _ILGetDataPointer(pidl); - - TRACE("(%p)\n",pidl); - - return (pidl && lpPData && PT_VALUEW == lpPData->type); -} - -BOOL _ILIsDesktop(LPCITEMIDLIST pidl) -{ - TRACE("(%p)\n",pidl); - - return pidl && pidl->mkid.cb ? 0 : 1; -} - -BOOL _ILIsMyDocuments(LPCITEMIDLIST pidl) -{ - REFIID iid = _ILGetGUIDPointer(pidl); - - TRACE("(%p)\n",pidl); - - if (iid) - return IsEqualIID(iid, &CLSID_MyDocuments); - return FALSE; -} - -BOOL _ILIsControlPanel(LPCITEMIDLIST pidl) -{ - REFIID iid = _ILGetGUIDPointer(pidl); - - TRACE("(%p)\n",pidl); - - if (iid) - return IsEqualIID(iid, &CLSID_ControlPanel); - return FALSE; -} - -BOOL _ILIsNetHood(LPCITEMIDLIST pidl) -{ - REFIID iid = _ILGetGUIDPointer(pidl); - - TRACE("(%p)\n",pidl); - - if (iid) - return IsEqualIID(iid, &CLSID_NetworkPlaces); - return FALSE; -} - - -LPITEMIDLIST _ILCreateNetHood(void) -{ - return _ILCreateGuid(PT_GUID, &CLSID_NetworkPlaces); -} - -LPITEMIDLIST _ILCreateFont(void) -{ - return _ILCreateGuid(PT_GUID, &CLSID_FontsFolderShortcut); -} - -BOOL _ILIsMyComputer(LPCITEMIDLIST pidl) -{ - REFIID iid = _ILGetGUIDPointer(pidl); - - TRACE("(%p)\n",pidl); - - if (iid) - return IsEqualIID(iid, &CLSID_MyComputer); - return FALSE; -} - -BOOL _ILIsPrinter(LPCITEMIDLIST pidl) -{ - REFIID iid = _ILGetGUIDPointer(pidl); - - TRACE("(%p)\n",pidl); - - if (iid) - return IsEqualIID(iid, &CLSID_Printers); - return FALSE; -} - -BOOL _ILIsBitBucket(LPCITEMIDLIST pidl) -{ - REFIID iid = _ILGetGUIDPointer(pidl); - - TRACE("(%p)\n",pidl); - - if (iid) - return IsEqualIID(iid, &CLSID_RecycleBin); - return FALSE; -} - -BOOL _ILIsAdminTools(LPCITEMIDLIST pidl) -{ - REFIID iid = _ILGetGUIDPointer(pidl); - - TRACE("(%p)\n",pidl); - - if (iid) - return IsEqualIID(iid, &CLSID_AdminFolderShortcut); - else - return FALSE; -} - -BOOL _ILIsSpecialFolder (LPCITEMIDLIST pidl) -{ - LPPIDLDATA lpPData = _ILGetDataPointer(pidl); - - TRACE("(%p)\n",pidl); - - return (pidl && ( (lpPData && (PT_GUID== lpPData->type || PT_SHELLEXT== lpPData->type || PT_YAGUID == lpPData->type)) || - (pidl && pidl->mkid.cb == 0x00) - )); -} - -BOOL _ILIsDrive(LPCITEMIDLIST pidl) -{ - LPPIDLDATA lpPData = _ILGetDataPointer(pidl); - - TRACE("(%p)\n",pidl); - - return (pidl && lpPData && (PT_DRIVE == lpPData->type || - PT_DRIVE1 == lpPData->type || - PT_DRIVE2 == lpPData->type || - PT_DRIVE3 == lpPData->type)); -} - -BOOL _ILIsFolder(LPCITEMIDLIST pidl) -{ - LPPIDLDATA lpPData = _ILGetDataPointer(pidl); - - TRACE("(%p)\n",pidl); - - return (pidl && lpPData && (PT_FOLDER == lpPData->type || PT_FOLDER1 == lpPData->type)); -} - -BOOL _ILIsValue(LPCITEMIDLIST pidl) -{ - LPPIDLDATA lpPData = _ILGetDataPointer(pidl); - - TRACE("(%p)\n",pidl); - - return (pidl && lpPData && PT_VALUE == lpPData->type); -} - -BOOL _ILIsCPanelStruct(LPCITEMIDLIST pidl) -{ - LPPIDLDATA lpPData = _ILGetDataPointer(pidl); - - TRACE("(%p)\n",pidl); - - return (pidl && lpPData && (lpPData->type == 0)); -} - -/************************************************************************** - * _ILIsPidlSimple - */ -BOOL _ILIsPidlSimple(LPCITEMIDLIST pidl) -{ - BOOL ret = TRUE; - - if(! _ILIsDesktop(pidl)) /* pidl=NULL or mkid.cb=0 */ - { - WORD len = pidl->mkid.cb; - LPCITEMIDLIST pidlnext = (LPCITEMIDLIST) (((const BYTE*)pidl) + len ); - - if (pidlnext->mkid.cb) - ret = FALSE; - } - - TRACE("%s\n", ret ? "Yes" : "No"); - return ret; -} - -/************************************************************************** - * - * ### 3. section getting values from pidls ### - */ - - /************************************************************************** - * _ILSimpleGetText - * - * gets the text for the first item in the pidl (eg. simple pidl) - * - * returns the length of the string - */ -DWORD _ILSimpleGetText (LPCITEMIDLIST pidl, LPSTR szOut, UINT uOutSize) -{ - DWORD dwReturn=0; - LPSTR szSrc; - LPWSTR szSrcW; - GUID const * riid; - char szTemp[MAX_PATH]; - - TRACE("(%p %p %x)\n",pidl,szOut,uOutSize); - - if (!pidl) - return 0; - - if (szOut) - *szOut = 0; - - if (_ILIsDesktop(pidl)) - { - /* desktop */ - if (HCR_GetClassNameA(&CLSID_ShellDesktop, szTemp, MAX_PATH)) - { - if (szOut) - lstrcpynA(szOut, szTemp, uOutSize); - - dwReturn = strlen (szTemp); - } - } - else if (( szSrc = _ILGetTextPointer(pidl) )) - { - /* filesystem */ - if (szOut) - lstrcpynA(szOut, szSrc, uOutSize); - - dwReturn = strlen(szSrc); - } - else if (( szSrcW = _ILGetTextPointerW(pidl) )) - { - /* unicode filesystem */ - WideCharToMultiByte(CP_ACP,0,szSrcW, -1, szTemp, MAX_PATH, NULL, NULL); - - if (szOut) - lstrcpynA(szOut, szTemp, uOutSize); - - dwReturn = strlen (szTemp); - } - else if (( riid = _ILGetGUIDPointer(pidl) )) - { - /* special folder */ - if ( HCR_GetClassNameA(riid, szTemp, MAX_PATH) ) - { - if (szOut) - lstrcpynA(szOut, szTemp, uOutSize); - - dwReturn = strlen (szTemp); - } - } - else - { - ERR("-- no text\n"); - } - - TRACE("-- (%p=%s 0x%08x)\n",szOut,debugstr_a(szOut),dwReturn); - return dwReturn; -} - - /************************************************************************** - * _ILSimpleGetTextW - * - * gets the text for the first item in the pidl (eg. simple pidl) - * - * returns the length of the string - */ -DWORD _ILSimpleGetTextW (LPCITEMIDLIST pidl, LPWSTR szOut, UINT uOutSize) -{ - DWORD dwReturn; - FileStructW *pFileStructW = _ILGetFileStructW(pidl); - - TRACE("(%p %p %x)\n",pidl,szOut,uOutSize); - - if (pFileStructW) { - lstrcpynW(szOut, pFileStructW->wszName, uOutSize); - dwReturn = wcslen(pFileStructW->wszName); - } else { - GUID const * riid; - WCHAR szTemp[MAX_PATH]; - LPSTR szSrc; - LPWSTR szSrcW; - dwReturn=0; - - if (!pidl) - return 0; - - if (szOut) - *szOut = 0; - - if (_ILIsDesktop(pidl)) - { - /* desktop */ - if (HCR_GetClassNameW(&CLSID_ShellDesktop, szTemp, MAX_PATH)) - { - if (szOut) - lstrcpynW(szOut, szTemp, uOutSize); - - dwReturn = wcslen (szTemp); - } - } - else if (( szSrcW = _ILGetTextPointerW(pidl) )) - { - /* unicode filesystem */ - if (szOut) - lstrcpynW(szOut, szSrcW, uOutSize); - - dwReturn = wcslen(szSrcW); - } - else if (( szSrc = _ILGetTextPointer(pidl) )) - { - /* filesystem */ - MultiByteToWideChar(CP_ACP, 0, szSrc, -1, szTemp, MAX_PATH); - - if (szOut) - lstrcpynW(szOut, szTemp, uOutSize); - - dwReturn = wcslen (szTemp); - } - else if (( riid = _ILGetGUIDPointer(pidl) )) - { - /* special folder */ - if ( HCR_GetClassNameW(riid, szTemp, MAX_PATH) ) - { - if (szOut) - lstrcpynW(szOut, szTemp, uOutSize); - - dwReturn = wcslen (szTemp); - } - } - else - { - ERR("-- no text\n"); - } - } - - TRACE("-- (%p=%s 0x%08x)\n",szOut,debugstr_w(szOut),dwReturn); - return dwReturn; -} - -/************************************************************************** - * - * ### 4. getting pointers to parts of pidls ### - * - ************************************************************************** - * _ILGetDataPointer() - */ -LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl) -{ - if(pidl && pidl->mkid.cb != 0x00) - return (LPPIDLDATA)pidl->mkid.abID; - return NULL; -} - -/************************************************************************** - * _ILGetTextPointerW() - * gets a pointer to the unicode long filename string stored in the pidl - */ -static LPWSTR _ILGetTextPointerW(LPCITEMIDLIST pidl) -{ - /* TRACE(pidl,"(pidl%p)\n", pidl);*/ - - LPPIDLDATA pdata = _ILGetDataPointer(pidl); - - if (!pdata) - return NULL; - - switch (pdata->type) - { - case PT_GUID: - case PT_SHELLEXT: - case PT_YAGUID: - return NULL; - - case PT_DRIVE: - case PT_DRIVE1: - case PT_DRIVE2: - case PT_DRIVE3: - /*return (LPSTR)&(pdata->u.drive.szDriveName);*/ - return NULL; - - case PT_FOLDER: - case PT_FOLDER1: - case PT_VALUE: - case PT_IESPECIAL1: - case PT_IESPECIAL2: - /*return (LPSTR)&(pdata->u.file.szNames);*/ - return NULL; - - case PT_WORKGRP: - case PT_COMP: - case PT_NETWORK: - case PT_NETPROVIDER: - case PT_SHARE: - /*return (LPSTR)&(pdata->u.network.szNames);*/ - return NULL; - - case PT_VALUEW: - return (LPWSTR)pdata->u.file.szNames; - } - return NULL; -} - - -/************************************************************************** - * _ILGetTextPointer() - * gets a pointer to the long filename string stored in the pidl - */ -LPSTR _ILGetTextPointer(LPCITEMIDLIST pidl) -{ - /* TRACE(pidl,"(pidl%p)\n", pidl);*/ - - LPPIDLDATA pdata = _ILGetDataPointer(pidl); - - if (!pdata) - return NULL; - - switch (pdata->type) - { - case PT_GUID: - case PT_SHELLEXT: - case PT_YAGUID: - return NULL; - - case PT_DRIVE: - case PT_DRIVE1: - case PT_DRIVE2: - case PT_DRIVE3: - return pdata->u.drive.szDriveName; - - case PT_FOLDER: - case PT_FOLDER1: - case PT_VALUE: - case PT_IESPECIAL1: - case PT_IESPECIAL2: - return pdata->u.file.szNames; - - case PT_WORKGRP: - case PT_COMP: - case PT_NETWORK: - case PT_NETPROVIDER: - case PT_SHARE: - return pdata->u.network.szNames; - } - return NULL; -} - -/************************************************************************** - * _ILGetSTextPointer() - * gets a pointer to the short filename string stored in the pidl - */ -static LPSTR _ILGetSTextPointer(LPCITEMIDLIST pidl) -{ - /* TRACE(pidl,"(pidl%p)\n", pidl); */ - - LPPIDLDATA pdata =_ILGetDataPointer(pidl); - - if (!pdata) - return NULL; - - switch (pdata->type) - { - case PT_FOLDER: - case PT_VALUE: - case PT_IESPECIAL1: - case PT_IESPECIAL2: - return pdata->u.file.szNames + strlen (pdata->u.file.szNames) + 1; - - case PT_WORKGRP: - return pdata->u.network.szNames + strlen (pdata->u.network.szNames) + 1; - } - return NULL; -} - -/************************************************************************** - * _ILGetGUIDPointer() - * - * returns reference to guid stored in some pidls - */ -IID* _ILGetGUIDPointer(LPCITEMIDLIST pidl) -{ - LPPIDLDATA pdata =_ILGetDataPointer(pidl); - - TRACE("%p\n", pidl); - - if (!pdata) - return NULL; - - TRACE("pdata->type 0x%04x\n", pdata->type); - switch (pdata->type) - { - case PT_SHELLEXT: - case PT_GUID: - case PT_YAGUID: - return &(pdata->u.guid.guid); - - default: - TRACE("Unknown pidl type 0x%04x\n", pdata->type); - break; - } - return NULL; -} - -/****************************************************************************** - * _ILGetFileStructW [Internal] - * - * Get pointer the a SHITEMID's FileStructW field if present - * - * PARAMS - * pidl [I] The SHITEMID - * - * RETURNS - * Success: Pointer to pidl's FileStructW field. - * Failure: NULL - */ -FileStructW* _ILGetFileStructW(LPCITEMIDLIST pidl) { - FileStructW *pFileStructW; - WORD cbOffset; - - if (!(_ILIsValue(pidl) || _ILIsFolder(pidl))) - return NULL; - - cbOffset = *(const WORD *)((const BYTE *)pidl + pidl->mkid.cb - sizeof(WORD)); - pFileStructW = (FileStructW*)((LPBYTE)pidl + cbOffset); - - /* Currently I don't see a fool prove way to figure out if a pidl is for sure of WinXP - * style with a FileStructW member. If we switch all our shellfolder-implementations to - * the new format, this won't be a problem. For now, we do as many sanity checks as possible. */ - if (cbOffset & 0x1 || /* FileStructW member is word aligned in the pidl */ - /* FileStructW is positioned after FileStruct */ - cbOffset < sizeof(pidl->mkid.cb) + sizeof(PIDLTYPE) + sizeof(FileStruct) || - /* There has to be enough space at cbOffset in the pidl to hold FileStructW and cbOffset */ - cbOffset > pidl->mkid.cb - sizeof(cbOffset) - sizeof(FileStructW) || - pidl->mkid.cb != cbOffset + pFileStructW->cbLen) - { - WARN("Invalid pidl format (cbOffset = %d)!\n", cbOffset); - return NULL; - } - - return pFileStructW; -} - -/************************************************************************* - * _ILGetFileDateTime - * - * Given the ItemIdList, get the FileTime - * - * PARAMS - * pidl [I] The ItemIDList - * pFt [I] the resulted FILETIME of the file - * - * RETURNS - * True if Successful - * - * NOTES - * - */ -BOOL _ILGetFileDateTime(LPCITEMIDLIST pidl, FILETIME *pFt) -{ - LPPIDLDATA pdata = _ILGetDataPointer(pidl); - - if (!pdata) - return FALSE; - - switch (pdata->type) - { - case PT_FOLDER: - case PT_VALUE: - DosDateTimeToFileTime(pdata->u.file.uFileDate, pdata->u.file.uFileTime, pFt); - break; - default: - return FALSE; - } - return TRUE; -} - -BOOL _ILGetFileDate (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) -{ - FILETIME ft,lft; - SYSTEMTIME time; - BOOL ret; - - if (_ILGetFileDateTime( pidl, &ft )) - { - FileTimeToLocalFileTime(&ft, &lft); - FileTimeToSystemTime (&lft, &time); - - ret = GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&time, NULL, pOut, uOutSize); - if (ret) - { - /* Append space + time without seconds */ - pOut[ret-1] = ' '; - GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &time, NULL, &pOut[ret], uOutSize - ret); - } - } - else - { - pOut[0] = '\0'; - ret = FALSE; - } - return ret; -} - -/************************************************************************* - * _ILGetFileSize - * - * Given the ItemIdList, get the FileSize - * - * PARAMS - * pidl [I] The ItemIDList - * pOut [I] The buffer to save the result - * uOutsize [I] The size of the buffer - * - * RETURNS - * The FileSize - * - * NOTES - * pOut can be null when no string is needed - * - */ -DWORD _ILGetFileSize (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) -{ - LPPIDLDATA pdata = _ILGetDataPointer(pidl); - DWORD dwSize; - - if (!pdata) - return 0; - - switch (pdata->type) - { - case PT_VALUE: - dwSize = pdata->u.file.dwFileSize; - if (pOut) - StrFormatKBSizeA(dwSize, pOut, uOutSize); - return dwSize; - } - if (pOut) - *pOut = 0x00; - return 0; -} - -BOOL _ILGetExtension (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) -{ - char szTemp[MAX_PATH]; - const char * pPoint; - LPCITEMIDLIST pidlTemp=pidl; - - TRACE("pidl=%p\n",pidl); - - if (!pidl) - return FALSE; - - pidlTemp = ILFindLastID(pidl); - - if (!_ILIsValue(pidlTemp)) - return FALSE; - if (!_ILSimpleGetText(pidlTemp, szTemp, MAX_PATH)) - return FALSE; - - pPoint = PathFindExtensionA(szTemp); - - if (!*pPoint) - return FALSE; - - pPoint++; - lstrcpynA(pOut, pPoint, uOutSize); - TRACE("%s\n",pOut); - - return TRUE; -} - -/************************************************************************* - * _ILGetFileType - * - * Given the ItemIdList, get the file type description - * - * PARAMS - * pidl [I] The ItemIDList (simple) - * pOut [I] The buffer to save the result - * uOutsize [I] The size of the buffer - * - * RETURNS - * nothing - * - * NOTES - * This function copies as much as possible into the buffer. - */ -void _ILGetFileType(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) -{ - char sType[64]; - - if(_ILIsValue(pidl)) - { - char sTemp[64]; - - if(uOutSize > 0) - pOut[0] = 0; - if (_ILGetExtension (pidl, sType, 64)) - { - if (HCR_MapTypeToValueA(sType, sTemp, 64, TRUE)) - { - /* retrieve description */ - if(HCR_MapTypeToValueA(sTemp, pOut, uOutSize, FALSE )) - return; - } - /* display Ext-file as description */ - strcpy(pOut, sType); - _strupr(pOut); - /* load localized file string */ - sTemp[0] = '\0'; - if(LoadStringA(shell32_hInstance, IDS_SHV_COLUMN1, sTemp, 64)) - { - sTemp[63] = '\0'; - strcat(pOut, "-"); - strcat(pOut, sTemp); - } - } - } - else - { - pOut[0] = '\0'; - LoadStringA(shell32_hInstance, IDS_DIRECTORY, pOut, uOutSize); - /* make sure its null terminated */ - pOut[uOutSize-1] = '\0'; - } -} - -/************************************************************************* - * _ILGetFileAttributes - * - * Given the ItemIdList, get the Attrib string format - * - * PARAMS - * pidl [I] The ItemIDList - * pOut [I] The buffer to save the result - * uOutsize [I] The size of the Buffer - * - * RETURNS - * Attributes - * - * FIXME - * return value 0 in case of error is a valid return value - * - */ -DWORD _ILGetFileAttributes(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) -{ - LPPIDLDATA pData = _ILGetDataPointer(pidl); - WORD wAttrib = 0; - int i; - - if (!pData) - return 0; - - switch(pData->type) - { - case PT_FOLDER: - case PT_VALUE: - wAttrib = pData->u.file.uFileAttribs; - break; - } - - if(uOutSize >= 6) - { - i=0; - if(wAttrib & FILE_ATTRIBUTE_READONLY) - pOut[i++] = 'R'; - if(wAttrib & FILE_ATTRIBUTE_HIDDEN) - pOut[i++] = 'H'; - if(wAttrib & FILE_ATTRIBUTE_SYSTEM) - pOut[i++] = 'S'; - if(wAttrib & FILE_ATTRIBUTE_ARCHIVE) - pOut[i++] = 'A'; - if(wAttrib & FILE_ATTRIBUTE_COMPRESSED) - pOut[i++] = 'C'; - pOut[i] = 0x00; - } - return wAttrib; -} - -/************************************************************************* - * ILFreeaPidl - * - * free a aPidl struct - */ -void _ILFreeaPidl(LPITEMIDLIST * apidl, UINT cidl) -{ - UINT i; - - if (apidl) - { - for (i = 0; i < cidl; i++) - SHFree(apidl[i]); - SHFree(apidl); - } -} - -/************************************************************************* - * ILCopyaPidl - * - * copies an aPidl struct - */ -LPITEMIDLIST* _ILCopyaPidl(const LPCITEMIDLIST * apidlsrc, UINT cidl) -{ - UINT i; - LPITEMIDLIST *apidldest; - - apidldest = SHAlloc(cidl * sizeof(LPITEMIDLIST)); - if (!apidlsrc) - return NULL; - - for (i = 0; i < cidl; i++) - apidldest[i] = ILClone(apidlsrc[i]); - - return apidldest; -} - -/************************************************************************* - * _ILCopyCidaToaPidl - * - * creates aPidl from CIDA - */ -LPITEMIDLIST* _ILCopyCidaToaPidl(LPITEMIDLIST* pidl, const CIDA * cida) -{ - UINT i; - LPITEMIDLIST *dst; - - dst = SHAlloc(cida->cidl * sizeof(LPITEMIDLIST)); - if (!dst) - return NULL; - - if (pidl) - *pidl = ILClone((LPCITEMIDLIST)(&((const BYTE*)cida)[cida->aoffset[0]])); - - for (i = 0; i < cida->cidl; i++) - dst[i] = ILClone((LPCITEMIDLIST)(&((const BYTE*)cida)[cida->aoffset[i + 1]])); - - return dst; -} diff --git a/reactos/dll/win32/shell32/ros-systray.c b/reactos/dll/win32/shell32/ros-systray.c deleted file mode 100644 index f560b498e03..00000000000 --- a/reactos/dll/win32/shell32/ros-systray.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2004 Martin Fuchs - * - * Pass on icon notification messages to the systray implementation - * in the currently running shell. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - - /* copy data structure for tray notifications */ -typedef struct TrayNotifyCDS_Dummy { - DWORD cookie; - DWORD notify_code; - DWORD nicon_data[1]; // placeholder for NOTIFYICONDATA structure -} TrayNotifyCDS_Dummy; - - /* The only difference between Shell_NotifyIconA and Shell_NotifyIconW is the call to SendMessageA/W. */ -static BOOL SHELL_NotifyIcon(DWORD dwMessage, void* pnid, HWND nid_hwnd, int nid_size, BOOL unicode) -{ - HWND hwnd; - COPYDATASTRUCT data; - - BOOL ret = FALSE; - int len = sizeof(TrayNotifyCDS_Dummy)-sizeof(DWORD)+nid_size; - - TrayNotifyCDS_Dummy* pnotify_data = (TrayNotifyCDS_Dummy*) alloca(len); - - pnotify_data->cookie = 1; - pnotify_data->notify_code = dwMessage; - memcpy(&pnotify_data->nicon_data, pnid, nid_size); - - data.dwData = 1; - data.cbData = len; - data.lpData = pnotify_data; - - for(hwnd=0; (hwnd=FindWindowExW(0, hwnd, L"Shell_TrayWnd", NULL)); ) - if ((unicode?SendMessageW:SendMessageA)(hwnd, WM_COPYDATA, (WPARAM)nid_hwnd, (LPARAM)&data)) - ret = TRUE; - - return ret; -} - - -/************************************************************************* - * Shell_NotifyIcon [SHELL32.296] - * Shell_NotifyIconA [SHELL32.297] - */ -BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid) -{ - return SHELL_NotifyIcon(dwMessage, pnid, pnid->hWnd, pnid->cbSize, FALSE); -} - -/************************************************************************* - * Shell_NotifyIconW [SHELL32.298] - */ -BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW pnid) -{ - return SHELL_NotifyIcon(dwMessage, pnid, pnid->hWnd, pnid->cbSize, TRUE); -} diff --git a/reactos/dll/win32/shell32/she_ocmenu.c b/reactos/dll/win32/shell32/she_ocmenu.c deleted file mode 100644 index 9aea9e1b48e..00000000000 --- a/reactos/dll/win32/shell32/she_ocmenu.c +++ /dev/null @@ -1,1339 +0,0 @@ -/* - * Open With Context Menu extension - * - * Copyright 2007 Johannes Anderwald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL (shell); - -/// -/// [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system] -/// "NoInternetOpenWith"=dword:00000001 -/// - -// TODO -// implement duplicate checks in list box -// implement duplicate checks for MRU! -// implement owner drawn menu - -typedef struct -{ - const IContextMenu2Vtbl *lpVtblContextMenu; - const IShellExtInitVtbl *lpvtblShellExtInit; - LONG wId; - volatile LONG ref; - BOOL NoOpen; - UINT count; - WCHAR szPath[MAX_PATH]; - HMENU hSubMenu; -} SHEOWImpl, *LPSHEOWImpl; - -typedef struct -{ - BOOL bMenu; - HMENU hMenu; - HWND hDlgCtrl; - UINT Count; - BOOL NoOpen; - UINT idCmdFirst; -}OPEN_WITH_CONTEXT, *POPEN_WITH_CONTEXT; - -#define MANUFACTURER_NAME_SIZE 100 - -typedef struct -{ - HICON hIcon; - WCHAR szAppName[MAX_PATH]; - WCHAR szManufacturer[MANUFACTURER_NAME_SIZE]; -}OPEN_ITEM_CONTEXT, *POPEN_ITEM_CONTEXT; - - -typedef struct _LANGANDCODEPAGE_ - { - WORD lang; - WORD code; -} LANGANDCODEPAGE, *LPLANGANDCODEPAGE; - -typedef struct { - DWORD cbSize; - DWORD uMax; - DWORD fFlags; - HKEY hKey; - LPWSTR lpszSubKey; - PROC lpfnCompare; -} MRUINFO, *LPMRUINFO; - -#define MRUF_STRING_LIST 0 - -typedef HANDLE (WINAPI *CREATEMRULISTPROCW)( - LPMRUINFO lpmi -); - -typedef int (WINAPI *ENUMMRULISTW)( - HANDLE hMRU, - int nItem, - void *lpData, - UINT uLen -); - -typedef int (WINAPI *ADDMRUSTRINGW)( - HANDLE hMRU, - LPCWSTR szString -); - -typedef void (WINAPI *FREEMRULIST)( - HANDLE hList); - -static const IShellExtInitVtbl eivt; -static const IContextMenu2Vtbl cmvt; -static HRESULT WINAPI SHEOWCm_fnQueryInterface(IContextMenu2 *iface, REFIID riid, LPVOID *ppvObj); -static ULONG WINAPI SHEOWCm_fnRelease(IContextMenu2 *iface); - -HANDLE OpenMRUList(HKEY hKey); -void LoadItemFromHKCU(POPEN_WITH_CONTEXT pContext, WCHAR * szExt); -void LoadItemFromHKCR(POPEN_WITH_CONTEXT pContext, WCHAR * szExt); -void InsertOpenWithItem(POPEN_WITH_CONTEXT pContext, WCHAR * szAppName); - -static HMODULE hModule = NULL; -static CREATEMRULISTPROCW CreateMRUListProcW = NULL; -static ENUMMRULISTW EnumMRUListW = NULL; -static FREEMRULIST FreeMRUListProc = NULL; -static ADDMRUSTRINGW AddMRUStringW = NULL; - - -HRESULT WINAPI SHEOW_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID *ppv) -{ - SHEOWImpl * ow; - HRESULT res; - - ow = LocalAlloc(LMEM_ZEROINIT, sizeof(SHEOWImpl)); - if (!ow) - { - return E_OUTOFMEMORY; - } - - ow->ref = 1; - ow->lpVtblContextMenu = &cmvt; - ow->lpvtblShellExtInit = &eivt; - - TRACE("(%p)->()\n",ow); - - res = SHEOWCm_fnQueryInterface( (IContextMenu2*)&ow->lpVtblContextMenu, riid, ppv ); - SHEOWCm_fnRelease( (IContextMenu2*)&ow->lpVtblContextMenu ); - return res; -} - -static LPSHEOWImpl __inline impl_from_IShellExtInit( IShellExtInit *iface ) -{ - return (SHEOWImpl *)((char*)iface - FIELD_OFFSET(SHEOWImpl, lpvtblShellExtInit)); -} - -static LPSHEOWImpl __inline impl_from_IContextMenu( IContextMenu2 *iface ) -{ - return (SHEOWImpl *)((char*)iface - FIELD_OFFSET(SHEOWImpl, lpVtblContextMenu)); -} - -static HRESULT WINAPI SHEOWCm_fnQueryInterface(IContextMenu2 *iface, REFIID riid, LPVOID *ppvObj) -{ - SHEOWImpl *This = impl_from_IContextMenu(iface); - - TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj); - - *ppvObj = NULL; - - if(IsEqualIID(riid, &IID_IUnknown) || - IsEqualIID(riid, &IID_IContextMenu) || - IsEqualIID(riid, &IID_IContextMenu2)) - { - *ppvObj = (void *)&This->lpVtblContextMenu; - } - else if(IsEqualIID(riid, &IID_IShellExtInit)) - { - *ppvObj = (void *)&This->lpvtblShellExtInit; - } - - if(*ppvObj) - { - IUnknown_AddRef((IUnknown*)*ppvObj); - TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj); - return S_OK; - } - TRACE("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -static ULONG WINAPI SHEOWCm_fnAddRef(IContextMenu2 *iface) -{ - SHEOWImpl *This = impl_from_IContextMenu(iface); - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE("(%p)->(count=%u)\n", This, refCount - 1); - - return refCount; -} - -static ULONG WINAPI SHEOWCm_fnRelease(IContextMenu2 *iface) -{ - SHEOWImpl *This = impl_from_IContextMenu(iface); - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(count=%i)\n", This, refCount + 1); - - if (!refCount) - { - TRACE(" destroying IContextMenu(%p)\n",This); - HeapFree(GetProcessHeap(),0,This); - } - return refCount; -} - -VOID -AddItem(HMENU hMenu, UINT idCmdFirst) -{ - MENUITEMINFOW mii; - WCHAR szBuffer[MAX_PATH]; - static const WCHAR szChoose[] = { 'C','h','o','o','s','e',' ','P','r','o','g','r','a','m','.','.','.',0 }; - - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_TYPE | MIIM_ID; - mii.fType = MFT_SEPARATOR; - mii.wID = -1; - InsertMenuItemW(hMenu, -1, TRUE, &mii); - - if (!LoadStringW(shell32_hInstance, IDS_OPEN_WITH_CHOOSE, szBuffer, sizeof(szBuffer) / sizeof(WCHAR))) - wcscpy(szBuffer, szChoose); - - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - - mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE; - mii.fType = MFT_STRING; - mii.fState = MFS_ENABLED; - mii.wID = idCmdFirst; - mii.dwTypeData = (LPWSTR)szBuffer; - mii.cch = wcslen(szBuffer); - - InsertMenuItemW(hMenu, -1, TRUE, &mii); -} - -static -void -LoadOWItems(POPEN_WITH_CONTEXT pContext, LPCWSTR szName) -{ - WCHAR * szExt; - WCHAR szPath[100]; - DWORD dwPath; - - szExt = wcsrchr(szName, '.'); - if (!szExt) - { - /* FIXME - * show default list of available programs - */ - return; - } - - /* load programs directly associated from HKCU */ - LoadItemFromHKCU(pContext, szExt); - - /* load programs associated from HKCR\Extension */ - LoadItemFromHKCR(pContext, szExt); - - /* load programs referenced from HKCR\ProgId */ - dwPath = sizeof(szPath); - szPath[0] = 0; - if (RegGetValueW(HKEY_CLASSES_ROOT, szExt, NULL, RRF_RT_REG_SZ, NULL, szPath, &dwPath) == ERROR_SUCCESS) - { - szPath[(sizeof(szPath)/sizeof(WCHAR))-1] = L'\0'; - LoadItemFromHKCR(pContext, szPath); - } -} - - - -static HRESULT WINAPI SHEOWCm_fnQueryContextMenu( - IContextMenu2 *iface, - HMENU hmenu, - UINT indexMenu, - UINT idCmdFirst, - UINT idCmdLast, - UINT uFlags) -{ - MENUITEMINFOW mii; - WCHAR szBuffer[100] = {0}; - INT pos; - HMENU hSubMenu = NULL; - OPEN_WITH_CONTEXT Context; - SHEOWImpl *This = impl_from_IContextMenu(iface); - - if (LoadStringW(shell32_hInstance, IDS_OPEN_WITH, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)) < 0) - { - TRACE("failed to load string\n"); - return E_FAIL; - } - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - - hSubMenu = CreatePopupMenu(); - - /* set up context */ - ZeroMemory(&Context, sizeof(OPEN_WITH_CONTEXT)); - Context.bMenu = TRUE; - Context.Count = 0; - Context.hMenu = hSubMenu; - Context.idCmdFirst = idCmdFirst; - /* load items */ - LoadOWItems(&Context, This->szPath); - if (!Context.Count) - { - DestroyMenu(hSubMenu); - hSubMenu = NULL; - This->wId = 0; - This->count = 0; - } - else - { - AddItem(hSubMenu, Context.idCmdFirst++); - This->count = Context.idCmdFirst - idCmdFirst; - /* verb start at index zero */ - This->wId = This->count -1; - This->hSubMenu = hSubMenu; - } - - pos = GetMenuDefaultItem(hmenu, TRUE, 0) + 1; - - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE; - if (hSubMenu) - { - mii.fMask |= MIIM_SUBMENU; - mii.hSubMenu = hSubMenu; - } - mii.dwTypeData = (LPWSTR) szBuffer; - mii.fState = MFS_ENABLED; - if (!pos) - { - mii.fState |= MFS_DEFAULT; - } - - mii.wID = Context.idCmdFirst; - mii.fType = MFT_STRING; - if (InsertMenuItemW( hmenu, pos, TRUE, &mii)) - Context.Count++; - - return MAKE_HRESULT(SEVERITY_SUCCESS, 0, Context.Count); -} - -void -FreeListItems(HWND hwndDlg) -{ - HWND hList; - LRESULT iIndex, iCount; - POPEN_ITEM_CONTEXT pContext; - - hList = GetDlgItem(hwndDlg, 14002); - iCount = SendMessageW(hList, LB_GETCOUNT, 0, 0); - if (iCount == LB_ERR) - return; - - for (iIndex = 0; iIndex < iCount; iIndex++) - { - pContext = (POPEN_ITEM_CONTEXT)SendMessageW(hList, LB_GETITEMDATA, iIndex, 0); - if (pContext) - { - DestroyIcon(pContext->hIcon); - SendMessageW(hList, LB_SETITEMDATA, iIndex, (LPARAM)0); - HeapFree(GetProcessHeap(), 0, pContext); - } - } -} - -BOOL HideApplicationFromList(WCHAR * pFileName) -{ - WCHAR szBuffer[100] = {'A','p','p','l','i','c','a','t','i','o','n','s','\\',0}; - DWORD dwSize = 0; - LONG result; - - if (wcslen(pFileName) > (sizeof(szBuffer)/sizeof(WCHAR)) - 14) - { - ERR("insufficient buffer\n"); - return FALSE; - } - wcscpy(&szBuffer[13], pFileName); - - result = RegGetValueW(HKEY_CLASSES_ROOT, szBuffer, L"NoOpenWith", RRF_RT_REG_SZ, NULL, NULL, &dwSize); - - TRACE("result %d szBuffer %s\n", result, debugstr_w(szBuffer)); - - if (result == ERROR_SUCCESS) - return TRUE; - else - return FALSE; -} - -VOID -WriteStaticShellExtensionKey(HKEY hRootKey, WCHAR * pVerb, WCHAR *pFullPath) -{ - HKEY hShell; - LONG result; - WCHAR szBuffer[MAX_PATH+10] = {'s','h','e','l','l','\\', 0 }; - - if (wcslen(pVerb) > (sizeof(szBuffer)/sizeof(WCHAR)) - 15 || - wcslen(pFullPath) > (sizeof(szBuffer)/sizeof(WCHAR)) - 4) - { - ERR("insufficient buffer\n"); - return; - } - - /* construct verb reg path */ - wcscpy(&szBuffer[6], pVerb); - wcscat(szBuffer, L"\\command"); - - /* create verb reg key */ - if (RegCreateKeyExW(hRootKey, szBuffer, 0, NULL, 0, KEY_WRITE, NULL, &hShell, NULL) != ERROR_SUCCESS) - return; - - /* build command buffer */ - wcscpy(szBuffer, pFullPath); - wcscat(szBuffer, L" %1"); - - result = RegSetValueExW(hShell, NULL, 0, REG_SZ, (const BYTE*)szBuffer, (wcslen(szBuffer)+1)* sizeof(WCHAR)); - RegCloseKey(hShell); -} - -VOID -StoreNewSettings(LPCWSTR szFileName, WCHAR *szAppName) -{ - WCHAR szBuffer[100] = { L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\"}; - WCHAR * pFileExt; - HKEY hKey; - LONG result; - HANDLE hList; - - /* get file extension */ - pFileExt = wcsrchr(szFileName, L'.'); - if (wcslen(pFileExt) > (sizeof(szBuffer)/sizeof(WCHAR)) - 60) - { - ERR("insufficient buffer\n"); - return; - } - wcscpy(&szBuffer[60], pFileExt); - /* open base key for this file extension */ - if (RegCreateKeyExW(HKEY_CURRENT_USER, szBuffer, 0, NULL, 0, KEY_WRITE | KEY_READ, NULL, &hKey, NULL) != ERROR_SUCCESS) - return; - - /* open mru list */ - hList = OpenMRUList(hKey); - - if (!hList) - { - RegCloseKey(hKey); - return; - } - - /* insert the entry */ - result = (*AddMRUStringW)(hList, szAppName); - - /* close mru list */ - (*FreeMRUListProc)((HANDLE)hList); - /* create mru list key */ - RegCloseKey(hKey); -} - -VOID -SetProgrammAsDefaultHandler(LPCWSTR szFileName, WCHAR * szAppName) -{ - HKEY hKey; - HKEY hAppKey; - DWORD dwDisposition; - WCHAR szBuffer[100]; - DWORD dwSize; - BOOL result; - WCHAR * pFileExt; - WCHAR * pFileName; - - /* extract file extension */ - pFileExt = wcsrchr(szFileName, L'.'); - if (!pFileExt) - return; - - /* create file extension key */ - if (RegCreateKeyExW(HKEY_CLASSES_ROOT, pFileExt, 0, NULL, 0, KEY_WRITE, NULL, &hKey, &dwDisposition) != ERROR_SUCCESS) - return; - - if (dwDisposition & REG_CREATED_NEW_KEY) - { - /* a new entry was created create the prog key id */ - wcscpy(szBuffer, &pFileExt[1]); - wcscat(szBuffer, L"_auto_file"); - if (RegSetValueExW(hKey, NULL, 0, REG_SZ, (const BYTE*)szBuffer, (wcslen(szBuffer)+1) * sizeof(WCHAR)) != ERROR_SUCCESS) - { - RegCloseKey(hKey); - return; - } - } - else - { - /* entry already exists fetch prog key id */ - dwSize = sizeof(szBuffer); - if (RegGetValueW(hKey, NULL, NULL, RRF_RT_REG_SZ, NULL, szBuffer, &dwSize) != ERROR_SUCCESS) - { - RegCloseKey(hKey); - return; - } - } - /* close file extension key */ - RegCloseKey(hKey); - - /* create prog id key */ - if (RegCreateKeyExW(HKEY_CLASSES_ROOT, szBuffer, 0, NULL, 0, KEY_WRITE, NULL, &hKey, &dwDisposition) != ERROR_SUCCESS) - return; - - - /* check if there already verbs existing for that app */ - pFileName = wcsrchr(szAppName, L'\\'); - wcscpy(szBuffer, L"Classes\\Applications\\"); - wcscat(szBuffer, pFileName); - wcscat(szBuffer, L"\\shell"); - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szBuffer, 0, KEY_READ, &hAppKey) == ERROR_SUCCESS) - { - /* copy static verbs from Classes\Applications key */ - HKEY hTemp; - if (RegCreateKeyExW(hKey, L"shell", 0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &hTemp, &dwDisposition) == ERROR_SUCCESS) - { - result = RegCopyTreeW(hAppKey, NULL, hTemp); - RegCloseKey(hTemp); - if (result == ERROR_SUCCESS) - { - /* copied all subkeys, we are done */ - RegCloseKey(hKey); - RegCloseKey(hAppKey); - return; - } - } - RegCloseKey(hAppKey); - } - /* write standard static shell extension */ - WriteStaticShellExtensionKey(hKey, L"open", szAppName); - RegCloseKey(hKey); -} - -void -BrowseForApplication(HWND hwndDlg) -{ - WCHAR szBuffer[64] = {0}; - WCHAR szFilter[256] = {0}; - WCHAR szPath[MAX_PATH]; - OPENFILENAMEW ofn; - OPEN_WITH_CONTEXT Context; - INT count; - - /* load resource open with */ - if (LoadStringW(shell32_hInstance, IDS_OPEN_WITH, szBuffer, sizeof(szBuffer) / sizeof(WCHAR))) - { - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - ofn.lpstrTitle = szBuffer; - ofn.nMaxFileTitle = wcslen(szBuffer); - } - - ZeroMemory(&ofn, sizeof(OPENFILENAMEW)); - ofn.lStructSize = sizeof(OPENFILENAMEW); - ofn.hInstance = shell32_hInstance; - ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; - ofn.nMaxFile = (sizeof(szPath) / sizeof(WCHAR)); - ofn.lpstrFile = szPath; - - /* load the filter resource string */ - if (LoadStringW(shell32_hInstance, IDS_OPEN_WITH_FILTER, szFilter, sizeof(szFilter) / sizeof(WCHAR))) - { - szFilter[(sizeof(szFilter)/sizeof(WCHAR))-1] = 0; - ofn.lpstrFilter = szFilter; - } - ZeroMemory(szPath, sizeof(szPath)); - - /* call openfilename */ - if (!GetOpenFileNameW(&ofn)) - return; - - /* setup context for insert proc */ - ZeroMemory(&Context, sizeof(OPEN_WITH_CONTEXT)); - Context.hDlgCtrl = GetDlgItem(hwndDlg, 14002); - count = SendMessage(Context.hDlgCtrl, LB_GETCOUNT, 0, 0); - InsertOpenWithItem(&Context, szPath); - /* select new item */ - SendMessage(Context.hDlgCtrl, LB_SETCURSEL, count, 0); -} - -POPEN_ITEM_CONTEXT -GetCurrentOpenItemContext(HWND hwndDlg) -{ - LRESULT result; - - /* get current item */ - result = SendDlgItemMessage(hwndDlg, 14002, LB_GETCURSEL, 0, 0); - if(result == LB_ERR) - return NULL; - - /* get item context */ - result = SendDlgItemMessage(hwndDlg, 14002, LB_GETITEMDATA, result, 0); - if (result == LB_ERR) - return NULL; - - return (POPEN_ITEM_CONTEXT)result; -} - -void -ExecuteOpenItem(POPEN_ITEM_CONTEXT pItemContext, LPCWSTR FileName) -{ - STARTUPINFOW si; - PROCESS_INFORMATION pi; - WCHAR szPath[(MAX_PATH * 2)]; - - /* setup path with argument */ - ZeroMemory(&si, sizeof(STARTUPINFOW)); - si.cb = sizeof(STARTUPINFOW); - wcscpy(szPath, pItemContext->szAppName); - wcscat(szPath, L" "); - wcscat(szPath, FileName); - - ERR("path %s\n", debugstr_w(szPath)); - - if (CreateProcessW(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) - { - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); - SHAddToRecentDocs(SHARD_PATHW, FileName); - } -} - - -static INT_PTR CALLBACK OpenWithProgrammDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - LPMEASUREITEMSTRUCT lpmis; - LPDRAWITEMSTRUCT lpdis; - INT index; - WCHAR szBuffer[MAX_PATH + 30] = { 0 }; - OPENASINFO *poainfo; - TEXTMETRIC mt; - COLORREF preColor, preBkColor; - POPEN_ITEM_CONTEXT pItemContext; - LONG YOffset; - OPEN_WITH_CONTEXT Context; - - poainfo = (OPENASINFO*) GetWindowLongPtr(hwndDlg, DWLP_USER); - - switch(uMsg) - { - case WM_INITDIALOG: - SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG)lParam); - poainfo = (OPENASINFO*)lParam; - if (!(poainfo->oaifInFlags & OAIF_ALLOW_REGISTRATION)) - EnableWindow(GetDlgItem(hwndDlg, 14003), FALSE); - if (poainfo->oaifInFlags & OAIF_FORCE_REGISTRATION) - SendDlgItemMessage(hwndDlg, 14003, BM_SETCHECK, BST_CHECKED, 0); - if (poainfo->oaifInFlags & OAIF_HIDE_REGISTRATION) - ShowWindow(GetDlgItem(hwndDlg, 14003), SW_HIDE); - if (poainfo->pcszFile) - { - szBuffer[0] = L'\0'; - SendDlgItemMessageW(hwndDlg, 14001, WM_GETTEXT, sizeof(szBuffer), (LPARAM)szBuffer); - index = wcslen(szBuffer); - if (index + wcslen(poainfo->pcszFile) + 1 < sizeof(szBuffer)/sizeof(szBuffer[0])) - wcscat(szBuffer, poainfo->pcszFile); - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - SendDlgItemMessageW(hwndDlg, 14001, WM_SETTEXT, 0, (LPARAM)szBuffer); - ZeroMemory(&Context, sizeof(OPEN_WITH_CONTEXT)); - Context.hDlgCtrl = GetDlgItem(hwndDlg, 14002); - LoadOWItems(&Context, poainfo->pcszFile); - SendMessage(Context.hDlgCtrl, LB_SETCURSEL, 0, 0); - } - return TRUE; - case WM_MEASUREITEM: - lpmis = (LPMEASUREITEMSTRUCT) lParam; - lpmis->itemHeight = 64; - return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case 14004: /* browse */ - BrowseForApplication(hwndDlg); - return TRUE; - case 14002: - if (HIWORD(wParam) == LBN_SELCHANGE) - InvalidateRect((HWND)lParam, NULL, TRUE); // FIXME USE UPDATE RECT - break; - case 14005: /* ok */ - pItemContext = GetCurrentOpenItemContext(hwndDlg); - if (pItemContext) - { - /* store settings in HKCU path */ - StoreNewSettings(poainfo->pcszFile, pItemContext->szAppName); - - if (SendDlgItemMessage(hwndDlg, 14003, BM_GETCHECK, 0, 0) == BST_CHECKED) - { - /* set programm as default handler */ - SetProgrammAsDefaultHandler(poainfo->pcszFile, pItemContext->szAppName); - } - - if (poainfo->oaifInFlags & OAIF_EXEC) - ExecuteOpenItem(pItemContext, poainfo->pcszFile); - } - FreeListItems(hwndDlg); - EndDialog(hwndDlg, 1); - return TRUE; - case 14006: /* cancel */ - FreeListItems(hwndDlg); - EndDialog(hwndDlg, 0); - return TRUE; - default: - break; - } - break; - case WM_DRAWITEM: - lpdis = (LPDRAWITEMSTRUCT) lParam; - if (lpdis->itemID == -1) - break; - - switch (lpdis->itemAction) - { - case ODA_SELECT: - case ODA_DRAWENTIRE: - index = SendMessageW(lpdis->hwndItem, LB_GETCURSEL, 0, 0); - pItemContext =(POPEN_ITEM_CONTEXT)SendMessage(lpdis->hwndItem, LB_GETITEMDATA, lpdis->itemID, (LPARAM) 0); - - if (lpdis->itemID == index) - { - /* paint focused item with standard background colour */ - HBRUSH hBrush; - hBrush = CreateSolidBrush(RGB(46, 104, 160)); - FillRect(lpdis->hDC, &lpdis->rcItem, hBrush); - DeleteObject(hBrush); - preBkColor = SetBkColor(lpdis->hDC, RGB(46, 104, 160)); - } - else - { - /* paint non focused item with white background */ - HBRUSH hBrush; - hBrush = CreateSolidBrush(RGB(255, 255, 255)); - FillRect(lpdis->hDC, &lpdis->rcItem, hBrush); - DeleteObject(hBrush); - preBkColor = SetBkColor(lpdis->hDC, RGB(255, 255, 255)); - } - - SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, (LPARAM) szBuffer); - /* paint the icon */ - DrawIconEx(lpdis->hDC, lpdis->rcItem.left,lpdis->rcItem.top, pItemContext->hIcon, 0, 0, 0, NULL, DI_NORMAL); - /* get text size */ - GetTextMetrics(lpdis->hDC, &mt); - /* paint app name */ - YOffset = lpdis->rcItem.top + mt.tmHeight/2; - TextOutW(lpdis->hDC, 45, YOffset, szBuffer, wcslen(szBuffer)); - /* paint manufacturer description */ - YOffset += mt.tmHeight + 2; - preColor = SetTextColor(lpdis->hDC, RGB(192, 192, 192)); - if (pItemContext->szManufacturer[0]) - TextOutW(lpdis->hDC, 45, YOffset, pItemContext->szManufacturer, wcslen(pItemContext->szManufacturer)); - else - TextOutW(lpdis->hDC, 45, YOffset, pItemContext->szAppName, wcslen(pItemContext->szAppName)); - SetTextColor(lpdis->hDC, preColor); - SetBkColor(lpdis->hDC, preBkColor); - break; - } - break; - case WM_CLOSE: - FreeListItems(hwndDlg); - EndDialog(hwndDlg, 0); - return TRUE; - default: - break; - } - return FALSE; -} - -void -FreeMenuItemContext(HMENU hMenu) -{ - INT Count; - INT Index; - MENUITEMINFOW mii; - - /* get item count */ - Count = GetMenuItemCount(hMenu); - if (Count == -1) - return; - - /* setup menuitem info */ - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_DATA | MIIM_FTYPE; - - for(Index = 0; Index < Count; Index++) - { - if (GetMenuItemInfoW(hMenu, Index, TRUE, &mii)) - { - if ((mii.fType & MFT_SEPARATOR) || mii.dwItemData == 0) - continue; - HeapFree(GetProcessHeap(), 0, (LPVOID)mii.dwItemData); - } - } -} - - -static HRESULT WINAPI -SHEOWCm_fnInvokeCommand( IContextMenu2* iface, LPCMINVOKECOMMANDINFO lpici ) -{ - MENUITEMINFOW mii; - SHEOWImpl *This = impl_from_IContextMenu(iface); - - ERR("This %p wId %x count %u verb %x\n", This, This->wId, This->count, LOWORD(lpici->lpVerb)); - - if (This->wId < LOWORD(lpici->lpVerb)) - return E_FAIL; - - if (This->wId == LOWORD(lpici->lpVerb)) - { - OPENASINFO info; - - info.pcszFile = This->szPath; - info.oaifInFlags = OAIF_ALLOW_REGISTRATION | OAIF_REGISTER_EXT | OAIF_EXEC; - info.pcszClass = NULL; - FreeMenuItemContext(This->hSubMenu); - return SHOpenWithDialog(lpici->hwnd, &info); - } - - /* retrieve menu item info */ - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_DATA | MIIM_FTYPE; - - if (GetMenuItemInfoW(This->hSubMenu, LOWORD(lpici->lpVerb), TRUE, &mii)) - { - POPEN_ITEM_CONTEXT pItemContext = (POPEN_ITEM_CONTEXT)mii.dwItemData; - if (pItemContext) - { - /* launch item with specified app */ - ExecuteOpenItem(pItemContext, This->szPath); - } - } - /* free menu item context */ - FreeMenuItemContext(This->hSubMenu); - return S_OK; -} - -static HRESULT WINAPI -SHEOWCm_fnGetCommandString( IContextMenu2* iface, UINT_PTR idCmd, UINT uType, - UINT* pwReserved, LPSTR pszName, UINT cchMax ) -{ - SHEOWImpl *This = impl_from_IContextMenu(iface); - - FIXME("%p %lu %u %p %p %u\n", This, - idCmd, uType, pwReserved, pszName, cchMax ); - - return E_NOTIMPL; -} - -static HRESULT WINAPI SHEOWCm_fnHandleMenuMsg( - IContextMenu2 *iface, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) -{ - SHEOWImpl *This = impl_from_IContextMenu(iface); - - TRACE("This %p uMsg %x\n",This, uMsg); - - return E_NOTIMPL; -} - -static const IContextMenu2Vtbl cmvt = -{ - SHEOWCm_fnQueryInterface, - SHEOWCm_fnAddRef, - SHEOWCm_fnRelease, - SHEOWCm_fnQueryContextMenu, - SHEOWCm_fnInvokeCommand, - SHEOWCm_fnGetCommandString, - SHEOWCm_fnHandleMenuMsg -}; - -VOID -GetManufacturer(WCHAR * szAppName, POPEN_ITEM_CONTEXT pContext) -{ - UINT VerSize; - DWORD DummyHandle; - LPVOID pBuf; - WORD lang = 0; - WORD code = 0; - LPLANGANDCODEPAGE lplangcode; - WCHAR szBuffer[100]; - WCHAR * pResult; - BOOL bResult; - - static const WCHAR wFormat[] = L"\\StringFileInfo\\%04x%04x\\CompanyName"; - static const WCHAR wTranslation[] = L"VarFileInfo\\Translation"; - - /* query version info size */ - VerSize = GetFileVersionInfoSizeW(szAppName, &DummyHandle); - if (!VerSize) - { - pContext->szManufacturer[0] = 0; - return; - } - - /* allocate buffer */ - pBuf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, VerSize); - if (!pBuf) - { - pContext->szManufacturer[0] = 0; - return; - } - - /* query version info */ - if(!GetFileVersionInfoW(szAppName, 0, VerSize, pBuf)) - { - pContext->szManufacturer[0] = 0; - HeapFree(GetProcessHeap(), 0, pBuf); - return; - } - - /* query lang code */ - if(VerQueryValueW(pBuf, wTranslation, (LPVOID *)&lplangcode, &VerSize)) - { - /* FIXME find language from current locale / if not available, - * default to english - * for now default to first available language - */ - lang = lplangcode->lang; - code = lplangcode->code; - } - /* set up format */ - swprintf(szBuffer, wFormat, lang, code); - /* query manufacturer */ - pResult = NULL; - bResult = VerQueryValueW(pBuf, szBuffer, (LPVOID *)&pResult, &VerSize); - - if (VerSize && bResult && pResult) - wcscpy(pContext->szManufacturer, pResult); - else - pContext->szManufacturer[0] = 0; - HeapFree(GetProcessHeap(), 0, pBuf); -} - - - - -void -InsertOpenWithItem(POPEN_WITH_CONTEXT pContext, WCHAR * szAppName) -{ - MENUITEMINFOW mii; - POPEN_ITEM_CONTEXT pItemContext; - LRESULT index; - WCHAR * Offset; - WCHAR Buffer[_MAX_FNAME]; - - pItemContext = HeapAlloc(GetProcessHeap(), 0, sizeof(OPEN_ITEM_CONTEXT)); - if (!pItemContext) - return; - - /* store app path */ - wcscpy(pItemContext->szAppName, szAppName); - /* null terminate it */ - pItemContext->szAppName[MAX_PATH-1] = 0; - /* extract path name */ - _wsplitpath(szAppName, NULL, NULL, Buffer, NULL); - Offset = wcsrchr(Buffer, '.'); - if (Offset) - Offset[0] = L'\0'; - Buffer[0] = towupper(Buffer[0]); - - if (pContext->bMenu) - { - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | MIIM_DATA; - mii.fType = MFT_STRING; //MFT_OWNERDRAW; - mii.fState = MFS_ENABLED; - mii.wID = pContext->idCmdFirst; - mii.dwTypeData = Buffer; - mii.cch = wcslen(Buffer); - mii.dwItemData = (ULONG_PTR)pItemContext; - wcscpy(pItemContext->szManufacturer, Buffer); - if (InsertMenuItemW(pContext->hMenu, -1, TRUE, &mii)) - { - pContext->idCmdFirst++; - pContext->Count++; - } - } - else - { - /* get default icon */ - pItemContext->hIcon = ExtractIconW(shell32_hInstance, szAppName, 0); - /* get manufacturer */ - GetManufacturer(pItemContext->szAppName, pItemContext); - index = SendMessageW(pContext->hDlgCtrl, LB_ADDSTRING, 0, (LPARAM)Buffer); - if (index != LB_ERR) - SendMessageW(pContext->hDlgCtrl, LB_SETITEMDATA, index, (LPARAM)pItemContext); - } -} - -void -AddItemFromProgIDList(POPEN_WITH_CONTEXT pContext, HKEY hKey) -{ - FIXME("implement me :)))\n"); -} - -HANDLE -OpenMRUList(HKEY hKey) -{ - MRUINFO info; - - if (!hModule) - { - WCHAR szPath[MAX_PATH]; - if (!GetSystemDirectoryW(szPath, MAX_PATH)) - return 0; - PathAddBackslashW(szPath); - wcscat(szPath, L"comctl32.dll"); - hModule = LoadLibraryExW(szPath, NULL, 0); - } - CreateMRUListProcW = (CREATEMRULISTPROCW)GetProcAddress(hModule, MAKEINTRESOURCEA(400)); - EnumMRUListW = (ENUMMRULISTW)GetProcAddress(hModule, MAKEINTRESOURCEA(403)); - FreeMRUListProc = (FREEMRULIST)GetProcAddress(hModule, MAKEINTRESOURCEA(152)); - AddMRUStringW = (ADDMRUSTRINGW)GetProcAddress(hModule, MAKEINTRESOURCEA(401)); - - if (!CreateMRUListProcW || !EnumMRUListW || !FreeMRUListProc || !AddMRUStringW) - return 0; - - /* initialize mru list info */ - info.cbSize = sizeof(MRUINFO); - info.uMax = 32; - info.fFlags = MRUF_STRING_LIST; - info.hKey = hKey; - info.lpszSubKey = L"OpenWithList"; - info.lpfnCompare = NULL; - - /* load list */ - return (*CreateMRUListProcW)(&info); -} - -void -AddItemFromMRUList(POPEN_WITH_CONTEXT pContext, HKEY hKey) -{ - HANDLE hList; - int nItem, nCount, nResult; - WCHAR szBuffer[MAX_PATH]; - - /* open mru list */ - hList = OpenMRUList(hKey); - if (!hList) - return; - - /* get list count */ - nCount = (*EnumMRUListW)((HANDLE)hList, -1, NULL, 0); - - for(nItem = 0; nItem < nCount; nItem++) - { - nResult = (*EnumMRUListW)((HANDLE)hList, nItem, szBuffer, MAX_PATH); - if (nResult <= 0) - continue; - /* make sure its zero terminated */ - szBuffer[min(MAX_PATH-1, nResult)] = '\0'; - /* insert item */ - if (!HideApplicationFromList(szBuffer)) - InsertOpenWithItem(pContext, szBuffer); - } - - /* free the mru list */ - (*FreeMRUList)((HANDLE)hList); -} - - - -void -LoadItemFromHKCR(POPEN_WITH_CONTEXT pContext, WCHAR * szExt) -{ - HKEY hKey; - HKEY hSubKey; - WCHAR szBuffer[MAX_PATH+10]; - WCHAR szResult[100]; - DWORD dwSize; - - static const WCHAR szOpenWithList[] = L"OpenWithList"; - static const WCHAR szOpenWithProgIds[] = L"OpenWithProgIDs"; - static const WCHAR szPerceivedType[] = L"PerceivedType"; - static const WCHAR szSysFileAssoc[] = L"SystemFileAssociations\\%s"; - - /* check if extension exists */ - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szExt, 0, KEY_READ | KEY_WRITE, &hKey) != ERROR_SUCCESS) - return; - - if (RegGetValueW(hKey, NULL, L"NoOpen", RRF_RT_REG_SZ, NULL, NULL, &dwSize) == ERROR_SUCCESS) - { - /* display warning dialog */ - pContext->NoOpen = TRUE; - } - - /* check if there is a directly available execute key */ - if (RegOpenKeyExW(hKey, L"shell\\open\\command", 0, KEY_READ, &hSubKey) == ERROR_SUCCESS) - { - DWORD dwBuffer = sizeof(szBuffer); - - if (RegGetValueW(hSubKey, NULL, NULL, RRF_RT_REG_SZ, NULL, (PVOID)szBuffer, &dwBuffer) == ERROR_SUCCESS) - { - WCHAR * Ext = wcsrchr(szBuffer, ' '); - if (Ext) - { - /* erase %1 or extra arguments */ - Ext[0] = 0; - } - if(!HideApplicationFromList(szBuffer)) - InsertOpenWithItem(pContext, szBuffer); - } - RegCloseKey(hSubKey); - } - - /* load items from HKCR\Ext\OpenWithList */ - if (RegOpenKeyExW(hKey, szOpenWithList, 0, KEY_READ | KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS) - { - AddItemFromMRUList(pContext, hKey); - RegCloseKey(hSubKey); - } - - /* load items from HKCR\Ext\OpenWithProgIDs */ - if (RegOpenKeyExW(hKey, szOpenWithProgIds, 0, KEY_READ | KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS) - { - AddItemFromProgIDList(pContext, hSubKey); - RegCloseKey(hSubKey); - } - - /* load items from SystemFileAssociations\Ext key */ - swprintf(szResult, szSysFileAssoc, szExt); - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szResult, 0, KEY_READ | KEY_WRITE, &hSubKey) == ERROR_SUCCESS) - { - AddItemFromMRUList(pContext, hSubKey); - RegCloseKey(hSubKey); - } - - /* load additional items from referenced PerceivedType*/ - dwSize = sizeof(szBuffer); - if (RegGetValueW(hKey, NULL, szPerceivedType, RRF_RT_REG_SZ, NULL, szBuffer, &dwSize) != ERROR_SUCCESS) - { - RegCloseKey(hKey); - return; - } - RegCloseKey(hKey); - - /* terminate it explictely */ - szBuffer[29] = 0; - swprintf(szResult, szSysFileAssoc, szBuffer); - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szResult, 0, KEY_READ | KEY_WRITE, &hSubKey) == ERROR_SUCCESS) - { - AddItemFromMRUList(pContext, hSubKey); - RegCloseKey(hSubKey); - } -} - -void -LoadItemFromHKCU(POPEN_WITH_CONTEXT pContext, WCHAR * szExt) -{ - WCHAR szBuffer[MAX_PATH]; - HKEY hKey; - - static const WCHAR szOpenWithProgIDs[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%s\\OpenWithProgIDs"; - static const WCHAR szOpenWithList[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%s"; - - /* handle first progid lists */ - swprintf(szBuffer, szOpenWithProgIDs, szExt); - if (RegOpenKeyExW(HKEY_CURRENT_USER, szBuffer, 0, KEY_READ | KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) - { - AddItemFromProgIDList(pContext, hKey); - RegCloseKey(hKey); - } - - /* now handle mru lists */ - swprintf(szBuffer, szOpenWithList, szExt); - if (RegOpenKeyExW(HKEY_CURRENT_USER, szBuffer, 0, KEY_READ | KEY_WRITE, &hKey) == ERROR_SUCCESS) - { - AddItemFromMRUList(pContext, hKey); - RegCloseKey(hKey); - } -} - -HRESULT -SHEOW_LoadOpenWithItems(SHEOWImpl *This, IDataObject *pdtobj) -{ - STGMEDIUM medium; - FORMATETC fmt; - HRESULT hr; - LPIDA pida; - LPCITEMIDLIST pidl_folder; - LPCITEMIDLIST pidl_child; - LPCITEMIDLIST pidl; - DWORD dwPath; - LPWSTR szPtr; - static const WCHAR szShortCut[] = { '.','l','n','k', 0 }; - - fmt.cfFormat = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); - fmt.ptd = NULL; - fmt.dwAspect = DVASPECT_CONTENT; - fmt.lindex = -1; - fmt.tymed = TYMED_HGLOBAL; - - hr = IDataObject_GetData(pdtobj, &fmt, &medium); - - if (FAILED(hr)) - { - ERR("IDataObject_GetData failed with 0x%x\n", hr); - return hr; - } - - /*assert(pida->cidl==1);*/ - pida = (LPIDA)GlobalLock(medium.u.hGlobal); - - pidl_folder = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[0]); - pidl_child = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[1]); - - pidl = ILCombine(pidl_folder, pidl_child); - - GlobalUnlock(medium.u.hGlobal); - GlobalFree(medium.u.hGlobal); - - if (!pidl) - { - ERR("no mem\n"); - return E_OUTOFMEMORY; - } - if (_ILIsDesktop(pidl) || _ILIsMyDocuments(pidl) || _ILIsControlPanel(pidl) || _ILIsNetHood(pidl) || - _ILIsBitBucket(pidl) || _ILIsDrive(pidl) || _ILIsCPanelStruct(pidl) || _ILIsFolder(pidl) || _ILIsControlPanel(pidl)) - { - TRACE("pidl is a folder\n"); - SHFree((void*)pidl); - return E_FAIL; - } - - if (!SHGetPathFromIDListW(pidl, This->szPath)) - { - SHFree((void*)pidl); - ERR("SHGetPathFromIDListW failed\n"); - return E_FAIL; - } - - SHFree((void*)pidl); - TRACE("szPath %s\n", debugstr_w(This->szPath)); - - if (GetBinaryTypeW(This->szPath, &dwPath)) - { - TRACE("path is a executable %x\n", dwPath); - return E_FAIL; - } - - szPtr = wcsrchr(This->szPath, '.'); - if (szPtr) - { - if (!_wcsicmp(szPtr, szShortCut)) - { - FIXME("pidl is a shortcut\n"); - return E_FAIL; - } - } - return S_OK; -} - -static HRESULT WINAPI -SHEOW_ExtInit_Initialize( IShellExtInit* iface, LPCITEMIDLIST pidlFolder, - IDataObject *pdtobj, HKEY hkeyProgID ) -{ - SHEOWImpl *This = impl_from_IShellExtInit(iface); - - TRACE("This %p\n", This); - - return SHEOW_LoadOpenWithItems(This, pdtobj); -} - -static ULONG WINAPI SHEOW_ExtInit_AddRef(IShellExtInit *iface) -{ - SHEOWImpl *This = impl_from_IShellExtInit(iface); - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE("(%p)->(count=%u)\n", This, refCount - 1); - - return refCount; -} - -static ULONG WINAPI SHEOW_ExtInit_Release(IShellExtInit *iface) -{ - SHEOWImpl *This = impl_from_IShellExtInit(iface); - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(count=%i)\n", This, refCount + 1); - - if (!refCount) - { - HeapFree(GetProcessHeap(),0,This); - } - return refCount; -} - -static HRESULT WINAPI -SHEOW_ExtInit_QueryInterface( IShellExtInit* iface, REFIID riid, void** ppvObject ) -{ - SHEOWImpl *This = impl_from_IShellExtInit(iface); - return SHEOWCm_fnQueryInterface((IContextMenu2*)This, riid, ppvObject); -} - -static const IShellExtInitVtbl eivt = -{ - SHEOW_ExtInit_QueryInterface, - SHEOW_ExtInit_AddRef, - SHEOW_ExtInit_Release, - SHEOW_ExtInit_Initialize -}; - - -HRESULT WINAPI SHOpenWithDialog( - HWND hwndParent, - const OPENASINFO *poainfo -) -{ - MSG msg; - BOOL bRet; - HWND hwnd; - - if (poainfo->pcszClass == NULL && poainfo->pcszFile == NULL) - return E_FAIL; - - - hwnd = CreateDialogParam(shell32_hInstance, MAKEINTRESOURCE(OPEN_WITH_PROGRAMM_DLG), hwndParent, OpenWithProgrammDlg, (LPARAM)poainfo); - if (hwnd == NULL) - { - ERR("Failed to create dialog\n"); - return E_FAIL; - } - ShowWindow(hwnd, SW_SHOWNORMAL); - - while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0) - { - if (!IsWindow(hwnd) || !IsDialogMessage(hwnd, &msg)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - return S_OK; -} diff --git a/reactos/dll/win32/shell32/shell.c b/reactos/dll/win32/shell32/shell.c deleted file mode 100644 index 71761fc49ad..00000000000 --- a/reactos/dll/win32/shell32/shell.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Shell Library Functions - * - * Copyright 1998 Marcus Meissner - * Copyright 2000 Juergen Schmied - * Copyright 2002 Eric Pouech - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include -#include -#include -#include - - - - diff --git a/reactos/dll/win32/shell32/shell32_main.c b/reactos/dll/win32/shell32/shell32_main.c deleted file mode 100644 index 2bf6502443f..00000000000 --- a/reactos/dll/win32/shell32/shell32_main.c +++ /dev/null @@ -1,1370 +0,0 @@ -/* - * Shell basics - * - * Copyright 1998 Marcus Meissner - * Copyright 1998 Juergen Schmied (jsch) * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -extern const char * const SHELL_Authors[]; - -#define MORE_DEBUG 1 -/************************************************************************* - * CommandLineToArgvW [SHELL32.@] - * - * We must interpret the quotes in the command line to rebuild the argv - * array correctly: - * - arguments are separated by spaces or tabs - * - quotes serve as optional argument delimiters - * '"a b"' -> 'a b' - * - escaped quotes must be converted back to '"' - * '\"' -> '"' - * - an odd number of '\'s followed by '"' correspond to half that number - * of '\' followed by a '"' (extension of the above) - * '\\\"' -> '\"' - * '\\\\\"' -> '\\"' - * - an even number of '\'s followed by a '"' correspond to half that number - * of '\', plus a regular quote serving as an argument delimiter (which - * means it does not appear in the result) - * 'a\\"b c"' -> 'a\b c' - * 'a\\\\"b c"' -> 'a\\b c' - * - '\' that are not followed by a '"' are copied literally - * 'a\b' -> 'a\b' - * 'a\\b' -> 'a\\b' - * - * Note: - * '\t' == 0x0009 - * ' ' == 0x0020 - * '"' == 0x0022 - * '\\' == 0x005c - */ -LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs) -{ - DWORD argc; - LPWSTR *argv; - LPCWSTR cs; - LPWSTR arg,s,d; - LPWSTR cmdline; - int in_quotes,bcount; - - if (*lpCmdline==0) - { - /* Return the path to the executable */ - DWORD len, size=16; - - argv=LocalAlloc(LMEM_FIXED, size); - for (;;) - { - len = GetModuleFileNameW(0, (LPWSTR)(argv+1), (size-sizeof(LPWSTR))/sizeof(WCHAR)); - if (!len) - { - LocalFree(argv); - return NULL; - } - if (len < size) break; - size*=2; - argv=LocalReAlloc(argv, size, 0); - } - argv[0]=(LPWSTR)(argv+1); - if (numargs) - *numargs=1; - - return argv; - } - - /* to get a writable copy */ - argc=0; - bcount=0; - in_quotes=0; - cs=lpCmdline; - while (1) - { - if (*cs==0 || ((*cs==0x0009 || *cs==0x0020) && !in_quotes)) - { - /* space */ - argc++; - /* skip the remaining spaces */ - while (*cs==0x0009 || *cs==0x0020) { - cs++; - } - if (*cs==0) - break; - bcount=0; - continue; - } - else if (*cs==0x005c) - { - /* '\', count them */ - bcount++; - } - else if ((*cs==0x0022) && ((bcount & 1)==0)) - { - /* unescaped '"' */ - in_quotes=!in_quotes; - bcount=0; - } - else - { - /* a regular character */ - bcount=0; - } - cs++; - } - /* Allocate in a single lump, the string array, and the strings that go with it. - * This way the caller can make a single GlobalFree call to free both, as per MSDN. - */ - argv=LocalAlloc(LMEM_FIXED, argc*sizeof(LPWSTR)+(wcslen(lpCmdline)+1)*sizeof(WCHAR)); - if (!argv) - return NULL; - cmdline=(LPWSTR)(argv+argc); - wcscpy(cmdline, lpCmdline); - - argc=0; - bcount=0; - in_quotes=0; - arg=d=s=cmdline; - while (*s) - { - if ((*s==0x0009 || *s==0x0020) && !in_quotes) - { - /* Close the argument and copy it */ - *d=0; - argv[argc++]=arg; - - /* skip the remaining spaces */ - do { - s++; - } while (*s==0x0009 || *s==0x0020); - - /* Start with a new argument */ - arg=d=s; - bcount=0; - } - else if (*s==0x005c) - { - /* '\\' */ - *d++=*s++; - bcount++; - } - else if (*s==0x0022) - { - /* '"' */ - if ((bcount & 1)==0) - { - /* Preceded by an even number of '\', this is half that - * number of '\', plus a quote which we erase. - */ - d-=bcount/2; - in_quotes=!in_quotes; - s++; - } - else - { - /* Preceded by an odd number of '\', this is half that - * number of '\' followed by a '"' - */ - d=d-bcount/2-1; - *d++='"'; - s++; - } - bcount=0; - } - else - { - /* a regular character */ - *d++=*s++; - bcount=0; - } - } - if (*arg) - { - *d='\0'; - argv[argc++]=arg; - } - if (numargs) - *numargs=argc; - - return argv; -} - -static DWORD shgfi_get_exe_type(LPCWSTR szFullPath) -{ - BOOL status = FALSE; - HANDLE hfile; - DWORD BinaryType; - IMAGE_DOS_HEADER mz_header; - IMAGE_NT_HEADERS nt; - DWORD len; - char magic[4]; - - status = GetBinaryTypeW (szFullPath, &BinaryType); - if (!status) - return 0; - if (BinaryType == SCS_DOS_BINARY || BinaryType == SCS_PIF_BINARY) - return 0x4d5a; - - hfile = CreateFileW( szFullPath, GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, 0, 0 ); - if ( hfile == INVALID_HANDLE_VALUE ) - return 0; - - /* - * The next section is adapted from MODULE_GetBinaryType, as we need - * to examine the image header to get OS and version information. We - * know from calling GetBinaryTypeA that the image is valid and either - * an NE or PE, so much error handling can be omitted. - * Seek to the start of the file and read the header information. - */ - - SetFilePointer( hfile, 0, NULL, SEEK_SET ); - ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL ); - - SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET ); - ReadFile( hfile, magic, sizeof(magic), &len, NULL ); - if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE ) - { - SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET ); - ReadFile( hfile, &nt, sizeof(nt), &len, NULL ); - CloseHandle( hfile ); - /* DLL files are not executable and should return 0 */ - if (nt.FileHeader.Characteristics & IMAGE_FILE_DLL) - return 0; - if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) - { - return IMAGE_NT_SIGNATURE | - (nt.OptionalHeader.MajorSubsystemVersion << 24) | - (nt.OptionalHeader.MinorSubsystemVersion << 16); - } - return IMAGE_NT_SIGNATURE; - } - else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE ) - { - IMAGE_OS2_HEADER ne; - SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET ); - ReadFile( hfile, &ne, sizeof(ne), &len, NULL ); - CloseHandle( hfile ); - if (ne.ne_exetyp == 2) - return IMAGE_OS2_SIGNATURE | (ne.ne_expver << 16); - return 0; - } - CloseHandle( hfile ); - return 0; -} - -/************************************************************************* - * SHELL_IsShortcut [internal] - * - * Decide if an item id list points to a shell shortcut - */ -BOOL SHELL_IsShortcut(LPCITEMIDLIST pidlLast) -{ - char szTemp[MAX_PATH]; - HKEY keyCls; - BOOL ret = FALSE; - - if (_ILGetExtension(pidlLast, szTemp, MAX_PATH) && - HCR_MapTypeToValueA(szTemp, szTemp, MAX_PATH, TRUE)) - { - if (ERROR_SUCCESS == RegOpenKeyExA(HKEY_CLASSES_ROOT, szTemp, 0, KEY_QUERY_VALUE, &keyCls)) - { - if (ERROR_SUCCESS == RegQueryValueExA(keyCls, "IsShortcut", NULL, NULL, NULL, NULL)) - ret = TRUE; - - RegCloseKey(keyCls); - } - } - - return ret; -} - -#define SHGFI_KNOWN_FLAGS \ - (SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_SHELLICONSIZE | SHGFI_PIDL | \ - SHGFI_USEFILEATTRIBUTES | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX | \ - SHGFI_ICON | SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ATTRIBUTES | \ - SHGFI_ICONLOCATION | SHGFI_EXETYPE | SHGFI_SYSICONINDEX | \ - SHGFI_LINKOVERLAY | SHGFI_SELECTED | SHGFI_ATTR_SPECIFIED) - -/************************************************************************* - * SHGetFileInfoW [SHELL32.@] - * - */ -DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, - SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags ) -{ - WCHAR szLocation[MAX_PATH], szFullPath[MAX_PATH]; - int iIndex; - DWORD_PTR ret = TRUE; - DWORD dwAttributes = 0; - IShellFolder * psfParent = NULL; - IExtractIconW * pei = NULL; - LPITEMIDLIST pidlLast = NULL, pidl = NULL; - HRESULT hr = S_OK; - BOOL IconNotYetLoaded=TRUE; - UINT uGilFlags = 0; - - TRACE("%s fattr=0x%x sfi=%p(attr=0x%08x) size=0x%x flags=0x%x\n", - (flags & SHGFI_PIDL)? "pidl" : debugstr_w(path), dwFileAttributes, - psfi, psfi->dwAttributes, sizeofpsfi, flags); - - if (!path) - return FALSE; - - /* windows initializes these values regardless of the flags */ - if (psfi != NULL) - { - psfi->szDisplayName[0] = '\0'; - psfi->szTypeName[0] = '\0'; - psfi->iIcon = 0; - } - - if (!(flags & SHGFI_PIDL)) - { - /* SHGetFileInfo should work with absolute and relative paths */ - if (PathIsRelativeW(path)) - { - GetCurrentDirectoryW(MAX_PATH, szLocation); - PathCombineW(szFullPath, szLocation, path); - } - else - { - lstrcpynW(szFullPath, path, MAX_PATH); - } - } - - if (flags & SHGFI_EXETYPE) - { - if (flags != SHGFI_EXETYPE) - return 0; - return shgfi_get_exe_type(szFullPath); - } - - /* - * psfi is NULL normally to query EXE type. If it is NULL, none of the - * below makes sense anyway. Windows allows this and just returns FALSE - */ - if (psfi == NULL) - return FALSE; - - /* - * translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES - * is not specified. - * The pidl functions fail on not existing file names - */ - - if (flags & SHGFI_PIDL) - { - pidl = ILClone((LPCITEMIDLIST)path); - } - else if (!(flags & SHGFI_USEFILEATTRIBUTES)) - { - hr = SHILCreateFromPathW(szFullPath, &pidl, &dwAttributes); - } - - if ((flags & SHGFI_PIDL) || !(flags & SHGFI_USEFILEATTRIBUTES)) - { - /* get the parent shellfolder */ - if (pidl) - { - hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, - (LPCITEMIDLIST*)&pidlLast ); - if (SUCCEEDED(hr)) - pidlLast = ILClone(pidlLast); - ILFree(pidl); - } - else - { - ERR("pidl is null!\n"); - return FALSE; - } - } - - /* get the attributes of the child */ - if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES)) - { - if (!(flags & SHGFI_ATTR_SPECIFIED)) - { - psfi->dwAttributes = 0xffffffff; - } - if (psfParent) - IShellFolder_GetAttributesOf( psfParent, 1, (LPCITEMIDLIST*)&pidlLast, - &(psfi->dwAttributes) ); - } - - /* get the displayname */ - if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME)) - { - if (flags & SHGFI_USEFILEATTRIBUTES) - { - wcscpy (psfi->szDisplayName, PathFindFileNameW(szFullPath)); - } - else - { - STRRET str; - hr = IShellFolder_GetDisplayNameOf( psfParent, pidlLast, - SHGDN_INFOLDER, &str); - StrRetToStrNW (psfi->szDisplayName, MAX_PATH, &str, pidlLast); - } - } - - /* get the type name */ - if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME)) - { - static const WCHAR szFile[] = { 'F','i','l','e',0 }; - static const WCHAR szDashFile[] = { '-','f','i','l','e',0 }; - - if (!(flags & SHGFI_USEFILEATTRIBUTES)) - { - char ftype[80]; - - _ILGetFileType(pidlLast, ftype, 80); - MultiByteToWideChar(CP_ACP, 0, ftype, -1, psfi->szTypeName, 80 ); - } - else - { - if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - wcscat (psfi->szTypeName, szFile); - else - { - WCHAR sTemp[64]; - - wcscpy(sTemp,PathFindExtensionW(szFullPath)); - if (!( HCR_MapTypeToValueW(sTemp, sTemp, 64, TRUE) && - HCR_MapTypeToValueW(sTemp, psfi->szTypeName, 80, FALSE ))) - { - lstrcpynW (psfi->szTypeName, sTemp, 64); - wcscat (psfi->szTypeName, szDashFile); - } - } - } - } - - /* ### icons ###*/ - if (flags & SHGFI_OPENICON) - uGilFlags |= GIL_OPENICON; - - if (flags & SHGFI_LINKOVERLAY) - uGilFlags |= GIL_FORSHORTCUT; - else if ((flags&SHGFI_ADDOVERLAYS) || - (flags&(SHGFI_ICON|SHGFI_SMALLICON))==SHGFI_ICON) - { - if (SHELL_IsShortcut(pidlLast)) - uGilFlags |= GIL_FORSHORTCUT; - } - - if (flags & SHGFI_OVERLAYINDEX) - FIXME("SHGFI_OVERLAYINDEX unhandled\n"); - - if (flags & SHGFI_SELECTED) - FIXME("set icon to selected, stub\n"); - - if (flags & SHGFI_SHELLICONSIZE) - FIXME("set icon to shell size, stub\n"); - - /* get the iconlocation */ - if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION )) - { - UINT uDummy,uFlags; - - if (flags & SHGFI_USEFILEATTRIBUTES) - { - if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - { - wcscpy(psfi->szDisplayName, swShell32Name); - psfi->iIcon = -IDI_SHELL_FOLDER; - } - else - { - WCHAR* szExt; - static const WCHAR p1W[] = {'%','1',0}; - WCHAR sTemp [MAX_PATH]; - - szExt = PathFindExtensionW(szFullPath); - TRACE("szExt=%s\n", debugstr_w(szExt)); - if ( szExt && - HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) && - HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &psfi->iIcon)) - { - if (lstrcmpW(p1W, sTemp)) - wcscpy(psfi->szDisplayName, sTemp); - else - { - /* the icon is in the file */ - wcscpy(psfi->szDisplayName, szFullPath); - } - } - else - ret = FALSE; - } - } - else - { - hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, - (LPCITEMIDLIST*)&pidlLast, &IID_IExtractIconW, - &uDummy, (LPVOID*)&pei); - if (SUCCEEDED(hr)) - { - hr = IExtractIconW_GetIconLocation(pei, uGilFlags, - szLocation, MAX_PATH, &iIndex, &uFlags); - - if (uFlags & GIL_NOTFILENAME) - ret = FALSE; - else - { - wcscpy (psfi->szDisplayName, szLocation); - psfi->iIcon = iIndex; - } - IExtractIconW_Release(pei); - } - } - } - - /* get icon index (or load icon)*/ - if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX))) - { - if (flags & SHGFI_USEFILEATTRIBUTES && !(flags & SHGFI_PIDL)) - { - WCHAR sTemp [MAX_PATH]; - WCHAR * szExt; - int icon_idx=0; - - lstrcpynW(sTemp, szFullPath, MAX_PATH); - - if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - psfi->iIcon = SIC_GetIconIndex(swShell32Name, -IDI_SHELL_FOLDER, 0); - else - { - static const WCHAR p1W[] = {'%','1',0}; - - psfi->iIcon = 0; - szExt = PathFindExtensionW(sTemp); - if ( szExt && - HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) && - HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &icon_idx)) - { - if (!lstrcmpW(p1W,sTemp)) /* icon is in the file */ - wcscpy(sTemp, szFullPath); - - if (flags & SHGFI_SYSICONINDEX) - { - psfi->iIcon = SIC_GetIconIndex(sTemp,icon_idx,0); - if (psfi->iIcon == -1) - psfi->iIcon = 0; - } - else - { - UINT ret; - if (flags & SHGFI_SMALLICON) - ret = PrivateExtractIconsW( sTemp,icon_idx, - GetSystemMetrics( SM_CXSMICON ), - GetSystemMetrics( SM_CYSMICON ), - &psfi->hIcon, 0, 1, 0); - else - ret = PrivateExtractIconsW( sTemp, icon_idx, - GetSystemMetrics( SM_CXICON), - GetSystemMetrics( SM_CYICON), - &psfi->hIcon, 0, 1, 0); - if (ret != 0 && ret != 0xFFFFFFFF) - { - IconNotYetLoaded=FALSE; - psfi->iIcon = icon_idx; - } - } - } - } - } - else - { - if (!(PidlToSicIndex(psfParent, pidlLast, !(flags & SHGFI_SMALLICON), - uGilFlags, &(psfi->iIcon)))) - { - ret = FALSE; - } - } - if (ret && (flags & SHGFI_SYSICONINDEX)) - { - if (flags & SHGFI_SMALLICON) - ret = (DWORD_PTR) ShellSmallIconList; - else - ret = (DWORD_PTR) ShellBigIconList; - } - } - - /* icon handle */ - if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded) - { - if (flags & SHGFI_SMALLICON) - psfi->hIcon = ImageList_GetIcon( ShellSmallIconList, psfi->iIcon, ILD_NORMAL); - else - psfi->hIcon = ImageList_GetIcon( ShellBigIconList, psfi->iIcon, ILD_NORMAL); - } - - if (flags & ~SHGFI_KNOWN_FLAGS) - FIXME("unknown flags %08x\n", flags & ~SHGFI_KNOWN_FLAGS); - - if (psfParent) - IShellFolder_Release(psfParent); - - if (hr != S_OK) - ret = FALSE; - - SHFree(pidlLast); - -#ifdef MORE_DEBUG - TRACE ("icon=%p index=0x%08x attr=0x%08x name=%s type=%s ret=0x%08lx\n", - psfi->hIcon, psfi->iIcon, psfi->dwAttributes, - debugstr_w(psfi->szDisplayName), debugstr_w(psfi->szTypeName), ret); -#endif - - return ret; -} - -/************************************************************************* - * SHGetFileInfoA [SHELL32.@] - * - * Note: - * MSVBVM60.__vbaNew2 expects this function to return a value in range - * 1 .. 0x7fff when the function succeeds and flags does not contain - * SHGFI_EXETYPE or SHGFI_SYSICONINDEX (see bug 7701) - */ -DWORD_PTR WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes, - SHFILEINFOA *psfi, UINT sizeofpsfi, - UINT flags ) -{ - INT len; - LPWSTR temppath = NULL; - LPCWSTR pathW; - DWORD ret; - SHFILEINFOW temppsfi; - - if (flags & SHGFI_PIDL) - { - /* path contains a pidl */ - pathW = (LPCWSTR)path; - } - else - { - len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0); - temppath = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, path, -1, temppath, len); - pathW = temppath; - } - - if (psfi && (flags & SHGFI_ATTR_SPECIFIED)) - temppsfi.dwAttributes=psfi->dwAttributes; - - if (psfi == NULL) - ret = SHGetFileInfoW(pathW, dwFileAttributes, NULL, sizeof(temppsfi), flags); - else - ret = SHGetFileInfoW(pathW, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags); - - if (psfi) - { - if(flags & SHGFI_ICON) - psfi->hIcon=temppsfi.hIcon; - if(flags & (SHGFI_SYSICONINDEX|SHGFI_ICON|SHGFI_ICONLOCATION)) - psfi->iIcon=temppsfi.iIcon; - if(flags & SHGFI_ATTRIBUTES) - psfi->dwAttributes=temppsfi.dwAttributes; - if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION)) - { - WideCharToMultiByte(CP_ACP, 0, temppsfi.szDisplayName, -1, - psfi->szDisplayName, sizeof(psfi->szDisplayName), NULL, NULL); - } - if(flags & SHGFI_TYPENAME) - { - WideCharToMultiByte(CP_ACP, 0, temppsfi.szTypeName, -1, - psfi->szTypeName, sizeof(psfi->szTypeName), NULL, NULL); - } - } - - HeapFree(GetProcessHeap(), 0, temppath); - - return ret; -} - -/************************************************************************* - * DuplicateIcon [SHELL32.@] - */ -HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon) -{ - ICONINFO IconInfo; - HICON hDupIcon = 0; - - TRACE("%p %p\n", hInstance, hIcon); - - if (GetIconInfo(hIcon, &IconInfo)) - { - hDupIcon = CreateIconIndirect(&IconInfo); - - /* clean up hbmMask and hbmColor */ - DeleteObject(IconInfo.hbmMask); - DeleteObject(IconInfo.hbmColor); - } - - return hDupIcon; -} - -/************************************************************************* - * ExtractIconA [SHELL32.@] - */ -HICON WINAPI ExtractIconA(HINSTANCE hInstance, LPCSTR lpszFile, UINT nIconIndex) -{ - HICON ret; - INT len = MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, NULL, 0); - LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - - TRACE("%p %s %d\n", hInstance, lpszFile, nIconIndex); - - MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, lpwstrFile, len); - ret = ExtractIconW(hInstance, lpwstrFile, nIconIndex); - HeapFree(GetProcessHeap(), 0, lpwstrFile); - - return ret; -} - -/************************************************************************* - * ExtractIconW [SHELL32.@] - */ -HICON WINAPI ExtractIconW(HINSTANCE hInstance, LPCWSTR lpszFile, UINT nIconIndex) -{ - HICON hIcon = NULL; - UINT ret; - UINT cx = GetSystemMetrics(SM_CXICON), cy = GetSystemMetrics(SM_CYICON); - - TRACE("%p %s %d\n", hInstance, debugstr_w(lpszFile), nIconIndex); - - if (nIconIndex == 0xFFFFFFFF) - { - ret = PrivateExtractIconsW(lpszFile, 0, cx, cy, NULL, NULL, 0, LR_DEFAULTCOLOR); - if (ret != 0xFFFFFFFF && ret) - return (HICON)(UINT_PTR)ret; - return NULL; - } - else - ret = PrivateExtractIconsW(lpszFile, nIconIndex, cx, cy, &hIcon, NULL, 1, LR_DEFAULTCOLOR); - - if (ret == 0xFFFFFFFF) - return (HICON)1; - else if (ret > 0 && hIcon) - return hIcon; - - return NULL; -} - -/************************************************************************* - * Printer_LoadIconsW [SHELL32.205] - */ -VOID WINAPI Printer_LoadIconsW(LPCWSTR wsPrinterName, HICON * pLargeIcon, HICON * pSmallIcon) -{ - INT iconindex=IDI_SHELL_PRINTERS_FOLDER; - - TRACE("(%s, %p, %p)\n", debugstr_w(wsPrinterName), pLargeIcon, pSmallIcon); - - /* We should check if wsPrinterName is - 1. the Default Printer or not - 2. connected or not - 3. a Local Printer or a Network-Printer - and use different Icons - */ - if((wsPrinterName != NULL) && (wsPrinterName[0] != 0)) - { - FIXME("(select Icon by PrinterName %s not implemented)\n", debugstr_w(wsPrinterName)); - } - - if(pLargeIcon != NULL) - *pLargeIcon = LoadImageW(shell32_hInstance, - (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON, - 0, 0, LR_DEFAULTCOLOR|LR_DEFAULTSIZE); - - if(pSmallIcon != NULL) - *pSmallIcon = LoadImageW(shell32_hInstance, - (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON, - 16, 16, LR_DEFAULTCOLOR); -} - -/************************************************************************* - * Printers_RegisterWindowW [SHELL32.213] - * used by "printui.dll": - * find the Window of the given Type for the specific Printer and - * return the already existent hwnd or open a new window - */ -BOOL WINAPI Printers_RegisterWindowW(LPCWSTR wsPrinter, DWORD dwType, - HANDLE * phClassPidl, HWND * phwnd) -{ - FIXME("(%s, %x, %p (%p), %p (%p)) stub!\n", debugstr_w(wsPrinter), dwType, - phClassPidl, (phClassPidl != NULL) ? *(phClassPidl) : NULL, - phwnd, (phwnd != NULL) ? *(phwnd) : NULL); - - return FALSE; -} - -/************************************************************************* - * Printers_UnregisterWindow [SHELL32.214] - */ -VOID WINAPI Printers_UnregisterWindow(HANDLE hClassPidl, HWND hwnd) -{ - FIXME("(%p, %p) stub!\n", hClassPidl, hwnd); -} - -/*************************************************************************/ - -typedef struct -{ - LPCWSTR szApp; - LPCWSTR szOtherStuff; - HICON hIcon; -} ABOUT_INFO; - -#define DROP_FIELD_TOP (-15) -#define DROP_FIELD_HEIGHT 15 - -/************************************************************************* - * SHAppBarMessage [SHELL32.@] - */ -UINT_PTR WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data) -{ - int width=data->rc.right - data->rc.left; - int height=data->rc.bottom - data->rc.top; - RECT rec=data->rc; - - TRACE("msg=%d, data={cb=%d, hwnd=%p, callback=%x, edge=%d, rc=%s, lparam=%lx}\n", - msg, data->cbSize, data->hWnd, data->uCallbackMessage, data->uEdge, - wine_dbgstr_rect(&data->rc), data->lParam); - - switch (msg) - { - case ABM_GETSTATE: - return ABS_ALWAYSONTOP | ABS_AUTOHIDE; - case ABM_GETTASKBARPOS: - GetWindowRect(data->hWnd, &rec); - data->rc=rec; - return TRUE; - case ABM_ACTIVATE: - SetActiveWindow(data->hWnd); - return TRUE; - case ABM_GETAUTOHIDEBAR: - return 0; /* pretend there is no autohide bar */ - case ABM_NEW: - /* cbSize, hWnd, and uCallbackMessage are used. All other ignored */ - SetWindowPos(data->hWnd,HWND_TOP,0,0,0,0,SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE); - return TRUE; - case ABM_QUERYPOS: - GetWindowRect(data->hWnd, &(data->rc)); - return TRUE; - case ABM_REMOVE: - FIXME("ABM_REMOVE broken\n"); - /* FIXME: this is wrong; should it be DestroyWindow instead? */ - /*CloseHandle(data->hWnd);*/ - return TRUE; - case ABM_SETAUTOHIDEBAR: - SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top, - width,height,SWP_SHOWWINDOW); - return TRUE; - case ABM_SETPOS: - data->uEdge=(ABE_RIGHT | ABE_LEFT); - SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top, - width,height,SWP_SHOWWINDOW); - return TRUE; - case ABM_WINDOWPOSCHANGED: - return TRUE; - } - return FALSE; -} - -/************************************************************************* - * SHHelpShortcuts_RunDLLA [SHELL32.@] - * - */ -DWORD WINAPI SHHelpShortcuts_RunDLLA(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4) -{ - FIXME("(%x, %x, %x, %x) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4); - return 0; -} - -/************************************************************************* - * SHHelpShortcuts_RunDLLA [SHELL32.@] - * - */ -DWORD WINAPI SHHelpShortcuts_RunDLLW(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4) -{ - FIXME("(%x, %x, %x, %x) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4); - return 0; -} - -/************************************************************************* - * SHLoadInProc [SHELL32.@] - * Create an instance of specified object class from within - * the shell process and release it immediately - */ -HRESULT WINAPI SHLoadInProc (REFCLSID rclsid) -{ - void *ptr = NULL; - - TRACE("%s\n", debugstr_guid(rclsid)); - - CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,&ptr); - if(ptr) - { - IUnknown * pUnk = ptr; - IUnknown_Release(pUnk); - return NOERROR; - } - return DISP_E_MEMBERNOTFOUND; -} - -static VOID SetRegTextData(HWND hWnd, HKEY hKey, LPWSTR Value, UINT uID) -{ - DWORD dwBufferSize; - DWORD dwType; - LPWSTR lpBuffer; - - if( RegQueryValueExW(hKey, Value, NULL, &dwType, NULL, &dwBufferSize) == ERROR_SUCCESS ) - { - if(dwType == REG_SZ) - { - lpBuffer = HeapAlloc(GetProcessHeap(), 0, dwBufferSize); - - if(lpBuffer) - { - if( RegQueryValueExW(hKey, Value, NULL, &dwType, (LPBYTE)lpBuffer, &dwBufferSize) == ERROR_SUCCESS ) - { - SetDlgItemTextW(hWnd, uID, lpBuffer); - } - - HeapFree(GetProcessHeap(), 0, lpBuffer); - } - } - } -} - -INT_PTR CALLBACK AboutAuthorsDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) -{ - switch(msg) - { - case WM_INITDIALOG: - { - const char* const *pstr = SHELL_Authors; - - // Add the authors to the list - SendDlgItemMessageW( hWnd, IDC_SHELL_ABOUT_AUTHORS_LISTBOX, WM_SETREDRAW, FALSE, 0 ); - - while (*pstr) - { - WCHAR name[64]; - - /* authors list is in utf-8 format */ - MultiByteToWideChar( CP_UTF8, 0, *pstr, -1, name, sizeof(name)/sizeof(WCHAR) ); - SendDlgItemMessageW( hWnd, IDC_SHELL_ABOUT_AUTHORS_LISTBOX, LB_ADDSTRING, (WPARAM)-1, (LPARAM)name ); - pstr++; - } - - SendDlgItemMessageW( hWnd, IDC_SHELL_ABOUT_AUTHORS_LISTBOX, WM_SETREDRAW, TRUE, 0 ); - - return TRUE; - } - } - - return FALSE; -} -/************************************************************************* - * AboutDlgProc (internal) - */ -INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) -{ - static DWORD cxLogoBmp; - static DWORD cyLogoBmp; - static HBITMAP hLogoBmp; - static HWND hWndAuthors; - - switch(msg) - { - case WM_INITDIALOG: - { - ABOUT_INFO *info = (ABOUT_INFO *)lParam; - - if (info) - { - const WCHAR szRegKey[] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"; - HKEY hRegKey; - MEMORYSTATUSEX MemStat; - WCHAR szAppTitle[512]; - WCHAR szAppTitleTemplate[512]; - WCHAR szAuthorsText[20]; - - // Preload the ROS bitmap - hLogoBmp = LoadImage(shell32_hInstance, MAKEINTRESOURCE(IDB_SHELL_ABOUT_LOGO_24BPP), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); - - if(hLogoBmp) - { - BITMAP bmpLogo; - - GetObject( hLogoBmp, sizeof(BITMAP), &bmpLogo ); - - cxLogoBmp = bmpLogo.bmWidth; - cyLogoBmp = bmpLogo.bmHeight; - } - - // Set App-specific stuff (icon, app name, szOtherStuff string) - SendDlgItemMessageW(hWnd, IDC_SHELL_ABOUT_ICON, STM_SETICON, (WPARAM)info->hIcon, 0); - - GetWindowTextW( hWnd, szAppTitleTemplate, sizeof(szAppTitleTemplate) / sizeof(WCHAR) ); - swprintf( szAppTitle, szAppTitleTemplate, info->szApp ); - SetWindowTextW( hWnd, szAppTitle ); - - SetDlgItemTextW( hWnd, IDC_SHELL_ABOUT_APPNAME, info->szApp ); - SetDlgItemTextW( hWnd, IDC_SHELL_ABOUT_OTHERSTUFF, info->szOtherStuff ); - - // Set the registered user and organization name - if(RegOpenKeyExW( HKEY_LOCAL_MACHINE, szRegKey, 0, KEY_QUERY_VALUE, &hRegKey ) == ERROR_SUCCESS) - { - SetRegTextData( hWnd, hRegKey, L"RegisteredOwner", IDC_SHELL_ABOUT_REG_USERNAME ); - SetRegTextData( hWnd, hRegKey, L"RegisteredOrganization", IDC_SHELL_ABOUT_REG_ORGNAME ); - - RegCloseKey( hRegKey ); - } - - // Set the value for the installed physical memory - MemStat.dwLength = sizeof(MemStat); - if( GlobalMemoryStatusEx(&MemStat) ) - { - WCHAR szBuf[12]; - - if (MemStat.ullTotalPhys > 1024 * 1024 * 1024) - { - double dTotalPhys; - WCHAR szDecimalSeparator[4]; - WCHAR szUnits[3]; - - // We're dealing with GBs or more - MemStat.ullTotalPhys /= 1024 * 1024; - - if (MemStat.ullTotalPhys > 1024 * 1024) - { - // We're dealing with TBs or more - MemStat.ullTotalPhys /= 1024; - - if (MemStat.ullTotalPhys > 1024 * 1024) - { - // We're dealing with PBs or more - MemStat.ullTotalPhys /= 1024; - - dTotalPhys = (double)MemStat.ullTotalPhys / 1024; - wcscpy( szUnits, L"PB" ); - } - else - { - dTotalPhys = (double)MemStat.ullTotalPhys / 1024; - wcscpy( szUnits, L"TB" ); - } - } - else - { - dTotalPhys = (double)MemStat.ullTotalPhys / 1024; - wcscpy( szUnits, L"GB" ); - } - - // We need the decimal point of the current locale to display the RAM size correctly - if( GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, szDecimalSeparator, sizeof(szDecimalSeparator) / sizeof(WCHAR)) > 0) - { - UCHAR uDecimals; - UINT uIntegral; - - uIntegral = (UINT)dTotalPhys; - uDecimals = (UCHAR)((UINT)(dTotalPhys * 100) - uIntegral * 100); - - // Display the RAM size with 2 decimals - swprintf(szBuf, L"%u%s%02u %s", uIntegral, szDecimalSeparator, uDecimals, szUnits); - } - } - else - { - // We're dealing with MBs, don't show any decimals - swprintf( szBuf, L"%u MB", (UINT)MemStat.ullTotalPhys / 1024 / 1024 ); - } - - SetDlgItemTextW( hWnd, IDC_SHELL_ABOUT_PHYSMEM, szBuf); - } - - // Add the Authors dialog - hWndAuthors = CreateDialogW( shell32_hInstance, MAKEINTRESOURCEW(IDD_SHELL_ABOUT_AUTHORS), hWnd, AboutAuthorsDlgProc ); - LoadStringW( shell32_hInstance, IDS_SHELL_ABOUT_AUTHORS, szAuthorsText, sizeof(szAuthorsText) / sizeof(WCHAR) ); - SetDlgItemTextW( hWnd, IDC_SHELL_ABOUT_AUTHORS, szAuthorsText ); - } - - return TRUE; - } - - case WM_PAINT: - { - if(hLogoBmp) - { - PAINTSTRUCT ps; - HDC hdc; - HDC hdcMem; - - hdc = BeginPaint(hWnd, &ps); - hdcMem = CreateCompatibleDC(hdc); - - if(hdcMem) - { - SelectObject(hdcMem, hLogoBmp); - BitBlt(hdc, 0, 0, cxLogoBmp, cyLogoBmp, hdcMem, 0, 0, SRCCOPY); - - DeleteDC(hdcMem); - } - - EndPaint(hWnd, &ps); - } - - break; - } - - case WM_COMMAND: - switch(wParam) - { - case IDOK: - case IDCANCEL: - EndDialog(hWnd, TRUE); - return TRUE; - - case IDC_SHELL_ABOUT_AUTHORS: - { - static BOOL bShowingAuthors = FALSE; - WCHAR szAuthorsText[20]; - - if(bShowingAuthors) - { - LoadStringW( shell32_hInstance, IDS_SHELL_ABOUT_AUTHORS, szAuthorsText, sizeof(szAuthorsText) / sizeof(WCHAR) ); - ShowWindow( hWndAuthors, SW_HIDE ); - } - else - { - LoadStringW( shell32_hInstance, IDS_SHELL_ABOUT_BACK, szAuthorsText, sizeof(szAuthorsText) / sizeof(WCHAR) ); - ShowWindow( hWndAuthors, SW_SHOW ); - } - - SetDlgItemTextW( hWnd, IDC_SHELL_ABOUT_AUTHORS, szAuthorsText ); - bShowingAuthors = !bShowingAuthors; - return TRUE; - } - } - break; - - case WM_CLOSE: - EndDialog(hWnd, TRUE); - break; - } - - return FALSE; -} - - -/************************************************************************* - * ShellAboutA [SHELL32.288] - */ -BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon ) -{ - BOOL ret; - LPWSTR appW = NULL, otherW = NULL; - int len; - - if (szApp) - { - len = MultiByteToWideChar(CP_ACP, 0, szApp, -1, NULL, 0); - appW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, szApp, -1, appW, len); - } - if (szOtherStuff) - { - len = MultiByteToWideChar(CP_ACP, 0, szOtherStuff, -1, NULL, 0); - otherW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, szOtherStuff, -1, otherW, len); - } - - ret = ShellAboutW(hWnd, appW, otherW, hIcon); - - HeapFree(GetProcessHeap(), 0, otherW); - HeapFree(GetProcessHeap(), 0, appW); - return ret; -} - - -/************************************************************************* - * ShellAboutW [SHELL32.289] - */ -BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, - HICON hIcon ) -{ - ABOUT_INFO info; - HRSRC hRes; - LPVOID DlgTemplate; - BOOL bRet; - - TRACE("\n"); - - // DialogBoxIndirectParamW will be called with the hInstance of the calling application, so we have to preload the dialog template - if(!(hRes = FindResourceW(shell32_hInstance, MAKEINTRESOURCEW(IDD_SHELL_ABOUT), (LPWSTR)RT_DIALOG))) - return FALSE; - if(!(DlgTemplate = (LPVOID)LoadResource(shell32_hInstance, hRes))) - return FALSE; - - info.szApp = szApp; - info.szOtherStuff = szOtherStuff; - info.hIcon = hIcon ? hIcon : LoadIconW( 0, (LPWSTR)IDI_WINLOGO ); - - bRet = DialogBoxIndirectParamW((HINSTANCE)GetWindowLongPtrW( hWnd, GWLP_HINSTANCE ), - DlgTemplate, hWnd, AboutDlgProc, (LPARAM)&info ); - return bRet; -} - -/************************************************************************* - * FreeIconList (SHELL32.@) - */ -void WINAPI FreeIconList( DWORD dw ) -{ - FIXME("%x: stub\n",dw); -} - -/************************************************************************* - * SHLoadNonloadedIconOverlayIdentifiers (SHELL32.@) - */ -HRESULT WINAPI SHLoadNonloadedIconOverlayIdentifiers( VOID ) -{ - FIXME("stub\n"); - return S_OK; -} - -/*********************************************************************** - * DllGetVersion [SHELL32.@] - * - * Retrieves version information of the 'SHELL32.DLL' - * - * PARAMS - * pdvi [O] pointer to version information structure. - * - * RETURNS - * Success: S_OK - * Failure: E_INVALIDARG - * - * NOTES - * Returns version of a shell32.dll from IE4.01 SP1. - */ - -HRESULT WINAPI DllGetVersion (DLLVERSIONINFO *pdvi) -{ - /* FIXME: shouldn't these values come from the version resource? */ - if (pdvi->cbSize == sizeof(DLLVERSIONINFO) || - pdvi->cbSize == sizeof(DLLVERSIONINFO2)) - { - pdvi->dwMajorVersion = WINE_FILEVERSION_MAJOR; - pdvi->dwMinorVersion = WINE_FILEVERSION_MINOR; - pdvi->dwBuildNumber = WINE_FILEVERSION_BUILD; - pdvi->dwPlatformID = WINE_FILEVERSION_PLATFORMID; - if (pdvi->cbSize == sizeof(DLLVERSIONINFO2)) - { - DLLVERSIONINFO2 *pdvi2 = (DLLVERSIONINFO2 *)pdvi; - - pdvi2->dwFlags = 0; - pdvi2->ullVersion = MAKEDLLVERULL(WINE_FILEVERSION_MAJOR, - WINE_FILEVERSION_MINOR, - WINE_FILEVERSION_BUILD, - WINE_FILEVERSION_PLATFORMID); - } - TRACE("%u.%u.%u.%u\n", - pdvi->dwMajorVersion, pdvi->dwMinorVersion, - pdvi->dwBuildNumber, pdvi->dwPlatformID); - return S_OK; - } - else - { - WARN("wrong DLLVERSIONINFO size from app\n"); - return E_INVALIDARG; - } -} - -/************************************************************************* - * global variables of the shell32.dll - * all are once per process - * - */ -HINSTANCE shell32_hInstance = 0; -HIMAGELIST ShellSmallIconList = 0; -HIMAGELIST ShellBigIconList = 0; - - -/************************************************************************* - * SHELL32 DllMain - * - * NOTES - * calling oleinitialize here breaks sone apps. - */ -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) -{ - TRACE("%p 0x%x %p\n", hinstDLL, fdwReason, fImpLoad); - - switch (fdwReason) - { - case DLL_PROCESS_ATTACH: - shell32_hInstance = hinstDLL; - DisableThreadLibraryCalls(shell32_hInstance); - - /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */ - GetModuleFileNameW(hinstDLL, swShell32Name, MAX_PATH); - swShell32Name[MAX_PATH - 1] = '\0'; - - InitCommonControlsEx(NULL); - - SIC_Initialize(); - InitChangeNotifications(); - InitIconOverlays(); - break; - - case DLL_PROCESS_DETACH: - shell32_hInstance = 0; - SIC_Destroy(); - FreeChangeNotifications(); - break; - } - return TRUE; -} - -/************************************************************************* - * DllInstall [SHELL32.@] - * - * PARAMETERS - * - * BOOL bInstall - TRUE for install, FALSE for uninstall - * LPCWSTR pszCmdLine - command line (unused by shell32?) - */ - -HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline) -{ - FIXME("%s %s: stub\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline)); - return S_OK; /* indicate success */ -} - -/*********************************************************************** - * DllCanUnloadNow (SHELL32.@) - */ -HRESULT WINAPI DllCanUnloadNow(void) -{ - TRACE("stub\n"); - return S_FALSE; -} diff --git a/reactos/dll/win32/shell32/shellitem.c b/reactos/dll/win32/shell32/shellitem.c deleted file mode 100644 index 620f854efed..00000000000 --- a/reactos/dll/win32/shell32/shellitem.c +++ /dev/null @@ -1,382 +0,0 @@ -/* - * IShellItem implementation - * - * Copyright 2008 Vincent Povirk for CodeWeavers - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "precomp.h" - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -typedef struct _ShellItem { - const IShellItemVtbl *lpIShellItemVtbl; - LONG ref; - LPITEMIDLIST pidl; - const IPersistIDListVtbl *lpIPersistIDListVtbl; -} ShellItem; - -HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent, - IShellFolder *psfParent, LPCITEMIDLIST pidl, IShellItem **ppsi); - - -static inline ShellItem *impl_from_IPersistIDList( IPersistIDList *iface ) -{ - return (ShellItem*)((char*)iface - FIELD_OFFSET(ShellItem, lpIPersistIDListVtbl)); -} - - -static HRESULT WINAPI ShellItem_QueryInterface(IShellItem *iface, REFIID riid, - void **ppv) -{ - ShellItem *This = (ShellItem*)iface; - - TRACE("(%p,%p,%p)\n", iface, riid, ppv); - - if (!ppv) return E_INVALIDARG; - - if (IsEqualIID(&IID_IUnknown, riid) || IsEqualIID(&IID_IShellItem, riid)) - { - *ppv = This; - } - else if (IsEqualIID(&IID_IPersist, riid) || IsEqualIID(&IID_IPersistIDList, riid)) - { - *ppv = (IPersistIDListVtbl *)&(This->lpIPersistIDListVtbl); - } - else { - FIXME("not implemented for %s\n", shdebugstr_guid(riid)); - *ppv = NULL; - return E_NOINTERFACE; - } - - IUnknown_AddRef((IUnknown*)*ppv); - return S_OK; -} - -static ULONG WINAPI ShellItem_AddRef(IShellItem *iface) -{ - ShellItem *This = (ShellItem*)iface; - ULONG ref = InterlockedIncrement(&This->ref); - - TRACE("(%p), new refcount=%i\n", iface, ref); - - return ref; -} - -static ULONG WINAPI ShellItem_Release(IShellItem *iface) -{ - ShellItem *This = (ShellItem*)iface; - ULONG ref = InterlockedDecrement(&This->ref); - - TRACE("(%p), new refcount=%i\n", iface, ref); - - if (ref == 0) - { - ILFree(This->pidl); - HeapFree(GetProcessHeap(), 0, This); - } - - return ref; -} - -static HRESULT ShellItem_get_parent_pidl(ShellItem *This, LPITEMIDLIST *parent_pidl) -{ - *parent_pidl = ILClone(This->pidl); - if (*parent_pidl) - { - if (ILRemoveLastID(*parent_pidl)) - return S_OK; - else - { - ILFree(*parent_pidl); - *parent_pidl = NULL; - return E_INVALIDARG; - } - } - else - { - *parent_pidl = NULL; - return E_OUTOFMEMORY; - } -} - -static HRESULT ShellItem_get_parent_shellfolder(ShellItem *This, IShellFolder **ppsf) -{ - LPITEMIDLIST parent_pidl; - IShellFolder *desktop; - HRESULT ret; - - ret = ShellItem_get_parent_pidl(This, &parent_pidl); - if (SUCCEEDED(ret)) - { - ret = SHGetDesktopFolder(&desktop); - if (SUCCEEDED(ret)) - { - ret = IShellFolder_BindToObject(desktop, parent_pidl, NULL, &IID_IShellFolder, (void**)ppsf); - IShellFolder_Release(desktop); - } - ILFree(parent_pidl); - } - - return ret; -} - -static HRESULT WINAPI ShellItem_BindToHandler(IShellItem *iface, IBindCtx *pbc, - REFGUID rbhid, REFIID riid, void **ppvOut) -{ - FIXME("(%p,%p,%s,%p,%p)\n", iface, pbc, shdebugstr_guid(rbhid), riid, ppvOut); - - *ppvOut = NULL; - - return E_NOTIMPL; -} - -static HRESULT WINAPI ShellItem_GetParent(IShellItem *iface, IShellItem **ppsi) -{ - ShellItem *This = (ShellItem*)iface; - LPITEMIDLIST parent_pidl; - HRESULT ret; - - TRACE("(%p,%p)\n", iface, ppsi); - - ret = ShellItem_get_parent_pidl(This, &parent_pidl); - if (SUCCEEDED(ret)) - { - ret = SHCreateShellItem(NULL, NULL, parent_pidl, ppsi); - ILFree(parent_pidl); - } - - return ret; -} - -static HRESULT WINAPI ShellItem_GetDisplayName(IShellItem *iface, SIGDN sigdnName, - LPWSTR *ppszName) -{ - FIXME("(%p,%x,%p)\n", iface, sigdnName, ppszName); - - *ppszName = NULL; - - return E_NOTIMPL; -} - -static HRESULT WINAPI ShellItem_GetAttributes(IShellItem *iface, SFGAOF sfgaoMask, - SFGAOF *psfgaoAttribs) -{ - ShellItem *This = (ShellItem*)iface; - IShellFolder *parent_folder; - LPITEMIDLIST child_pidl; - HRESULT ret; - - TRACE("(%p,%x,%p)\n", iface, sfgaoMask, psfgaoAttribs); - - ret = ShellItem_get_parent_shellfolder(This, &parent_folder); - if (SUCCEEDED(ret)) - { - child_pidl = ILFindLastID(This->pidl); - *psfgaoAttribs = sfgaoMask; - ret = IShellFolder_GetAttributesOf(parent_folder, 1, (LPCITEMIDLIST*)&child_pidl, psfgaoAttribs); - IShellFolder_Release(parent_folder); - } - - return ret; -} - -static HRESULT WINAPI ShellItem_Compare(IShellItem *iface, IShellItem *oth, - SICHINTF hint, int *piOrder) -{ - FIXME("(%p,%p,%x,%p)\n", iface, oth, hint, piOrder); - - return E_NOTIMPL; -} - -static const IShellItemVtbl ShellItem_Vtbl = { - ShellItem_QueryInterface, - ShellItem_AddRef, - ShellItem_Release, - ShellItem_BindToHandler, - ShellItem_GetParent, - ShellItem_GetDisplayName, - ShellItem_GetAttributes, - ShellItem_Compare -}; - - -static HRESULT ShellItem_GetClassID(ShellItem* This, CLSID *pClassID) -{ - TRACE("(%p,%p)\n", This, pClassID); - - *pClassID = CLSID_ShellItem; - return S_OK; -} - - -static HRESULT WINAPI ShellItem_IPersistIDList_QueryInterface(IPersistIDList *iface, - REFIID riid, void **ppv) -{ - ShellItem *This = impl_from_IPersistIDList(iface); - return ShellItem_QueryInterface((IShellItem*)This, riid, ppv); -} - -static ULONG WINAPI ShellItem_IPersistIDList_AddRef(IPersistIDList *iface) -{ - ShellItem *This = impl_from_IPersistIDList(iface); - return ShellItem_AddRef((IShellItem*)This); -} - -static ULONG WINAPI ShellItem_IPersistIDList_Release(IPersistIDList *iface) -{ - ShellItem *This = impl_from_IPersistIDList(iface); - return ShellItem_Release((IShellItem*)This); -} - -static HRESULT WINAPI ShellItem_IPersistIDList_GetClassID(IPersistIDList* iface, - CLSID *pClassID) -{ - ShellItem *This = impl_from_IPersistIDList(iface); - - return ShellItem_GetClassID(This, pClassID); -} - -static HRESULT WINAPI ShellItem_IPersistIDList_SetIDList(IPersistIDList* iface, - LPCITEMIDLIST pidl) -{ - ShellItem *This = impl_from_IPersistIDList(iface); - LPITEMIDLIST new_pidl; - - TRACE("(%p,%p)\n", This, pidl); - - new_pidl = ILClone(pidl); - - if (new_pidl) - { - ILFree(This->pidl); - This->pidl = new_pidl; - return S_OK; - } - else - return E_OUTOFMEMORY; -} - -static HRESULT WINAPI ShellItem_IPersistIDList_GetIDList(IPersistIDList* iface, - LPITEMIDLIST *ppidl) -{ - ShellItem *This = impl_from_IPersistIDList(iface); - - TRACE("(%p,%p)\n", This, ppidl); - - *ppidl = ILClone(This->pidl); - if (*ppidl) - return S_OK; - else - return E_OUTOFMEMORY; -} - -static const IPersistIDListVtbl ShellItem_IPersistIDList_Vtbl = { - ShellItem_IPersistIDList_QueryInterface, - ShellItem_IPersistIDList_AddRef, - ShellItem_IPersistIDList_Release, - ShellItem_IPersistIDList_GetClassID, - ShellItem_IPersistIDList_SetIDList, - ShellItem_IPersistIDList_GetIDList -}; - - -HRESULT WINAPI IShellItem_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv) -{ - ShellItem *This; - HRESULT ret; - - TRACE("(%p,%s)\n",pUnkOuter, debugstr_guid(riid)); - - *ppv = NULL; - - if (pUnkOuter) return CLASS_E_NOAGGREGATION; - - This = HeapAlloc(GetProcessHeap(), 0, sizeof(ShellItem)); - This->lpIShellItemVtbl = &ShellItem_Vtbl; - This->ref = 1; - This->pidl = NULL; - This->lpIPersistIDListVtbl = &ShellItem_IPersistIDList_Vtbl; - - ret = ShellItem_QueryInterface((IShellItem*)This, riid, ppv); - ShellItem_Release((IShellItem*)This); - - return ret; -} - -HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent, - IShellFolder *psfParent, LPCITEMIDLIST pidl, IShellItem **ppsi) -{ - ShellItem *This; - LPITEMIDLIST new_pidl; - HRESULT ret; - - TRACE("(%p,%p,%p,%p)\n", pidlParent, psfParent, pidl, ppsi); - - if (!pidl) - { - return E_INVALIDARG; - } - else if (pidlParent || psfParent) - { - LPITEMIDLIST temp_parent=NULL; - if (!pidlParent) - { - IPersistFolder2* ppf2Parent; - - if (FAILED(IPersistFolder2_QueryInterface(psfParent, &IID_IPersistFolder2, (void**)&ppf2Parent))) - { - FIXME("couldn't get IPersistFolder2 interface of parent\n"); - return E_NOINTERFACE; - } - - if (FAILED(IPersistFolder2_GetCurFolder(ppf2Parent, &temp_parent))) - { - FIXME("couldn't get parent PIDL\n"); - IPersistFolder2_Release(ppf2Parent); - return E_NOINTERFACE; - } - - pidlParent = temp_parent; - IPersistFolder2_Release(ppf2Parent); - } - - new_pidl = ILCombine(pidlParent, pidl); - ILFree(temp_parent); - - if (!new_pidl) - return E_OUTOFMEMORY; - } - else - { - new_pidl = ILClone(pidl); - if (!new_pidl) - return E_OUTOFMEMORY; - } - - ret = IShellItem_Constructor(NULL, &IID_IShellItem, (void**)&This); - if (This) - { - *ppsi = (IShellItem*)This; - This->pidl = new_pidl; - } - else - { - *ppsi = NULL; - ILFree(new_pidl); - } - return ret; -} diff --git a/reactos/dll/win32/shell32/shelllink.c b/reactos/dll/win32/shell32/shelllink.c deleted file mode 100644 index 78c25c45ffc..00000000000 --- a/reactos/dll/win32/shell32/shelllink.c +++ /dev/null @@ -1,2989 +0,0 @@ -/* - * - * Copyright 1997 Marcus Meissner - * Copyright 1998 Juergen Schmied - * Copyright 2005 Mike McCormack - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - * - * NOTES - * Nearly complete information about the binary formats - * of .lnk files available at http://www.wotsit.org - * - * You can use winedump to examine the contents of a link file: - * winedump lnk sc.lnk - * - * MSI advertised shortcuts are totally undocumented. They provide an - * icon for a program that is not yet installed, and invoke MSI to - * install the program when the shortcut is clicked on. They are - * created by passing a special string to SetPath, and the information - * in that string is parsed an stored. - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -/* link file formats */ - -#include "pshpack1.h" - -typedef struct _LINK_HEADER -{ - DWORD dwSize; /* 0x00 size of the header - 0x4c */ - GUID MagicGuid; /* 0x04 is CLSID_ShellLink */ - DWORD dwFlags; /* 0x14 describes elements following */ - DWORD dwFileAttr; /* 0x18 attributes of the target file */ - FILETIME Time1; /* 0x1c */ - FILETIME Time2; /* 0x24 */ - FILETIME Time3; /* 0x2c */ - DWORD dwFileLength; /* 0x34 File length */ - DWORD nIcon; /* 0x38 icon number */ - DWORD fStartup; /* 0x3c startup type */ - DWORD wHotKey; /* 0x40 hotkey */ - DWORD Unknown5; /* 0x44 */ - DWORD Unknown6; /* 0x48 */ -} LINK_HEADER, * PLINK_HEADER; - -#define SHLINK_LOCAL 0 -#define SHLINK_REMOTE 1 -#define MAX_PROPERTY_SHEET_PAGE 32 - -typedef struct _LOCATION_INFO -{ - DWORD dwTotalSize; - DWORD dwHeaderSize; - DWORD dwFlags; - DWORD dwVolTableOfs; - DWORD dwLocalPathOfs; - DWORD dwNetworkVolTableOfs; - DWORD dwFinalPathOfs; -} LOCATION_INFO; - -typedef struct _LOCAL_VOLUME_INFO -{ - DWORD dwSize; - DWORD dwType; - DWORD dwVolSerial; - DWORD dwVolLabelOfs; -} LOCAL_VOLUME_INFO; - -typedef struct volume_info_t -{ - DWORD type; - DWORD serial; - WCHAR label[12]; /* assume 8.3 */ -} volume_info; - -#include "poppack.h" - -static const IShellLinkAVtbl slvt; -static const IShellLinkWVtbl slvtw; -static const IPersistFileVtbl pfvt; -static const IPersistStreamVtbl psvt; -static const IShellLinkDataListVtbl dlvt; -static const IShellExtInitVtbl eivt; -static const IContextMenuVtbl cmvt; -static const IObjectWithSiteVtbl owsvt; -static const IShellPropSheetExtVtbl pse; - -/* IShellLink Implementation */ - -typedef struct -{ - const IShellLinkAVtbl *lpVtbl; - const IShellLinkWVtbl *lpvtblw; - const IPersistFileVtbl *lpvtblPersistFile; - const IPersistStreamVtbl *lpvtblPersistStream; - const IShellLinkDataListVtbl *lpvtblShellLinkDataList; - const IShellExtInitVtbl *lpvtblShellExtInit; - const IContextMenuVtbl *lpvtblContextMenu; - const IObjectWithSiteVtbl *lpvtblObjectWithSite; - const IShellPropSheetExtVtbl * lpvtblPropSheetExt; - - LONG ref; - - /* data structures according to the information in the link */ - LPITEMIDLIST pPidl; - WORD wHotKey; - SYSTEMTIME time1; - SYSTEMTIME time2; - SYSTEMTIME time3; - - DWORD iShowCmd; - LPWSTR sIcoPath; - INT iIcoNdx; - LPWSTR sPath; - LPWSTR sArgs; - LPWSTR sWorkDir; - LPWSTR sDescription; - LPWSTR sPathRel; - LPWSTR sProduct; - LPWSTR sComponent; - volume_info volume; - LPWSTR sLinkPath; - LPWSTR sCurFile; - BOOL bRunAs; - BOOL bDirty; - INT iIdOpen; /* id of the "Open" entry in the context menu */ - IUnknown *site; -} IShellLinkImpl, *LPIShellLinkImpl; - -static LPIShellLinkImpl __inline impl_from_IShellLinkW( IShellLinkW *iface ) -{ - return (IShellLinkImpl *)((char*)iface - FIELD_OFFSET(IShellLinkImpl, lpvtblw)); -} - -static LPIShellLinkImpl __inline impl_from_IPersistFile( IPersistFile *iface ) -{ - return (IShellLinkImpl *)((char*)iface - FIELD_OFFSET(IShellLinkImpl, lpvtblPersistFile)); -} - -static LPIShellLinkImpl __inline impl_from_IPersistStream( IPersistStream *iface ) -{ - return (IShellLinkImpl *)((char*)iface - FIELD_OFFSET(IShellLinkImpl, lpvtblPersistStream)); -} - -static LPIShellLinkImpl __inline impl_from_IShellLinkDataList( IShellLinkDataList *iface ) -{ - return (IShellLinkImpl *)((char*)iface - FIELD_OFFSET(IShellLinkImpl, lpvtblShellLinkDataList)); -} - -static LPIShellLinkImpl __inline impl_from_IShellExtInit( IShellExtInit *iface ) -{ - return (IShellLinkImpl *)((char*)iface - FIELD_OFFSET(IShellLinkImpl, lpvtblShellExtInit)); -} - -static LPIShellLinkImpl __inline impl_from_IContextMenu( IContextMenu *iface ) -{ - return (IShellLinkImpl *)((char*)iface - FIELD_OFFSET(IShellLinkImpl, lpvtblContextMenu)); -} - -static LPIShellLinkImpl __inline impl_from_IObjectWithSite( IObjectWithSite *iface ) -{ - return (IShellLinkImpl *)((char*)iface - FIELD_OFFSET(IShellLinkImpl, lpvtblObjectWithSite)); -} - -static LPIShellLinkImpl __inline impl_from_IShellPropSheetExt( IShellPropSheetExt *iface ) -{ - return (IShellLinkImpl *)((char*)iface - FIELD_OFFSET(IShellLinkImpl, lpvtblPropSheetExt)); -} - - -static HRESULT ShellLink_UpdatePath(LPCWSTR sPathRel, LPCWSTR path, LPCWSTR sWorkDir, LPWSTR* psPath); - -/* strdup on the process heap */ -static LPWSTR __inline HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str) -{ - INT len; - LPWSTR p; - - assert(str); - - len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); - p = HeapAlloc( heap, flags, len*sizeof (WCHAR) ); - if( !p ) - return p; - MultiByteToWideChar( CP_ACP, 0, str, -1, p, len ); - return p; -} - -static LPWSTR __inline strdupW( LPCWSTR src ) -{ - LPWSTR dest; - if (!src) return NULL; - dest = HeapAlloc( GetProcessHeap(), 0, (wcslen(src)+1)*sizeof(WCHAR) ); - if (dest) - wcscpy(dest, src); - return dest; -} - -/************************************************************************** - * ShellLink::QueryInterface implementation - */ -static HRESULT ShellLink_QueryInterface( IShellLinkImpl *This, REFIID riid, LPVOID *ppvObj) -{ - TRACE("(%p)->(\n\tIID:\t%s)\n",This,debugstr_guid(riid)); - - *ppvObj = NULL; - - if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IShellLinkA)) - { - *ppvObj = This; - } - else if(IsEqualIID(riid, &IID_IShellLinkW)) - { - *ppvObj = &(This->lpvtblw); - } - else if(IsEqualIID(riid, &IID_IPersistFile)) - { - *ppvObj = &(This->lpvtblPersistFile); - } - else if(IsEqualIID(riid, &IID_IPersistStream)) - { - *ppvObj = &(This->lpvtblPersistStream); - } - else if(IsEqualIID(riid, &IID_IShellLinkDataList)) - { - *ppvObj = &(This->lpvtblShellLinkDataList); - } - else if(IsEqualIID(riid, &IID_IShellExtInit)) - { - *ppvObj = &(This->lpvtblShellExtInit); - } - else if(IsEqualIID(riid, &IID_IContextMenu)) - { - *ppvObj = &(This->lpvtblContextMenu); - } - else if(IsEqualIID(riid, &IID_IObjectWithSite)) - { - *ppvObj = &(This->lpvtblObjectWithSite); - } - else if(IsEqualIID(riid, &IID_IShellPropSheetExt)) - { - *ppvObj = &(This->lpvtblPropSheetExt); - } - - if(*ppvObj) - { - IUnknown_AddRef((IUnknown*)(*ppvObj)); - TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj); - return S_OK; - } - ERR("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -/************************************************************************** - * ShellLink::AddRef implementation - */ -static ULONG ShellLink_AddRef( IShellLinkImpl *This ) -{ - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE("(%p)->(count=%u)\n", This, refCount - 1); - - return refCount; -} - -/************************************************************************** - * ShellLink::Release implementation - */ -static ULONG ShellLink_Release( IShellLinkImpl *This ) -{ - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(count=%u)\n", This, refCount + 1); - - if (refCount) - return refCount; - - TRACE("-- destroying IShellLink(%p)\n",This); - - HeapFree(GetProcessHeap(), 0, This->sIcoPath); - HeapFree(GetProcessHeap(), 0, This->sArgs); - HeapFree(GetProcessHeap(), 0, This->sWorkDir); - HeapFree(GetProcessHeap(), 0, This->sDescription); - HeapFree(GetProcessHeap(),0,This->sPath); - HeapFree(GetProcessHeap(),0,This->sLinkPath); - - if (This->site) - IUnknown_Release( This->site ); - - if (This->pPidl) - ILFree(This->pPidl); - - LocalFree(This); - - return 0; -} - -static HRESULT ShellLink_GetClassID( IShellLinkImpl *This, CLSID *pclsid ) -{ - TRACE("%p %p\n", This, pclsid); - - *pclsid = CLSID_ShellLink; - return S_OK; -} - -/************************************************************************** - * IPersistFile_QueryInterface - */ -static HRESULT WINAPI IPersistFile_fnQueryInterface( - IPersistFile* iface, - REFIID riid, - LPVOID *ppvObj) -{ - IShellLinkImpl *This = impl_from_IPersistFile(iface); - return ShellLink_QueryInterface( This, riid, ppvObj ); -} - -/****************************************************************************** - * IPersistFile_AddRef - */ -static ULONG WINAPI IPersistFile_fnAddRef(IPersistFile* iface) -{ - IShellLinkImpl *This = impl_from_IPersistFile(iface); - return ShellLink_AddRef( This ); -} - -/****************************************************************************** - * IPersistFile_Release - */ -static ULONG WINAPI IPersistFile_fnRelease(IPersistFile* iface) -{ - IShellLinkImpl *This = impl_from_IPersistFile(iface); - return IShellLinkA_Release((IShellLinkA*)This); -} - -static HRESULT WINAPI IPersistFile_fnGetClassID(IPersistFile* iface, CLSID *pClassID) -{ - IShellLinkImpl *This = impl_from_IPersistFile(iface); - return ShellLink_GetClassID( This, pClassID ); -} - -static HRESULT WINAPI IPersistFile_fnIsDirty(IPersistFile* iface) -{ - IShellLinkImpl *This = impl_from_IPersistFile(iface); - - TRACE("(%p)\n",This); - - if (This->bDirty) - return S_OK; - - return S_FALSE; -} - -static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode) -{ - IShellLinkImpl *This = impl_from_IPersistFile(iface); - IPersistStream *StreamThis = (IPersistStream *)&This->lpvtblPersistStream; - HRESULT r; - IStream *stm; - - TRACE("(%p, %s, %x)\n",This, debugstr_w(pszFileName), dwMode); - - if( dwMode == 0 ) - dwMode = STGM_READ | STGM_SHARE_DENY_WRITE; - r = SHCreateStreamOnFileW(pszFileName, dwMode, &stm); - if( SUCCEEDED( r ) ) - { - HeapFree(GetProcessHeap(), 0, This->sLinkPath); - This->sLinkPath = strdupW(pszFileName); - r = IPersistStream_Load(StreamThis, stm); - ShellLink_UpdatePath(This->sPathRel, pszFileName, This->sWorkDir, &This->sPath); - IStream_Release( stm ); - This->bDirty = FALSE; - } - TRACE("-- returning hr %08x\n", r); - return r; -} - -static BOOL StartLinkProcessor( LPCOLESTR szLink ) -{ - static const WCHAR szFormat[] = { - 'w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e', - ' ','-','w',' ','"','%','s','"',0 }; - LONG len; - LPWSTR buffer; - STARTUPINFOW si; - PROCESS_INFORMATION pi; - BOOL ret; - - len = sizeof(szFormat) + wcslen( szLink ) * sizeof(WCHAR); - buffer = HeapAlloc( GetProcessHeap(), 0, len ); - if( !buffer ) - return FALSE; - - swprintf( buffer, szFormat, szLink ); - - TRACE("starting %s\n",debugstr_w(buffer)); - - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); - - ret = CreateProcessW( NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ); - - HeapFree( GetProcessHeap(), 0, buffer ); - - if (ret) - { - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); - } - - return ret; -} - -static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFileName, BOOL fRemember) -{ - IShellLinkImpl *This = impl_from_IPersistFile(iface); - IPersistStream *StreamThis = (IPersistStream *)&This->lpvtblPersistStream; - HRESULT r; - IStream *stm; - - TRACE("(%p)->(%s)\n",This,debugstr_w(pszFileName)); - - if (!pszFileName) - return E_FAIL; - - r = SHCreateStreamOnFileW( pszFileName, STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE, &stm ); - if( SUCCEEDED( r ) ) - { - r = IPersistStream_Save(StreamThis, stm, FALSE); - IStream_Release( stm ); - - if( SUCCEEDED( r ) ) - { - if ( This->sLinkPath ) - { - HeapFree(GetProcessHeap(), 0, This->sLinkPath); - } - This->sLinkPath = HeapAlloc(GetProcessHeap(), 0, (wcslen(pszFileName)+1) * sizeof(WCHAR)); - if ( This->sLinkPath ) - { - wcscpy(This->sLinkPath, pszFileName); - } - - StartLinkProcessor( pszFileName ); - - This->bDirty = FALSE; - } - else - { - DeleteFileW( pszFileName ); - WARN("Failed to create shortcut %s\n", debugstr_w(pszFileName) ); - } - } - - return r; -} - -static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile* iface, LPCOLESTR pszFileName) -{ - IShellLinkImpl *This = impl_from_IPersistFile(iface); - FIXME("(%p)->(%s)\n",This,debugstr_w(pszFileName)); - return NOERROR; -} - -static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile* iface, LPOLESTR *ppszFileName) -{ - IShellLinkImpl *This = impl_from_IPersistFile(iface); - - *ppszFileName = NULL; - - if ( !This->sLinkPath) - { - /* IPersistFile::GetCurFile called before IPersistFile::Save */ - return S_FALSE; - } - - *ppszFileName = CoTaskMemAlloc((wcslen(This->sLinkPath)+1) * sizeof(WCHAR)); - if (!*ppszFileName) - { - /* out of memory */ - return E_OUTOFMEMORY; - } - - /* copy last saved filename */ - wcscpy(*ppszFileName, This->sLinkPath); - - return NOERROR; -} - -static const IPersistFileVtbl pfvt = -{ - IPersistFile_fnQueryInterface, - IPersistFile_fnAddRef, - IPersistFile_fnRelease, - IPersistFile_fnGetClassID, - IPersistFile_fnIsDirty, - IPersistFile_fnLoad, - IPersistFile_fnSave, - IPersistFile_fnSaveCompleted, - IPersistFile_fnGetCurFile -}; - -/************************************************************************ - * IPersistStream_QueryInterface - */ -static HRESULT WINAPI IPersistStream_fnQueryInterface( - IPersistStream* iface, - REFIID riid, - VOID** ppvObj) -{ - IShellLinkImpl *This = impl_from_IPersistStream(iface); - return ShellLink_QueryInterface( This, riid, ppvObj ); -} - -/************************************************************************ - * IPersistStream_Release - */ -static ULONG WINAPI IPersistStream_fnRelease( - IPersistStream* iface) -{ - IShellLinkImpl *This = impl_from_IPersistStream(iface); - return IShellLinkA_Release((IShellLinkA*)This); -} - -/************************************************************************ - * IPersistStream_AddRef - */ -static ULONG WINAPI IPersistStream_fnAddRef( - IPersistStream* iface) -{ - IShellLinkImpl *This = impl_from_IPersistStream(iface); - return ShellLink_AddRef( This ); -} - -/************************************************************************ - * IPersistStream_GetClassID - * - */ -static HRESULT WINAPI IPersistStream_fnGetClassID( - IPersistStream* iface, - CLSID* pClassID) -{ - IShellLinkImpl *This = impl_from_IPersistStream(iface); - return ShellLink_GetClassID( This, pClassID ); -} - -/************************************************************************ - * IPersistStream_IsDirty (IPersistStream) - */ -static HRESULT WINAPI IPersistStream_fnIsDirty( - IPersistStream* iface) -{ - IShellLinkImpl *This = impl_from_IPersistStream(iface); - - TRACE("(%p)\n", This); - - return S_OK; -} - - -static HRESULT Stream_LoadString( IStream* stm, BOOL unicode, LPWSTR *pstr ) -{ - DWORD count; - USHORT len; - LPVOID temp; - LPWSTR str; - HRESULT r; - - TRACE("%p\n", stm); - - count = 0; - r = IStream_Read(stm, &len, sizeof(len), &count); - if ( FAILED (r) || ( count != sizeof(len) ) ) - return E_FAIL; - - if( unicode ) - len *= sizeof (WCHAR); - - TRACE("reading %d\n", len); - temp = HeapAlloc(GetProcessHeap(), 0, len+sizeof(WCHAR)); - if( !temp ) - return E_OUTOFMEMORY; - count = 0; - r = IStream_Read(stm, temp, len, &count); - if( FAILED (r) || ( count != len ) ) - { - HeapFree( GetProcessHeap(), 0, temp ); - return E_FAIL; - } - - TRACE("read %s\n", debugstr_an(temp,len)); - - /* convert to unicode if necessary */ - if( !unicode ) - { - count = MultiByteToWideChar( CP_ACP, 0, temp, len, NULL, 0 ); - str = HeapAlloc( GetProcessHeap(), 0, (count+1)*sizeof (WCHAR) ); - if( !str ) - { - HeapFree( GetProcessHeap(), 0, temp ); - return E_OUTOFMEMORY; - } - MultiByteToWideChar( CP_ACP, 0, temp, len, str, count ); - HeapFree( GetProcessHeap(), 0, temp ); - } - else - { - count /= 2; - str = temp; - } - str[count] = 0; - - *pstr = str; - - return S_OK; -} - -static HRESULT Stream_ReadChunk( IStream* stm, LPVOID *data ) -{ - DWORD size; - ULONG count; - HRESULT r; - struct sized_chunk { - DWORD size; - unsigned char data[1]; - } *chunk; - - TRACE("%p\n",stm); - - r = IStream_Read( stm, &size, sizeof(size), &count ); - if( FAILED( r ) || count != sizeof(size) ) - return E_FAIL; - - chunk = HeapAlloc( GetProcessHeap(), 0, size ); - if( !chunk ) - return E_OUTOFMEMORY; - - chunk->size = size; - r = IStream_Read( stm, chunk->data, size - sizeof(size), &count ); - if( FAILED( r ) || count != (size - sizeof(size)) ) - { - HeapFree( GetProcessHeap(), 0, chunk ); - return E_FAIL; - } - - TRACE("Read %d bytes\n",chunk->size); - - *data = chunk; - - return S_OK; -} - -static BOOL Stream_LoadVolume( LOCAL_VOLUME_INFO *vol, volume_info *volume ) -{ - const int label_sz = sizeof volume->label/sizeof volume->label[0]; - LPSTR label; - int len; - - volume->serial = vol->dwVolSerial; - volume->type = vol->dwType; - - if( !vol->dwVolLabelOfs ) - return FALSE; - if( vol->dwSize <= vol->dwVolLabelOfs ) - return FALSE; - len = vol->dwSize - vol->dwVolLabelOfs; - - label = (LPSTR) vol; - label += vol->dwVolLabelOfs; - MultiByteToWideChar( CP_ACP, 0, label, len, volume->label, label_sz-1); - - return TRUE; -} - -static LPWSTR Stream_LoadPath( LPCSTR p, DWORD maxlen ) -{ - int len = 0, wlen; - LPWSTR path; - - while( p[len] && (len < maxlen) ) - len++; - - wlen = MultiByteToWideChar(CP_ACP, 0, p, len, NULL, 0); - path = HeapAlloc(GetProcessHeap(), 0, (wlen+1)*sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, p, len, path, wlen); - path[wlen] = 0; - - return path; -} - -static HRESULT Stream_LoadLocation( IStream *stm, - volume_info *volume, LPWSTR *path ) -{ - char *p = NULL; - LOCATION_INFO *loc; - HRESULT r; - DWORD n; - - r = Stream_ReadChunk( stm, (LPVOID*) &p ); - if( FAILED(r) ) - return r; - - loc = (LOCATION_INFO*) p; - if (loc->dwTotalSize < sizeof(LOCATION_INFO)) - { - HeapFree( GetProcessHeap(), 0, p ); - return E_FAIL; - } - - /* if there's valid local volume information, load it */ - if( loc->dwVolTableOfs && - ((loc->dwVolTableOfs + sizeof(LOCAL_VOLUME_INFO)) <= loc->dwTotalSize) ) - { - LOCAL_VOLUME_INFO *volume_info; - - volume_info = (LOCAL_VOLUME_INFO*) &p[loc->dwVolTableOfs]; - Stream_LoadVolume( volume_info, volume ); - } - - /* if there's a local path, load it */ - n = loc->dwLocalPathOfs; - if( n && (n < loc->dwTotalSize) ) - *path = Stream_LoadPath( &p[n], loc->dwTotalSize - n ); - - TRACE("type %d serial %08x name %s path %s\n", volume->type, - volume->serial, debugstr_w(volume->label), debugstr_w(*path)); - - HeapFree( GetProcessHeap(), 0, p ); - return S_OK; -} - -/* - * The format of the advertised shortcut info seems to be: - * - * Offset Description - * ------ ----------- - * - * 0 Length of the block (4 bytes, usually 0x314) - * 4 tag (dword) - * 8 string data in ASCII - * 8+0x104 string data in UNICODE - * - * In the original Win32 implementation the buffers are not initialized - * to zero, so data trailing the string is random garbage. - */ -static HRESULT Stream_LoadAdvertiseInfo( IStream* stm, LPWSTR *str ) -{ - DWORD size; - ULONG count; - HRESULT r; - EXP_DARWIN_LINK buffer; - - TRACE("%p\n",stm); - - r = IStream_Read( stm, &buffer.dbh.cbSize, sizeof (DWORD), &count ); - if( FAILED( r ) ) - return r; - - /* make sure that we read the size of the structure even on error */ - size = sizeof buffer - sizeof (DWORD); - if( buffer.dbh.cbSize != sizeof buffer ) - { - ERR("Ooops. This structure is not as expected...\n"); - return E_FAIL; - } - - r = IStream_Read( stm, &buffer.dbh.dwSignature, size, &count ); - if( FAILED( r ) ) - return r; - - if( count != size ) - return E_FAIL; - - TRACE("magic %08x string = %s\n", buffer.dbh.dwSignature, debugstr_w(buffer.szwDarwinID)); - - if( (buffer.dbh.dwSignature&0xffff0000) != 0xa0000000 ) - { - ERR("Unknown magic number %08x in advertised shortcut\n", buffer.dbh.dwSignature); - return E_FAIL; - } - - *str = HeapAlloc( GetProcessHeap(), 0, - (wcslen(buffer.szwDarwinID)+1) * sizeof(WCHAR) ); - wcscpy( *str, buffer.szwDarwinID ); - - return S_OK; -} - -/************************************************************************ - * IPersistStream_Load (IPersistStream) - */ -static HRESULT WINAPI IPersistStream_fnLoad( - IPersistStream* iface, - IStream* stm) -{ - LINK_HEADER hdr; - ULONG dwBytesRead; - BOOL unicode; - HRESULT r; - DWORD zero; - - IShellLinkImpl *This = impl_from_IPersistStream(iface); - - TRACE("%p %p\n", This, stm); - - if( !stm ) - return STG_E_INVALIDPOINTER; - - dwBytesRead = 0; - r = IStream_Read(stm, &hdr, sizeof(hdr), &dwBytesRead); - if( FAILED( r ) ) - return r; - - if( dwBytesRead != sizeof(hdr)) - return E_FAIL; - if( hdr.dwSize != sizeof(hdr)) - return E_FAIL; - if( !IsEqualIID(&hdr.MagicGuid, &CLSID_ShellLink) ) - return E_FAIL; - - /* free all the old stuff */ - ILFree(This->pPidl); - This->pPidl = NULL; - memset( &This->volume, 0, sizeof This->volume ); - HeapFree(GetProcessHeap(), 0, This->sPath); - This->sPath = NULL; - HeapFree(GetProcessHeap(), 0, This->sDescription); - This->sDescription = NULL; - HeapFree(GetProcessHeap(), 0, This->sPathRel); - This->sPathRel = NULL; - HeapFree(GetProcessHeap(), 0, This->sWorkDir); - This->sWorkDir = NULL; - HeapFree(GetProcessHeap(), 0, This->sArgs); - This->sArgs = NULL; - HeapFree(GetProcessHeap(), 0, This->sIcoPath); - This->sIcoPath = NULL; - HeapFree(GetProcessHeap(), 0, This->sProduct); - This->sProduct = NULL; - HeapFree(GetProcessHeap(), 0, This->sComponent); - This->sComponent = NULL; - - This->wHotKey = (WORD)hdr.wHotKey; - This->iIcoNdx = hdr.nIcon; - FileTimeToSystemTime (&hdr.Time1, &This->time1); - FileTimeToSystemTime (&hdr.Time2, &This->time2); - FileTimeToSystemTime (&hdr.Time3, &This->time3); - if (TRACE_ON(shell)) - { - WCHAR sTemp[MAX_PATH]; - GetDateFormatW(LOCALE_USER_DEFAULT,DATE_SHORTDATE, &This->time1, - NULL, sTemp, sizeof(sTemp)/sizeof(*sTemp)); - TRACE("-- time1: %s\n", debugstr_w(sTemp) ); - GetDateFormatW(LOCALE_USER_DEFAULT,DATE_SHORTDATE, &This->time2, - NULL, sTemp, sizeof(sTemp)/sizeof(*sTemp)); - TRACE("-- time2: %s\n", debugstr_w(sTemp) ); - GetDateFormatW(LOCALE_USER_DEFAULT,DATE_SHORTDATE, &This->time3, - NULL, sTemp, sizeof(sTemp)/sizeof(*sTemp)); - TRACE("-- time3: %s\n", debugstr_w(sTemp) ); - } - - /* load all the new stuff */ - if( hdr.dwFlags & SLDF_HAS_ID_LIST ) - { - r = ILLoadFromStream( stm, &This->pPidl ); - if( FAILED( r ) ) - return r; - } - pdump(This->pPidl); - - /* load the location information */ - if( hdr.dwFlags & SLDF_HAS_LINK_INFO ) - r = Stream_LoadLocation( stm, &This->volume, &This->sPath ); - if( FAILED( r ) ) - goto end; - - unicode = hdr.dwFlags & SLDF_UNICODE; - if( hdr.dwFlags & SLDF_HAS_NAME ) - { - r = Stream_LoadString( stm, unicode, &This->sDescription ); - TRACE("Description -> %s\n",debugstr_w(This->sDescription)); - } - if( FAILED( r ) ) - goto end; - - if( hdr.dwFlags & SLDF_HAS_RELPATH ) - { - r = Stream_LoadString( stm, unicode, &This->sPathRel ); - TRACE("Relative Path-> %s\n",debugstr_w(This->sPathRel)); - } - if( FAILED( r ) ) - goto end; - - if( hdr.dwFlags & SLDF_HAS_WORKINGDIR ) - { - r = Stream_LoadString( stm, unicode, &This->sWorkDir ); - TRACE("Working Dir -> %s\n",debugstr_w(This->sWorkDir)); - } - if( FAILED( r ) ) - goto end; - - if( hdr.dwFlags & SLDF_HAS_ARGS ) - { - r = Stream_LoadString( stm, unicode, &This->sArgs ); - TRACE("Working Dir -> %s\n",debugstr_w(This->sArgs)); - } - if( FAILED( r ) ) - goto end; - - if( hdr.dwFlags & SLDF_HAS_ICONLOCATION ) - { - r = Stream_LoadString( stm, unicode, &This->sIcoPath ); - TRACE("Icon file -> %s\n",debugstr_w(This->sIcoPath)); - } - if( FAILED( r ) ) - goto end; - -#if (NTDDI_VERSION < NTDDI_LONGHORN) - if( hdr.dwFlags & SLDF_HAS_LOGO3ID ) - { - r = Stream_LoadAdvertiseInfo( stm, &This->sProduct ); - TRACE("Product -> %s\n",debugstr_w(This->sProduct)); - } - if( FAILED( r ) ) - goto end; -#endif - - if( hdr.dwFlags & SLDF_HAS_DARWINID ) - { - r = Stream_LoadAdvertiseInfo( stm, &This->sComponent ); - TRACE("Component -> %s\n",debugstr_w(This->sComponent)); - } - if( hdr.dwFlags & SLDF_RUNAS_USER ) - { - This->bRunAs = TRUE; - } - else - { - This->bRunAs = FALSE; - } - - if( FAILED( r ) ) - goto end; - - r = IStream_Read(stm, &zero, sizeof zero, &dwBytesRead); - if( FAILED( r ) || zero || dwBytesRead != sizeof zero ) - ERR("Last word was not zero\n"); - - TRACE("OK\n"); - - pdump (This->pPidl); - - return S_OK; -end: - return r; -} - -/************************************************************************ - * Stream_WriteString - * - * Helper function for IPersistStream_Save. Writes a unicode string - * with terminating nul byte to a stream, preceded by the its length. - */ -static HRESULT Stream_WriteString( IStream* stm, LPCWSTR str ) -{ - USHORT len = wcslen( str ) + 1; - DWORD count; - HRESULT r; - - r = IStream_Write( stm, &len, sizeof(len), &count ); - if( FAILED( r ) ) - return r; - - len *= sizeof(WCHAR); - - r = IStream_Write( stm, str, len, &count ); - if( FAILED( r ) ) - return r; - - return S_OK; -} - -/************************************************************************ - * Stream_WriteLocationInfo - * - * Writes the location info to a stream - * - * FIXME: One day we might want to write the network volume information - * and the final path. - * Figure out how Windows deals with unicode paths here. - */ -static HRESULT Stream_WriteLocationInfo( IStream* stm, LPCWSTR path, - volume_info *volume ) -{ - DWORD total_size, path_size, volume_info_size, label_size, final_path_size; - LOCAL_VOLUME_INFO *vol; - LOCATION_INFO *loc; - LPSTR szLabel, szPath, szFinalPath; - ULONG count = 0; - HRESULT hr; - - TRACE("%p %s %p\n", stm, debugstr_w(path), volume); - - /* figure out the size of everything */ - label_size = WideCharToMultiByte( CP_ACP, 0, volume->label, -1, - NULL, 0, NULL, NULL ); - path_size = WideCharToMultiByte( CP_ACP, 0, path, -1, - NULL, 0, NULL, NULL ); - volume_info_size = sizeof *vol + label_size; - final_path_size = 1; - total_size = sizeof *loc + volume_info_size + path_size + final_path_size; - - /* create pointers to everything */ - loc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, total_size); - vol = (LOCAL_VOLUME_INFO*) &loc[1]; - szLabel = (LPSTR) &vol[1]; - szPath = &szLabel[label_size]; - szFinalPath = &szPath[path_size]; - - /* fill in the location information header */ - loc->dwTotalSize = total_size; - loc->dwHeaderSize = sizeof (*loc); - loc->dwFlags = 1; - loc->dwVolTableOfs = sizeof (*loc); - loc->dwLocalPathOfs = sizeof (*loc) + volume_info_size; - loc->dwNetworkVolTableOfs = 0; - loc->dwFinalPathOfs = sizeof (*loc) + volume_info_size + path_size; - - /* fill in the volume information */ - vol->dwSize = volume_info_size; - vol->dwType = volume->type; - vol->dwVolSerial = volume->serial; - vol->dwVolLabelOfs = sizeof (*vol); - - /* copy in the strings */ - WideCharToMultiByte( CP_ACP, 0, volume->label, -1, - szLabel, label_size, NULL, NULL ); - WideCharToMultiByte( CP_ACP, 0, path, -1, - szPath, path_size, NULL, NULL ); - szFinalPath[0] = 0; - - hr = IStream_Write( stm, loc, total_size, &count ); - HeapFree(GetProcessHeap(), 0, loc); - - return hr; -} - -static EXP_DARWIN_LINK* shelllink_build_darwinid( LPCWSTR string, DWORD magic ) -{ - EXP_DARWIN_LINK *buffer; - - buffer = LocalAlloc( LMEM_ZEROINIT, sizeof *buffer ); - buffer->dbh.cbSize = sizeof *buffer; - buffer->dbh.dwSignature = magic; - lstrcpynW( buffer->szwDarwinID, string, MAX_PATH ); - WideCharToMultiByte(CP_ACP, 0, string, -1, buffer->szDarwinID, MAX_PATH, NULL, NULL ); - - return buffer; -} - -static HRESULT Stream_WriteAdvertiseInfo( IStream* stm, LPCWSTR string, DWORD magic ) -{ - EXP_DARWIN_LINK *buffer; - ULONG count; - - TRACE("%p\n",stm); - - buffer = shelllink_build_darwinid( string, magic ); - - return IStream_Write( stm, buffer, buffer->dbh.cbSize, &count ); -} - -/************************************************************************ - * IPersistStream_Save (IPersistStream) - * - * FIXME: makes assumptions about byte order - */ -static HRESULT WINAPI IPersistStream_fnSave( - IPersistStream* iface, - IStream* stm, - BOOL fClearDirty) -{ - LINK_HEADER header; - ULONG count; - DWORD zero; - HRESULT r; - - IShellLinkImpl *This = impl_from_IPersistStream(iface); - - TRACE("%p %p %x\n", This, stm, fClearDirty); - - memset(&header, 0, sizeof(header)); - header.dwSize = sizeof(header); - header.fStartup = This->iShowCmd; - header.MagicGuid = CLSID_ShellLink; - - header.wHotKey = This->wHotKey; - header.nIcon = This->iIcoNdx; - header.dwFlags = SLDF_UNICODE; /* strings are in unicode */ - if( This->pPidl ) - header.dwFlags |= SLDF_HAS_ID_LIST; - if( This->sPath ) - header.dwFlags |= SLDF_HAS_LINK_INFO; - if( This->sDescription ) - header.dwFlags |= SLDF_HAS_NAME; - if( This->sWorkDir ) - header.dwFlags |= SLDF_HAS_WORKINGDIR; - if( This->sArgs ) - header.dwFlags |= SLDF_HAS_ARGS; - if( This->sIcoPath ) - header.dwFlags |= SLDF_HAS_ICONLOCATION; -#if (NTDDI_VERSION < NTDDI_LONGHORN) - if( This->sProduct ) - header.dwFlags |= SLDF_HAS_LOGO3ID; -#endif - if( This->sComponent ) - header.dwFlags |= SLDF_HAS_DARWINID; - if( This->bRunAs ) - header.dwFlags |= SLDF_RUNAS_USER; - - SystemTimeToFileTime ( &This->time1, &header.Time1 ); - SystemTimeToFileTime ( &This->time2, &header.Time2 ); - SystemTimeToFileTime ( &This->time3, &header.Time3 ); - - /* write the Shortcut header */ - r = IStream_Write( stm, &header, sizeof(header), &count ); - if( FAILED( r ) ) - { - ERR("Write failed at %d\n",__LINE__); - return r; - } - - TRACE("Writing pidl\n"); - - /* write the PIDL to the shortcut */ - if( This->pPidl ) - { - r = ILSaveToStream( stm, This->pPidl ); - if( FAILED( r ) ) - { - ERR("Failed to write PIDL at %d\n",__LINE__); - return r; - } - } - - if( This->sPath ) - Stream_WriteLocationInfo( stm, This->sPath, &This->volume ); - - if( This->sDescription ) - r = Stream_WriteString( stm, This->sDescription ); - - if( This->sPathRel ) - r = Stream_WriteString( stm, This->sPathRel ); - - if( This->sWorkDir ) - r = Stream_WriteString( stm, This->sWorkDir ); - - if( This->sArgs ) - r = Stream_WriteString( stm, This->sArgs ); - - if( This->sIcoPath ) - r = Stream_WriteString( stm, This->sIcoPath ); - - if( This->sProduct ) - r = Stream_WriteAdvertiseInfo( stm, This->sProduct, EXP_SZ_ICON_SIG ); - - if( This->sComponent ) - r = Stream_WriteAdvertiseInfo( stm, This->sComponent, EXP_DARWIN_ID_SIG ); - - /* the last field is a single zero dword */ - zero = 0; - r = IStream_Write( stm, &zero, sizeof zero, &count ); - - return S_OK; -} - -/************************************************************************ - * IPersistStream_GetSizeMax (IPersistStream) - */ -static HRESULT WINAPI IPersistStream_fnGetSizeMax( - IPersistStream* iface, - ULARGE_INTEGER* pcbSize) -{ - IShellLinkImpl *This = impl_from_IPersistStream(iface); - - TRACE("(%p)\n", This); - - return E_NOTIMPL; -} - -static const IPersistStreamVtbl psvt = -{ - IPersistStream_fnQueryInterface, - IPersistStream_fnAddRef, - IPersistStream_fnRelease, - IPersistStream_fnGetClassID, - IPersistStream_fnIsDirty, - IPersistStream_fnLoad, - IPersistStream_fnSave, - IPersistStream_fnGetSizeMax -}; - -/************************************************************************** - * IShellLink_Constructor - */ -HRESULT WINAPI IShellLink_Constructor( IUnknown *pUnkOuter, - REFIID riid, LPVOID *ppv ) -{ - IShellLinkImpl * sl; - HRESULT r; - - TRACE("unkOut=%p riid=%s\n",pUnkOuter, debugstr_guid(riid)); - - *ppv = NULL; - - if (pUnkOuter) - return CLASS_E_NOAGGREGATION; - sl = LocalAlloc(LMEM_ZEROINIT,sizeof(IShellLinkImpl)); - if (!sl) - return E_OUTOFMEMORY; - - sl->ref = 1; - sl->lpVtbl = &slvt; - sl->lpvtblw = &slvtw; - sl->lpvtblPersistFile = &pfvt; - sl->lpvtblPersistStream = &psvt; - sl->lpvtblShellLinkDataList = &dlvt; - sl->lpvtblShellExtInit = &eivt; - sl->lpvtblContextMenu = &cmvt; - sl->lpvtblObjectWithSite = &owsvt; - sl->lpvtblPropSheetExt = &pse; - sl->iShowCmd = SW_SHOWNORMAL; - sl->bDirty = FALSE; - sl->iIdOpen = -1; - sl->site = NULL; - sl->bRunAs = FALSE; - - TRACE("(%p)->()\n",sl); - - r = ShellLink_QueryInterface( sl, riid, ppv ); - ShellLink_Release( sl ); - return r; -} - - -static BOOL SHELL_ExistsFileW(LPCWSTR path) -{ - if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW(path)) - return FALSE; - return TRUE; -} - -/************************************************************************** - * ShellLink_UpdatePath - * update absolute path in sPath using relative path in sPathRel - */ -static HRESULT ShellLink_UpdatePath(LPCWSTR sPathRel, LPCWSTR path, LPCWSTR sWorkDir, LPWSTR* psPath) -{ - if (!path || !psPath) - return E_INVALIDARG; - - if (!*psPath && sPathRel) { - WCHAR buffer[2*MAX_PATH], abs_path[2*MAX_PATH]; - LPWSTR final = NULL; - - /* first try if [directory of link file] + [relative path] finds an existing file */ - - GetFullPathNameW( path, MAX_PATH*2, buffer, &final ); - if( !final ) - final = buffer; - wcscpy(final, sPathRel); - - *abs_path = '\0'; - - if (SHELL_ExistsFileW(buffer)) { - if (!GetFullPathNameW(buffer, MAX_PATH, abs_path, &final)) - wcscpy(abs_path, buffer); - } else { - /* try if [working directory] + [relative path] finds an existing file */ - if (sWorkDir) { - wcscpy(buffer, sWorkDir); - wcscpy(PathAddBackslashW(buffer), sPathRel); - - if (SHELL_ExistsFileW(buffer)) - if (!GetFullPathNameW(buffer, MAX_PATH, abs_path, &final)) - wcscpy(abs_path, buffer); - } - } - - /* FIXME: This is even not enough - not all shell links can be resolved using this algorithm. */ - if (!*abs_path) - wcscpy(abs_path, sPathRel); - - *psPath = HeapAlloc(GetProcessHeap(), 0, (wcslen(abs_path)+1)*sizeof(WCHAR)); - if (!*psPath) - return E_OUTOFMEMORY; - - wcscpy(*psPath, abs_path); - } - - return S_OK; -} - -/************************************************************************** - * IShellLink_ConstructFromFile - */ -HRESULT WINAPI IShellLink_ConstructFromFile( IUnknown* pUnkOuter, REFIID riid, - LPCITEMIDLIST pidl, LPVOID* ppv) -{ - IShellLinkW* psl; - - HRESULT hr = IShellLink_Constructor(NULL, riid, (LPVOID*)&psl); - - if (SUCCEEDED(hr)) { - IPersistFile* ppf; - - *ppv = NULL; - - hr = IShellLinkW_QueryInterface(psl, &IID_IPersistFile, (LPVOID*)&ppf); - - if (SUCCEEDED(hr)) { - WCHAR path[MAX_PATH]; - - if (SHGetPathFromIDListW(pidl, path)) - hr = IPersistFile_Load(ppf, path, 0); - else - hr = E_FAIL; - - if (SUCCEEDED(hr)) - *ppv = psl; - - IPersistFile_Release(ppf); - } - - if (!*ppv) - IShellLinkW_Release(psl); - } - - return hr; -} - -/************************************************************************** - * IShellLinkA_QueryInterface - */ -static HRESULT WINAPI IShellLinkA_fnQueryInterface( IShellLinkA * iface, REFIID riid, LPVOID *ppvObj) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - return ShellLink_QueryInterface( This, riid, ppvObj ); -} - -/****************************************************************************** - * IShellLinkA_AddRef - */ -static ULONG WINAPI IShellLinkA_fnAddRef(IShellLinkA * iface) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - return ShellLink_AddRef( This ); -} - -/****************************************************************************** - * IShellLinkA_Release - */ -static ULONG WINAPI IShellLinkA_fnRelease(IShellLinkA * iface) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - return ShellLink_Release( This ); -} - -static HRESULT WINAPI IShellLinkA_fnGetPath(IShellLinkA * iface, LPSTR pszFile, - INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n", - This, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(This->sPath)); - - if (cchMaxPath) - pszFile[0] = 0; - if (This->sPath) - WideCharToMultiByte( CP_ACP, 0, This->sPath, -1, - pszFile, cchMaxPath, NULL, NULL); - - if (pfd) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", This); - - return S_OK; -} - -static HRESULT WINAPI IShellLinkA_fnGetIDList(IShellLinkA * iface, LPITEMIDLIST * ppidl) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(ppidl=%p)\n",This, ppidl); - - return IShellLinkW_GetIDList((IShellLinkW*)&(This->lpvtblw), ppidl); -} - -static HRESULT WINAPI IShellLinkA_fnSetIDList(IShellLinkA * iface, LPCITEMIDLIST pidl) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(pidl=%p)\n",This, pidl); - - if (This->pPidl) - ILFree(This->pPidl); - This->pPidl = ILClone (pidl); - This->bDirty = TRUE; - - return S_OK; -} - -static HRESULT WINAPI IShellLinkA_fnGetDescription(IShellLinkA * iface, LPSTR pszName,INT cchMaxName) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(%p len=%u)\n",This, pszName, cchMaxName); - - if( cchMaxName ) - pszName[0] = 0; - if( This->sDescription ) - WideCharToMultiByte( CP_ACP, 0, This->sDescription, -1, - pszName, cchMaxName, NULL, NULL); - - return S_OK; -} - -static HRESULT WINAPI IShellLinkA_fnSetDescription(IShellLinkA * iface, LPCSTR pszName) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(pName=%s)\n", This, pszName); - - HeapFree(GetProcessHeap(), 0, This->sDescription); - This->sDescription = NULL; - - if ( pszName ) { - This->sDescription = HEAP_strdupAtoW( GetProcessHeap(), 0, pszName); - if ( !This->sDescription ) - return E_OUTOFMEMORY; - } - This->bDirty = TRUE; - - return S_OK; -} - -static HRESULT WINAPI IShellLinkA_fnGetWorkingDirectory(IShellLinkA * iface, LPSTR pszDir,INT cchMaxPath) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(%p len=%u)\n", This, pszDir, cchMaxPath); - - if( cchMaxPath ) - pszDir[0] = 0; - if( This->sWorkDir ) - WideCharToMultiByte( CP_ACP, 0, This->sWorkDir, -1, - pszDir, cchMaxPath, NULL, NULL); - - return S_OK; -} - -static HRESULT WINAPI IShellLinkA_fnSetWorkingDirectory(IShellLinkA * iface, LPCSTR pszDir) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(dir=%s)\n",This, pszDir); - - HeapFree(GetProcessHeap(), 0, This->sWorkDir); - This->sWorkDir = NULL; - - if ( pszDir ) { - This->sWorkDir = HEAP_strdupAtoW( GetProcessHeap(), 0, pszDir); - if ( !This->sWorkDir ) - return E_OUTOFMEMORY; - } - This->bDirty = TRUE; - - return S_OK; -} - -static HRESULT WINAPI IShellLinkA_fnGetArguments(IShellLinkA * iface, LPSTR pszArgs,INT cchMaxPath) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(%p len=%u)\n", This, pszArgs, cchMaxPath); - - if( cchMaxPath ) - pszArgs[0] = 0; - if( This->sArgs ) - WideCharToMultiByte( CP_ACP, 0, This->sArgs, -1, - pszArgs, cchMaxPath, NULL, NULL); - - return S_OK; -} - -static HRESULT WINAPI IShellLinkA_fnSetArguments(IShellLinkA * iface, LPCSTR pszArgs) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(args=%s)\n",This, pszArgs); - - HeapFree(GetProcessHeap(), 0, This->sArgs); - This->sArgs = NULL; - - if ( pszArgs ) { - This->sArgs = HEAP_strdupAtoW( GetProcessHeap(), 0, pszArgs); - if( !This->sArgs ) - return E_OUTOFMEMORY; - } - - This->bDirty = TRUE; - - return S_OK; -} - -static HRESULT WINAPI IShellLinkA_fnGetHotkey(IShellLinkA * iface, WORD *pwHotkey) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(%p)(0x%08x)\n",This, pwHotkey, This->wHotKey); - - *pwHotkey = This->wHotKey; - - return S_OK; -} - -static HRESULT WINAPI IShellLinkA_fnSetHotkey(IShellLinkA * iface, WORD wHotkey) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(hotkey=%x)\n",This, wHotkey); - - This->wHotKey = wHotkey; - This->bDirty = TRUE; - - return S_OK; -} - -static HRESULT WINAPI IShellLinkA_fnGetShowCmd(IShellLinkA * iface, INT *piShowCmd) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(%p)\n",This, piShowCmd); - *piShowCmd = This->iShowCmd; - return S_OK; -} - -static HRESULT WINAPI IShellLinkA_fnSetShowCmd(IShellLinkA * iface, INT iShowCmd) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p) %d\n",This, iShowCmd); - - This->iShowCmd = iShowCmd; - This->bDirty = TRUE; - - return NOERROR; -} - -static HRESULT SHELL_PidlGeticonLocationA(IShellFolder* psf, LPCITEMIDLIST pidl, - LPSTR pszIconPath, int cchIconPath, int* piIcon) -{ - LPCITEMIDLIST pidlLast; - - HRESULT hr = SHBindToParent(pidl, &IID_IShellFolder, (LPVOID*)&psf, &pidlLast); - - if (SUCCEEDED(hr)) { - IExtractIconA* pei; - - hr = IShellFolder_GetUIObjectOf(psf, 0, 1, &pidlLast, &IID_IExtractIconA, NULL, (LPVOID*)&pei); - - if (SUCCEEDED(hr)) { - hr = IExtractIconA_GetIconLocation(pei, 0, pszIconPath, MAX_PATH, piIcon, NULL); - - IExtractIconA_Release(pei); - } - - IShellFolder_Release(psf); - } - - return hr; -} - -static HRESULT WINAPI IShellLinkA_fnGetIconLocation(IShellLinkA * iface, LPSTR pszIconPath,INT cchIconPath,INT *piIcon) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(%p len=%u iicon=%p)\n", This, pszIconPath, cchIconPath, piIcon); - - pszIconPath[0] = 0; - *piIcon = This->iIcoNdx; - - if (This->sIcoPath) - { - WideCharToMultiByte(CP_ACP, 0, This->sIcoPath, -1, pszIconPath, cchIconPath, NULL, NULL); - return S_OK; - } - - if (This->pPidl || This->sPath) - { - IShellFolder* pdsk; - - HRESULT hr = SHGetDesktopFolder(&pdsk); - - if (SUCCEEDED(hr)) - { - /* first look for an icon using the PIDL (if present) */ - if (This->pPidl) - hr = SHELL_PidlGeticonLocationA(pdsk, This->pPidl, pszIconPath, cchIconPath, piIcon); - else - hr = E_FAIL; - - /* if we couldn't find an icon yet, look for it using the file system path */ - if (FAILED(hr) && This->sPath) - { - LPITEMIDLIST pidl; - - hr = IShellFolder_ParseDisplayName(pdsk, 0, NULL, This->sPath, NULL, &pidl, NULL); - - if (SUCCEEDED(hr)) { - hr = SHELL_PidlGeticonLocationA(pdsk, pidl, pszIconPath, cchIconPath, piIcon); - - SHFree(pidl); - } - } - - IShellFolder_Release(pdsk); - } - - return hr; - } - return S_OK; -} - -static HRESULT WINAPI IShellLinkA_fnSetIconLocation(IShellLinkA * iface, LPCSTR pszIconPath,INT iIcon) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(path=%s iicon=%u)\n",This, pszIconPath, iIcon); - - HeapFree(GetProcessHeap(), 0, This->sIcoPath); - This->sIcoPath = NULL; - - if ( pszIconPath ) { - This->sIcoPath = HEAP_strdupAtoW(GetProcessHeap(), 0, pszIconPath); - if ( !This->sIcoPath ) - return E_OUTOFMEMORY; - } - - This->iIcoNdx = iIcon; - This->bDirty = TRUE; - - return S_OK; -} - -static HRESULT WINAPI IShellLinkA_fnSetRelativePath(IShellLinkA * iface, LPCSTR pszPathRel, DWORD dwReserved) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(path=%s %x)\n",This, pszPathRel, dwReserved); - - HeapFree(GetProcessHeap(), 0, This->sPathRel); - This->sPathRel = NULL; - - if ( pszPathRel ) { - This->sPathRel = HEAP_strdupAtoW(GetProcessHeap(), 0, pszPathRel); - - if ( !This->sPathRel ) - return E_OUTOFMEMORY; - } - - This->bDirty = TRUE; - - return ShellLink_UpdatePath(This->sPathRel, This->sPath, This->sWorkDir, &This->sPath); -} - -static HRESULT WINAPI IShellLinkA_fnResolve(IShellLinkA * iface, HWND hwnd, DWORD fFlags) -{ - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(hwnd=%p flags=%x)\n",This, hwnd, fFlags); - - return IShellLinkW_Resolve( (IShellLinkW*)&(This->lpvtblw), hwnd, fFlags ); -} - -static HRESULT WINAPI IShellLinkA_fnSetPath(IShellLinkA * iface, LPCSTR pszFile) -{ - HRESULT r; - LPWSTR str; - IShellLinkImpl *This = (IShellLinkImpl *)iface; - - TRACE("(%p)->(path=%s)\n",This, pszFile); - - if (!pszFile) return E_INVALIDARG; - - str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszFile); - if( !str ) - return E_OUTOFMEMORY; - - r = IShellLinkW_SetPath((IShellLinkW*)&(This->lpvtblw), str); - HeapFree( GetProcessHeap(), 0, str ); - - return r; -} - -/************************************************************************** -* IShellLink Implementation -*/ - -static const IShellLinkAVtbl slvt = -{ - IShellLinkA_fnQueryInterface, - IShellLinkA_fnAddRef, - IShellLinkA_fnRelease, - IShellLinkA_fnGetPath, - IShellLinkA_fnGetIDList, - IShellLinkA_fnSetIDList, - IShellLinkA_fnGetDescription, - IShellLinkA_fnSetDescription, - IShellLinkA_fnGetWorkingDirectory, - IShellLinkA_fnSetWorkingDirectory, - IShellLinkA_fnGetArguments, - IShellLinkA_fnSetArguments, - IShellLinkA_fnGetHotkey, - IShellLinkA_fnSetHotkey, - IShellLinkA_fnGetShowCmd, - IShellLinkA_fnSetShowCmd, - IShellLinkA_fnGetIconLocation, - IShellLinkA_fnSetIconLocation, - IShellLinkA_fnSetRelativePath, - IShellLinkA_fnResolve, - IShellLinkA_fnSetPath -}; - - -/************************************************************************** - * IShellLinkW_fnQueryInterface - */ -static HRESULT WINAPI IShellLinkW_fnQueryInterface( - IShellLinkW * iface, REFIID riid, LPVOID *ppvObj) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - return ShellLink_QueryInterface( This, riid, ppvObj ); -} - -/****************************************************************************** - * IShellLinkW_fnAddRef - */ -static ULONG WINAPI IShellLinkW_fnAddRef(IShellLinkW * iface) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - return ShellLink_AddRef( This ); -} - -/****************************************************************************** - * IShellLinkW_fnRelease - */ -static ULONG WINAPI IShellLinkW_fnRelease(IShellLinkW * iface) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - return ShellLink_Release( This ); -} - -static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAW *pfd, DWORD fFlags) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n", - This, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(This->sPath)); - - if (This->sComponent || This->sProduct) - return S_FALSE; - - if (cchMaxPath) - pszFile[0] = 0; - if (This->sPath) - lstrcpynW( pszFile, This->sPath, cchMaxPath ); - - if (pfd) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", This); - - return S_OK; -} - -static HRESULT WINAPI IShellLinkW_fnGetIDList(IShellLinkW * iface, LPITEMIDLIST * ppidl) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(ppidl=%p)\n",This, ppidl); - - if (!This->pPidl) - { - *ppidl = NULL; - return S_FALSE; - } - *ppidl = ILClone(This->pPidl); - return S_OK; -} - -static HRESULT WINAPI IShellLinkW_fnSetIDList(IShellLinkW * iface, LPCITEMIDLIST pidl) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(pidl=%p)\n",This, pidl); - - if( This->pPidl ) - ILFree( This->pPidl ); - This->pPidl = ILClone( pidl ); - if( !This->pPidl ) - return E_FAIL; - - This->bDirty = TRUE; - - return S_OK; -} - -static HRESULT WINAPI IShellLinkW_fnGetDescription(IShellLinkW * iface, LPWSTR pszName,INT cchMaxName) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(%p len=%u)\n",This, pszName, cchMaxName); - - pszName[0] = 0; - if( This->sDescription ) - lstrcpynW( pszName, This->sDescription, cchMaxName ); - - return S_OK; -} - -static HRESULT WINAPI IShellLinkW_fnSetDescription(IShellLinkW * iface, LPCWSTR pszName) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(desc=%s)\n",This, debugstr_w(pszName)); - - HeapFree(GetProcessHeap(), 0, This->sDescription); - This->sDescription = HeapAlloc( GetProcessHeap(), 0, - (wcslen( pszName )+1)*sizeof(WCHAR) ); - if ( !This->sDescription ) - return E_OUTOFMEMORY; - - wcscpy( This->sDescription, pszName ); - This->bDirty = TRUE; - - return S_OK; -} - -static HRESULT WINAPI IShellLinkW_fnGetWorkingDirectory(IShellLinkW * iface, LPWSTR pszDir,INT cchMaxPath) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(%p len %u)\n", This, pszDir, cchMaxPath); - - if( cchMaxPath ) - pszDir[0] = 0; - if( This->sWorkDir ) - lstrcpynW( pszDir, This->sWorkDir, cchMaxPath ); - - return S_OK; -} - -static HRESULT WINAPI IShellLinkW_fnSetWorkingDirectory(IShellLinkW * iface, LPCWSTR pszDir) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(dir=%s)\n",This, debugstr_w(pszDir)); - - HeapFree(GetProcessHeap(), 0, This->sWorkDir); - This->sWorkDir = HeapAlloc( GetProcessHeap(), 0, - (wcslen( pszDir )+1)*sizeof (WCHAR) ); - if ( !This->sWorkDir ) - return E_OUTOFMEMORY; - wcscpy( This->sWorkDir, pszDir ); - This->bDirty = TRUE; - - return S_OK; -} - -static HRESULT WINAPI IShellLinkW_fnGetArguments(IShellLinkW * iface, LPWSTR pszArgs,INT cchMaxPath) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(%p len=%u)\n", This, pszArgs, cchMaxPath); - - if( cchMaxPath ) - pszArgs[0] = 0; - if( This->sArgs ) - lstrcpynW( pszArgs, This->sArgs, cchMaxPath ); - - return NOERROR; -} - -static HRESULT WINAPI IShellLinkW_fnSetArguments(IShellLinkW * iface, LPCWSTR pszArgs) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(args=%s)\n",This, debugstr_w(pszArgs)); - - HeapFree(GetProcessHeap(), 0, This->sArgs); - This->sArgs = HeapAlloc( GetProcessHeap(), 0, - (wcslen( pszArgs )+1)*sizeof (WCHAR) ); - if ( !This->sArgs ) - return E_OUTOFMEMORY; - wcscpy( This->sArgs, pszArgs ); - This->bDirty = TRUE; - - return S_OK; -} - -static HRESULT WINAPI IShellLinkW_fnGetHotkey(IShellLinkW * iface, WORD *pwHotkey) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(%p)\n",This, pwHotkey); - - *pwHotkey=This->wHotKey; - - return S_OK; -} - -static HRESULT WINAPI IShellLinkW_fnSetHotkey(IShellLinkW * iface, WORD wHotkey) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(hotkey=%x)\n",This, wHotkey); - - This->wHotKey = wHotkey; - This->bDirty = TRUE; - - return S_OK; -} - -static HRESULT WINAPI IShellLinkW_fnGetShowCmd(IShellLinkW * iface, INT *piShowCmd) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(%p)\n",This, piShowCmd); - - *piShowCmd = This->iShowCmd; - - return S_OK; -} - -static HRESULT WINAPI IShellLinkW_fnSetShowCmd(IShellLinkW * iface, INT iShowCmd) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - This->iShowCmd = iShowCmd; - This->bDirty = TRUE; - - return S_OK; -} - -static HRESULT SHELL_PidlGeticonLocationW(IShellFolder* psf, LPCITEMIDLIST pidl, - LPWSTR pszIconPath, int cchIconPath, int* piIcon) -{ - LPCITEMIDLIST pidlLast; - UINT wFlags; - - HRESULT hr = SHBindToParent(pidl, &IID_IShellFolder, (LPVOID*)&psf, &pidlLast); - - if (SUCCEEDED(hr)) { - IExtractIconW* pei; - - hr = IShellFolder_GetUIObjectOf(psf, 0, 1, &pidlLast, &IID_IExtractIconW, NULL, (LPVOID*)&pei); - - if (SUCCEEDED(hr)) { - hr = IExtractIconW_GetIconLocation(pei, 0, pszIconPath, MAX_PATH, piIcon, &wFlags); - - IExtractIconW_Release(pei); - } - - IShellFolder_Release(psf); - } - - return hr; -} - -static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR pszIconPath,INT cchIconPath,INT *piIcon) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(%p len=%u iicon=%p)\n", This, pszIconPath, cchIconPath, piIcon); - - pszIconPath[0] = 0; - *piIcon = This->iIcoNdx; - - if (This->sIcoPath) - { - lstrcpynW(pszIconPath, This->sIcoPath, cchIconPath); - return S_OK; - } - - if (This->pPidl || This->sPath) - { - IShellFolder* pdsk; - - HRESULT hr = SHGetDesktopFolder(&pdsk); - - if (SUCCEEDED(hr)) - { - /* first look for an icon using the PIDL (if present) */ - if (This->pPidl) - hr = SHELL_PidlGeticonLocationW(pdsk, This->pPidl, pszIconPath, cchIconPath, piIcon); - else - hr = E_FAIL; - - /* if we couldn't find an icon yet, look for it using the file system path */ - if (FAILED(hr) && This->sPath) - { - LPITEMIDLIST pidl; - - hr = IShellFolder_ParseDisplayName(pdsk, 0, NULL, This->sPath, NULL, &pidl, NULL); - - if (SUCCEEDED(hr)) - { - hr = SHELL_PidlGeticonLocationW(pdsk, pidl, pszIconPath, cchIconPath, piIcon); - - SHFree(pidl); - } - } - - IShellFolder_Release(pdsk); - } - return hr; - } - return S_OK; -} - -static HRESULT WINAPI IShellLinkW_fnSetIconLocation(IShellLinkW * iface, LPCWSTR pszIconPath,INT iIcon) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(path=%s iicon=%u)\n",This, debugstr_w(pszIconPath), iIcon); - - HeapFree(GetProcessHeap(), 0, This->sIcoPath); - This->sIcoPath = HeapAlloc( GetProcessHeap(), 0, - (wcslen( pszIconPath )+1)*sizeof (WCHAR) ); - if ( !This->sIcoPath ) - return E_OUTOFMEMORY; - wcscpy( This->sIcoPath, pszIconPath ); - - This->iIcoNdx = iIcon; - This->bDirty = TRUE; - - return S_OK; -} - -static HRESULT WINAPI IShellLinkW_fnSetRelativePath(IShellLinkW * iface, LPCWSTR pszPathRel, DWORD dwReserved) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(path=%s %x)\n",This, debugstr_w(pszPathRel), dwReserved); - - HeapFree(GetProcessHeap(), 0, This->sPathRel); - This->sPathRel = HeapAlloc( GetProcessHeap(), 0, - (wcslen( pszPathRel )+1) * sizeof (WCHAR) ); - if ( !This->sPathRel ) - return E_OUTOFMEMORY; - wcscpy( This->sPathRel, pszPathRel ); - This->bDirty = TRUE; - - return ShellLink_UpdatePath(This->sPathRel, This->sPath, This->sWorkDir, &This->sPath); -} - -static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWORD fFlags) -{ - HRESULT hr = S_OK; - BOOL bSuccess; - - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - - TRACE("(%p)->(hwnd=%p flags=%x)\n",This, hwnd, fFlags); - - /*FIXME: use IResolveShellLink interface */ - - if (!This->sPath && This->pPidl) { - WCHAR buffer[MAX_PATH]; - - bSuccess = SHGetPathFromIDListW(This->pPidl, buffer); - - if (bSuccess && *buffer) { - This->sPath = HeapAlloc(GetProcessHeap(), 0, (wcslen(buffer)+1)*sizeof(WCHAR)); - if (!This->sPath) - return E_OUTOFMEMORY; - - wcscpy(This->sPath, buffer); - - This->bDirty = TRUE; - } else - hr = S_OK; /* don't report an error occurred while just caching information */ - } - - if (!This->sIcoPath && This->sPath) { - This->sIcoPath = HeapAlloc(GetProcessHeap(), 0, (wcslen(This->sPath)+1)*sizeof(WCHAR)); - if (!This->sIcoPath) - return E_OUTOFMEMORY; - - wcscpy(This->sIcoPath, This->sPath); - This->iIcoNdx = 0; - - This->bDirty = TRUE; - } - - return hr; -} - -static LPWSTR ShellLink_GetAdvertisedArg(LPCWSTR str) -{ - LPWSTR ret; - LPCWSTR p; - DWORD len; - - if( !str ) - return NULL; - - p = wcschr( str, ':' ); - if( !p ) - return NULL; - len = p - str; - ret = HeapAlloc( GetProcessHeap(), 0, sizeof(WCHAR)*(len+1)); - if( !ret ) - return ret; - memcpy( ret, str, sizeof(WCHAR)*len ); - ret[len] = 0; - return ret; -} - -static HRESULT ShellLink_SetAdvertiseInfo(IShellLinkImpl *This, LPCWSTR str) -{ - LPCWSTR szComponent = NULL, szProduct = NULL, p; - WCHAR szGuid[39]; - HRESULT r; - GUID guid; - int len; - - while( str[0] ) - { - /* each segment must start with two colons */ - if( str[0] != ':' || str[1] != ':' ) - return E_FAIL; - - /* the last segment is just two colons */ - if( !str[2] ) - break; - str += 2; - - /* there must be a colon straight after a guid */ - p = wcschr( str, ':' ); - if( !p ) - return E_FAIL; - len = p - str; - if( len != 38 ) - return E_FAIL; - - /* get the guid, and check it's validly formatted */ - memcpy( szGuid, str, sizeof(WCHAR)*len ); - szGuid[len] = 0; - r = CLSIDFromString( szGuid, &guid ); - if( r != S_OK ) - return r; - str = p + 1; - - /* match it up to a guid that we care about */ - if( IsEqualGUID( &guid, &SHELL32_AdvtShortcutComponent ) && !szComponent ) - szComponent = str; - else if( IsEqualGUID( &guid, &SHELL32_AdvtShortcutProduct ) && !szProduct ) - szProduct = str; - else - return E_FAIL; - - /* skip to the next field */ - str = wcschr( str, ':' ); - if( !str ) - return E_FAIL; - } - - /* we have to have a component for an advertised shortcut */ - if( !szComponent ) - return E_FAIL; - - This->sComponent = ShellLink_GetAdvertisedArg( szComponent ); - This->sProduct = ShellLink_GetAdvertisedArg( szProduct ); - - TRACE("Component = %s\n", debugstr_w(This->sComponent)); - TRACE("Product = %s\n", debugstr_w(This->sProduct)); - - return S_OK; -} - -static BOOL ShellLink_GetVolumeInfo(LPCWSTR path, volume_info *volume) -{ - const int label_sz = sizeof volume->label/sizeof volume->label[0]; - WCHAR drive[4] = { path[0], ':', '\\', 0 }; - BOOL r; - - volume->type = GetDriveTypeW(drive); - r = GetVolumeInformationW(drive, volume->label, label_sz, - &volume->serial, NULL, NULL, NULL, 0); - TRACE("r = %d type %d serial %08x name %s\n", r, - volume->type, volume->serial, debugstr_w(volume->label)); - return r; -} - -static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile) -{ - IShellLinkImpl *This = impl_from_IShellLinkW(iface); - WCHAR buffer[MAX_PATH]; - LPWSTR fname, unquoted = NULL; - HRESULT hr = S_OK; - UINT len; - - TRACE("(%p)->(path=%s)\n",This, debugstr_w(pszFile)); - - if (!pszFile) return E_INVALIDARG; - - /* quotes at the ends of the string are stripped */ - len = wcslen(pszFile); - if (pszFile[0] == '"' && pszFile[len-1] == '"') - { - unquoted = strdupW(pszFile); - PathUnquoteSpacesW(unquoted); - pszFile = unquoted; - } - - /* any other quote marks are invalid */ - if (wcschr(pszFile, '"')) - { - HeapFree(GetProcessHeap(), 0, unquoted); - return S_FALSE; - } - - HeapFree(GetProcessHeap(), 0, This->sPath); - This->sPath = NULL; - - HeapFree(GetProcessHeap(), 0, This->sComponent); - This->sComponent = NULL; - - if (This->pPidl) - ILFree(This->pPidl); - This->pPidl = NULL; - - if (S_OK != ShellLink_SetAdvertiseInfo( This, pszFile )) - { - if (*pszFile == '\0') - *buffer = '\0'; - else if (!GetFullPathNameW(pszFile, MAX_PATH, buffer, &fname)) - return E_FAIL; - else if(!PathFileExistsW(buffer) && - !SearchPathW(NULL, pszFile, NULL, MAX_PATH, buffer, NULL)) - hr = S_FALSE; - - This->pPidl = SHSimpleIDListFromPathW(pszFile); - ShellLink_GetVolumeInfo(buffer, &This->volume); - - This->sPath = HeapAlloc( GetProcessHeap(), 0, - (wcslen( buffer )+1) * sizeof (WCHAR) ); - if (!This->sPath) - return E_OUTOFMEMORY; - - wcscpy(This->sPath, buffer); - } - This->bDirty = TRUE; - HeapFree(GetProcessHeap(), 0, unquoted); - - return hr; -} - -/************************************************************************** -* IShellLinkW Implementation -*/ - -static const IShellLinkWVtbl slvtw = -{ - IShellLinkW_fnQueryInterface, - IShellLinkW_fnAddRef, - IShellLinkW_fnRelease, - IShellLinkW_fnGetPath, - IShellLinkW_fnGetIDList, - IShellLinkW_fnSetIDList, - IShellLinkW_fnGetDescription, - IShellLinkW_fnSetDescription, - IShellLinkW_fnGetWorkingDirectory, - IShellLinkW_fnSetWorkingDirectory, - IShellLinkW_fnGetArguments, - IShellLinkW_fnSetArguments, - IShellLinkW_fnGetHotkey, - IShellLinkW_fnSetHotkey, - IShellLinkW_fnGetShowCmd, - IShellLinkW_fnSetShowCmd, - IShellLinkW_fnGetIconLocation, - IShellLinkW_fnSetIconLocation, - IShellLinkW_fnSetRelativePath, - IShellLinkW_fnResolve, - IShellLinkW_fnSetPath -}; - -static HRESULT WINAPI -ShellLink_DataList_QueryInterface( IShellLinkDataList* iface, REFIID riid, void** ppvObject) -{ - IShellLinkImpl *This = impl_from_IShellLinkDataList(iface); - return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvObject); -} - -static ULONG WINAPI -ShellLink_DataList_AddRef( IShellLinkDataList* iface ) -{ - IShellLinkImpl *This = impl_from_IShellLinkDataList(iface); - return IShellLinkA_AddRef((IShellLinkA*)This); -} - -static ULONG WINAPI -ShellLink_DataList_Release( IShellLinkDataList* iface ) -{ - IShellLinkImpl *This = impl_from_IShellLinkDataList(iface); - return ShellLink_Release( This ); -} - -static HRESULT WINAPI -ShellLink_AddDataBlock( IShellLinkDataList* iface, void* pDataBlock ) -{ - FIXME("\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI -ShellLink_CopyDataBlock( IShellLinkDataList* iface, DWORD dwSig, void** ppDataBlock ) -{ - IShellLinkImpl *This = impl_from_IShellLinkDataList(iface); - LPVOID block = NULL; - HRESULT r = E_FAIL; - - TRACE("%p %08x %p\n", iface, dwSig, ppDataBlock ); - - switch (dwSig) - { - case EXP_DARWIN_ID_SIG: - if (!This->sComponent) - break; - block = shelllink_build_darwinid( This->sComponent, dwSig ); - r = S_OK; - break; - case EXP_SZ_LINK_SIG: - case NT_CONSOLE_PROPS_SIG: - case NT_FE_CONSOLE_PROPS_SIG: - case EXP_SPECIAL_FOLDER_SIG: - case EXP_SZ_ICON_SIG: - FIXME("valid but unhandled datablock %08x\n", dwSig); - break; - default: - ERR("unknown datablock %08x\n", dwSig); - } - *ppDataBlock = block; - return r; -} - -static HRESULT WINAPI -ShellLink_RemoveDataBlock( IShellLinkDataList* iface, DWORD dwSig ) -{ - FIXME("\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI -ShellLink_GetFlags( IShellLinkDataList* iface, DWORD* pdwFlags ) -{ - IShellLinkImpl *This = impl_from_IShellLinkDataList(iface); - DWORD flags = 0; - - FIXME("%p %p\n", This, pdwFlags ); - - /* FIXME: add more */ - if (This->sArgs) - flags |= SLDF_HAS_ARGS; - if (This->sComponent) - flags |= SLDF_HAS_DARWINID; - if (This->sIcoPath) - flags |= SLDF_HAS_ICONLOCATION; -#if (NTDDI_VERSION < NTDDI_LONGHORN) - if (This->sProduct) - flags |= SLDF_HAS_LOGO3ID; -#endif - if (This->pPidl) - flags |= SLDF_HAS_ID_LIST; - - *pdwFlags = flags; - - return S_OK; -} - -static HRESULT WINAPI -ShellLink_SetFlags( IShellLinkDataList* iface, DWORD dwFlags ) -{ - FIXME("\n"); - return E_NOTIMPL; -} - -static const IShellLinkDataListVtbl dlvt = -{ - ShellLink_DataList_QueryInterface, - ShellLink_DataList_AddRef, - ShellLink_DataList_Release, - ShellLink_AddDataBlock, - ShellLink_CopyDataBlock, - ShellLink_RemoveDataBlock, - ShellLink_GetFlags, - ShellLink_SetFlags -}; - -static HRESULT WINAPI -ShellLink_ExtInit_QueryInterface( IShellExtInit* iface, REFIID riid, void** ppvObject ) -{ - IShellLinkImpl *This = impl_from_IShellExtInit(iface); - return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvObject); -} - -static ULONG WINAPI -ShellLink_ExtInit_AddRef( IShellExtInit* iface ) -{ - IShellLinkImpl *This = impl_from_IShellExtInit(iface); - return IShellLinkA_AddRef((IShellLinkA*)This); -} - -static ULONG WINAPI -ShellLink_ExtInit_Release( IShellExtInit* iface ) -{ - IShellLinkImpl *This = impl_from_IShellExtInit(iface); - return ShellLink_Release( This ); -} - -/************************************************************************** - * ShellLink implementation of IShellExtInit::Initialize() - * - * Loads the shelllink from the dataobject the shell is pointing to. - */ -static HRESULT WINAPI -ShellLink_ExtInit_Initialize( IShellExtInit* iface, LPCITEMIDLIST pidlFolder, - IDataObject *pdtobj, HKEY hkeyProgID ) -{ - IShellLinkImpl *This = impl_from_IShellExtInit(iface); - FORMATETC format; - STGMEDIUM stgm; - UINT count; - HRESULT r = E_FAIL; - - TRACE("%p %p %p %p\n", This, pidlFolder, pdtobj, hkeyProgID ); - - if( !pdtobj ) - return r; - - format.cfFormat = CF_HDROP; - format.ptd = NULL; - format.dwAspect = DVASPECT_CONTENT; - format.lindex = -1; - format.tymed = TYMED_HGLOBAL; - - if( FAILED( IDataObject_GetData( pdtobj, &format, &stgm ) ) ) - return r; - - count = DragQueryFileW( stgm.u.hGlobal, -1, NULL, 0 ); - if( count == 1 ) - { - LPWSTR path; - - count = DragQueryFileW( stgm.u.hGlobal, 0, NULL, 0 ); - count++; - path = HeapAlloc( GetProcessHeap(), 0, count*sizeof(WCHAR) ); - if( path ) - { - IPersistFile *pf = (IPersistFile*) &This->lpvtblPersistFile; - - count = DragQueryFileW( stgm.u.hGlobal, 0, path, count ); - r = IPersistFile_Load( pf, path, 0 ); - HeapFree( GetProcessHeap(), 0, path ); - } - } - ReleaseStgMedium( &stgm ); - - return r; -} - -static const IShellExtInitVtbl eivt = -{ - ShellLink_ExtInit_QueryInterface, - ShellLink_ExtInit_AddRef, - ShellLink_ExtInit_Release, - ShellLink_ExtInit_Initialize -}; - -static HRESULT WINAPI -ShellLink_ContextMenu_QueryInterface( IContextMenu* iface, REFIID riid, void** ppvObject ) -{ - IShellLinkImpl *This = impl_from_IContextMenu(iface); - return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvObject); -} - -static ULONG WINAPI -ShellLink_ContextMenu_AddRef( IContextMenu* iface ) -{ - IShellLinkImpl *This = impl_from_IContextMenu(iface); - return IShellLinkA_AddRef((IShellLinkA*)This); -} - -static ULONG WINAPI -ShellLink_ContextMenu_Release( IContextMenu* iface ) -{ - IShellLinkImpl *This = impl_from_IContextMenu(iface); - return ShellLink_Release( This ); -} - -static HRESULT WINAPI -ShellLink_QueryContextMenu( IContextMenu* iface, HMENU hmenu, UINT indexMenu, - UINT idCmdFirst, UINT idCmdLast, UINT uFlags ) -{ - IShellLinkImpl *This = impl_from_IContextMenu(iface); - WCHAR szOpen[20]; - MENUITEMINFOW mii; - int id = 1; - - TRACE("%p %p %u %u %u %u\n", This, - hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags ); - - if ( !hmenu ) - return E_INVALIDARG; - - if (!LoadStringW(shell32_hInstance, IDS_OPEN_VERB, szOpen, sizeof(szOpen)/sizeof(WCHAR))) - szOpen[0] = L'\0'; - else - szOpen[(sizeof(szOpen)/sizeof(WCHAR))-1] = L'\0'; - - memset( &mii, 0, sizeof(mii) ); - mii.cbSize = sizeof (mii); - mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE; - mii.dwTypeData = (LPWSTR)szOpen; - mii.cch = wcslen( mii.dwTypeData ); - mii.wID = idCmdFirst + id++; - mii.fState = MFS_DEFAULT | MFS_ENABLED; - mii.fType = MFT_STRING; - if (!InsertMenuItemW( hmenu, indexMenu, TRUE, &mii )) - return E_FAIL; - This->iIdOpen = 1; - - return MAKE_HRESULT( SEVERITY_SUCCESS, 0, id ); -} - -static LPWSTR -shelllink_get_msi_component_path( LPWSTR component ) -{ - LPWSTR path; - DWORD r, sz = 0; - - r = CommandLineFromMsiDescriptor( component, NULL, &sz ); - if (r != ERROR_SUCCESS) - return NULL; - - sz++; - path = HeapAlloc( GetProcessHeap(), 0, sz*sizeof(WCHAR) ); - r = CommandLineFromMsiDescriptor( component, path, &sz ); - if (r != ERROR_SUCCESS) - { - HeapFree( GetProcessHeap(), 0, path ); - path = NULL; - } - - TRACE("returning %s\n", debugstr_w( path ) ); - - return path; -} - -INT_PTR CALLBACK ExtendedShortcutProc( - HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam -) -{ - HWND hDlgCtrl; - - switch(uMsg) - { - case WM_INITDIALOG: - if (lParam) - { - hDlgCtrl = GetDlgItem(hwndDlg, 14000); - SendMessage(hDlgCtrl, BM_SETCHECK, BST_CHECKED, 0); - } - return TRUE; - case WM_COMMAND: - hDlgCtrl = GetDlgItem(hwndDlg, 14000); - if (LOWORD(wParam) == IDOK) - { - if ( SendMessage(hDlgCtrl, BM_GETCHECK, 0, 0) == BST_CHECKED ) - EndDialog(hwndDlg, 1); - else - EndDialog(hwndDlg, 0); - } - else if (LOWORD(wParam) == IDCANCEL) - { - EndDialog(hwndDlg, -1); - } - else if (LOWORD(wParam) == 14000) - { - if ( SendMessage(hDlgCtrl, BM_GETCHECK, 0, 0) == BST_CHECKED) - SendMessage(hDlgCtrl, BM_SETCHECK, BST_UNCHECKED, 0); - else - SendMessage(hDlgCtrl, BM_SETCHECK, BST_CHECKED, 0); - - } - } - return FALSE; -} - -/************************************************************************** - * SH_ShellLinkDlgProc - * - * dialog proc of the shortcut property dialog - */ - -INT_PTR -CALLBACK -SH_ShellLinkDlgProc( - HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam -) -{ - LPPROPSHEETPAGEW ppsp; - LPPSHNOTIFY lppsn; - IShellLinkImpl *This; - HWND hDlgCtrl; - WCHAR szBuffer[MAX_PATH]; - WCHAR * ptr; - int IconIndex; - INT_PTR result; - - This = (IShellLinkImpl *)GetWindowLongPtr(hwndDlg, DWLP_USER); - - switch(uMsg) - { - case WM_INITDIALOG: - ppsp = (LPPROPSHEETPAGEW)lParam; - if (ppsp == NULL) - break; - - TRACE("ShellLink_DlgProc (WM_INITDIALOG hwnd %p lParam %p ppsplParam %x)\n",hwndDlg, lParam, ppsp->lParam); - - This = (IShellLinkImpl *)ppsp->lParam; - SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)This); - - TRACE("sArgs: %S sComponent: %S sDescription: %S sIcoPath: %S sPath: %S sPathRel: %S sProduct: %S sWorkDir: %S\n", This->sArgs, This->sComponent ,This->sDescription, - This->sIcoPath, This->sPath, This->sPathRel, This->sProduct, This->sWorkDir); - - /* target path */ - hDlgCtrl = GetDlgItem( hwndDlg, 14009 ); - if ( hDlgCtrl != NULL ) - SendMessageW( hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)This->sPath ); - - /* working dir */ - hDlgCtrl = GetDlgItem( hwndDlg, 14011 ); - if ( hDlgCtrl != NULL ) - SendMessageW( hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)This->sWorkDir ); - - /* description */ - hDlgCtrl = GetDlgItem( hwndDlg, 14019 ); - if ( hDlgCtrl != NULL ) - SendMessageW( hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)This->sDescription ); - return TRUE; - case WM_NOTIFY: - lppsn = (LPPSHNOTIFY) lParam; - if ( lppsn->hdr.code == PSN_APPLY ) - { - /* set working directory */ - hDlgCtrl = GetDlgItem( hwndDlg, 14011 ); - SendMessageW( hDlgCtrl, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)szBuffer ); - IShellLinkW_fnSetWorkingDirectory((IShellLinkW*)&This->lpvtblw, szBuffer); - /* set link destination */ - hDlgCtrl = GetDlgItem( hwndDlg, 14009 ); - SendMessageW( hDlgCtrl, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)szBuffer); - if ( !SHELL_ExistsFileW(szBuffer) ) - { - //FIXME load localized error msg - MessageBoxW( hwndDlg, L"file not existing", szBuffer, MB_OK ); - SetWindowLongPtr( hwndDlg, DWL_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE ); - return TRUE; - } - ptr = wcsrchr(szBuffer, L'.'); - if (ptr && !_wcsnicmp(ptr, L".lnk", 4)) - { - // FIXME load localized error msg - MessageBoxW( hwndDlg, L"You cannot create a link to a shortcut", L"Error", MB_ICONERROR ); - SetWindowLongPtr( hwndDlg, DWL_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE ); - return TRUE; - } - - IShellLinkW_fnSetPath((IShellLinkW*)&This->lpvtblw, szBuffer); - - TRACE("This %p sLinkPath %S\n", This, This->sLinkPath); - IPersistFile_fnSave( (IPersistFile*)&This->lpvtblPersistFile, This->sLinkPath, TRUE ); - SetWindowLongPtr( hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR ); - return TRUE; - } - break; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case 14020: - /// - /// FIXME - /// open target directory - /// - return TRUE; - case 14021: - if (This->sIcoPath) - wcscpy(szBuffer, This->sIcoPath); - else - wcscpy(szBuffer, This->sPath); - - IconIndex = This->iIcoNdx; - if (PickIconDlg(hwndDlg, szBuffer, MAX_PATH, &IconIndex)) - { - IShellLinkW_fnSetIconLocation((IShellLinkW*)&This->lpvtblw, szBuffer, IconIndex); - /// - /// FIXME redraw icon - } - return TRUE; - case 14022: - result = DialogBoxParamW(shell32_hInstance, MAKEINTRESOURCEW(SHELL_EXTENDED_SHORTCUT_DLG), hwndDlg, ExtendedShortcutProc, (LPARAM)This->bRunAs); - if (result == 1 || result == 0) - { - if ( This->bRunAs != result ) - { - PropSheet_Changed(GetParent(hwndDlg), hwndDlg); - } - - This->bRunAs = result; - } - return TRUE; - } - switch(HIWORD(wParam)) - { - case EN_CHANGE: - PropSheet_Changed(GetParent(hwndDlg), hwndDlg); - break; - } - break; - default: - break; - } - return FALSE; -} - -/************************************************************************** - * ShellLink_IShellPropSheetExt interface - */ - -static HRESULT WINAPI - ShellLink_IShellPropSheetExt_QueryInterface( IShellPropSheetExt* iface, REFIID riid, void** ppvObject ) -{ - IShellLinkImpl *This = impl_from_IShellPropSheetExt(iface); - return ShellLink_QueryInterface( This, riid, ppvObject ); -} - -static ULONG WINAPI - ShellLink_IShellPropSheetExt_AddRef( IShellPropSheetExt* iface ) -{ - IShellLinkImpl *This = impl_from_IShellPropSheetExt(iface); - return ShellLink_AddRef( This ); -} - -static ULONG WINAPI - ShellLink_IShellPropSheetExt_Release( IShellPropSheetExt* iface ) -{ - IShellLinkImpl *This = impl_from_IShellPropSheetExt(iface); - return ShellLink_Release( This ); -} - -static HRESULT WINAPI - ShellLink_IShellPropSheetExt_AddPages( IShellPropSheetExt *iface, LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam) -{ - HPROPSHEETPAGE hPage; - BOOL bRet; - IShellLinkImpl *This = impl_from_IShellPropSheetExt(iface); - - hPage = SH_CreatePropertySheetPage("SHELL_GENERAL_SHORTCUT_DLG", SH_ShellLinkDlgProc, (LPARAM)This, NULL); - if (hPage == NULL) - { - ERR("failed to create property sheet page\n"); - return E_FAIL; - } - - bRet = pfnAddPage(hPage, lParam); - if (bRet) - return S_OK; - else - return E_FAIL; -} - -static HRESULT WINAPI - ShellLink_IShellPropSheetExt_ReplacePages( IShellPropSheetExt *iface, UINT uPageID, LPFNADDPROPSHEETPAGE pfnReplacePage, LPARAM lParam) -{ - IShellLinkImpl *This = impl_from_IShellPropSheetExt(iface); - TRACE("(%p) (uPageID %u, pfnReplacePage %p lParam %p\n", This, uPageID, pfnReplacePage, lParam); - return E_NOTIMPL; -} - -static const IShellPropSheetExtVtbl pse = -{ - ShellLink_IShellPropSheetExt_QueryInterface, - ShellLink_IShellPropSheetExt_AddRef, - ShellLink_IShellPropSheetExt_Release, - ShellLink_IShellPropSheetExt_AddPages, - ShellLink_IShellPropSheetExt_ReplacePages -}; - -static HRESULT WINAPI -ShellLink_InvokeCommand( IContextMenu* iface, LPCMINVOKECOMMANDINFO lpici ) -{ - IShellLinkImpl *This = impl_from_IContextMenu(iface); - static const WCHAR szOpen[] = { 'o','p','e','n',0 }; - static const WCHAR szCplOpen[] = { 'c','p','l','o','p','e','n',0 }; - SHELLEXECUTEINFOW sei; - HWND hwnd = NULL; /* FIXME: get using interface set from IObjectWithSite */ - LPWSTR args = NULL; - LPWSTR path = NULL; - HRESULT r; - - TRACE("%p %p\n", This, lpici ); - - if ( lpici->cbSize < sizeof (CMINVOKECOMMANDINFO) ) - return E_INVALIDARG; - - r = IShellLinkW_Resolve( (IShellLinkW*)&(This->lpvtblw), hwnd, 0 ); - if ( FAILED( r ) ) - { - TRACE("failed to resolve component with error 0x%08x", r); - return r; - } - if ( This->sComponent ) - { - path = shelllink_get_msi_component_path( This->sComponent ); - if (!path) - return E_FAIL; - } - else - path = strdupW( This->sPath ); - - if ( lpici->cbSize == sizeof (CMINVOKECOMMANDINFOEX) && - ( lpici->fMask & CMIC_MASK_UNICODE ) ) - { - LPCMINVOKECOMMANDINFOEX iciex = (LPCMINVOKECOMMANDINFOEX) lpici; - DWORD len = 2; - - if ( This->sArgs ) - len += wcslen( This->sArgs ); - if ( iciex->lpParametersW ) - len += wcslen( iciex->lpParametersW ); - - args = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); - args[0] = 0; - if ( This->sArgs ) - wcscat( args, This->sArgs ); - if ( iciex->lpParametersW ) - { - static const WCHAR space[] = { ' ', 0 }; - wcscat( args, space ); - wcscat( args, iciex->lpParametersW ); - } - } - else if (This->sArgs != NULL) - { - args = strdupW( This->sArgs ); - } - - memset( &sei, 0, sizeof sei ); - sei.cbSize = sizeof sei; - sei.fMask = SEE_MASK_UNICODE | (lpici->fMask & (SEE_MASK_NOASYNC|SEE_MASK_ASYNCOK|SEE_MASK_FLAG_NO_UI)); - sei.lpFile = path; - sei.nShow = This->iShowCmd; - sei.lpDirectory = This->sWorkDir; - sei.lpParameters = args; - sei.lpVerb = szOpen; - - // HACK for ShellExecuteExW - if (!wcsstr(This->sPath, L".cpl")) - sei.lpVerb = szOpen; - else - sei.lpVerb = szCplOpen; - - if( ShellExecuteExW( &sei ) ) - r = S_OK; - else - r = E_FAIL; - - HeapFree( GetProcessHeap(), 0, args ); - HeapFree( GetProcessHeap(), 0, path ); - - return r; -} - -static HRESULT WINAPI -ShellLink_GetCommandString( IContextMenu* iface, UINT_PTR idCmd, UINT uType, - UINT* pwReserved, LPSTR pszName, UINT cchMax ) -{ - IShellLinkImpl *This = impl_from_IContextMenu(iface); - - FIXME("%p %lu %u %p %p %u\n", This, - idCmd, uType, pwReserved, pszName, cchMax ); - - return E_NOTIMPL; -} - -static const IContextMenuVtbl cmvt = -{ - ShellLink_ContextMenu_QueryInterface, - ShellLink_ContextMenu_AddRef, - ShellLink_ContextMenu_Release, - ShellLink_QueryContextMenu, - ShellLink_InvokeCommand, - ShellLink_GetCommandString -}; - -static HRESULT WINAPI -ShellLink_ObjectWithSite_QueryInterface( IObjectWithSite* iface, REFIID riid, void** ppvObject ) -{ - IShellLinkImpl *This = impl_from_IObjectWithSite(iface); - return ShellLink_QueryInterface( This, riid, ppvObject ); -} - -static ULONG WINAPI -ShellLink_ObjectWithSite_AddRef( IObjectWithSite* iface ) -{ - IShellLinkImpl *This = impl_from_IObjectWithSite(iface); - return ShellLink_AddRef( This ); -} - -static ULONG WINAPI -ShellLink_ObjectWithSite_Release( IObjectWithSite* iface ) -{ - IShellLinkImpl *This = impl_from_IObjectWithSite(iface); - return ShellLink_Release( This ); -} - -static HRESULT WINAPI -ShellLink_GetSite( IObjectWithSite *iface, REFIID iid, void ** ppvSite ) -{ - IShellLinkImpl *This = impl_from_IObjectWithSite(iface); - - TRACE("%p %s %p\n", This, debugstr_guid( iid ), ppvSite ); - - if ( !This->site ) - return E_FAIL; - return IUnknown_QueryInterface( This->site, iid, ppvSite ); -} - -static HRESULT WINAPI -ShellLink_SetSite( IObjectWithSite *iface, IUnknown *punk ) -{ - IShellLinkImpl *This = impl_from_IObjectWithSite(iface); - - TRACE("%p %p\n", iface, punk); - - if ( punk ) - IUnknown_AddRef( punk ); - This->site = punk; - - return S_OK; -} - -static const IObjectWithSiteVtbl owsvt = -{ - ShellLink_ObjectWithSite_QueryInterface, - ShellLink_ObjectWithSite_AddRef, - ShellLink_ObjectWithSite_Release, - ShellLink_SetSite, - ShellLink_GetSite, -}; diff --git a/reactos/dll/win32/shell32/shellole.c b/reactos/dll/win32/shell32/shellole.c deleted file mode 100644 index 37a3334d310..00000000000 --- a/reactos/dll/win32/shell32/shellole.c +++ /dev/null @@ -1,673 +0,0 @@ -/* - * handling of SHELL32.DLL OLE-Objects - * - * Copyright 1997 Marcus Meissner - * Copyright 1998 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -extern HRESULT WINAPI IFSFolder_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv); - -static const WCHAR sShell32[12] = {'S','H','E','L','L','3','2','.','D','L','L','\0'}; -static const GUID dummy1 = {0xD969A300, 0xE7FF, 0x11d0, {0xA9, 0x3B, 0x00, 0xA0, 0xC9, 0x0F, 0x27, 0x19} }; - -/************************************************************************** - * Default ClassFactory types - */ -typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject); -static IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst); - -/* this table contains all CLSID's of shell32 objects */ -static const struct { - REFIID riid; - LPFNCREATEINSTANCE lpfnCI; -} InterfaceTable[] = { - {&CLSID_ShellFSFolder, &IFSFolder_Constructor}, - {&CLSID_MyComputer, &ISF_MyComputer_Constructor}, - {&CLSID_NetworkPlaces, &ISF_NetworkPlaces_Constructor}, - {&CLSID_ShellDesktop, &ISF_Desktop_Constructor}, - {&CLSID_ShellItem, &IShellItem_Constructor}, - {&CLSID_ShellLink, &IShellLink_Constructor}, - {&CLSID_DragDropHelper, &IDropTargetHelper_Constructor}, - {&CLSID_ControlPanel, &IControlPanel_Constructor}, - {&CLSID_AutoComplete, &IAutoComplete_Constructor}, -#if 0 - {&CLSID_UnixFolder, &UnixFolder_Constructor}, - {&CLSID_UnixDosFolder, &UnixDosFolder_Constructor}, - {&CLSID_FolderShortcut, &FolderShortcut_Constructor}, -#endif - {&CLSID_MyDocuments, &ISF_MyDocuments_Constructor}, - {&CLSID_FontsFolderShortcut, &ISF_Fonts_Constructor}, - {&CLSID_Printers, &ISF_Printers_Constructor}, - {&CLSID_AdminFolderShortcut, &ISF_AdminTools_Constructor}, - {&CLSID_RecycleBin, &RecycleBin_Constructor}, - {&CLSID_OpenWith, &SHEOW_Constructor}, - {&dummy1, &INewItem_Constructor}, - {&CLSID_StartMenu, &StartMenu_Constructor}, - {&CLSID_MenuBandSite, &MenuBandSite_Constructor}, - {NULL,NULL} -}; - - -/* FIXME: this should be SHLWAPI.24 since we can't yet import by ordinal */ - -DWORD WINAPI __SHGUIDToStringW (REFGUID guid, LPWSTR str) -{ - WCHAR sFormat[52] = {'{','%','0','8','l','x','-','%','0','4', - 'x','-','%','0','4','x','-','%','0','2', - 'x','%','0','2','x','-','%','0','2','x', - '%','0','2','x','%','0','2','x','%','0', - '2','x','%','0','2','x','%','0','2','x', - '}','\0'}; - - return swprintf ( str, sFormat, - guid->Data1, guid->Data2, guid->Data3, - guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], - guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] ); - -} - -/************************************************************************* - * SHCoCreateInstance [SHELL32.102] - * - * Equivalent to CoCreateInstance. Under Windows 9x this function could sometimes - * use the shell32 built-in "mini-COM" without the need to load ole32.dll - see - * SHLoadOLE for details. - * - * Under wine if a "LoadWithoutCOM" value is present or the object resides in - * shell32.dll the function will load the object manually without the help of ole32 - * - * NOTES - * exported by ordinal - * - * SEE ALSO - * CoCreateInstace, SHLoadOLE - */ -HRESULT WINAPI SHCoCreateInstance( - LPCWSTR aclsid, - const CLSID *clsid, - LPUNKNOWN pUnkOuter, - REFIID refiid, - LPVOID *ppv) -{ - DWORD hres; - CLSID iid; - const CLSID * myclsid = clsid; - WCHAR sKeyName[MAX_PATH]; - const WCHAR sCLSID[7] = {'C','L','S','I','D','\\','\0'}; - WCHAR sClassID[60]; - const WCHAR sInProcServer32[16] ={'\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2','\0'}; - const WCHAR sLoadWithoutCOM[15] ={'L','o','a','d','W','i','t','h','o','u','t','C','O','M','\0'}; - WCHAR sDllPath[MAX_PATH]; - HKEY hKey; - DWORD dwSize; - BOOLEAN bLoadFromShell32 = FALSE; - BOOLEAN bLoadWithoutCOM = FALSE; - IClassFactory * pcf = NULL; - - if(!ppv) return E_POINTER; - *ppv=NULL; - - /* if the clsid is a string, convert it */ - if (!clsid) - { - if (!aclsid) return REGDB_E_CLASSNOTREG; - CLSIDFromString((LPOLESTR)aclsid, &iid); - myclsid = &iid; - } - - TRACE("(%p,%s,unk:%p,%s,%p)\n", - aclsid,shdebugstr_guid(myclsid),pUnkOuter,shdebugstr_guid(refiid),ppv); - - /* we look up the dll path in the registry */ - __SHGUIDToStringW(myclsid, sClassID); - wcscpy(sKeyName, sCLSID); - wcscat(sKeyName, sClassID); - wcscat(sKeyName, sInProcServer32); - - if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CLASSES_ROOT, sKeyName, 0, KEY_READ, &hKey)) { - dwSize = sizeof(sDllPath); - SHQueryValueExW(hKey, NULL, 0,0, sDllPath, &dwSize ); - - /* if a special registry key is set, we load a shell extension without help of OLE32 */ - bLoadWithoutCOM = (ERROR_SUCCESS == SHQueryValueExW(hKey, sLoadWithoutCOM, 0, 0, 0, 0)); - - /* if the com object is inside shell32, omit use of ole32 */ - bLoadFromShell32 = (0==lstrcmpiW( PathFindFileNameW(sDllPath), sShell32)); - - RegCloseKey (hKey); - } else { - /* since we can't find it in the registry we try internally */ - bLoadFromShell32 = TRUE; - } - - TRACE("WithoutCom=%u FromShell=%u\n", bLoadWithoutCOM, bLoadFromShell32); - - /* now we create an instance */ - if (bLoadFromShell32) { - if (! SUCCEEDED(DllGetClassObject(myclsid, &IID_IClassFactory,(LPVOID*)&pcf))) { - ERR("LoadFromShell failed for CLSID=%s\n", shdebugstr_guid(myclsid)); - } - } else if (bLoadWithoutCOM) { - - /* load an external dll without ole32 */ - HANDLE hLibrary; - typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv); - DllGetClassObjectFunc DllGetClassObject; - - if ((hLibrary = LoadLibraryExW(sDllPath, 0, LOAD_WITH_ALTERED_SEARCH_PATH)) == 0) { - ERR("couldn't load InprocServer32 dll %s\n", debugstr_w(sDllPath)); - hres = E_ACCESSDENIED; - goto end; - } else if (!(DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"))) { - ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(sDllPath)); - FreeLibrary( hLibrary ); - hres = E_ACCESSDENIED; - goto end; - } else if (FAILED(hres = DllGetClassObject(myclsid, &IID_IClassFactory, (LPVOID*)&pcf))) { - TRACE("GetClassObject failed 0x%08x\n", hres); - goto end; - } - - } else { - - /* load an external dll in the usual way */ - hres = CoCreateInstance(myclsid, pUnkOuter, CLSCTX_INPROC_SERVER, refiid, ppv); - goto end; - } - - /* here we should have a ClassFactory */ - if (!pcf) return E_ACCESSDENIED; - - hres = IClassFactory_CreateInstance(pcf, pUnkOuter, refiid, ppv); - IClassFactory_Release(pcf); -end: - if(hres!=S_OK) - { - ERR("failed (0x%08x) to create CLSID:%s IID:%s\n", - hres, shdebugstr_guid(myclsid), shdebugstr_guid(refiid)); - ERR("class not found in registry\n"); - } - - TRACE("-- instance: %p\n",*ppv); - return hres; -} - -/************************************************************************* - * DllGetClassObject [SHELL32.@] - * SHDllGetClassObject [SHELL32.128] - */ -HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) -{ - HRESULT hres = E_OUTOFMEMORY; - IClassFactory * pcf = NULL; - int i; - - TRACE("CLSID:%s,IID:%s\n",shdebugstr_guid(rclsid),shdebugstr_guid(iid)); - - if (!ppv) return E_INVALIDARG; - *ppv = NULL; - - /* search our internal interface table */ - for(i=0;InterfaceTable[i].riid;i++) { - if(IsEqualIID(InterfaceTable[i].riid, rclsid)) { - TRACE("index[%u]\n", i); - pcf = IDefClF_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL); - } - } - - if (!pcf) { - FIXME("failed for CLSID=%s\n", shdebugstr_guid(rclsid)); - return CLASS_E_CLASSNOTAVAILABLE; - } - - hres = IClassFactory_QueryInterface(pcf, iid, ppv); - IClassFactory_Release(pcf); - - TRACE("-- pointer to class factory: %p\n",*ppv); - return hres; -} - -/************************************************************************* - * SHCLSIDFromString [SHELL32.147] - * - * Under Windows 9x this was an ANSI version of CLSIDFromString. It also allowed - * to avoid dependency on ole32.dll (see SHLoadOLE for details). - * - * Under Windows NT/2000/XP this is equivalent to CLSIDFromString - * - * NOTES - * exported by ordinal - * - * SEE ALSO - * CLSIDFromString, SHLoadOLE - */ -DWORD WINAPI SHCLSIDFromStringA (LPCSTR clsid, CLSID *id) -{ - WCHAR buffer[40]; - TRACE("(%p(%s) %p)\n", clsid, clsid, id); - if (!MultiByteToWideChar( CP_ACP, 0, clsid, -1, buffer, sizeof(buffer)/sizeof(WCHAR) )) - return CO_E_CLASSSTRING; - return CLSIDFromString( buffer, id ); -} -DWORD WINAPI SHCLSIDFromStringW (LPCWSTR clsid, CLSID *id) -{ - TRACE("(%p(%s) %p)\n", clsid, debugstr_w(clsid), id); - return CLSIDFromString((LPWSTR)clsid, id); -} -DWORD WINAPI SHCLSIDFromStringAW (LPCVOID clsid, CLSID *id) -{ - if (SHELL_OsIsUnicode()) - return SHCLSIDFromStringW (clsid, id); - return SHCLSIDFromStringA (clsid, id); -} - -/************************************************************************* - * SHGetMalloc [SHELL32.@] - * - * Equivalent to CoGetMalloc(MEMCTX_TASK, ...). Under Windows 9x this function - * could use the shell32 built-in "mini-COM" without the need to load ole32.dll - - * see SHLoadOLE for details. - * - * PARAMS - * lpmal [O] Destination for IMalloc interface. - * - * RETURNS - * Success: S_OK. lpmal contains the shells IMalloc interface. - * Failure. An HRESULT error code. - * - * SEE ALSO - * CoGetMalloc, SHLoadOLE - */ -HRESULT WINAPI SHGetMalloc(LPMALLOC *lpmal) -{ - TRACE("(%p)\n", lpmal); - return CoGetMalloc(MEMCTX_TASK, lpmal); -} - -/************************************************************************* - * SHAlloc [SHELL32.196] - * - * Equivalent to CoTaskMemAlloc. Under Windows 9x this function could use - * the shell32 built-in "mini-COM" without the need to load ole32.dll - - * see SHLoadOLE for details. - * - * NOTES - * exported by ordinal - * - * SEE ALSO - * CoTaskMemAlloc, SHLoadOLE - */ -LPVOID WINAPI SHAlloc(DWORD len) -{ - LPVOID ret; - - ret = CoTaskMemAlloc(len); - TRACE("%u bytes at %p\n",len, ret); - return ret; -} - -/************************************************************************* - * SHFree [SHELL32.195] - * - * Equivalent to CoTaskMemFree. Under Windows 9x this function could use - * the shell32 built-in "mini-COM" without the need to load ole32.dll - - * see SHLoadOLE for details. - * - * NOTES - * exported by ordinal - * - * SEE ALSO - * CoTaskMemFree, SHLoadOLE - */ -void WINAPI SHFree(LPVOID pv) -{ - TRACE("%p\n",pv); - CoTaskMemFree(pv); -} - -/************************************************************************* - * SHGetDesktopFolder [SHELL32.@] - */ -HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf) -{ - HRESULT hres = S_OK; - TRACE("\n"); - - if(!psf) return E_INVALIDARG; - *psf = NULL; - hres = ISF_Desktop_Constructor(NULL, &IID_IShellFolder,(LPVOID*)psf); - - TRACE("-- %p->(%p)\n",psf, *psf); - return hres; -} -/************************************************************************** - * Default ClassFactory Implementation - * - * SHCreateDefClassObject - * - * NOTES - * Helper function for dlls without their own classfactory. - * A generic classfactory is returned. - * When the CreateInstance of the cf is called the callback is executed. - */ - -typedef struct -{ - const IClassFactoryVtbl *lpVtbl; - LONG ref; - CLSID *rclsid; - LPFNCREATEINSTANCE lpfnCI; - const IID * riidInst; - LONG * pcRefDll; /* pointer to refcounter in external dll (ugrrr...) */ -} IDefClFImpl; - -static const IClassFactoryVtbl dclfvt; - -/************************************************************************** - * IDefClF_fnConstructor - */ - -static IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst) -{ - IDefClFImpl* lpclf; - - lpclf = HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl)); - lpclf->ref = 1; - lpclf->lpVtbl = &dclfvt; - lpclf->lpfnCI = lpfnCI; - lpclf->pcRefDll = pcRefDll; - - if (pcRefDll) InterlockedIncrement(pcRefDll); - lpclf->riidInst = riidInst; - - TRACE("(%p)%s\n",lpclf, shdebugstr_guid(riidInst)); - return (LPCLASSFACTORY)lpclf; -} -/************************************************************************** - * IDefClF_fnQueryInterface - */ -static HRESULT WINAPI IDefClF_fnQueryInterface( - LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj) -{ - IDefClFImpl *This = (IDefClFImpl *)iface; - - TRACE("(%p)->(%s)\n",This,shdebugstr_guid(riid)); - - *ppvObj = NULL; - - if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory)) { - *ppvObj = This; - InterlockedIncrement(&This->ref); - return S_OK; - } - - TRACE("-- E_NOINTERFACE\n"); - return E_NOINTERFACE; -} -/****************************************************************************** - * IDefClF_fnAddRef - */ -static ULONG WINAPI IDefClF_fnAddRef(LPCLASSFACTORY iface) -{ - IDefClFImpl *This = (IDefClFImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE("(%p)->(count=%u)\n", This, refCount - 1); - - return refCount; -} -/****************************************************************************** - * IDefClF_fnRelease - */ -static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface) -{ - IDefClFImpl *This = (IDefClFImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(count=%u)\n", This, refCount + 1); - - if (!refCount) - { - if (This->pcRefDll) InterlockedDecrement(This->pcRefDll); - - TRACE("-- destroying IClassFactory(%p)\n",This); - HeapFree(GetProcessHeap(),0,This); - return 0; - } - return refCount; -} -/****************************************************************************** - * IDefClF_fnCreateInstance - */ -static HRESULT WINAPI IDefClF_fnCreateInstance( - LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject) -{ - IDefClFImpl *This = (IDefClFImpl *)iface; - - TRACE("%p->(%p,%s,%p)\n",This,pUnkOuter,shdebugstr_guid(riid),ppvObject); - - *ppvObject = NULL; - - if ( This->riidInst==NULL || - IsEqualCLSID(riid, This->riidInst) || - IsEqualCLSID(riid, &IID_IUnknown) ) - { - return This->lpfnCI(pUnkOuter, riid, ppvObject); - } - - ERR("unknown IID requested %s\n",shdebugstr_guid(riid)); - return E_NOINTERFACE; -} -/****************************************************************************** - * IDefClF_fnLockServer - */ -static HRESULT WINAPI IDefClF_fnLockServer(LPCLASSFACTORY iface, BOOL fLock) -{ - IDefClFImpl *This = (IDefClFImpl *)iface; - TRACE("%p->(0x%x), not implemented\n",This, fLock); - return E_NOTIMPL; -} - -static const IClassFactoryVtbl dclfvt = -{ - IDefClF_fnQueryInterface, - IDefClF_fnAddRef, - IDefClF_fnRelease, - IDefClF_fnCreateInstance, - IDefClF_fnLockServer -}; - -/****************************************************************************** - * SHCreateDefClassObject [SHELL32.70] - */ -HRESULT WINAPI SHCreateDefClassObject( - REFIID riid, - LPVOID* ppv, - LPFNCREATEINSTANCE lpfnCI, /* [in] create instance callback entry */ - LPDWORD pcRefDll, /* [in/out] ref count of the dll */ - REFIID riidInst) /* [in] optional interface to the instance */ -{ - IClassFactory * pcf; - - TRACE("%s %p %p %p %s\n", - shdebugstr_guid(riid), ppv, lpfnCI, pcRefDll, shdebugstr_guid(riidInst)); - - if (! IsEqualCLSID(riid, &IID_IClassFactory) ) return E_NOINTERFACE; - if (! (pcf = IDefClF_fnConstructor(lpfnCI, (PLONG)pcRefDll, riidInst))) return E_OUTOFMEMORY; - *ppv = pcf; - return NOERROR; -} - -/************************************************************************* - * DragAcceptFiles [SHELL32.@] - */ -void WINAPI DragAcceptFiles(HWND hWnd, BOOL b) -{ - LONG exstyle; - - if( !IsWindow(hWnd) ) return; - exstyle = GetWindowLongPtrA(hWnd,GWL_EXSTYLE); - if (b) - exstyle |= WS_EX_ACCEPTFILES; - else - exstyle &= ~WS_EX_ACCEPTFILES; - SetWindowLongPtrA(hWnd,GWL_EXSTYLE,exstyle); -} - -/************************************************************************* - * DragFinish [SHELL32.@] - */ -void WINAPI DragFinish(HDROP h) -{ - TRACE("\n"); - GlobalFree(h); -} - -/************************************************************************* - * DragQueryPoint [SHELL32.@] - */ -BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p) -{ - DROPFILES *lpDropFileStruct; - BOOL bRet; - - TRACE("\n"); - - lpDropFileStruct = GlobalLock(hDrop); - - *p = lpDropFileStruct->pt; - bRet = lpDropFileStruct->fNC; - - GlobalUnlock(hDrop); - return bRet; -} - -/************************************************************************* - * DragQueryFileA [SHELL32.@] - * DragQueryFile [SHELL32.@] - */ -UINT WINAPI DragQueryFileA( - HDROP hDrop, - UINT lFile, - LPSTR lpszFile, - UINT lLength) -{ - LPSTR lpDrop; - UINT i = 0; - DROPFILES *lpDropFileStruct = GlobalLock(hDrop); - - TRACE("(%p, %x, %p, %u)\n", hDrop,lFile,lpszFile,lLength); - - if(!lpDropFileStruct) goto end; - - lpDrop = (LPSTR) lpDropFileStruct + lpDropFileStruct->pFiles; - - if(lpDropFileStruct->fWide) { - LPWSTR lpszFileW = NULL; - - if(lpszFile) { - lpszFileW = HeapAlloc(GetProcessHeap(), 0, lLength*sizeof(WCHAR)); - if(lpszFileW == NULL) { - goto end; - } - } - i = DragQueryFileW(hDrop, lFile, lpszFileW, lLength); - - if(lpszFileW) { - WideCharToMultiByte(CP_ACP, 0, lpszFileW, -1, lpszFile, lLength, 0, NULL); - HeapFree(GetProcessHeap(), 0, lpszFileW); - } - goto end; - } - - while (i++ < lFile) - { - while (*lpDrop++); /* skip filename */ - if (!*lpDrop) - { - i = (lFile == 0xFFFFFFFF) ? i : 0; - goto end; - } - } - - i = strlen(lpDrop); - if (!lpszFile ) goto end; /* needed buffer size */ - lstrcpynA (lpszFile, lpDrop, lLength); -end: - GlobalUnlock(hDrop); - return i; -} - -/************************************************************************* - * DragQueryFileW [SHELL32.@] - */ -UINT WINAPI DragQueryFileW( - HDROP hDrop, - UINT lFile, - LPWSTR lpszwFile, - UINT lLength) -{ - LPWSTR lpwDrop; - UINT i = 0; - DROPFILES *lpDropFileStruct = GlobalLock(hDrop); - - TRACE("(%p, %x, %p, %u)\n", hDrop,lFile,lpszwFile,lLength); - - if(!lpDropFileStruct) goto end; - - lpwDrop = (LPWSTR) ((LPSTR)lpDropFileStruct + lpDropFileStruct->pFiles); - - if(lpDropFileStruct->fWide == FALSE) { - LPSTR lpszFileA = NULL; - - if(lpszwFile) { - lpszFileA = HeapAlloc(GetProcessHeap(), 0, lLength); - if(lpszFileA == NULL) { - goto end; - } - } - i = DragQueryFileA(hDrop, lFile, lpszFileA, lLength); - - if(lpszFileA) { - MultiByteToWideChar(CP_ACP, 0, lpszFileA, -1, lpszwFile, lLength); - HeapFree(GetProcessHeap(), 0, lpszFileA); - } - goto end; - } - - i = 0; - while (i++ < lFile) - { - while (*lpwDrop++); /* skip filename */ - if (!*lpwDrop) - { - i = (lFile == 0xFFFFFFFF) ? i : 0; - goto end; - } - } - - i = wcslen(lpwDrop); - if ( !lpszwFile) goto end; /* needed buffer size */ - lstrcpynW (lpszwFile, lpwDrop, lLength); -end: - GlobalUnlock(hDrop); - return i; -} diff --git a/reactos/dll/win32/shell32/shellord.c b/reactos/dll/win32/shell32/shellord.c deleted file mode 100644 index b1f5aed4dba..00000000000 --- a/reactos/dll/win32/shell32/shellord.c +++ /dev/null @@ -1,2323 +0,0 @@ -/* - * The parameters of many functions changes between different OS versions - * (NT uses Unicode strings, 95 uses ASCII strings) - * - * Copyright 1997 Marcus Meissner - * 1998 Jürgen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ -#include "config.h" - -#include -#include -#include - -#define COBJMACROS - -#include "winerror.h" -#include "windef.h" -#include "winbase.h" -#include "winreg.h" -#include "wine/debug.h" -#include "winnls.h" -#include "winternl.h" - -#include "shellapi.h" -#include "objbase.h" -#include "shlguid.h" -#include "wingdi.h" -#include "winuser.h" -#include "shlobj.h" -#include "shell32_main.h" -#include "undocshell.h" -#include "pidl.h" -#include "shlwapi.h" -#include "commdlg.h" -#include "recyclebin.h" -#include "commoncontrols.h" - -WINE_DEFAULT_DEBUG_CHANNEL(shell); -WINE_DECLARE_DEBUG_CHANNEL(pidl); - -/* FIXME: !!! move CREATEMRULIST and flags to header file !!! */ -/* !!! it is in both here and comctl32undoc.c !!! */ -typedef struct tagCREATEMRULIST -{ - DWORD cbSize; /* size of struct */ - DWORD nMaxItems; /* max no. of items in list */ - DWORD dwFlags; /* see below */ - HKEY hKey; /* root reg. key under which list is saved */ - LPCSTR lpszSubKey; /* reg. subkey */ - PROC lpfnCompare; /* item compare proc */ -} CREATEMRULISTA, *LPCREATEMRULISTA; - -/* dwFlags */ -#define MRUF_STRING_LIST 0 /* list will contain strings */ -#define MRUF_BINARY_LIST 1 /* list will contain binary data */ -#define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */ - -extern HANDLE WINAPI CreateMRUListA(LPCREATEMRULISTA lpcml); -extern DWORD WINAPI FreeMRUList(HANDLE hMRUList); -extern INT WINAPI AddMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData); -extern INT WINAPI FindMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum); -extern INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize); - - -/* Get a function pointer from a DLL handle */ -#define GET_FUNC(func, module, name, fail) \ - do { \ - if (!func) { \ - if (!SHELL32_h##module && !(SHELL32_h##module = LoadLibraryA(#module ".dll"))) return fail; \ - func = (void*)GetProcAddress(SHELL32_h##module, name); \ - if (!func) return fail; \ - } \ - } while (0) - -/* Function pointers for GET_FUNC macro */ -static HMODULE SHELL32_hshlwapi=NULL; -static HANDLE (WINAPI *pSHAllocShared)(LPCVOID,DWORD,DWORD); -static LPVOID (WINAPI *pSHLockShared)(HANDLE,DWORD); -static BOOL (WINAPI *pSHUnlockShared)(LPVOID); -static BOOL (WINAPI *pSHFreeShared)(HANDLE,DWORD); - - -/************************************************************************* - * ParseFieldA [internal] - * - * copies a field from a ',' delimited string - * - * first field is nField = 1 - */ -DWORD WINAPI ParseFieldA( - LPCSTR src, - DWORD nField, - LPSTR dst, - DWORD len) -{ - WARN("(%s,0x%08x,%p,%d) semi-stub.\n",debugstr_a(src),nField,dst,len); - - if (!src || !src[0] || !dst || !len) - return 0; - - /* skip n fields delimited by ',' */ - while (nField > 1) - { - if (*src=='\0') return FALSE; - if (*(src++)==',') nField--; - } - - /* copy part till the next ',' to dst */ - while ( *src!='\0' && *src!=',' && (len--)>0 ) *(dst++)=*(src++); - - /* finalize the string */ - *dst=0x0; - - return TRUE; -} - -/************************************************************************* - * ParseFieldW [internal] - * - * copies a field from a ',' delimited string - * - * first field is nField = 1 - */ -DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len) -{ - WARN("(%s,0x%08x,%p,%d) semi-stub.\n", debugstr_w(src), nField, dst, len); - - if (!src || !src[0] || !dst || !len) - return 0; - - /* skip n fields delimited by ',' */ - while (nField > 1) - { - if (*src == 0x0) return FALSE; - if (*src++ == ',') nField--; - } - - /* copy part till the next ',' to dst */ - while ( *src != 0x0 && *src != ',' && (len--)>0 ) *(dst++) = *(src++); - - /* finalize the string */ - *dst = 0x0; - - return TRUE; -} - -/************************************************************************* - * ParseField [SHELL32.58] - */ -DWORD WINAPI ParseFieldAW(LPCVOID src, DWORD nField, LPVOID dst, DWORD len) -{ - if (SHELL_OsIsUnicode()) - return ParseFieldW(src, nField, dst, len); - return ParseFieldA(src, nField, dst, len); -} - -/************************************************************************* - * GetFileNameFromBrowse [SHELL32.63] - * - */ -BOOL WINAPI GetFileNameFromBrowse( - HWND hwndOwner, - LPWSTR lpstrFile, - UINT nMaxFile, - LPCWSTR lpstrInitialDir, - LPCWSTR lpstrDefExt, - LPCWSTR lpstrFilter, - LPCWSTR lpstrTitle) -{ - HMODULE hmodule; - FARPROC pGetOpenFileNameW; - OPENFILENAMEW ofn; - BOOL ret; - - TRACE("%p, %s, %d, %s, %s, %s, %s)\n", - hwndOwner, debugstr_w(lpstrFile), nMaxFile, lpstrInitialDir, lpstrDefExt, - lpstrFilter, lpstrTitle); - - hmodule = LoadLibraryW(L"comdlg32.dll"); - if(!hmodule) return FALSE; - pGetOpenFileNameW = GetProcAddress(hmodule, "GetOpenFileNameW"); - if(!pGetOpenFileNameW) - { - FreeLibrary(hmodule); - return FALSE; - } - - memset(&ofn, 0, sizeof(ofn)); - - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwndOwner; - ofn.lpstrFilter = lpstrFilter; - ofn.lpstrFile = lpstrFile; - ofn.nMaxFile = nMaxFile; - ofn.lpstrInitialDir = lpstrInitialDir; - ofn.lpstrTitle = lpstrTitle; - ofn.lpstrDefExt = lpstrDefExt; - ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; - ret = pGetOpenFileNameW(&ofn); - - FreeLibrary(hmodule); - return ret; -} - -/************************************************************************* - * SHGetSetSettings [SHELL32.68] - */ -VOID WINAPI SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet) -{ - if(bSet) - { - FIXME("%p 0x%08x TRUE\n", lpss, dwMask); - } - else - { - SHGetSettings((LPSHELLFLAGSTATE)lpss,dwMask); - } -} - -/************************************************************************* - * SHGetSettings [SHELL32.@] - * - * NOTES - * the registry path are for win98 (tested) - * and possibly are the same in nt40 - * - */ -VOID WINAPI SHGetSettings(LPSHELLFLAGSTATE lpsfs, DWORD dwMask) -{ - HKEY hKey; - DWORD dwData; - DWORD dwDataSize = sizeof (DWORD); - - TRACE("(%p 0x%08x)\n",lpsfs,dwMask); - - if (RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", - 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0)) - return; - - if ( (SSF_SHOWEXTENSIONS & dwMask) && !RegQueryValueExA(hKey, "HideFileExt", 0, 0, (LPBYTE)&dwData, &dwDataSize)) - lpsfs->fShowExtensions = ((dwData == 0) ? 0 : 1); - - if ( (SSF_SHOWINFOTIP & dwMask) && !RegQueryValueExA(hKey, "ShowInfoTip", 0, 0, (LPBYTE)&dwData, &dwDataSize)) - lpsfs->fShowInfoTip = ((dwData == 0) ? 0 : 1); - - if ( (SSF_DONTPRETTYPATH & dwMask) && !RegQueryValueExA(hKey, "DontPrettyPath", 0, 0, (LPBYTE)&dwData, &dwDataSize)) - lpsfs->fDontPrettyPath = ((dwData == 0) ? 0 : 1); - - if ( (SSF_HIDEICONS & dwMask) && !RegQueryValueExA(hKey, "HideIcons", 0, 0, (LPBYTE)&dwData, &dwDataSize)) - lpsfs->fHideIcons = ((dwData == 0) ? 0 : 1); - - if ( (SSF_MAPNETDRVBUTTON & dwMask) && !RegQueryValueExA(hKey, "MapNetDrvBtn", 0, 0, (LPBYTE)&dwData, &dwDataSize)) - lpsfs->fMapNetDrvBtn = ((dwData == 0) ? 0 : 1); - - if ( (SSF_SHOWATTRIBCOL & dwMask) && !RegQueryValueExA(hKey, "ShowAttribCol", 0, 0, (LPBYTE)&dwData, &dwDataSize)) - lpsfs->fShowAttribCol = ((dwData == 0) ? 0 : 1); - - if (((SSF_SHOWALLOBJECTS | SSF_SHOWSYSFILES) & dwMask) && !RegQueryValueExA(hKey, "Hidden", 0, 0, (LPBYTE)&dwData, &dwDataSize)) - { if (dwData == 0) - { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0; - if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0; - } - else if (dwData == 1) - { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 1; - if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0; - } - else if (dwData == 2) - { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0; - if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 1; - } - } - RegCloseKey (hKey); - - TRACE("-- 0x%04x\n", *(WORD*)lpsfs); -} - -/************************************************************************* - * SHShellFolderView_Message [SHELL32.73] - * - * Send a message to an explorer cabinet window. - * - * PARAMS - * hwndCabinet [I] The window containing the shellview to communicate with - * dwMessage [I] The SFVM message to send - * dwParam [I] Message parameter - * - * RETURNS - * fixme. - * - * NOTES - * Message SFVM_REARRANGE = 1 - * - * This message gets sent when a column gets clicked to instruct the - * shell view to re-sort the item list. dwParam identifies the column - * that was clicked. - */ -LRESULT WINAPI SHShellFolderView_Message( - HWND hwndCabinet, - UINT uMessage, - LPARAM lParam) -{ - FIXME("%p %08x %08lx stub\n",hwndCabinet, uMessage, lParam); - return 0; -} - -/************************************************************************* - * RegisterShellHook [SHELL32.181] - * - * Register a shell hook. - * - * PARAMS - * hwnd [I] Window handle - * dwType [I] Type of hook. - * - * NOTES - * Exported by ordinal - */ -BOOL WINAPI RegisterShellHook( - HWND hWnd, - DWORD dwType) -{ - FIXME("(%p,0x%08x):stub.\n",hWnd, dwType); - return TRUE; -} - -/************************************************************************* - * ShellMessageBoxW [SHELL32.182] - * - * See ShellMessageBoxA. - * - * NOTE: - * shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW - * because we can't forward to it in the .spec file since it's exported by - * ordinal. If you change the implementation here please update the code in - * shlwapi as well. - */ -int WINAPI ShellMessageBoxW( - HINSTANCE hInstance, - HWND hWnd, - LPCWSTR lpText, - LPCWSTR lpCaption, - UINT uType, - ...) -{ - WCHAR szText[100],szTitle[100]; - LPCWSTR pszText = szText, pszTitle = szTitle; - LPWSTR pszTemp; - va_list args; - int ret; - - va_start(args, uType); - /* wvsprintfA(buf,fmt, args); */ - - TRACE("(%p,%p,%p,%p,%08x)\n", - hInstance,hWnd,lpText,lpCaption,uType); - - if (IS_INTRESOURCE(lpCaption)) - LoadStringW(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle)/sizeof(szTitle[0])); - else - pszTitle = lpCaption; - - if (IS_INTRESOURCE(lpText)) - LoadStringW(hInstance, LOWORD(lpText), szText, sizeof(szText)/sizeof(szText[0])); - else - pszText = lpText; - - FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING, - pszText, 0, 0, (LPWSTR)&pszTemp, 0, &args); - - va_end(args); - - ret = MessageBoxW(hWnd,pszTemp,pszTitle,uType); - LocalFree(pszTemp); - return ret; -} - -/************************************************************************* - * ShellMessageBoxA [SHELL32.183] - * - * Format and output an error message. - * - * PARAMS - * hInstance [I] Instance handle of message creator - * hWnd [I] Window handle of message creator - * lpText [I] Resource Id of title or LPSTR - * lpCaption [I] Resource Id of title or LPSTR - * uType [I] Type of error message - * - * RETURNS - * A return value from MessageBoxA(). - * - * NOTES - * Exported by ordinal - */ -int WINAPI ShellMessageBoxA( - HINSTANCE hInstance, - HWND hWnd, - LPCSTR lpText, - LPCSTR lpCaption, - UINT uType, - ...) -{ - char szText[100],szTitle[100]; - LPCSTR pszText = szText, pszTitle = szTitle; - LPSTR pszTemp; - va_list args; - int ret; - - va_start(args, uType); - /* wvsprintfA(buf,fmt, args); */ - - TRACE("(%p,%p,%p,%p,%08x)\n", - hInstance,hWnd,lpText,lpCaption,uType); - - if (IS_INTRESOURCE(lpCaption)) - LoadStringA(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle)); - else - pszTitle = lpCaption; - - if (IS_INTRESOURCE(lpText)) - LoadStringA(hInstance, LOWORD(lpText), szText, sizeof(szText)); - else - pszText = lpText; - - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING, - pszText, 0, 0, (LPSTR)&pszTemp, 0, &args); - - va_end(args); - - ret = MessageBoxA(hWnd,pszTemp,pszTitle,uType); - LocalFree(pszTemp); - return ret; -} - -/************************************************************************* - * SHRegisterDragDrop [SHELL32.86] - * - * Probably equivalent to RegisterDragDrop but under Windows 95 it could use the - * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE - * for details. Under Windows 98 this function initializes the true OLE when called - * the first time, on XP always returns E_OUTOFMEMORY and it got removed from Vista. - * - * - * NOTES - * exported by ordinal - * - * SEE ALSO - * RegisterDragDrop, SHLoadOLE - */ -HRESULT WINAPI SHRegisterDragDrop( - HWND hWnd, - LPDROPTARGET pDropTarget) -{ - FIXME("(%p,%p):stub.\n", hWnd, pDropTarget); - return RegisterDragDrop(hWnd, pDropTarget); -} - -/************************************************************************* - * SHRevokeDragDrop [SHELL32.87] - * - * Probably equivalent to RevokeDragDrop but under Windows 9x it could use the - * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE - * for details. Function removed from Windows Vista. - * - * NOTES - * exported by ordinal - * - * SEE ALSO - * RevokeDragDrop, SHLoadOLE - */ -HRESULT WINAPI SHRevokeDragDrop(HWND hWnd) -{ - FIXME("(%p):stub.\n",hWnd); - return RevokeDragDrop(hWnd); -} - -/************************************************************************* - * SHDoDragDrop [SHELL32.88] - * - * Probably equivalent to DoDragDrop but under Windows 9x it could use the - * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE - * for details - * - * NOTES - * exported by ordinal - * - * SEE ALSO - * DoDragDrop, SHLoadOLE - */ -HRESULT WINAPI SHDoDragDrop( - HWND hWnd, - LPDATAOBJECT lpDataObject, - LPDROPSOURCE lpDropSource, - DWORD dwOKEffect, - LPDWORD pdwEffect) -{ - FIXME("(%p %p %p 0x%08x %p):stub.\n", - hWnd, lpDataObject, lpDropSource, dwOKEffect, pdwEffect); - return DoDragDrop(lpDataObject, lpDropSource, dwOKEffect, pdwEffect); -} - -/************************************************************************* - * ArrangeWindows [SHELL32.184] - * - */ -WORD WINAPI ArrangeWindows( - HWND hwndParent, - DWORD dwReserved, - LPCRECT lpRect, - WORD cKids, - CONST HWND * lpKids) -{ - /* Unimplemented in WinXP SP3 */ - TRACE("(%p 0x%08x %p 0x%04x %p):stub.\n", - hwndParent, dwReserved, lpRect, cKids, lpKids); - return 0; -} - -/************************************************************************* - * SignalFileOpen [SHELL32.103] - * - * NOTES - * exported by ordinal - */ -DWORD WINAPI -SignalFileOpen (LPCITEMIDLIST pidl) -{ - FIXME("(0x%08x):stub.\n", pidl); - - return 0; -} - -/************************************************************************* - * SHADD_get_policy - helper function for SHAddToRecentDocs - * - * PARAMETERS - * policy [IN] policy name (null termed string) to find - * type [OUT] ptr to DWORD to receive type - * buffer [OUT] ptr to area to hold data retrieved - * len [IN/OUT] ptr to DWORD holding size of buffer and getting - * length filled - * - * RETURNS - * result of the SHQueryValueEx call - */ -static INT SHADD_get_policy(LPCSTR policy, LPDWORD type, LPVOID buffer, LPDWORD len) -{ - HKEY Policy_basekey; - INT ret; - - /* Get the key for the policies location in the registry - */ - if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, - "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", - 0, KEY_READ, &Policy_basekey)) { - - if (RegOpenKeyExA(HKEY_CURRENT_USER, - "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", - 0, KEY_READ, &Policy_basekey)) { - TRACE("No Explorer Policies location exists. Policy wanted=%s\n", - policy); - *len = 0; - return ERROR_FILE_NOT_FOUND; - } - } - - /* Retrieve the data if it exists - */ - ret = SHQueryValueExA(Policy_basekey, policy, 0, type, buffer, len); - RegCloseKey(Policy_basekey); - return ret; -} - - -/************************************************************************* - * SHADD_compare_mru - helper function for SHAddToRecentDocs - * - * PARAMETERS - * data1 [IN] data being looked for - * data2 [IN] data in MRU - * cbdata [IN] length from FindMRUData call (not used) - * - * RETURNS - * position within MRU list that data was added. - */ -static INT CALLBACK SHADD_compare_mru(LPCVOID data1, LPCVOID data2, DWORD cbData) -{ - return lstrcmpiA(data1, data2); -} - -/************************************************************************* - * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs - * - * PARAMETERS - * mruhandle [IN] handle for created MRU list - * doc_name [IN] null termed pure doc name - * new_lnk_name [IN] null termed path and file name for .lnk file - * buffer [IN/OUT] 2048 byte area to construct MRU data - * len [OUT] ptr to int to receive space used in buffer - * - * RETURNS - * position within MRU list that data was added. - */ -static INT SHADD_create_add_mru_data(HANDLE mruhandle, LPCSTR doc_name, LPCSTR new_lnk_name, - LPSTR buffer, INT *len) -{ - LPSTR ptr; - INT wlen; - - /*FIXME: Document: - * RecentDocs MRU data structure seems to be: - * +0h document file name w/ terminating 0h - * +nh short int w/ size of remaining - * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown - * +n+4h 10 bytes zeros - unknown - * +n+eh shortcut file name w/ terminating 0h - * +n+e+nh 3 zero bytes - unknown - */ - - /* Create the MRU data structure for "RecentDocs" - */ - ptr = buffer; - lstrcpyA(ptr, doc_name); - ptr += (lstrlenA(buffer) + 1); - wlen= lstrlenA(new_lnk_name) + 1 + 12; - *((short int*)ptr) = wlen; - ptr += 2; /* step past the length */ - *(ptr++) = 0x30; /* unknown reason */ - *(ptr++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */ - memset(ptr, 0, 10); - ptr += 10; - lstrcpyA(ptr, new_lnk_name); - ptr += (lstrlenA(new_lnk_name) + 1); - memset(ptr, 0, 3); - ptr += 3; - *len = ptr - buffer; - - /* Add the new entry into the MRU list - */ - return AddMRUData(mruhandle, buffer, *len); -} - -/************************************************************************* - * SHAddToRecentDocs [SHELL32.@] - * - * Modify (add/clear) Shell's list of recently used documents. - * - * PARAMETERS - * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL - * pv [IN] string or pidl, NULL clears the list - * - * NOTES - * exported by name - * - * FIXME - * convert to unicode - */ -void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv) -{ -/* If list is a string list lpfnCompare has the following prototype - * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2) - * for binary lists the prototype is - * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData) - * where cbData is the no. of bytes to compare. - * Need to check what return value means identical - 0? - */ - - - UINT olderrormode; - HKEY HCUbasekey; - CHAR doc_name[MAX_PATH]; - CHAR link_dir[MAX_PATH]; - CHAR new_lnk_filepath[MAX_PATH]; - CHAR new_lnk_name[MAX_PATH]; - CHAR * ext; - IMalloc *ppM; - LPITEMIDLIST pidl; - HWND hwnd = 0; /* FIXME: get real window handle */ - INT ret; - DWORD data[64], datalen, type; - - TRACE("%04x %p\n", uFlags, pv); - - /*FIXME: Document: - * RecentDocs MRU data structure seems to be: - * +0h document file name w/ terminating 0h - * +nh short int w/ size of remaining - * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown - * +n+4h 10 bytes zeros - unknown - * +n+eh shortcut file name w/ terminating 0h - * +n+e+nh 3 zero bytes - unknown - */ - - /* See if we need to do anything. - */ - datalen = 64; - ret=SHADD_get_policy( "NoRecentDocsHistory", &type, data, &datalen); - if ((ret > 0) && (ret != ERROR_FILE_NOT_FOUND)) { - ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret); - return; - } - if (ret == ERROR_SUCCESS) { - if (!( (type == REG_DWORD) || - ((type == REG_BINARY) && (datalen == 4)) )) { - ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n", - type, datalen); - return; - } - - TRACE("policy value for NoRecentDocsHistory = %08x\n", data[0]); - /* now test the actual policy value */ - if ( data[0] != 0) - return; - } - - /* Open key to where the necessary info is - */ - /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH) - * and the close should be done during the _DETACH. The resulting - * key is stored in the DLL global data. - */ - if (RegCreateKeyExA(HKEY_CURRENT_USER, - "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer", - 0, 0, 0, KEY_READ, 0, &HCUbasekey, 0)) { - ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n"); - return; - } - - /* Get path to user's "Recent" directory - */ - if(SUCCEEDED(SHGetMalloc(&ppM))) { - if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd, CSIDL_RECENT, - &pidl))) { - SHGetPathFromIDListA(pidl, link_dir); - IMalloc_Free(ppM, pidl); - } - else { - /* serious issues */ - link_dir[0] = 0; - ERR("serious issues 1\n"); - } - IMalloc_Release(ppM); - } - else { - /* serious issues */ - link_dir[0] = 0; - ERR("serious issues 2\n"); - } - TRACE("Users Recent dir %s\n", link_dir); - - /* If no input, then go clear the lists */ - if (!pv) { - /* clear user's Recent dir - */ - - /* FIXME: delete all files in "link_dir" - * - * while( more files ) { - * lstrcpyA(old_lnk_name, link_dir); - * PathAppendA(old_lnk_name, filenam); - * DeleteFileA(old_lnk_name); - * } - */ - FIXME("should delete all files in %s\\\n", link_dir); - - /* clear MRU list - */ - /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against - * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer - * and naturally it fails w/ rc=2. It should do it against - * HKEY_CURRENT_USER which is where it is stored, and where - * the MRU routines expect it!!!! - */ - RegDeleteKeyA(HCUbasekey, "RecentDocs"); - RegCloseKey(HCUbasekey); - return; - } - - /* Have data to add, the jobs to be done: - * 1. Add document to MRU list in registry "HKCU\Software\ - * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs". - * 2. Add shortcut to document in the user's Recent directory - * (CSIDL_RECENT). - * 3. Add shortcut to Start menu's Documents submenu. - */ - - /* Get the pure document name from the input - */ - switch (uFlags) - { - case SHARD_PIDL: - SHGetPathFromIDListA(pv, doc_name); - break; - - case SHARD_PATHA: - lstrcpynA(doc_name, pv, MAX_PATH); - break; - - case SHARD_PATHW: - WideCharToMultiByte(CP_ACP, 0, pv, -1, doc_name, MAX_PATH, NULL, NULL); - break; - - default: - FIXME("Unsupported flags: %u\n", uFlags); - return; - } - - TRACE("full document name %s\n", debugstr_a(doc_name)); - - /* check if file is a shortcut */ - ext = strrchr(doc_name, '.'); - if (!lstrcmpiA(ext, ".lnk")) - { - IShellLinkA * ShellLink; - - IShellLink_ConstructFromFile(NULL, &IID_IShellLinkA, (LPCITEMIDLIST)SHSimpleIDListFromPathA(doc_name), (LPVOID*)&ShellLink); - IShellLinkA_GetPath(ShellLink, doc_name, MAX_PATH, NULL, 0); - - IShellLinkA_Release(ShellLink); - } - - ext = strrchr(doc_name, '.'); - if (!lstrcmpiA(ext, ".exe")) - { - /* executables are not added */ - return; - } - - PathStripPathA(doc_name); - TRACE("stripped document name %s\n", debugstr_a(doc_name)); - - /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */ - - { /* on input needs: - * doc_name - pure file-spec, no path - * link_dir - path to the user's Recent directory - * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node - * creates: - * new_lnk_name- pure file-spec, no path for new .lnk file - * new_lnk_filepath - * - path and file name of new .lnk file - */ - CREATEMRULISTA mymru; - HANDLE mruhandle; - INT len, pos, bufused, err; - INT i; - DWORD attr; - CHAR buffer[2048]; - CHAR *ptr; - CHAR old_lnk_name[MAX_PATH]; - short int slen; - - mymru.cbSize = sizeof(CREATEMRULISTA); - mymru.nMaxItems = 15; - mymru.dwFlags = MRUF_BINARY_LIST | MRUF_DELAYED_SAVE; - mymru.hKey = HCUbasekey; - mymru.lpszSubKey = "RecentDocs"; - mymru.lpfnCompare = (PROC)SHADD_compare_mru; - mruhandle = CreateMRUListA(&mymru); - if (!mruhandle) { - /* MRU failed */ - ERR("MRU processing failed, handle zero\n"); - RegCloseKey(HCUbasekey); - return; - } - len = lstrlenA(doc_name); - pos = FindMRUData(mruhandle, doc_name, len, 0); - - /* Now get the MRU entry that will be replaced - * and delete the .lnk file for it - */ - if ((bufused = EnumMRUListA(mruhandle, (pos == -1) ? 14 : pos, - buffer, 2048)) != -1) { - ptr = buffer; - ptr += (lstrlenA(buffer) + 1); - slen = *((short int*)ptr); - ptr += 2; /* skip the length area */ - if (bufused >= slen + (ptr-buffer)) { - /* buffer size looks good */ - ptr += 12; /* get to string */ - len = bufused - (ptr-buffer); /* get length of buf remaining */ - if ((lstrlenA(ptr) > 0) && (lstrlenA(ptr) <= len-1)) { - /* appears to be good string */ - lstrcpyA(old_lnk_name, link_dir); - PathAppendA(old_lnk_name, ptr); - if (!DeleteFileA(old_lnk_name)) { - if ((attr = GetFileAttributesA(old_lnk_name)) == INVALID_FILE_ATTRIBUTES) { - if ((err = GetLastError()) != ERROR_FILE_NOT_FOUND) { - ERR("Delete for %s failed, err=%d, attr=%08x\n", - old_lnk_name, err, attr); - } - else { - TRACE("old .lnk file %s did not exist\n", - old_lnk_name); - } - } - else { - ERR("Delete for %s failed, attr=%08x\n", - old_lnk_name, attr); - } - } - else { - TRACE("deleted old .lnk file %s\n", old_lnk_name); - } - } - } - } - - /* Create usable .lnk file name for the "Recent" directory - */ - wsprintfA(new_lnk_name, "%s.lnk", doc_name); - lstrcpyA(new_lnk_filepath, link_dir); - PathAppendA(new_lnk_filepath, new_lnk_name); - i = 1; - olderrormode = SetErrorMode(SEM_FAILCRITICALERRORS); - while (GetFileAttributesA(new_lnk_filepath) != INVALID_FILE_ATTRIBUTES) { - i++; - wsprintfA(new_lnk_name, "%s (%u).lnk", doc_name, i); - lstrcpyA(new_lnk_filepath, link_dir); - PathAppendA(new_lnk_filepath, new_lnk_name); - } - SetErrorMode(olderrormode); - TRACE("new shortcut will be %s\n", new_lnk_filepath); - - /* Now add the new MRU entry and data - */ - pos = SHADD_create_add_mru_data(mruhandle, doc_name, new_lnk_name, - buffer, &len); - FreeMRUList(mruhandle); - TRACE("Updated MRU list, new doc is position %d\n", pos); - } - - /* *** JOB 2: Create shortcut in user's "Recent" directory *** */ - - { /* on input needs: - * doc_name - pure file-spec, no path - * new_lnk_filepath - * - path and file name of new .lnk file - * uFlags[in] - flags on call to SHAddToRecentDocs - * pv[in] - document path/pidl on call to SHAddToRecentDocs - */ - IShellLinkA *psl = NULL; - IPersistFile *pPf = NULL; - HRESULT hres; - CHAR desc[MAX_PATH]; - WCHAR widelink[MAX_PATH]; - - CoInitialize(0); - - hres = CoCreateInstance( &CLSID_ShellLink, - NULL, - CLSCTX_INPROC_SERVER, - &IID_IShellLinkA, - (LPVOID )&psl); - if(SUCCEEDED(hres)) { - - hres = IShellLinkA_QueryInterface(psl, &IID_IPersistFile, - (LPVOID *)&pPf); - if(FAILED(hres)) { - /* bombed */ - ERR("failed QueryInterface for IPersistFile %08x\n", hres); - goto fail; - } - - /* Set the document path or pidl */ - if (uFlags == SHARD_PIDL) { - hres = IShellLinkA_SetIDList(psl, pv); - } else { - hres = IShellLinkA_SetPath(psl, pv); - } - if(FAILED(hres)) { - /* bombed */ - ERR("failed Set{IDList|Path} %08x\n", hres); - goto fail; - } - - lstrcpyA(desc, "Shortcut to "); - lstrcatA(desc, doc_name); - hres = IShellLinkA_SetDescription(psl, desc); - if(FAILED(hres)) { - /* bombed */ - ERR("failed SetDescription %08x\n", hres); - goto fail; - } - - MultiByteToWideChar(CP_ACP, 0, new_lnk_filepath, -1, - widelink, MAX_PATH); - /* create the short cut */ - hres = IPersistFile_Save(pPf, widelink, TRUE); - if(FAILED(hres)) { - /* bombed */ - ERR("failed IPersistFile::Save %08x\n", hres); - IPersistFile_Release(pPf); - IShellLinkA_Release(psl); - goto fail; - } - hres = IPersistFile_SaveCompleted(pPf, widelink); - IPersistFile_Release(pPf); - IShellLinkA_Release(psl); - TRACE("shortcut %s has been created, result=%08x\n", - new_lnk_filepath, hres); - } - else { - ERR("CoCreateInstance failed, hres=%08x\n", hres); - } - } - - fail: - CoUninitialize(); - - /* all done */ - RegCloseKey(HCUbasekey); - return; -} - -/************************************************************************* - * SHCreateShellFolderViewEx [SHELL32.174] - * - * Create a new instance of the default Shell folder view object. - * - * RETURNS - * Success: S_OK - * Failure: error value - * - * NOTES - * see IShellFolder::CreateViewObject - */ -HRESULT WINAPI SHCreateShellFolderViewEx( - LPCSFV psvcbi, /* [in] shelltemplate struct */ - IShellView **ppv) /* [out] IShellView pointer */ -{ - IShellView * psf; - HRESULT hRes; - - TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n", - psvcbi->pshf, psvcbi->pidl, psvcbi->pfnCallback, - psvcbi->fvm, psvcbi->psvOuter); - - psf = IShellView_Constructor(psvcbi->pshf); - - if (!psf) - return E_OUTOFMEMORY; - - IShellView_AddRef(psf); - hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppv); - IShellView_Release(psf); - - return hRes; -} -/************************************************************************* - * SHWinHelp [SHELL32.127] - * - */ -HRESULT WINAPI SHWinHelp (DWORD v, DWORD w, DWORD x, DWORD z) -{ FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v,w,x,z); - return 0; -} -/************************************************************************* - * SHRunControlPanel [SHELL32.161] - * - */ -HRESULT WINAPI SHRunControlPanel (LPCWSTR lpcszCmdLine, HWND hwndMsgParent) -{ - FIXME("0x%08x 0x%08x stub\n",lpcszCmdLine,hwndMsgParent); - return 0; -} - -static LPUNKNOWN SHELL32_IExplorerInterface=0; -/************************************************************************* - * SHSetInstanceExplorer [SHELL32.176] - * - * NOTES - * Sets the interface - */ -VOID WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown) -{ TRACE("%p\n", lpUnknown); - SHELL32_IExplorerInterface = lpUnknown; -} -/************************************************************************* - * SHGetInstanceExplorer [SHELL32.@] - * - * NOTES - * gets the interface pointer of the explorer and a reference - */ -HRESULT WINAPI SHGetInstanceExplorer (IUnknown **lpUnknown) -{ TRACE("%p\n", lpUnknown); - - *lpUnknown = SHELL32_IExplorerInterface; - - if (!SHELL32_IExplorerInterface) - return E_FAIL; - - IUnknown_AddRef(SHELL32_IExplorerInterface); - return NOERROR; -} -/************************************************************************* - * SHFreeUnusedLibraries [SHELL32.123] - * - * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use - * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE - * for details - * - * NOTES - * exported by ordinal - * - * SEE ALSO - * CoFreeUnusedLibraries, SHLoadOLE - */ -void WINAPI SHFreeUnusedLibraries (void) -{ - FIXME("stub\n"); - CoFreeUnusedLibraries(); -} -/************************************************************************* - * DAD_AutoScroll [SHELL32.129] - * - */ -BOOL WINAPI DAD_AutoScroll(HWND hwnd, AUTO_SCROLL_DATA *samples, const POINT * pt) -{ - FIXME("hwnd = %p %p %p\n",hwnd,samples,pt); - return 0; -} -/************************************************************************* - * DAD_DragEnter [SHELL32.130] - * - */ -BOOL WINAPI DAD_DragEnter(HWND hwnd) -{ - FIXME("hwnd = %p\n",hwnd); - return FALSE; -} -/************************************************************************* - * DAD_DragEnterEx [SHELL32.131] - * - */ -BOOL WINAPI DAD_DragEnterEx(HWND hwnd, POINT p) -{ - FIXME("hwnd = %p (%d,%d)\n",hwnd,p.x,p.y); - return FALSE; -} -/************************************************************************* - * DAD_DragMove [SHELL32.134] - * - */ -BOOL WINAPI DAD_DragMove(POINT p) -{ - FIXME("(%d,%d)\n",p.x,p.y); - return FALSE; -} -/************************************************************************* - * DAD_DragLeave [SHELL32.132] - * - */ -BOOL WINAPI DAD_DragLeave(VOID) -{ - FIXME("\n"); - return FALSE; -} -/************************************************************************* - * DAD_SetDragImage [SHELL32.136] - * - * NOTES - * exported by name - */ -BOOL WINAPI DAD_SetDragImage( - HIMAGELIST himlTrack, - LPPOINT lppt) -{ - FIXME("%p %p stub\n",himlTrack, lppt); - return 0; -} -/************************************************************************* - * DAD_ShowDragImage [SHELL32.137] - * - * NOTES - * exported by name - */ -BOOL WINAPI DAD_ShowDragImage(BOOL bShow) -{ - FIXME("0x%08x stub\n",bShow); - return 0; -} - -static const WCHAR szwCabLocation[] = { - 'S','o','f','t','w','a','r','e','\\', - 'M','i','c','r','o','s','o','f','t','\\', - 'W','i','n','d','o','w','s','\\', - 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', - 'E','x','p','l','o','r','e','r','\\', - 'C','a','b','i','n','e','t','S','t','a','t','e',0 -}; - -static const WCHAR szwSettings[] = { 'S','e','t','t','i','n','g','s',0 }; - -/************************************************************************* - * ReadCabinetState [SHELL32.651] NT 4.0 - * - */ -BOOL WINAPI ReadCabinetState(CABINETSTATE *cs, int length) -{ - HKEY hkey = 0; - DWORD type, r; - - TRACE("%p %d\n", cs, length); - - if( (cs == NULL) || (length < (int)sizeof(*cs)) ) - return FALSE; - - r = RegOpenKeyW( HKEY_CURRENT_USER, szwCabLocation, &hkey ); - if( r == ERROR_SUCCESS ) - { - type = REG_BINARY; - r = RegQueryValueExW( hkey, szwSettings, - NULL, &type, (LPBYTE)cs, (LPDWORD)&length ); - RegCloseKey( hkey ); - - } - - /* if we can't read from the registry, create default values */ - if ( (r != ERROR_SUCCESS) || (cs->cLength < sizeof(*cs)) || - (cs->cLength != length) ) - { - ERR("Initializing shell cabinet settings\n"); - memset(cs, 0, sizeof(*cs)); - cs->cLength = sizeof(*cs); - cs->nVersion = 2; - cs->fFullPathTitle = FALSE; - cs->fSaveLocalView = TRUE; - cs->fNotShell = FALSE; - cs->fSimpleDefault = TRUE; - cs->fDontShowDescBar = FALSE; - cs->fNewWindowMode = FALSE; - cs->fShowCompColor = FALSE; - cs->fDontPrettyNames = FALSE; - cs->fAdminsCreateCommonGroups = TRUE; - cs->fMenuEnumFilter = 96; - } - - return TRUE; -} - -/************************************************************************* - * WriteCabinetState [SHELL32.652] NT 4.0 - * - */ -BOOL WINAPI WriteCabinetState(CABINETSTATE *cs) -{ - DWORD r; - HKEY hkey = 0; - - TRACE("%p\n",cs); - - if( cs == NULL ) - return FALSE; - - r = RegCreateKeyExW( HKEY_CURRENT_USER, szwCabLocation, 0, - NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL); - if( r == ERROR_SUCCESS ) - { - r = RegSetValueExW( hkey, szwSettings, 0, - REG_BINARY, (LPBYTE) cs, cs->cLength); - - RegCloseKey( hkey ); - } - - return (r==ERROR_SUCCESS); -} - -/************************************************************************* - * FileIconInit [SHELL32.660] - * - */ -BOOL WINAPI FileIconInit(BOOL bFullInit) -{ FIXME("(%s)\n", bFullInit ? "true" : "false"); - return 0; -} - -/************************************************************************* - * IsUserAnAdmin [SHELL32.680] NT 4.0 - * - * Checks whether the current user is a member of the Administrators group. - * - * PARAMS - * None - * - * RETURNS - * Success: TRUE - * Failure: FALSE - */ -BOOL WINAPI IsUserAnAdmin(VOID) -{ - SID_IDENTIFIER_AUTHORITY Authority = {SECURITY_NT_AUTHORITY}; - HANDLE hToken; - DWORD dwSize; - PTOKEN_GROUPS lpGroups; - PSID lpSid; - DWORD i; - BOOL bResult = FALSE; - - TRACE("\n"); - if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) - { - return FALSE; - } - - if (!GetTokenInformation(hToken, TokenGroups, NULL, 0, &dwSize)) - { - if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) - { - CloseHandle(hToken); - return FALSE; - } - } - - lpGroups = HeapAlloc(GetProcessHeap(), 0, dwSize); - if (lpGroups == NULL) - { - CloseHandle(hToken); - return FALSE; - } - - if (!GetTokenInformation(hToken, TokenGroups, lpGroups, dwSize, &dwSize)) - { - HeapFree(GetProcessHeap(), 0, lpGroups); - CloseHandle(hToken); - return FALSE; - } - - CloseHandle(hToken); - - if (!AllocateAndInitializeSid(&Authority, 2, SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, - &lpSid)) - { - HeapFree(GetProcessHeap(), 0, lpGroups); - return FALSE; - } - - for (i = 0; i < lpGroups->GroupCount; i++) - { - if (EqualSid(lpSid, lpGroups->Groups[i].Sid)) - { - bResult = TRUE; - break; - } - } - - FreeSid(lpSid); - HeapFree(GetProcessHeap(), 0, lpGroups); - return bResult; -} - -/************************************************************************* - * SHAllocShared [SHELL32.520] - * - * See shlwapi.SHAllocShared - */ -HANDLE WINAPI SHAllocShared(LPVOID lpvData, DWORD dwSize, DWORD dwProcId) -{ - GET_FUNC(pSHAllocShared, shlwapi, (char*)7, NULL); - return pSHAllocShared(lpvData, dwSize, dwProcId); -} - -/************************************************************************* - * SHLockShared [SHELL32.521] - * - * See shlwapi.SHLockShared - */ -LPVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId) -{ - GET_FUNC(pSHLockShared, shlwapi, (char*)8, NULL); - return pSHLockShared(hShared, dwProcId); -} - -/************************************************************************* - * SHUnlockShared [SHELL32.522] - * - * See shlwapi.SHUnlockShared - */ -BOOL WINAPI SHUnlockShared(LPVOID lpView) -{ - GET_FUNC(pSHUnlockShared, shlwapi, (char*)9, FALSE); - return pSHUnlockShared(lpView); -} - -/************************************************************************* - * SHFreeShared [SHELL32.523] - * - * See shlwapi.SHFreeShared - */ -BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId) -{ - GET_FUNC(pSHFreeShared, shlwapi, (char*)10, FALSE); - return pSHFreeShared(hShared, dwProcId); -} - -/************************************************************************* - * SetAppStartingCursor [SHELL32.99] - */ -HRESULT WINAPI SetAppStartingCursor(HWND u, DWORD v) -{ FIXME("hwnd=%p 0x%04x stub\n",u,v ); - return 0; -} - -/************************************************************************* - * SHLoadOLE [SHELL32.151] - * - * To reduce the memory usage of Windows 95, its shell32 contained an - * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance, - * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without - * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function - * would just call the Co* functions. - * - * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the - * information from the shell32 "mini-COM" to ole32.dll. - * - * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a - * detailed description. - * - * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is - * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM" - * hack in SHCoCreateInstance) - */ -HRESULT WINAPI SHLoadOLE(LPARAM lParam) -{ FIXME("0x%08lx stub\n",lParam); - return S_OK; -} -/************************************************************************* - * DriveType [SHELL32.64] - * - */ -HRESULT WINAPI DriveType(int DriveType) -{ - WCHAR root[] = L"A:\\"; - root[0] = L'A' + DriveType; - return GetDriveTypeW(root); -} -/************************************************************************* - * InvalidateDriveType [SHELL32.65] - * Unimplemented in XP SP3 - */ -int WINAPI InvalidateDriveType(int u) -{ - TRACE("0x%08x stub\n",u); - return 0; -} -/************************************************************************* - * SHAbortInvokeCommand [SHELL32.198] - * - */ -HRESULT WINAPI SHAbortInvokeCommand(void) -{ FIXME("stub\n"); - return 1; -} -/************************************************************************* - * SHOutOfMemoryMessageBox [SHELL32.126] - * - */ -int WINAPI SHOutOfMemoryMessageBox( - HWND hwndOwner, - LPCSTR lpCaption, - UINT uType) -{ - FIXME("%p %s 0x%08x stub\n",hwndOwner, lpCaption, uType); - return 0; -} -/************************************************************************* - * SHFlushClipboard [SHELL32.121] - * - */ -HRESULT WINAPI SHFlushClipboard(void) -{ - return OleFlushClipboard(); -} - -/************************************************************************* - * SHWaitForFileToOpen [SHELL32.97] - * - */ -BOOL WINAPI SHWaitForFileToOpen( - LPCITEMIDLIST pidl, - DWORD dwFlags, - DWORD dwTimeout) -{ - FIXME("%p 0x%08x 0x%08x stub\n", pidl, dwFlags, dwTimeout); - return 0; -} - -/************************************************************************ - * RLBuildListOfPaths [SHELL32.146] - * - * NOTES - * builds a DPA - */ -DWORD WINAPI RLBuildListOfPaths (void) -{ FIXME("stub\n"); - return 0; -} -/************************************************************************ - * SHValidateUNC [SHELL32.173] - * - */ -HRESULT WINAPI SHValidateUNC (HWND hwndOwner, LPWSTR pszFile, UINT fConnect) -{ - FIXME("0x%08x 0x%08x 0x%08x stub\n",hwndOwner,pszFile,fConnect); - return 0; -} - -/************************************************************************ - * DoEnvironmentSubstA [SHELL32.@] - * - * Replace %KEYWORD% in the str with the value of variable KEYWORD - * from environment. If it is not found the %KEYWORD% is left - * intact. If the buffer is too small, str is not modified. - * - * PARAMS - * pszString [I] '\0' terminated string with %keyword%. - * [O] '\0' terminated string with %keyword% substituted. - * cchString [I] size of str. - * - * RETURNS - * cchString length in the HIWORD; - * TRUE in LOWORD if subst was successful and FALSE in other case - */ -DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString) -{ - LPSTR dst; - BOOL res = FALSE; - FIXME("(%s, %d) stub\n", debugstr_a(pszString), cchString); - if (pszString == NULL) /* Really return 0? */ - return 0; - if ((dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(CHAR)))) - { - DWORD num = ExpandEnvironmentStringsA(pszString, dst, cchString); - if (num && num < cchString) /* dest buffer is too small */ - { - res = TRUE; - memcpy(pszString, dst, num); - } - HeapFree(GetProcessHeap(), 0, dst); - } - return MAKELONG(res,cchString); /* Always cchString? */ -} - -/************************************************************************ - * DoEnvironmentSubstW [SHELL32.@] - * - * See DoEnvironmentSubstA. - */ -DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString) -{ - LPWSTR dst; - BOOL res = FALSE; - FIXME("(%s, %d): stub\n", debugstr_w(pszString), cchString); - if ((dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(WCHAR)))) - { - DWORD num = ExpandEnvironmentStringsW(pszString, dst, cchString); - if (num) - { - res = TRUE; - wcscpy(pszString, dst); - } - HeapFree(GetProcessHeap(), 0, dst); - } - - return MAKELONG(res,cchString); -} - -/************************************************************************ - * DoEnvironmentSubst [SHELL32.53] - * - * See DoEnvironmentSubstA. - */ -DWORD WINAPI DoEnvironmentSubstAW(LPVOID x, UINT y) -{ - if (SHELL_OsIsUnicode()) - return DoEnvironmentSubstW(x, y); - return DoEnvironmentSubstA(x, y); -} - -/************************************************************************* - * GUIDFromStringA [SHELL32.703] - */ -BOOL WINAPI GUIDFromStringA(LPCSTR str, LPGUID guid) -{ - TRACE("GUIDFromStringA() stub\n"); - return FALSE; -} - -/************************************************************************* - * GUIDFromStringW [SHELL32.704] - */ -BOOL WINAPI GUIDFromStringW(LPCWSTR str, LPGUID guid) -{ - UNICODE_STRING guid_str; - - RtlInitUnicodeString(&guid_str, str); - return !RtlGUIDFromString(&guid_str, guid); -} - -/************************************************************************* - * PathIsTemporaryW [SHELL32.714] - */ -BOOL WINAPI PathIsTemporaryW(LPWSTR Str) -{ - FIXME("(%s)stub\n", debugstr_w(Str)); - return FALSE; -} - -/************************************************************************* - * PathIsTemporaryA [SHELL32.713] - */ -BOOL WINAPI PathIsTemporaryA(LPSTR Str) -{ - FIXME("(%s)stub\n", debugstr_a(Str)); - return FALSE; -} - -typedef struct _PSXA -{ - UINT uiCount; - UINT uiAllocated; - IShellPropSheetExt *pspsx[1]; -} PSXA, *PPSXA; - -typedef struct _PSXA_CALL -{ - LPFNADDPROPSHEETPAGE lpfnAddReplaceWith; - LPARAM lParam; - BOOL bCalled; - BOOL bMultiple; - UINT uiCount; -} PSXA_CALL, *PPSXA_CALL; - -static BOOL CALLBACK PsxaCall(HPROPSHEETPAGE hpage, LPARAM lParam) -{ - PPSXA_CALL Call = (PPSXA_CALL)lParam; - - if (Call != NULL) - { - if ((Call->bMultiple || !Call->bCalled) && - Call->lpfnAddReplaceWith(hpage, Call->lParam)) - { - Call->bCalled = TRUE; - Call->uiCount++; - return TRUE; - } - } - - return FALSE; -} - -/************************************************************************* - * SHAddFromPropSheetExtArray [SHELL32.167] - */ -UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam) -{ - PSXA_CALL Call; - UINT i; - PPSXA psxa = (PPSXA)hpsxa; - - TRACE("(%p,%p,%08lx)\n", hpsxa, lpfnAddPage, lParam); - - if (psxa) - { - ZeroMemory(&Call, sizeof(Call)); - Call.lpfnAddReplaceWith = lpfnAddPage; - Call.lParam = lParam; - Call.bMultiple = TRUE; - - /* Call the AddPage method of all registered IShellPropSheetExt interfaces */ - for (i = 0; i != psxa->uiCount; i++) - { - psxa->pspsx[i]->lpVtbl->AddPages(psxa->pspsx[i], PsxaCall, (LPARAM)&Call); - } - - return Call.uiCount; - } - - return 0; -} - -/************************************************************************* - * SHCreatePropSheetExtArray [SHELL32.168] - */ -HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface) -{ - return SHCreatePropSheetExtArrayEx(hKey, pszSubKey, max_iface, NULL); -} - -/************************************************************************* - * SHCreatePropSheetExtArrayEx [SHELL32.194] - */ -HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj) -{ - static const WCHAR szPropSheetSubKey[] = {'s','h','e','l','l','e','x','\\','P','r','o','p','e','r','t','y','S','h','e','e','t','H','a','n','d','l','e','r','s',0}; - WCHAR szHandler[64]; - DWORD dwHandlerLen; - WCHAR szClsidHandler[39]; - DWORD dwClsidSize; - CLSID clsid; - LONG lRet; - DWORD dwIndex; - IShellExtInit *psxi; - IShellPropSheetExt *pspsx; - HKEY hkBase, hkPropSheetHandlers; - PPSXA psxa = NULL; - HRESULT hr; - - TRACE("(%p,%s,%u)\n", hKey, debugstr_w(pszSubKey), max_iface); - - if (max_iface == 0) - return NULL; - - /* Open the registry key */ - lRet = RegOpenKeyW(hKey, pszSubKey, &hkBase); - if (lRet != ERROR_SUCCESS) - return NULL; - - lRet = RegOpenKeyExW(hkBase, szPropSheetSubKey, 0, KEY_ENUMERATE_SUB_KEYS, &hkPropSheetHandlers); - RegCloseKey(hkBase); - if (lRet == ERROR_SUCCESS) - { - /* Create and initialize the Property Sheet Extensions Array */ - psxa = LocalAlloc(LMEM_FIXED, FIELD_OFFSET(PSXA, pspsx[max_iface])); - if (psxa) - { - ZeroMemory(psxa, FIELD_OFFSET(PSXA, pspsx[max_iface])); - psxa->uiAllocated = max_iface; - - /* Enumerate all subkeys and attempt to load the shell extensions */ - dwIndex = 0; - do - { - dwHandlerLen = sizeof(szHandler) / sizeof(szHandler[0]); - lRet = RegEnumKeyExW(hkPropSheetHandlers, dwIndex++, szHandler, &dwHandlerLen, NULL, NULL, NULL, NULL); - if (lRet != ERROR_SUCCESS) - { - if (lRet == ERROR_MORE_DATA) - continue; - - if (lRet == ERROR_NO_MORE_ITEMS) - lRet = ERROR_SUCCESS; - break; - } - szHandler[(sizeof(szHandler) / sizeof(szHandler[0])) - 1] = 0; - hr = CLSIDFromString(szHandler, &clsid); - if (FAILED(hr)) - { - dwClsidSize = sizeof(szClsidHandler); - if (SHGetValueW(hkPropSheetHandlers, szHandler, NULL, NULL, szClsidHandler, &dwClsidSize) == ERROR_SUCCESS) - { - szClsidHandler[(sizeof(szClsidHandler) / sizeof(szClsidHandler[0])) - 1] = 0; - hr = CLSIDFromString(szClsidHandler, &clsid); - } - } - if (SUCCEEDED(hr)) - { - /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance. - Only if both interfaces are supported it's a real shell extension. - Then call IShellExtInit's Initialize method. */ - if (SUCCEEDED(CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt, (LPVOID *)&pspsx))) - { - if (SUCCEEDED(pspsx->lpVtbl->QueryInterface(pspsx, &IID_IShellExtInit, (PVOID *)&psxi))) - { - if (SUCCEEDED(psxi->lpVtbl->Initialize(psxi, NULL, pDataObj, hKey))) - { - /* Add the IShellPropSheetExt instance to the array */ - psxa->pspsx[psxa->uiCount++] = pspsx; - } - else - { - psxi->lpVtbl->Release(psxi); - pspsx->lpVtbl->Release(pspsx); - } - } - else - pspsx->lpVtbl->Release(pspsx); - } - } - } while (psxa->uiCount != psxa->uiAllocated); - } - else - lRet = ERROR_NOT_ENOUGH_MEMORY; - - RegCloseKey(hkPropSheetHandlers); - } - - if (lRet != ERROR_SUCCESS && psxa) - { - SHDestroyPropSheetExtArray((HPSXA)psxa); - psxa = NULL; - } - - return (HPSXA)psxa; -} - -/************************************************************************* - * SHReplaceFromPropSheetExtArray [SHELL32.170] - */ -UINT WINAPI SHReplaceFromPropSheetExtArray(HPSXA hpsxa, UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam) -{ - PSXA_CALL Call; - UINT i; - PPSXA psxa = (PPSXA)hpsxa; - - TRACE("(%p,%u,%p,%08lx)\n", hpsxa, uPageID, lpfnReplaceWith, lParam); - - if (psxa) - { - ZeroMemory(&Call, sizeof(Call)); - Call.lpfnAddReplaceWith = lpfnReplaceWith; - Call.lParam = lParam; - - /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces. - Each shell extension is only allowed to call the callback once during the callback. */ - for (i = 0; i != psxa->uiCount; i++) - { - Call.bCalled = FALSE; - psxa->pspsx[i]->lpVtbl->ReplacePage(psxa->pspsx[i], uPageID, PsxaCall, (LPARAM)&Call); - } - - return Call.uiCount; - } - - return 0; -} - -/************************************************************************* - * SHDestroyPropSheetExtArray [SHELL32.169] - */ -void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa) -{ - UINT i; - PPSXA psxa = (PPSXA)hpsxa; - - TRACE("(%p)\n", hpsxa); - - if (psxa) - { - for (i = 0; i != psxa->uiCount; i++) - { - psxa->pspsx[i]->lpVtbl->Release(psxa->pspsx[i]); - } - - LocalFree(psxa); - } -} - -/************************************************************************* - * CIDLData_CreateFromIDArray [SHELL32.83] - * - * Create IDataObject from PIDLs?? - */ -HRESULT WINAPI CIDLData_CreateFromIDArray( - LPCITEMIDLIST pidlFolder, - UINT cpidlFiles, - LPCITEMIDLIST *lppidlFiles, - IDataObject **ppdataObject) -{ - UINT i; - HWND hwnd = 0; /*FIXME: who should be hwnd of owner? set to desktop */ - - TRACE("(%p, %d, %p, %p)\n", pidlFolder, cpidlFiles, lppidlFiles, ppdataObject); - if (TRACE_ON(pidl)) - { - pdump (pidlFolder); - for (i=0; icbSize) - ret = E_INVALIDARG; - else - { - LPVOID lpdata = 0;/*LocalAlloc(LMEM_ZEROINIT, 0x4E4);*/ - - if (!lpdata) - ret = E_OUTOFMEMORY; - else - { - /* Initialize and return unknown lpdata structure */ - } - } - - return ret; -} - -/************************************************************************* - * SHFindFiles (SHELL32.90) - */ -BOOL WINAPI SHFindFiles( LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidlSaveFile ) -{ - FIXME("%p %p\n", pidlFolder, pidlSaveFile ); - return FALSE; -} - -/************************************************************************* - * SHUpdateImageW (SHELL32.192) - * - * Notifies the shell that an icon in the system image list has been changed. - * - * PARAMS - * pszHashItem [I] Path to file that contains the icon. - * iIndex [I] Zero-based index of the icon in the file. - * uFlags [I] Flags determining the icon attributes. See notes. - * iImageIndex [I] Index of the icon in the system image list. - * - * RETURNS - * Nothing - * - * NOTES - * uFlags can be one or more of the following flags: - * GIL_NOTFILENAME - pszHashItem is not a file name. - * GIL_SIMULATEDOC - Create a document icon using the specified icon. - */ -void WINAPI SHUpdateImageW(LPCWSTR pszHashItem, int iIndex, UINT uFlags, int iImageIndex) -{ - FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem), iIndex, uFlags, iImageIndex); -} - -/************************************************************************* - * SHUpdateImageA (SHELL32.191) - * - * See SHUpdateImageW. - */ -VOID WINAPI SHUpdateImageA(LPCSTR pszHashItem, INT iIndex, UINT uFlags, INT iImageIndex) -{ - FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem), iIndex, uFlags, iImageIndex); -} - -INT WINAPI SHHandleUpdateImage(LPCITEMIDLIST pidlExtra) -{ - FIXME("%p - stub\n", pidlExtra); - - return -1; -} - -BOOL WINAPI SHObjectProperties(HWND hwnd, DWORD dwType, LPCWSTR szObject, LPCWSTR szPage) -{ - FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd, dwType, debugstr_w(szObject), debugstr_w(szPage)); - - return TRUE; -} - -BOOL WINAPI SHGetNewLinkInfoA(LPCSTR pszLinkTo, LPCSTR pszDir, LPSTR pszName, BOOL *pfMustCopy, - UINT uFlags) -{ - WCHAR wszLinkTo[MAX_PATH]; - WCHAR wszDir[MAX_PATH]; - WCHAR wszName[MAX_PATH]; - BOOL res; - - MultiByteToWideChar(CP_ACP, 0, pszLinkTo, -1, wszLinkTo, MAX_PATH); - MultiByteToWideChar(CP_ACP, 0, pszDir, -1, wszDir, MAX_PATH); - - res = SHGetNewLinkInfoW(wszLinkTo, wszDir, wszName, pfMustCopy, uFlags); - - if (res) - WideCharToMultiByte(CP_ACP, 0, wszName, -1, pszName, MAX_PATH, NULL, NULL); - - return res; -} - -BOOL WINAPI SHGetNewLinkInfoW(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName, BOOL *pfMustCopy, - UINT uFlags) -{ - const WCHAR *basename; - WCHAR *dst_basename; - int i=2; - static const WCHAR lnkformat[] = {'%','s','.','l','n','k',0}; - static const WCHAR lnkformatnum[] = {'%','s',' ','(','%','d',')','.','l','n','k',0}; - - TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_w(pszLinkTo), debugstr_w(pszDir), - pszName, pfMustCopy, uFlags); - - *pfMustCopy = FALSE; - - if (uFlags & SHGNLI_PIDL) - { - FIXME("SHGNLI_PIDL flag unsupported\n"); - return FALSE; - } - - if (uFlags) - FIXME("ignoring flags: 0x%08x\n", uFlags); - - /* FIXME: should test if the file is a shortcut or DOS program */ - if (GetFileAttributesW(pszLinkTo) == INVALID_FILE_ATTRIBUTES) - return FALSE; - - basename = strrchrW(pszLinkTo, '\\'); - if (basename) - basename = basename+1; - else - basename = pszLinkTo; - - lstrcpynW(pszName, pszDir, MAX_PATH); - if (!PathAddBackslashW(pszName)) - return FALSE; - - dst_basename = pszName + strlenW(pszName); - - snprintfW(dst_basename, pszName + MAX_PATH - dst_basename, lnkformat, basename); - - while (GetFileAttributesW(pszName) != INVALID_FILE_ATTRIBUTES) - { - snprintfW(dst_basename, pszName + MAX_PATH - dst_basename, lnkformatnum, basename, i); - i++; - } - - return TRUE; -} - -/************************************************************************* - * SHStartNetConnectionDialog (SHELL32.@) - */ -HRESULT WINAPI SHStartNetConnectionDialog(HWND hwnd, LPCSTR pszRemoteName, DWORD dwType) -{ - FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRemoteName), dwType); - - return S_OK; -} -/************************************************************************* - * SHEmptyRecycleBinA (SHELL32.@) - */ -HRESULT WINAPI SHEmptyRecycleBinA(HWND hwnd, LPCSTR pszRootPath, DWORD dwFlags) -{ - LPWSTR szRootPathW = NULL; - int len; - HRESULT hr; - - TRACE("%p, %s, 0x%08x\n", hwnd, debugstr_a(pszRootPath), dwFlags); - - if (pszRootPath) - { - len = MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, NULL, 0); - if (len == 0) - return HRESULT_FROM_WIN32(GetLastError()); - szRootPathW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - if (!szRootPathW) - return E_OUTOFMEMORY; - if (MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, szRootPathW, len) == 0) - { - HeapFree(GetProcessHeap(), 0, szRootPathW); - return HRESULT_FROM_WIN32(GetLastError()); - } - } - - hr = SHEmptyRecycleBinW(hwnd, szRootPathW, dwFlags); - HeapFree(GetProcessHeap(), 0, szRootPathW); - - return hr; -} - -HRESULT WINAPI SHEmptyRecycleBinW(HWND hwnd, LPCWSTR pszRootPath, DWORD dwFlags) -{ - WCHAR szPath[MAX_PATH] = {0}; - DWORD dwSize, dwType; - LONG ret; - - TRACE("%p, %s, 0x%08x\n", hwnd, debugstr_w(pszRootPath), dwFlags); - - if (!(dwFlags & SHERB_NOCONFIRMATION)) - { - /* FIXME - * enumerate available files - * show confirmation dialog - */ - FIXME("show confirmation dialog\n"); - } - - if (dwFlags & SHERB_NOPROGRESSUI) - { - ret = EmptyRecycleBinW(pszRootPath); - } - else - { - /* FIXME - * show a progress dialog - */ - ret = EmptyRecycleBinW(pszRootPath); - } - - if (!ret) - return HRESULT_FROM_WIN32(GetLastError()); - - if (!(dwFlags & SHERB_NOSOUND)) - { - dwSize = sizeof(szPath); - ret = RegGetValueW(HKEY_CURRENT_USER, - L"AppEvents\\Schemes\\Apps\\Explorer\\EmptyRecycleBin\\.Current", - NULL, - RRF_RT_REG_EXPAND_SZ, - &dwType, - (PVOID)szPath, - &dwSize); - if (ret != ERROR_SUCCESS) - return S_OK; - - if (dwType != REG_EXPAND_SZ) /* type dismatch */ - return S_OK; - - szPath[(sizeof(szPath)/sizeof(WCHAR))-1] = L'\0'; - PlaySoundW(szPath, NULL, SND_FILENAME); - } - return S_OK; -} - -HRESULT WINAPI SHQueryRecycleBinA(LPCSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo) -{ - LPWSTR szRootPathW = NULL; - int len; - HRESULT hr; - - TRACE("%s, %p\n", debugstr_a(pszRootPath), pSHQueryRBInfo); - - if (pszRootPath) - { - len = MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, NULL, 0); - if (len == 0) - return HRESULT_FROM_WIN32(GetLastError()); - szRootPathW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - if (!szRootPathW) - return E_OUTOFMEMORY; - if (MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, szRootPathW, len) == 0) - { - HeapFree(GetProcessHeap(), 0, szRootPathW); - return HRESULT_FROM_WIN32(GetLastError()); - } - } - - hr = SHQueryRecycleBinW(szRootPathW, pSHQueryRBInfo); - HeapFree(GetProcessHeap(), 0, szRootPathW); - - return hr; -} - -HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo) -{ - FIXME("%s, %p - stub\n", debugstr_w(pszRootPath), pSHQueryRBInfo); - - if (!(pszRootPath) || (pszRootPath[0] == 0) || - !(pSHQueryRBInfo) || (pSHQueryRBInfo->cbSize < sizeof(SHQUERYRBINFO))) - { - return E_INVALIDARG; - } - - pSHQueryRBInfo->i64Size = 0; - pSHQueryRBInfo->i64NumItems = 0; - - return S_OK; -} - -/************************************************************************* - * SHSetLocalizedName (SHELL32.@) - */ -HRESULT WINAPI SHSetLocalizedName(LPCWSTR pszPath, LPCWSTR pszResModule, int idsRes) -{ - FIXME("%p, %s, %d - stub\n", pszPath, debugstr_w(pszResModule), idsRes); - - return S_OK; -} - -/************************************************************************* - * LinkWindow_RegisterClass (SHELL32.258) - */ -BOOL WINAPI LinkWindow_RegisterClass(void) -{ - FIXME("()\n"); - return TRUE; -} - -/************************************************************************* - * LinkWindow_UnregisterClass (SHELL32.259) - */ -BOOL WINAPI LinkWindow_UnregisterClass(void) -{ - FIXME("()\n"); - return TRUE; - -} - -/************************************************************************* - * SHFlushSFCache (SHELL32.526) - * - * Notifies the shell that a user-specified special folder location has changed. - * - * NOTES - * In Wine, the shell folder registry values are not cached, so this function - * has no effect. - */ -void WINAPI SHFlushSFCache(void) -{ -} - -/************************************************************************* - * SHGetImageList (SHELL32.727) - * - * Returns a copy of a shell image list. - * - * NOTES - * Windows XP features 4 sizes of image list, and Vista 5. Wine currently - * only supports the traditional small and large image lists, so requests - * for the others will currently fail. - */ -HRESULT WINAPI SHGetImageList(int iImageList, REFIID riid, void **ppv) -{ - HIMAGELIST hLarge, hSmall; - HIMAGELIST hNew; - HRESULT ret = E_FAIL; - - /* Wine currently only maintains large and small image lists */ - if ((iImageList != SHIL_LARGE) && (iImageList != SHIL_SMALL) && (iImageList != SHIL_SYSSMALL)) - { - FIXME("Unsupported image list %i requested\n", iImageList); - return E_FAIL; - } - - Shell_GetImageLists(&hLarge, &hSmall); - hNew = ImageList_Duplicate(iImageList == SHIL_LARGE ? hLarge : hSmall); - - /* Get the interface for the new image list */ - if (hNew) - { - ret = HIMAGELIST_QueryInterface(hNew, riid, ppv); - ImageList_Destroy(hNew); - } - - return ret; -} - -/************************************************************************* - * SHParseDisplayName [shell version 6.0] - */ -HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, -LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut) -{ - IShellFolder * psfDesktop; - HRESULT hr=E_FAIL; - ULONG dwAttr=sfgaoIn; - - if(!ppidl) - return E_INVALIDARG; - - if (!pszName || !psfgaoOut) - { - *ppidl = NULL; - return E_INVALIDARG; - } - - hr = SHGetDesktopFolder(&psfDesktop); - if (FAILED(hr)) - { - *ppidl = NULL; - return hr; - } - - hr = IShellFolder_ParseDisplayName(psfDesktop, (HWND)NULL, pbc, (LPOLESTR)pszName, (ULONG *)NULL, ppidl, &dwAttr); - - IShellFolder_Release(psfDesktop); - - if (SUCCEEDED(hr)) - *psfgaoOut = dwAttr; - else - *ppidl = NULL; - - return hr; -} diff --git a/reactos/dll/win32/shell32/shellpath.c b/reactos/dll/win32/shell32/shellpath.c deleted file mode 100644 index 76fc17c3bf2..00000000000 --- a/reactos/dll/win32/shell32/shellpath.c +++ /dev/null @@ -1,2029 +0,0 @@ -/* - * Path Functions - * - * Copyright 1998, 1999, 2000 Juergen Schmied - * Copyright 2004 Juan Lang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - * - * NOTES: - * - * Many of these functions are in SHLWAPI.DLL also - * - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -/* - ########## Combining and Constructing paths ########## -*/ - -/************************************************************************* - * PathAppend [SHELL32.36] - */ -BOOL WINAPI PathAppendAW( - LPVOID lpszPath1, - LPCVOID lpszPath2) -{ - if (SHELL_OsIsUnicode()) - return PathAppendW(lpszPath1, lpszPath2); - return PathAppendA(lpszPath1, lpszPath2); -} - -/************************************************************************* - * PathBuildRoot [SHELL32.30] - */ -LPVOID WINAPI PathBuildRootAW(LPVOID lpszPath, int drive) -{ - if(SHELL_OsIsUnicode()) - return PathBuildRootW(lpszPath, drive); - return PathBuildRootA(lpszPath, drive); -} - -/************************************************************************* - * PathGetExtensionA [internal] - * - * NOTES - * exported by ordinal - * return value points to the first char after the dot - */ -static LPSTR PathGetExtensionA(LPCSTR lpszPath) -{ - TRACE("(%s)\n",lpszPath); - - lpszPath = PathFindExtensionA(lpszPath); - return (LPSTR)(*lpszPath?(lpszPath+1):lpszPath); -} - -/************************************************************************* - * PathGetExtensionW [internal] - */ -LPWSTR PathGetExtensionW(LPCWSTR lpszPath) -{ - TRACE("(%s)\n",debugstr_w(lpszPath)); - - lpszPath = PathFindExtensionW(lpszPath); - return (LPWSTR)(*lpszPath?(lpszPath+1):lpszPath); -} - -/************************************************************************* - * SHPathGetExtension [SHELL32.158] - */ -LPVOID WINAPI SHPathGetExtensionW(LPCWSTR lpszPath, DWORD void1, DWORD void2) -{ - return PathGetExtensionW(lpszPath); -} - -/************************************************************************* - * PathRemoveFileSpec [SHELL32.35] - */ -BOOL WINAPI PathRemoveFileSpecAW(LPVOID lpszPath) -{ - if (SHELL_OsIsUnicode()) - return PathRemoveFileSpecW(lpszPath); - return PathRemoveFileSpecA(lpszPath); -} - -/* - Path Manipulations -*/ - -/************************************************************************* - * PathGetShortPathA [internal] - */ -static void PathGetShortPathA(LPSTR pszPath) -{ - CHAR path[MAX_PATH]; - - TRACE("%s\n", pszPath); - - if (GetShortPathNameA(pszPath, path, MAX_PATH)) - { - lstrcpyA(pszPath, path); - } -} - -/************************************************************************* - * PathGetShortPathW [internal] - */ -static void PathGetShortPathW(LPWSTR pszPath) -{ - WCHAR path[MAX_PATH]; - - TRACE("%s\n", debugstr_w(pszPath)); - - if (GetShortPathNameW(pszPath, path, MAX_PATH)) - { - wcscpy(pszPath, path); - } -} - -/************************************************************************* - * PathGetShortPath [SHELL32.92] - */ -VOID WINAPI PathGetShortPathAW(LPVOID pszPath) -{ - if(SHELL_OsIsUnicode()) - PathGetShortPathW(pszPath); - PathGetShortPathA(pszPath); -} - -/* - ########## Path Testing ########## -*/ - -/************************************************************************* - * PathIsRoot [SHELL32.29] - */ -BOOL WINAPI PathIsRootAW(LPCVOID lpszPath) -{ - if (SHELL_OsIsUnicode()) - return PathIsRootW(lpszPath); - return PathIsRootA(lpszPath); -} - -/************************************************************************* - * PathIsExeA [internal] - */ -static BOOL PathIsExeA (LPCSTR lpszPath) -{ - LPCSTR lpszExtension = PathGetExtensionA(lpszPath); - int i; - static const char * const lpszExtensions[] = - {"exe", "com", "pif", "cmd", "bat", "scf", "scr", NULL }; - - TRACE("path=%s\n",lpszPath); - - for(i=0; lpszExtensions[i]; i++) - if (!lstrcmpiA(lpszExtension,lpszExtensions[i])) return TRUE; - - return FALSE; -} - -/************************************************************************* - * PathIsExeW [internal] - */ -static BOOL PathIsExeW (LPCWSTR lpszPath) -{ - LPCWSTR lpszExtension = PathGetExtensionW(lpszPath); - int i; - static const WCHAR lpszExtensions[][4] = - {{'e','x','e','\0'}, {'c','o','m','\0'}, {'p','i','f','\0'}, - {'c','m','d','\0'}, {'b','a','t','\0'}, {'s','c','f','\0'}, - {'s','c','r','\0'}, {'\0'} }; - - TRACE("path=%s\n",debugstr_w(lpszPath)); - - for(i=0; lpszExtensions[i][0]; i++) - if (!strcmpiW(lpszExtension,lpszExtensions[i])) return TRUE; - - return FALSE; -} - -/************************************************************************* - * PathIsExe [SHELL32.43] - */ -BOOL WINAPI PathIsExeAW (LPCVOID path) -{ - if (SHELL_OsIsUnicode()) - return PathIsExeW (path); - return PathIsExeA(path); -} - -/************************************************************************* - * PathFileExists [SHELL32.45] - */ -BOOL WINAPI PathFileExistsAW (LPCVOID lpszPath) -{ - if (SHELL_OsIsUnicode()) - return PathFileExistsW (lpszPath); - return PathFileExistsA (lpszPath); -} - -/************************************************************************* - * PathIsSameRoot [SHELL32.650] - */ -BOOL WINAPI PathIsSameRootAW(LPCVOID lpszPath1, LPCVOID lpszPath2) -{ - if (SHELL_OsIsUnicode()) - return PathIsSameRootW(lpszPath1, lpszPath2); - return PathIsSameRootA(lpszPath1, lpszPath2); -} - -/************************************************************************* - * IsLFNDriveA [SHELL32.41] - */ -BOOL WINAPI IsLFNDriveA(LPCSTR lpszPath) -{ - DWORD fnlen; - - if (!GetVolumeInformationA(lpszPath, NULL, 0, NULL, &fnlen, NULL, NULL, 0)) - return FALSE; - return fnlen > 12; -} - -/************************************************************************* - * IsLFNDriveW [SHELL32.42] - */ -BOOL WINAPI IsLFNDriveW(LPCWSTR lpszPath) -{ - DWORD fnlen; - - if (!GetVolumeInformationW(lpszPath, NULL, 0, NULL, &fnlen, NULL, NULL, 0)) - return FALSE; - return fnlen > 12; -} - -/************************************************************************* - * IsLFNDrive [SHELL32.119] - */ -BOOL WINAPI IsLFNDriveAW(LPCVOID lpszPath) -{ - if (SHELL_OsIsUnicode()) - return IsLFNDriveW(lpszPath); - return IsLFNDriveA(lpszPath); -} - -/* - ########## Creating Something Unique ########## -*/ -/************************************************************************* - * PathMakeUniqueNameA [internal] - */ -BOOL WINAPI PathMakeUniqueNameA( - LPSTR lpszBuffer, - DWORD dwBuffSize, - LPCSTR lpszShortName, - LPCSTR lpszLongName, - LPCSTR lpszPathName) -{ - FIXME("%p %u %s %s %s stub\n", - lpszBuffer, dwBuffSize, debugstr_a(lpszShortName), - debugstr_a(lpszLongName), debugstr_a(lpszPathName)); - return TRUE; -} - -/************************************************************************* - * PathMakeUniqueNameW [internal] - */ -BOOL WINAPI PathMakeUniqueNameW( - LPWSTR lpszBuffer, - DWORD dwBuffSize, - LPCWSTR lpszShortName, - LPCWSTR lpszLongName, - LPCWSTR lpszPathName) -{ - FIXME("%p %u %s %s %s stub\n", - lpszBuffer, dwBuffSize, debugstr_w(lpszShortName), - debugstr_w(lpszLongName), debugstr_w(lpszPathName)); - return TRUE; -} - -/************************************************************************* - * PathMakeUniqueName [SHELL32.47] - */ -BOOL WINAPI PathMakeUniqueNameAW( - LPVOID lpszBuffer, - DWORD dwBuffSize, - LPCVOID lpszShortName, - LPCVOID lpszLongName, - LPCVOID lpszPathName) -{ - if (SHELL_OsIsUnicode()) - return PathMakeUniqueNameW(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName); - return PathMakeUniqueNameA(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName); -} - -/************************************************************************* - * PathYetAnotherMakeUniqueName [SHELL32.75] - * - * NOTES - * exported by ordinal - */ -BOOL WINAPI PathYetAnotherMakeUniqueName( - LPWSTR lpszBuffer, - LPCWSTR lpszPathName, - LPCWSTR lpszShortName, - LPCWSTR lpszLongName) -{ - FIXME("(%p, %s, %s ,%s):stub.\n", - lpszBuffer, debugstr_w(lpszPathName), debugstr_w(lpszShortName), debugstr_w(lpszLongName)); - return TRUE; -} - - -/* - ########## cleaning and resolving paths ########## - */ - -/************************************************************************* - * PathCleanupSpec [SHELL32.171] - * - * lpszFile is changed in place. - */ -int WINAPI PathCleanupSpec( LPCWSTR lpszPathW, LPWSTR lpszFileW ) -{ - int i = 0; - DWORD rc = 0; - int length = 0; - - if (SHELL_OsIsUnicode()) - { - LPWSTR p = lpszFileW; - - TRACE("Cleanup %s\n",debugstr_w(lpszFileW)); - - if (lpszPathW) - length = wcslen(lpszPathW); - - while (*p) - { - int gct = PathGetCharTypeW(*p); - if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR) - { - lpszFileW[i]='-'; - rc |= PCS_REPLACEDCHAR; - } - else - lpszFileW[i]=*p; - i++; - p++; - if (length + i == MAX_PATH) - { - rc |= PCS_FATAL | PCS_PATHTOOLONG; - break; - } - } - lpszFileW[i]=0; - } - else - { - LPSTR lpszFileA = (LPSTR)lpszFileW; - LPCSTR lpszPathA = (LPCSTR)lpszPathW; - LPSTR p = lpszFileA; - - TRACE("Cleanup %s\n",debugstr_a(lpszFileA)); - - if (lpszPathA) - length = strlen(lpszPathA); - - while (*p) - { - int gct = PathGetCharTypeA(*p); - if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR) - { - lpszFileA[i]='-'; - rc |= PCS_REPLACEDCHAR; - } - else - lpszFileA[i]=*p; - i++; - p++; - if (length + i == MAX_PATH) - { - rc |= PCS_FATAL | PCS_PATHTOOLONG; - break; - } - } - lpszFileA[i]=0; - } - return rc; -} - -/************************************************************************* - * PathQualifyA [SHELL32] - */ -BOOL WINAPI PathQualifyA(LPCSTR pszPath) -{ - FIXME("%s\n",pszPath); - return 0; -} - -/************************************************************************* - * PathQualifyW [SHELL32] - */ -BOOL WINAPI PathQualifyW(LPCWSTR pszPath) -{ - FIXME("%s\n",debugstr_w(pszPath)); - return 0; -} - -/************************************************************************* - * PathQualify [SHELL32.49] - */ -BOOL WINAPI PathQualifyAW(LPCVOID pszPath) -{ - if (SHELL_OsIsUnicode()) - return PathQualifyW(pszPath); - return PathQualifyA(pszPath); -} - -/************************************************************************* - * PathResolveA [SHELL32.51] - */ -BOOL WINAPI PathResolveA( - LPSTR lpszPath, - LPCSTR *alpszPaths, - DWORD dwFlags) -{ - FIXME("(%s,%p,0x%08x),stub!\n", - lpszPath, *alpszPaths, dwFlags); - return 0; -} - -/************************************************************************* - * PathResolveW [SHELL32] - */ -BOOL WINAPI PathResolveW( - LPWSTR lpszPath, - LPCWSTR *alpszPaths, - DWORD dwFlags) -{ - FIXME("(%s,%p,0x%08x),stub!\n", - debugstr_w(lpszPath), debugstr_w(*alpszPaths), dwFlags); - return 0; -} - -/************************************************************************* - * PathResolve [SHELL32.51] - */ -BOOL WINAPI PathResolveAW( - LPVOID lpszPath, - LPCVOID *alpszPaths, - DWORD dwFlags) -{ - if (SHELL_OsIsUnicode()) - return PathResolveW(lpszPath, (LPCWSTR*)alpszPaths, dwFlags); - return PathResolveA(lpszPath, (LPCSTR*)alpszPaths, dwFlags); -} - -/************************************************************************* -* PathProcessCommandA [SHELL32.653] -*/ -LONG WINAPI PathProcessCommandA ( - LPCSTR lpszPath, - LPSTR lpszBuff, - DWORD dwBuffSize, - DWORD dwFlags) -{ - FIXME("%s %p 0x%04x 0x%04x stub\n", - lpszPath, lpszBuff, dwBuffSize, dwFlags); - if(!lpszPath) return -1; - if(lpszBuff) strcpy(lpszBuff, lpszPath); - return strlen(lpszPath); -} - -/************************************************************************* -* PathProcessCommandW -*/ -LONG WINAPI PathProcessCommandW ( - LPCWSTR lpszPath, - LPWSTR lpszBuff, - DWORD dwBuffSize, - DWORD dwFlags) -{ - FIXME("(%s, %p, 0x%04x, 0x%04x) stub\n", - debugstr_w(lpszPath), lpszBuff, dwBuffSize, dwFlags); - if(!lpszPath) return -1; - if(lpszBuff) wcscpy(lpszBuff, lpszPath); - return wcslen(lpszPath); -} - -/************************************************************************* -* PathProcessCommand (SHELL32.653) -*/ -LONG WINAPI PathProcessCommandAW ( - LPCVOID lpszPath, - LPVOID lpszBuff, - DWORD dwBuffSize, - DWORD dwFlags) -{ - if (SHELL_OsIsUnicode()) - return PathProcessCommandW(lpszPath, lpszBuff, dwBuffSize, dwFlags); - return PathProcessCommandA(lpszPath, lpszBuff, dwBuffSize, dwFlags); -} - -/* - ########## special ########## -*/ - -static const WCHAR szCurrentVersion[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\0'}; -static const WCHAR Administrative_ToolsW[] = {'A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'}; -static const WCHAR AppDataW[] = {'A','p','p','D','a','t','a','\0'}; -static const WCHAR CacheW[] = {'C','a','c','h','e','\0'}; -static const WCHAR CD_BurningW[] = {'C','D',' ','B','u','r','n','i','n','g','\0'}; -static const WCHAR Common_Administrative_ToolsW[] = {'C','o','m','m','o','n',' ','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'}; -static const WCHAR Common_AppDataW[] = {'C','o','m','m','o','n',' ','A','p','p','D','a','t','a','\0'}; -static const WCHAR Common_DesktopW[] = {'C','o','m','m','o','n',' ','D','e','s','k','t','o','p','\0'}; -static const WCHAR Common_DocumentsW[] = {'C','o','m','m','o','n',' ','D','o','c','u','m','e','n','t','s','\0'}; -static const WCHAR CommonFilesDirW[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r','\0'}; -static const WCHAR CommonMusicW[] = {'C','o','m','m','o','n','M','u','s','i','c','\0'}; -static const WCHAR CommonPicturesW[] = {'C','o','m','m','o','n','P','i','c','t','u','r','e','s','\0'}; -static const WCHAR Common_ProgramsW[] = {'C','o','m','m','o','n',' ','P','r','o','g','r','a','m','s','\0'}; -static const WCHAR Common_StartUpW[] = {'C','o','m','m','o','n',' ','S','t','a','r','t','U','p','\0'}; -static const WCHAR Common_Start_MenuW[] = {'C','o','m','m','o','n',' ','S','t','a','r','t',' ','M','e','n','u','\0'}; -static const WCHAR Common_TemplatesW[] = {'C','o','m','m','o','n',' ','T','e','m','p','l','a','t','e','s','\0'}; -static const WCHAR CommonVideoW[] = {'C','o','m','m','o','n','V','i','d','e','o','\0'}; -static const WCHAR CookiesW[] = {'C','o','o','k','i','e','s','\0'}; -static const WCHAR DesktopW[] = {'D','e','s','k','t','o','p','\0'}; -static const WCHAR FavoritesW[] = {'F','a','v','o','r','i','t','e','s','\0'}; -static const WCHAR FontsW[] = {'F','o','n','t','s','\0'}; -static const WCHAR HistoryW[] = {'H','i','s','t','o','r','y','\0'}; -static const WCHAR Local_AppDataW[] = {'L','o','c','a','l',' ','A','p','p','D','a','t','a','\0'}; -static const WCHAR My_MusicW[] = {'M','y',' ','M','u','s','i','c','\0'}; -static const WCHAR My_PicturesW[] = {'M','y',' ','P','i','c','t','u','r','e','s','\0'}; -static const WCHAR My_VideoW[] = {'M','y',' ','V','i','d','e','o','\0'}; -static const WCHAR NetHoodW[] = {'N','e','t','H','o','o','d','\0'}; -static const WCHAR PersonalW[] = {'P','e','r','s','o','n','a','l','\0'}; -static const WCHAR PrintHoodW[] = {'P','r','i','n','t','H','o','o','d','\0'}; -static const WCHAR ProgramFilesDirW[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r','\0'}; -static const WCHAR ProgramsW[] = {'P','r','o','g','r','a','m','s','\0'}; -static const WCHAR RecentW[] = {'R','e','c','e','n','t','\0'}; -static const WCHAR ResourcesW[] = {'R','e','s','o','u','r','c','e','s','\0'}; -static const WCHAR SendToW[] = {'S','e','n','d','T','o','\0'}; -static const WCHAR StartUpW[] = {'S','t','a','r','t','U','p','\0'}; -static const WCHAR Start_MenuW[] = {'S','t','a','r','t',' ','M','e','n','u','\0'}; -static const WCHAR TemplatesW[] = {'T','e','m','p','l','a','t','e','s','\0'}; -static const WCHAR DefaultW[] = {'.','D','e','f','a','u','l','t','\0'}; -static const WCHAR AllUsersProfileW[] = {'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%','\0'}; -static const WCHAR UserProfileW[] = {'%','U','S','E','R','P','R','O','F','I','L','E','%','\0'}; -static const WCHAR SystemDriveW[] = {'%','S','y','s','t','e','m','D','r','i','v','e','%','\0'}; -static const WCHAR ProfileListW[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','P','r','o','f','i','l','e','L','i','s','t',0}; -static const WCHAR ProfilesDirectoryW[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0}; -static const WCHAR AllUsersProfileValueW[] = {'A','l','l','U','s','e','r','s','P','r','o','f','i','l','e','\0'}; -static const WCHAR szSHFolders[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'}; -static const WCHAR szSHUserFolders[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','U','s','e','r',' ','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'}; -/* This defaults to L"Documents and Settings" on Windows 2000/XP, but we're - * acting more Windows 9x-like for now. - */ -static const WCHAR szDefaultProfileDirW[] = {'p','r','o','f','i','l','e','s','\0'}; -static const WCHAR AllUsersW[] = {'A','l','l',' ','U','s','e','r','s','\0'}; - -typedef enum _CSIDL_Type { - CSIDL_Type_User, - CSIDL_Type_AllUsers, - CSIDL_Type_CurrVer, - CSIDL_Type_Disallowed, - CSIDL_Type_NonExistent, - CSIDL_Type_WindowsPath, - CSIDL_Type_SystemPath, -} CSIDL_Type; - -typedef struct -{ - CSIDL_Type type; - LPCWSTR szValueName; - LPCWSTR szDefaultPath; /* fallback string or resource ID */ -} CSIDL_DATA; - -static const CSIDL_DATA CSIDL_Data[] = -{ - { /* 0x00 - CSIDL_DESKTOP */ - CSIDL_Type_User, - DesktopW, - MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY) - }, - { /* 0x01 - CSIDL_INTERNET */ - CSIDL_Type_Disallowed, - NULL, - NULL - }, - { /* 0x02 - CSIDL_PROGRAMS */ - CSIDL_Type_User, - ProgramsW, - MAKEINTRESOURCEW(IDS_PROGRAMS) - }, - { /* 0x03 - CSIDL_CONTROLS (.CPL files) */ - CSIDL_Type_SystemPath, - NULL, - NULL - }, - { /* 0x04 - CSIDL_PRINTERS */ - CSIDL_Type_SystemPath, - NULL, - NULL - }, - { /* 0x05 - CSIDL_PERSONAL */ - CSIDL_Type_User, - PersonalW, - MAKEINTRESOURCEW(IDS_PERSONAL) - }, - { /* 0x06 - CSIDL_FAVORITES */ - CSIDL_Type_User, - FavoritesW, - MAKEINTRESOURCEW(IDS_FAVORITES) - }, - { /* 0x07 - CSIDL_STARTUP */ - CSIDL_Type_User, - StartUpW, - MAKEINTRESOURCEW(IDS_STARTUP) - }, - { /* 0x08 - CSIDL_RECENT */ - CSIDL_Type_User, - RecentW, - MAKEINTRESOURCEW(IDS_RECENT) - }, - { /* 0x09 - CSIDL_SENDTO */ - CSIDL_Type_User, - SendToW, - MAKEINTRESOURCEW(IDS_SENDTO) - }, - { /* 0x0a - CSIDL_BITBUCKET - Recycle Bin */ - CSIDL_Type_Disallowed, - NULL, - NULL, - }, - { /* 0x0b - CSIDL_STARTMENU */ - CSIDL_Type_User, - Start_MenuW, - MAKEINTRESOURCEW(IDS_STARTMENU) - }, - { /* 0x0c - CSIDL_MYDOCUMENTS */ - CSIDL_Type_Disallowed, /* matches WinXP--can't get its path */ - NULL, - NULL - }, - { /* 0x0d - CSIDL_MYMUSIC */ - CSIDL_Type_User, - My_MusicW, - MAKEINTRESOURCEW(IDS_MYMUSIC) - }, - { /* 0x0e - CSIDL_MYVIDEO */ - CSIDL_Type_User, - My_VideoW, - MAKEINTRESOURCEW(IDS_MYVIDEO) - }, - { /* 0x0f - unassigned */ - CSIDL_Type_Disallowed, - NULL, - NULL, - }, - { /* 0x10 - CSIDL_DESKTOPDIRECTORY */ - CSIDL_Type_User, - DesktopW, - MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY) - }, - { /* 0x11 - CSIDL_DRIVES */ - CSIDL_Type_Disallowed, - NULL, - NULL, - }, - { /* 0x12 - CSIDL_NETWORK */ - CSIDL_Type_Disallowed, - NULL, - NULL, - }, - { /* 0x13 - CSIDL_NETHOOD */ - CSIDL_Type_User, - NetHoodW, - MAKEINTRESOURCEW(IDS_NETHOOD) - }, - { /* 0x14 - CSIDL_FONTS */ - CSIDL_Type_WindowsPath, - FontsW, - FontsW - }, - { /* 0x15 - CSIDL_TEMPLATES */ - CSIDL_Type_User, - TemplatesW, - MAKEINTRESOURCEW(IDS_TEMPLATES) - }, - { /* 0x16 - CSIDL_COMMON_STARTMENU */ - CSIDL_Type_AllUsers, - Common_Start_MenuW, - MAKEINTRESOURCEW(IDS_STARTMENU) - }, - { /* 0x17 - CSIDL_COMMON_PROGRAMS */ - CSIDL_Type_AllUsers, - Common_ProgramsW, - MAKEINTRESOURCEW(IDS_PROGRAMS) - }, - { /* 0x18 - CSIDL_COMMON_STARTUP */ - CSIDL_Type_AllUsers, - Common_StartUpW, - MAKEINTRESOURCEW(IDS_STARTUP) - }, - { /* 0x19 - CSIDL_COMMON_DESKTOPDIRECTORY */ - CSIDL_Type_AllUsers, - Common_DesktopW, - MAKEINTRESOURCEW(IDS_DESKTOP) - }, - { /* 0x1a - CSIDL_APPDATA */ - CSIDL_Type_User, - AppDataW, - MAKEINTRESOURCEW(IDS_APPDATA) - }, - { /* 0x1b - CSIDL_PRINTHOOD */ - CSIDL_Type_User, - PrintHoodW, - MAKEINTRESOURCEW(IDS_PRINTHOOD) - }, - { /* 0x1c - CSIDL_LOCAL_APPDATA */ - CSIDL_Type_User, - Local_AppDataW, - MAKEINTRESOURCEW(IDS_LOCAL_APPDATA) - }, - { /* 0x1d - CSIDL_ALTSTARTUP */ - CSIDL_Type_NonExistent, - NULL, - NULL - }, - { /* 0x1e - CSIDL_COMMON_ALTSTARTUP */ - CSIDL_Type_NonExistent, - NULL, - NULL - }, - { /* 0x1f - CSIDL_COMMON_FAVORITES */ - CSIDL_Type_AllUsers, - FavoritesW, - MAKEINTRESOURCEW(IDS_FAVORITES) - }, - { /* 0x20 - CSIDL_INTERNET_CACHE */ - CSIDL_Type_User, - CacheW, - MAKEINTRESOURCEW(IDS_INTERNET_CACHE) - }, - { /* 0x21 - CSIDL_COOKIES */ - CSIDL_Type_User, - CookiesW, - MAKEINTRESOURCEW(IDS_COOKIES) - }, - { /* 0x22 - CSIDL_HISTORY */ - CSIDL_Type_User, - HistoryW, - MAKEINTRESOURCEW(IDS_HISTORY) - }, - { /* 0x23 - CSIDL_COMMON_APPDATA */ - CSIDL_Type_AllUsers, - Common_AppDataW, - MAKEINTRESOURCEW(IDS_APPDATA) - }, - { /* 0x24 - CSIDL_WINDOWS */ - CSIDL_Type_WindowsPath, - NULL, - NULL - }, - { /* 0x25 - CSIDL_SYSTEM */ - CSIDL_Type_SystemPath, - NULL, - NULL - }, - { /* 0x26 - CSIDL_PROGRAM_FILES */ - CSIDL_Type_CurrVer, - ProgramFilesDirW, - MAKEINTRESOURCEW(IDS_PROGRAM_FILES) - }, - { /* 0x27 - CSIDL_MYPICTURES */ - CSIDL_Type_User, - My_PicturesW, - MAKEINTRESOURCEW(IDS_MYPICTURES) - }, - { /* 0x28 - CSIDL_PROFILE */ - CSIDL_Type_User, - NULL, - NULL - }, - { /* 0x29 - CSIDL_SYSTEMX86 */ - CSIDL_Type_NonExistent, - NULL, - NULL - }, - { /* 0x2a - CSIDL_PROGRAM_FILESX86 */ - CSIDL_Type_NonExistent, - NULL, - NULL - }, - { /* 0x2b - CSIDL_PROGRAM_FILES_COMMON */ - CSIDL_Type_CurrVer, - CommonFilesDirW, - MAKEINTRESOURCEW(IDS_PROGRAM_FILES_COMMON) - }, - { /* 0x2c - CSIDL_PROGRAM_FILES_COMMONX86 */ - CSIDL_Type_NonExistent, - NULL, - NULL - }, - { /* 0x2d - CSIDL_COMMON_TEMPLATES */ - CSIDL_Type_AllUsers, - Common_TemplatesW, - MAKEINTRESOURCEW(IDS_TEMPLATES) - }, - { /* 0x2e - CSIDL_COMMON_DOCUMENTS */ - CSIDL_Type_AllUsers, - Common_DocumentsW, - MAKEINTRESOURCEW(IDS_COMMON_DOCUMENTS) - }, - { /* 0x2f - CSIDL_COMMON_ADMINTOOLS */ - CSIDL_Type_AllUsers, - Common_Administrative_ToolsW, - MAKEINTRESOURCEW(IDS_ADMINTOOLS) - }, - { /* 0x30 - CSIDL_ADMINTOOLS */ - CSIDL_Type_User, - Administrative_ToolsW, - MAKEINTRESOURCEW(IDS_ADMINTOOLS) - }, - { /* 0x31 - CSIDL_CONNECTIONS */ - CSIDL_Type_Disallowed, - NULL, - NULL - }, - { /* 0x32 - unassigned */ - CSIDL_Type_Disallowed, - NULL, - NULL - }, - { /* 0x33 - unassigned */ - CSIDL_Type_Disallowed, - NULL, - NULL - }, - { /* 0x34 - unassigned */ - CSIDL_Type_Disallowed, - NULL, - NULL - }, - { /* 0x35 - CSIDL_COMMON_MUSIC */ - CSIDL_Type_AllUsers, - CommonMusicW, - MAKEINTRESOURCEW(IDS_COMMON_MUSIC) - }, - { /* 0x36 - CSIDL_COMMON_PICTURES */ - CSIDL_Type_AllUsers, - CommonPicturesW, - MAKEINTRESOURCEW(IDS_COMMON_PICTURES) - }, - { /* 0x37 - CSIDL_COMMON_VIDEO */ - CSIDL_Type_AllUsers, - CommonVideoW, - MAKEINTRESOURCEW(IDS_COMMON_VIDEO) - }, - { /* 0x38 - CSIDL_RESOURCES */ - CSIDL_Type_WindowsPath, - NULL, - ResourcesW - }, - { /* 0x39 - CSIDL_RESOURCES_LOCALIZED */ - CSIDL_Type_NonExistent, - NULL, - NULL - }, - { /* 0x3a - CSIDL_COMMON_OEM_LINKS */ - CSIDL_Type_NonExistent, - NULL, - NULL - }, - { /* 0x3b - CSIDL_CDBURN_AREA */ - CSIDL_Type_User, - CD_BurningW, - MAKEINTRESOURCEW(IDS_CDBURN_AREA) - }, - { /* 0x3c unassigned */ - CSIDL_Type_Disallowed, - NULL, - NULL - }, - { /* 0x3d - CSIDL_COMPUTERSNEARME */ - CSIDL_Type_Disallowed, /* FIXME */ - NULL, - NULL - }, - { /* 0x3e - CSIDL_PROFILES */ - CSIDL_Type_Disallowed, /* oddly, this matches WinXP */ - NULL, - NULL - } -}; - -/* Gets the value named value from the registry key - * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders - * (or from rootKey\userPrefix\... if userPrefix is not NULL) into path, which - * is assumed to be MAX_PATH WCHARs in length. - * If it exists, expands the value and writes the expanded value to - * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - * Returns successful error code if the value was retrieved from the registry, - * and a failure otherwise. - */ -static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix, - LPCWSTR value, LPWSTR path) -{ - HRESULT hr; - WCHAR shellFolderPath[MAX_PATH], userShellFolderPath[MAX_PATH]; - LPCWSTR pShellFolderPath, pUserShellFolderPath; - DWORD dwDisp, dwType, dwPathLen; - HKEY userShellFolderKey, shellFolderKey; - - TRACE("%p,%s,%s,%p\n",rootKey, debugstr_w(userPrefix), debugstr_w(value), - path); - - if (userPrefix) - { - wcscpy(shellFolderPath, userPrefix); - PathAddBackslashW(shellFolderPath); - wcscat(shellFolderPath, szSHFolders); - pShellFolderPath = shellFolderPath; - wcscpy(userShellFolderPath, userPrefix); - PathAddBackslashW(userShellFolderPath); - wcscat(userShellFolderPath, szSHUserFolders); - pUserShellFolderPath = userShellFolderPath; - } - else - { - pUserShellFolderPath = szSHUserFolders; - pShellFolderPath = szSHFolders; - } - - if (RegCreateKeyExW(rootKey, pShellFolderPath, 0, NULL, 0, KEY_SET_VALUE, - NULL, &shellFolderKey, &dwDisp)) - { - TRACE("Failed to create %s\n", debugstr_w(pShellFolderPath)); - return E_FAIL; - } - if (RegCreateKeyExW(rootKey, pUserShellFolderPath, 0, NULL, 0, - KEY_QUERY_VALUE, NULL, &userShellFolderKey, &dwDisp)) - { - TRACE("Failed to create %s\n", - debugstr_w(pUserShellFolderPath)); - RegCloseKey(shellFolderKey); - return E_FAIL; - } - - dwPathLen = MAX_PATH * sizeof(WCHAR); - - if (!RegQueryValueExW(userShellFolderKey, value, NULL, &dwType, - (LPBYTE)path, &dwPathLen) && (dwType == REG_EXPAND_SZ || dwType == REG_SZ)) - { - LONG ret; - - dwPathLen /= sizeof(WCHAR); - - path[dwPathLen] = '\0'; - if (dwType == REG_EXPAND_SZ && path[0] == '%') - { - WCHAR szTemp[MAX_PATH]; - - dwPathLen = ExpandEnvironmentStringsW(path, szTemp, MAX_PATH); - lstrcpynW(path, szTemp, dwPathLen); - } - - ret = RegSetValueExW(shellFolderKey, value, 0, REG_SZ, (LPBYTE)path, dwPathLen * sizeof(WCHAR)); - if (ret != ERROR_SUCCESS) - hr = HRESULT_FROM_WIN32(ret); - else - hr = S_OK; - } - else - hr = E_FAIL; - - RegCloseKey(shellFolderKey); - RegCloseKey(userShellFolderKey); - TRACE("returning 0x%08x\n", hr); - return hr; -} - -/* Gets a 'semi-expanded' default value of the CSIDL with index folder into - * pszPath, based on the entries in CSIDL_Data. By semi-expanded, I mean: - * - The entry's szDefaultPath may be either a string value or an integer - * resource identifier. In the latter case, the string value of the resource - * is written. - * - Depending on the entry's type, the path may begin with an (unexpanded) - * environment variable name. The caller is responsible for expanding - * environment strings if so desired. - * The types that are prepended with environment variables are: - * CSIDL_Type_User: %USERPROFILE% - * CSIDL_Type_AllUsers: %ALLUSERSPROFILE% - * CSIDL_Type_CurrVer: %SystemDrive% - * (Others might make sense too, but as yet are unneeded.) - */ -static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath) -{ - DWORD dwSize; - HRESULT hr; - HKEY hKey; - WCHAR resourcePath[MAX_PATH]; - LPCWSTR pDefaultPath = NULL; - - TRACE("0x%02x,%p\n", folder, pszPath); - - if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0])) - return E_INVALIDARG; - if (!pszPath) - return E_INVALIDARG; - - if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", 0, KEY_READ, &hKey) == ERROR_SUCCESS) - { - /* FIXME assume MAX_PATH size */ - dwSize = MAX_PATH * sizeof(WCHAR); - if (RegQueryValueExW(hKey, CSIDL_Data[folder].szValueName, NULL, NULL, (LPBYTE)pszPath, &dwSize) == ERROR_SUCCESS) - { - RegCloseKey(hKey); - return S_OK; - } - RegCloseKey(hKey); - } - - if (CSIDL_Data[folder].szDefaultPath && - IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath)) - { - if (LoadStringW(shell32_hInstance, - LOWORD(CSIDL_Data[folder].szDefaultPath), resourcePath, MAX_PATH)) - { - hr = S_OK; - pDefaultPath = resourcePath; - } - else - { - FIXME("(%d,%s), LoadString failed, missing translation?\n", folder, - debugstr_w(pszPath)); - hr = E_FAIL; - } - } - else - { - hr = S_OK; - pDefaultPath = CSIDL_Data[folder].szDefaultPath; - } - if (SUCCEEDED(hr)) - { - switch (CSIDL_Data[folder].type) - { - case CSIDL_Type_User: - wcscpy(pszPath, UserProfileW); - break; - case CSIDL_Type_AllUsers: - wcscpy(pszPath, AllUsersProfileW); - break; - case CSIDL_Type_CurrVer: - wcscpy(pszPath, SystemDriveW); - break; - default: - ; /* no corresponding env. var, do nothing */ - } - if (pDefaultPath) - { - PathAddBackslashW(pszPath); - wcscat(pszPath, pDefaultPath); - } - } - TRACE("returning 0x%08x\n", hr); - return hr; -} - -/* Gets the (unexpanded) value of the folder with index folder into pszPath. - * The folder's type is assumed to be CSIDL_Type_CurrVer. Its default value - * can be overridden in the HKLM\\szCurrentVersion key. - * If dwFlags has SHGFP_TYPE_DEFAULT set or if the value isn't overridden in - * the registry, uses _SHGetDefaultValue to get the value. - */ -static HRESULT _SHGetCurrentVersionPath(DWORD dwFlags, BYTE folder, - LPWSTR pszPath) -{ - HRESULT hr; - - TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath); - - if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0])) - return E_INVALIDARG; - if (CSIDL_Data[folder].type != CSIDL_Type_CurrVer) - return E_INVALIDARG; - if (!pszPath) - return E_INVALIDARG; - - if (dwFlags & SHGFP_TYPE_DEFAULT) - hr = _SHGetDefaultValue(folder, pszPath); - else - { - HKEY hKey; - DWORD dwDisp; - - if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, szCurrentVersion, 0, - NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp)) - hr = E_FAIL; - else - { - DWORD dwType, dwPathLen = MAX_PATH * sizeof(WCHAR); - - if (RegQueryValueExW(hKey, CSIDL_Data[folder].szValueName, NULL, - &dwType, (LPBYTE)pszPath, &dwPathLen) || - (dwType != REG_SZ && dwType != REG_EXPAND_SZ)) - { - hr = _SHGetDefaultValue(folder, pszPath); - dwType = REG_EXPAND_SZ; - RegSetValueExW(hKey, CSIDL_Data[folder].szValueName, 0, dwType, - (LPBYTE)pszPath, (wcslen(pszPath)+1)*sizeof(WCHAR)); - } - else - { - pszPath[dwPathLen / sizeof(WCHAR)] = '\0'; - hr = S_OK; - } - RegCloseKey(hKey); - } - } - TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath)); - return hr; -} - -/* Gets the user's path (unexpanded) for the CSIDL with index folder: - * If SHGFP_TYPE_DEFAULT is set, calls _SHGetDefaultValue for it. Otherwise - * calls _SHGetUserShellFolderPath for it. Where it looks depends on hToken: - * - if hToken is -1, looks in HKEY_USERS\.Default - * - otherwise looks first in HKEY_CURRENT_USER, followed by HKEY_LOCAL_MACHINE - * if HKEY_CURRENT_USER doesn't contain any entries. If both fail, finally - * calls _SHGetDefaultValue for it. - */ -static HRESULT _SHGetUserProfilePath(HANDLE hToken, DWORD dwFlags, BYTE folder, - LPWSTR pszPath) -{ - HRESULT hr; - - TRACE("%p,0x%08x,0x%02x,%p\n", hToken, dwFlags, folder, pszPath); - - if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0])) - return E_INVALIDARG; - - if (CSIDL_Data[folder].type != CSIDL_Type_User) - return E_INVALIDARG; - - if (!pszPath) - return E_INVALIDARG; - - if (dwFlags & SHGFP_TYPE_DEFAULT) - { - hr = _SHGetDefaultValue(folder, pszPath); - } - else - { - LPWSTR userPrefix; - HKEY hRootKey; - - if (hToken == (HANDLE)-1) - { - /* Get the folder of the default user */ - hRootKey = HKEY_USERS; - userPrefix = (LPWSTR)DefaultW; - } - else if(!hToken) - { - /* Get the folder of the current user */ - hRootKey = HKEY_CURRENT_USER; - userPrefix = NULL; - } - else - { - /* Get the folder of the specified user */ - DWORD InfoLength; - PTOKEN_USER UserInfo; - - hRootKey = HKEY_USERS; - - GetTokenInformation(hToken, TokenUser, NULL, 0, &InfoLength); - UserInfo = (PTOKEN_USER)HeapAlloc(GetProcessHeap(), 0, InfoLength); - - if(!GetTokenInformation(hToken, TokenUser, UserInfo, InfoLength, &InfoLength)) - { - WARN("GetTokenInformation failed for %x!\n", hToken); - HeapFree(GetProcessHeap(), 0, UserInfo); - return E_FAIL; - } - - if(!ConvertSidToStringSidW(UserInfo->User.Sid, &userPrefix)) - { - WARN("ConvertSidToStringSidW failed for %x!\n", hToken); - HeapFree(GetProcessHeap(), 0, UserInfo); - return E_FAIL; - } - - HeapFree(GetProcessHeap(), 0, UserInfo); - } - - hr = _SHGetUserShellFolderPath(hRootKey, userPrefix, CSIDL_Data[folder].szValueName, pszPath); - - /* Free the memory allocated by ConvertSidToStringSidW */ - if(hToken && hToken != (HANDLE)-1) - LocalFree(userPrefix); - - if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE) - hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, NULL, CSIDL_Data[folder].szValueName, pszPath); - - if (FAILED(hr)) - hr = _SHGetDefaultValue(folder, pszPath); - } - - TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath)); - return hr; -} - -/* Gets the (unexpanded) path for the CSIDL with index folder. If dwFlags has - * SHGFP_TYPE_DEFAULT set, calls _SHGetDefaultValue. Otherwise calls - * _SHGetUserShellFolderPath for it, looking only in HKEY_LOCAL_MACHINE. - * If this fails, falls back to _SHGetDefaultValue. - */ -static HRESULT _SHGetAllUsersProfilePath(DWORD dwFlags, BYTE folder, - LPWSTR pszPath) -{ - HRESULT hr; - - TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath); - - if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0])) - return E_INVALIDARG; - if (CSIDL_Data[folder].type != CSIDL_Type_AllUsers) - return E_INVALIDARG; - if (!pszPath) - return E_INVALIDARG; - - if (dwFlags & SHGFP_TYPE_DEFAULT) - hr = _SHGetDefaultValue(folder, pszPath); - else - { - hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, NULL, - CSIDL_Data[folder].szValueName, pszPath); - if (FAILED(hr)) - hr = _SHGetDefaultValue(folder, pszPath); - } - TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath)); - return hr; -} - -/************************************************************************* - * SHGetFolderPathW [SHELL32.@] - * - * Convert nFolder to path. - * - * RETURNS - * Success: S_OK - * Failure: standard HRESULT error codes. - * - * NOTES - * Most values can be overridden in either - * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders - * or in the same location in HKLM. - * The "Shell Folders" registry key was used in NT4 and earlier systems. - * Beginning with Windows 2000, the "User Shell Folders" key is used, so - * changes made to it are made to the former key too. This synchronization is - * done on-demand: not until someone requests the value of one of these paths - * (by calling one of the SHGet functions) is the value synchronized. - * Furthermore, the HKCU paths take precedence over the HKLM paths. - */ -HRESULT WINAPI SHGetFolderPathW( - HWND hwndOwner, /* [I] owner window */ - int nFolder, /* [I] CSIDL identifying the folder */ - HANDLE hToken, /* [I] access token */ - DWORD dwFlags, /* [I] which path to return */ - LPWSTR pszPath) /* [O] converted path */ -{ - HRESULT hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, NULL, pszPath); - if(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == hr) - hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); - return hr; -} - -HRESULT WINAPI SHGetFolderPathAndSubDirA( - HWND hwndOwner, /* [I] owner window */ - int nFolder, /* [I] CSIDL identifying the folder */ - HANDLE hToken, /* [I] access token */ - DWORD dwFlags, /* [I] which path to return */ - LPCSTR pszSubPath, /* [I] sub directory of the specified folder */ - LPSTR pszPath) /* [O] converted path */ -{ - int length; - HRESULT hr = S_OK; - LPWSTR pszSubPathW = NULL; - LPWSTR pszPathW = NULL; - TRACE("%08x,%08x,%s\n",nFolder, dwFlags, debugstr_w(pszSubPathW)); - - if(pszPath) { - pszPathW = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR)); - if(!pszPathW) { - hr = HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY); - goto cleanup; - } - } - TRACE("%08x,%08x,%s\n",nFolder, dwFlags, debugstr_w(pszSubPathW)); - - /* SHGetFolderPathAndSubDirW does not distinguish if pszSubPath isn't - * set (null), or an empty string.therefore call it without the parameter set - * if pszSubPath is an empty string - */ - if (pszSubPath && pszSubPath[0]) { - length = MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, NULL, 0); - pszSubPathW = HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR)); - if(!pszSubPathW) { - hr = HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY); - goto cleanup; - } - MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, pszSubPathW, length); - } - - hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, pszSubPathW, pszPathW); - - if (SUCCEEDED(hr) && pszPath) - WideCharToMultiByte(CP_ACP, 0, pszPathW, -1, pszPath, MAX_PATH, NULL, NULL); - -cleanup: - HeapFree(GetProcessHeap(), 0, pszPathW); - HeapFree(GetProcessHeap(), 0, pszSubPathW); - return hr; -} - -HRESULT WINAPI SHGetFolderPathAndSubDirW( - HWND hwndOwner, /* [I] owner window */ - int nFolder, /* [I] CSIDL identifying the folder */ - HANDLE hToken, /* [I] access token */ - DWORD dwFlags, /* [I] which path to return */ - LPCWSTR pszSubPath,/* [I] sub directory of the specified folder */ - LPWSTR pszPath) /* [O] converted path */ -{ - HRESULT hr; - WCHAR szBuildPath[MAX_PATH], szTemp[MAX_PATH]; - DWORD folder = nFolder & CSIDL_FOLDER_MASK; //FIXME - CSIDL_Type type; - int ret; - - TRACE("%p,%p,nFolder=0x%04x,%s\n", hwndOwner,pszPath,nFolder,debugstr_w(pszSubPath)); - - /* Windows always NULL-terminates the resulting path regardless of success - * or failure, so do so first - */ - if (pszPath) - *pszPath = '\0'; - - if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0])) - return E_INVALIDARG; - if ((SHGFP_TYPE_CURRENT != dwFlags) && (SHGFP_TYPE_DEFAULT != dwFlags)) - return E_INVALIDARG; - szTemp[0] = 0; - type = CSIDL_Data[folder].type; - switch (type) - { - case CSIDL_Type_Disallowed: - hr = E_INVALIDARG; - break; - case CSIDL_Type_NonExistent: - hr = S_FALSE; - break; - case CSIDL_Type_WindowsPath: - GetWindowsDirectoryW(szTemp, MAX_PATH); - if (CSIDL_Data[folder].szDefaultPath && - !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) && - *CSIDL_Data[folder].szDefaultPath) - { - PathAddBackslashW(szTemp); - wcscat(szTemp, CSIDL_Data[folder].szDefaultPath); - } - hr = S_OK; - break; - case CSIDL_Type_SystemPath: - GetSystemDirectoryW(szTemp, MAX_PATH); - if (CSIDL_Data[folder].szDefaultPath && - !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) && - *CSIDL_Data[folder].szDefaultPath) - { - PathAddBackslashW(szTemp); - wcscat(szTemp, CSIDL_Data[folder].szDefaultPath); - } - hr = S_OK; - break; - case CSIDL_Type_CurrVer: - hr = _SHGetCurrentVersionPath(dwFlags, folder, szTemp); - break; - case CSIDL_Type_User: - hr = _SHGetUserProfilePath(hToken, dwFlags, folder, szTemp); - break; - case CSIDL_Type_AllUsers: - hr = _SHGetAllUsersProfilePath(dwFlags, folder, szTemp); - break; - default: - FIXME("bogus type %d, please fix\n", type); - hr = E_INVALIDARG; - break; - } - - /* Expand environment strings if necessary */ - if (*szTemp == '%') - { - DWORD ExpandRet = ExpandEnvironmentStringsW(szTemp, szBuildPath, MAX_PATH); - - if (ExpandRet > MAX_PATH) - hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - else if (ExpandRet == 0) - hr = HRESULT_FROM_WIN32(GetLastError()); - else - hr = S_OK; - } - else - { - wcscpy(szBuildPath, szTemp); - } - - if (FAILED(hr)) goto end; - - if(pszSubPath) { - /* make sure the new path does not exceed th bufferlength - * rememebr to backslash and the termination */ - if(MAX_PATH < (wcslen(szBuildPath) + wcslen(pszSubPath) + 2)) { - hr = HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE); - goto end; - } - PathAppendW(szBuildPath, pszSubPath); - PathRemoveBackslashW(szBuildPath); - } - /* Copy the path if it's available before we might return */ - if (SUCCEEDED(hr) && pszPath) - wcscpy(pszPath, szBuildPath); - - /* if we don't care about existing directories we are ready */ - if(nFolder & CSIDL_FLAG_DONT_VERIFY) goto end; - - if (PathFileExistsW(szBuildPath)) goto end; - - /* not existing but we are not allowed to create it. The return value - * is verified against shell32 version 6.0. - */ - if (!(nFolder & CSIDL_FLAG_CREATE)) - { - hr = HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND); - goto end; - } - - /* create directory/directories */ - ret = SHCreateDirectoryExW(hwndOwner, szBuildPath, NULL); - if (ret && ret != ERROR_ALREADY_EXISTS) - { - ERR("Failed to create directory %s.\n", debugstr_w(szBuildPath)); - hr = E_FAIL; - goto end; - } - - TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath)); -end: - TRACE("returning 0x%08x (final path is %s)\n", hr, debugstr_w(szBuildPath)); - return hr; -} - -/************************************************************************* - * SHGetFolderPathA [SHELL32.@] - * - * See SHGetFolderPathW. - */ -HRESULT WINAPI SHGetFolderPathA( - HWND hwndOwner, - int nFolder, - HANDLE hToken, - DWORD dwFlags, - LPSTR pszPath) -{ - WCHAR szTemp[MAX_PATH]; - HRESULT hr; - - TRACE("%p,%p,nFolder=0x%04x\n",hwndOwner,pszPath,nFolder); - - if (pszPath) - *pszPath = '\0'; - hr = SHGetFolderPathW(hwndOwner, nFolder, hToken, dwFlags, szTemp); - if (SUCCEEDED(hr) && pszPath) - WideCharToMultiByte(CP_ACP, 0, szTemp, -1, pszPath, MAX_PATH, NULL, - NULL); - - return hr; -} - -/* For each folder in folders, if its value has not been set in the registry, - * calls _SHGetUserProfilePath or _SHGetAllUsersProfilePath (depending on the - * folder's type) to get the unexpanded value first. - * Writes the unexpanded value to User Shell Folders, and queries it with - * SHGetFolderPathW to force the creation of the directory if it doesn't - * already exist. SHGetFolderPathW also returns the expanded value, which - * this then writes to Shell Folders. - */ -static HRESULT _SHRegisterFolders(HKEY hRootKey, HANDLE hToken, - LPCWSTR szUserShellFolderPath, LPCWSTR szShellFolderPath, const UINT folders[], - UINT foldersLen) -{ - UINT i; - WCHAR path[MAX_PATH]; - HRESULT hr = S_OK; - HKEY hUserKey = NULL, hKey = NULL; - DWORD dwDisp, dwType, dwPathLen; - LONG ret; - - TRACE("%p,%p,%s,%p,%u\n", hRootKey, hToken, - debugstr_w(szUserShellFolderPath), folders, foldersLen); - - ret = RegCreateKeyExW(hRootKey, szUserShellFolderPath, 0, NULL, 0, - KEY_ALL_ACCESS, NULL, &hUserKey, &dwDisp); - if (ret) - hr = HRESULT_FROM_WIN32(ret); - else - { - ret = RegCreateKeyExW(hRootKey, szShellFolderPath, 0, NULL, 0, - KEY_ALL_ACCESS, NULL, &hKey, &dwDisp); - if (ret) - hr = HRESULT_FROM_WIN32(ret); - } - for (i = 0; SUCCEEDED(hr) && i < foldersLen; i++) - { - dwPathLen = MAX_PATH * sizeof(WCHAR); - if (RegQueryValueExW(hUserKey, CSIDL_Data[folders[i]].szValueName, NULL, - &dwType, (LPBYTE)path, &dwPathLen) || (dwType != REG_SZ && - dwType != REG_EXPAND_SZ)) - { - *path = '\0'; - if (CSIDL_Data[folders[i]].type == CSIDL_Type_User) - _SHGetUserProfilePath(hToken, SHGFP_TYPE_DEFAULT, folders[i], - path); - else if (CSIDL_Data[folders[i]].type == CSIDL_Type_AllUsers) - _SHGetAllUsersProfilePath(SHGFP_TYPE_DEFAULT, folders[i], path); - else if (CSIDL_Data[folders[i]].type == CSIDL_Type_WindowsPath) - GetWindowsDirectoryW(path, MAX_PATH); - else - hr = E_FAIL; - if (*path) - { - ret = RegSetValueExW(hUserKey, - CSIDL_Data[folders[i]].szValueName, 0, REG_EXPAND_SZ, - (LPBYTE)path, (wcslen(path) + 1) * sizeof(WCHAR)); - if (ret) - hr = HRESULT_FROM_WIN32(ret); - else - { - hr = SHGetFolderPathW(NULL, folders[i] | CSIDL_FLAG_CREATE, - hToken, SHGFP_TYPE_DEFAULT, path); - ret = RegSetValueExW(hKey, - CSIDL_Data[folders[i]].szValueName, 0, REG_SZ, - (LPBYTE)path, (wcslen(path) + 1) * sizeof(WCHAR)); - if (ret) - hr = HRESULT_FROM_WIN32(ret); - } - } - } - } - if (hUserKey) - RegCloseKey(hUserKey); - if (hKey) - RegCloseKey(hKey); - - TRACE("returning 0x%08x\n", hr); - return hr; -} - -static HRESULT _SHRegisterUserShellFolders(BOOL bDefault) -{ - static const UINT folders[] = { - CSIDL_PROGRAMS, - CSIDL_PERSONAL, - CSIDL_FAVORITES, - CSIDL_APPDATA, - CSIDL_STARTUP, - CSIDL_RECENT, - CSIDL_SENDTO, - CSIDL_STARTMENU, - CSIDL_MYMUSIC, - CSIDL_MYVIDEO, - CSIDL_DESKTOPDIRECTORY, - CSIDL_NETHOOD, - CSIDL_TEMPLATES, - CSIDL_PRINTHOOD, - CSIDL_LOCAL_APPDATA, - CSIDL_INTERNET_CACHE, - CSIDL_COOKIES, - CSIDL_HISTORY, - CSIDL_MYPICTURES, - CSIDL_FONTS - }; - WCHAR userShellFolderPath[MAX_PATH], shellFolderPath[MAX_PATH]; - LPCWSTR pUserShellFolderPath, pShellFolderPath; - HRESULT hr = S_OK; - HKEY hRootKey; - HANDLE hToken; - - TRACE("%s\n", bDefault ? "TRUE" : "FALSE"); - if (bDefault) - { - hToken = (HANDLE)-1; - hRootKey = HKEY_USERS; - wcscpy(userShellFolderPath, DefaultW); - PathAddBackslashW(userShellFolderPath); - wcscat(userShellFolderPath, szSHUserFolders); - pUserShellFolderPath = userShellFolderPath; - wcscpy(shellFolderPath, DefaultW); - PathAddBackslashW(shellFolderPath); - wcscat(shellFolderPath, szSHFolders); - pShellFolderPath = shellFolderPath; - } - else - { - hToken = NULL; - hRootKey = HKEY_CURRENT_USER; - pUserShellFolderPath = szSHUserFolders; - pShellFolderPath = szSHFolders; - } - - hr = _SHRegisterFolders(hRootKey, hToken, pUserShellFolderPath, - pShellFolderPath, folders, sizeof(folders) / sizeof(folders[0])); - TRACE("returning 0x%08x\n", hr); - return hr; -} - -static HRESULT _SHRegisterCommonShellFolders(void) -{ - static const UINT folders[] = { - CSIDL_COMMON_STARTMENU, - CSIDL_COMMON_PROGRAMS, - CSIDL_COMMON_STARTUP, - CSIDL_COMMON_DESKTOPDIRECTORY, - CSIDL_COMMON_FAVORITES, - CSIDL_COMMON_APPDATA, - CSIDL_COMMON_TEMPLATES, - CSIDL_COMMON_DOCUMENTS, - }; - HRESULT hr; - - TRACE("\n"); - hr = _SHRegisterFolders(HKEY_LOCAL_MACHINE, NULL, szSHUserFolders, - szSHFolders, folders, sizeof(folders) / sizeof(folders[0])); - TRACE("returning 0x%08x\n", hr); - return hr; -} - -/****************************************************************************** - * _SHAppendToUnixPath [Internal] - * - * Helper function for _SHCreateSymbolicLinks. Appends pwszSubPath (or the - * corresponding resource, if IS_INTRESOURCE) to the unix base path 'szBasePath' - * and replaces backslashes with slashes. - * - * PARAMS - * szBasePath [IO] The unix base path, which will be appended to (CP_UNXICP). - * pwszSubPath [I] Sub-path or resource id (use MAKEINTRESOURCEW). - * - * RETURNS - * Success: TRUE, - * Failure: FALSE - */ -static BOOL __inline _SHAppendToUnixPath(char *szBasePath, LPCWSTR pwszSubPath) { - WCHAR wszSubPath[MAX_PATH]; - int cLen = strlen(szBasePath); - char *pBackslash; - - if (IS_INTRESOURCE(pwszSubPath)) { - if (!LoadStringW(shell32_hInstance, LOWORD(pwszSubPath), wszSubPath, MAX_PATH)) { - /* Fall back to hard coded defaults. */ - switch (LOWORD(pwszSubPath)) { - case IDS_PERSONAL: - wcscpy(wszSubPath, PersonalW); - break; - case IDS_MYMUSIC: - wcscpy(wszSubPath, My_MusicW); - break; - case IDS_MYPICTURES: - wcscpy(wszSubPath, My_PicturesW); - break; - case IDS_MYVIDEO: - wcscpy(wszSubPath, My_VideoW); - break; - default: - ERR("LoadString(%d) failed!\n", LOWORD(pwszSubPath)); - return FALSE; - } - } - } else { - wcscpy(wszSubPath, pwszSubPath); - } - - if (szBasePath[cLen-1] != '/') szBasePath[cLen++] = '/'; - - if (!WideCharToMultiByte(CP_ACP, 0, wszSubPath, -1, szBasePath + cLen, - FILENAME_MAX - cLen, NULL, NULL)) - { - return FALSE; - } - - pBackslash = szBasePath + cLen; - while ((pBackslash = strchr(pBackslash, '\\'))) *pBackslash = '/'; - - return TRUE; -} -#if 0 -/****************************************************************************** - * _SHCreateSymbolicLinks [Internal] - * - * Sets up symbol links for various shell folders to point into the users home - * directory. We do an educated guess about what the user would probably want: - * - If there is a 'My Documents' directory in $HOME, the user probably wants - * wine's 'My Documents' to point there. Furthermore, we imply that the user - * is a Windows lover and has no problem with wine creating 'My Pictures', - * 'My Music' and 'My Video' subfolders under '$HOME/My Documents', if those - * do not already exits. We put appropriate symbolic links in place for those, - * too. - * - If there is no 'My Documents' directory in $HOME, we let 'My Documents' - * point directly to $HOME. We assume the user to be a unix hacker who does not - * want wine to create anything anywhere besides the .wine directory. So, if - * there already is a 'My Music' directory in $HOME, we symlink the 'My Music' - * shell folder to it. But if not, we symlink it to $HOME directly. The same - * holds fo 'My Pictures' and 'My Video'. - * - The Desktop shell folder is symlinked to '$HOME/Desktop', if that does - * exists and left alone if not. - * ('My Music',... above in fact means LoadString(IDS_MYMUSIC)) - */ -static void _SHCreateSymbolicLinks(void) -{ - UINT aidsMyStuff[] = { IDS_MYPICTURES, IDS_MYVIDEO, IDS_MYMUSIC }, i; - int acsidlMyStuff[] = { CSIDL_MYPICTURES, CSIDL_MYVIDEO, CSIDL_MYMUSIC }; - WCHAR wszTempPath[MAX_PATH]; - char szPersonalTarget[FILENAME_MAX], *pszPersonal; - char szMyStuffTarget[FILENAME_MAX], *pszMyStuff; - char szDesktopTarget[FILENAME_MAX], *pszDesktop; - struct stat statFolder; - const char *pszHome; - HRESULT hr; - - /* Create all necessary profile sub-dirs up to 'My Documents' and get the unix path. */ - hr = SHGetFolderPathW(NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL, - SHGFP_TYPE_DEFAULT, wszTempPath); - if (FAILED(hr)) return; - pszPersonal = wine_get_unix_file_name(wszTempPath); - if (!pszPersonal) return; - - pszHome = getenv("HOME"); - if (pszHome && !stat(pszHome, &statFolder) && S_ISDIR(statFolder.st_mode)) { - strcpy(szPersonalTarget, pszHome); - if (_SHAppendToUnixPath(szPersonalTarget, MAKEINTRESOURCEW(IDS_PERSONAL)) && - !stat(szPersonalTarget, &statFolder) && S_ISDIR(statFolder.st_mode)) - { - /* '$HOME/My Documents' exists. Create 'My Pictures', 'My Videos' and - * 'My Music' subfolders or fail silently if they already exist. */ - for (i = 0; i < sizeof(aidsMyStuff)/sizeof(aidsMyStuff[0]); i++) { - strcpy(szMyStuffTarget, szPersonalTarget); - if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i]))) - mkdir(szMyStuffTarget); - } - } - else - { - /* '$HOME/My Documents' doesn't exists, but '$HOME' does. */ - strcpy(szPersonalTarget, pszHome); - } - - /* Replace 'My Documents' directory with a symlink of fail silently if not empty. */ - rmdir(pszPersonal); - symlink(szPersonalTarget, pszPersonal); - } - else - { - /* '$HOME' doesn't exist. Create 'My Pictures', 'My Videos' and 'My Music' subdirs - * in '%USERPROFILE%\\My Documents' or fail silently if they already exist. */ - strcpy(szPersonalTarget, pszPersonal); - for (i = 0; i < sizeof(aidsMyStuff)/sizeof(aidsMyStuff[0]); i++) { - strcpy(szMyStuffTarget, szPersonalTarget); - if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i]))) - mkdir(szMyStuffTarget); - } - } - - /* Create symbolic links for 'My Pictures', 'My Video' and 'My Music'. */ - for (i=0; i < sizeof(aidsMyStuff)/sizeof(aidsMyStuff[0]); i++) { - /* Create the current 'My Whatever' folder and get it's unix path. */ - hr = SHGetFolderPathW(NULL, acsidlMyStuff[i]|CSIDL_FLAG_CREATE, NULL, - SHGFP_TYPE_DEFAULT, wszTempPath); - if (FAILED(hr)) continue; - pszMyStuff = wine_get_unix_file_name(wszTempPath); - if (!pszMyStuff) continue; - - strcpy(szMyStuffTarget, szPersonalTarget); - if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])) && - !stat(szMyStuffTarget, &statFolder) && S_ISDIR(statFolder.st_mode)) - { - /* If there's a 'My Whatever' directory where 'My Documents' links to, link to it. */ - rmdir(pszMyStuff); - symlink(szMyStuffTarget, pszMyStuff); - } - else - { - /* Else link to where 'My Documents' itself links to. */ - rmdir(pszMyStuff); - symlink(szPersonalTarget, pszMyStuff); - } - HeapFree(GetProcessHeap(), 0, pszMyStuff); - } - - /* Last but not least, the Desktop folder */ - if (pszHome) - strcpy(szDesktopTarget, pszHome); - else - strcpy(szDesktopTarget, pszPersonal); - HeapFree(GetProcessHeap(), 0, pszPersonal); - - if (_SHAppendToUnixPath(szDesktopTarget, DesktopW) && - !stat(szDesktopTarget, &statFolder) && S_ISDIR(statFolder.st_mode)) - { - hr = SHGetFolderPathW(NULL, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, NULL, - SHGFP_TYPE_DEFAULT, wszTempPath); - if (SUCCEEDED(hr) && (pszDesktop = wine_get_unix_file_name(wszTempPath))) - { - rmdir(pszDesktop); - symlink(szDesktopTarget, pszDesktop); - HeapFree(GetProcessHeap(), 0, pszDesktop); - } - } -} -#endif - -/* Register the default values in the registry, as some apps seem to depend - * on their presence. The set registered was taken from Windows XP. - */ -HRESULT SHELL_RegisterShellFolders(void) -{ - HRESULT hr; - - /* Set up '$HOME' targeted symlinks for 'My Documents', 'My Pictures', - * 'My Video', 'My Music' and 'Desktop' in advance, so that the - * _SHRegister*ShellFolders() functions will find everything nice and clean - * and thus will not attempt to create them in the profile directory. */ -#if 0 - _SHCreateSymbolicLinks(); -#endif - - hr = _SHRegisterUserShellFolders(TRUE); - if (SUCCEEDED(hr)) - hr = _SHRegisterUserShellFolders(FALSE); - if (SUCCEEDED(hr)) - hr = _SHRegisterCommonShellFolders(); - return hr; -} - -/************************************************************************* - * SHGetSpecialFolderPathA [SHELL32.@] - */ -BOOL WINAPI SHGetSpecialFolderPathA ( - HWND hwndOwner, - LPSTR szPath, - int nFolder, - BOOL bCreate) -{ - return (SHGetFolderPathA( - hwndOwner, - nFolder + (bCreate ? CSIDL_FLAG_CREATE : 0), - NULL, - 0, - szPath)) == S_OK ? TRUE : FALSE; -} - -/************************************************************************* - * SHGetSpecialFolderPathW - */ -BOOL WINAPI SHGetSpecialFolderPathW ( - HWND hwndOwner, - LPWSTR szPath, - int nFolder, - BOOL bCreate) -{ - return (SHGetFolderPathW( - hwndOwner, - nFolder + (bCreate ? CSIDL_FLAG_CREATE : 0), - NULL, - 0, - szPath)) == S_OK ? TRUE : FALSE; -} - -/************************************************************************* - * SHGetFolderLocation [SHELL32.@] - * - * Gets the folder locations from the registry and creates a pidl. - * - * PARAMS - * hwndOwner [I] - * nFolder [I] CSIDL_xxxxx - * hToken [I] token representing user, or NULL for current user, or -1 for - * default user - * dwReserved [I] must be zero - * ppidl [O] PIDL of a special folder - * - * RETURNS - * Success: S_OK - * Failure: Standard OLE-defined error result, S_FALSE or E_INVALIDARG - * - * NOTES - * Creates missing reg keys and directories. - * Mostly forwards to SHGetFolderPathW, but a few values of nFolder return - * virtual folders that are handled here. - */ -HRESULT WINAPI SHGetFolderLocation( - HWND hwndOwner, - int nFolder, - HANDLE hToken, - DWORD dwReserved, - LPITEMIDLIST *ppidl) -{ - HRESULT hr = E_INVALIDARG; - - TRACE("%p 0x%08x %p 0x%08x %p\n", - hwndOwner, nFolder, hToken, dwReserved, ppidl); - - if (!ppidl) - return E_INVALIDARG; - if (dwReserved) - return E_INVALIDARG; - - /* The virtual folders' locations are not user-dependent */ - *ppidl = NULL; - switch (nFolder) - { - case CSIDL_DESKTOP: - *ppidl = _ILCreateDesktop(); - break; - - case CSIDL_PERSONAL: - *ppidl = _ILCreateMyDocuments(); - break; - - case CSIDL_INTERNET: - *ppidl = _ILCreateIExplore(); - break; - - case CSIDL_CONTROLS: - *ppidl = _ILCreateControlPanel(); - break; - - case CSIDL_PRINTERS: - *ppidl = _ILCreatePrinters(); - break; - - case CSIDL_BITBUCKET: - *ppidl = _ILCreateBitBucket(); - break; - - case CSIDL_DRIVES: - *ppidl = _ILCreateMyComputer(); - break; - - case CSIDL_NETWORK: - *ppidl = _ILCreateNetwork(); - break; - - default: - { - WCHAR szPath[MAX_PATH]; - - hr = SHGetFolderPathW(hwndOwner, nFolder, hToken, - SHGFP_TYPE_CURRENT, szPath); - if (SUCCEEDED(hr)) - { - DWORD attributes=0; - - TRACE("Value=%s\n", debugstr_w(szPath)); - hr = SHILCreateFromPathW(szPath, ppidl, &attributes); - } - else if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) - { - /* unlike SHGetFolderPath, SHGetFolderLocation in shell32 - * version 6.0 returns E_FAIL for nonexistent paths - */ - hr = E_FAIL; - } - } - } - if(*ppidl) - hr = NOERROR; - - TRACE("-- (new pidl %p)\n",*ppidl); - return hr; -} - -/************************************************************************* - * SHGetSpecialFolderLocation [SHELL32.@] - * - * NOTES - * In NT5, SHGetSpecialFolderLocation needs the /Recent - * directory. - */ -HRESULT WINAPI SHGetSpecialFolderLocation( - HWND hwndOwner, - INT nFolder, - LPITEMIDLIST * ppidl) -{ - HRESULT hr = E_INVALIDARG; - - TRACE("(%p,0x%x,%p)\n", hwndOwner,nFolder,ppidl); - - if (!ppidl) - return E_INVALIDARG; - - hr = SHGetFolderLocation(hwndOwner, nFolder, NULL, 0, ppidl); - return hr; -} diff --git a/reactos/dll/win32/shell32/shellreg.c b/reactos/dll/win32/shell32/shellreg.c deleted file mode 100644 index 812566cd7fd..00000000000 --- a/reactos/dll/win32/shell32/shellreg.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Shell Registry Access - * - * Copyright 2000 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -/************************************************************************* - * SHRegOpenKeyA [SHELL32.506] - * - */ -HRESULT WINAPI SHRegOpenKeyA( - HKEY hKey, - LPSTR lpSubKey, - PHKEY phkResult) -{ - TRACE("(%p, %s, %p)\n", hKey, debugstr_a(lpSubKey), phkResult); - return RegOpenKeyA(hKey, lpSubKey, phkResult); -} - -/************************************************************************* - * SHRegOpenKeyW [SHELL32.507] NT 4.0 - * - */ -HRESULT WINAPI SHRegOpenKeyW ( - HKEY hkey, - LPCWSTR lpszSubKey, - PHKEY retkey) -{ - WARN("%p %s %p\n",hkey,debugstr_w(lpszSubKey),retkey); - return RegOpenKeyW( hkey, lpszSubKey, retkey ); -} - -/************************************************************************* - * SHRegQueryValueA [SHELL32.508] - * - */ -HRESULT WINAPI SHRegQueryValueA(HKEY hkey, LPSTR lpSubKey, LPSTR lpValue, LPDWORD lpcbValue) -{ - TRACE("(%p %s %p %p)\n", hkey, debugstr_a(lpSubKey), lpValue, lpcbValue); - return RegQueryValueA(hkey, lpSubKey, lpValue, (LONG*)lpcbValue); -} - -/************************************************************************* - * SHRegQueryValueExA [SHELL32.509] - * - */ -HRESULT WINAPI SHRegQueryValueExA( - HKEY hkey, - LPSTR lpValueName, - LPDWORD lpReserved, - LPDWORD lpType, - LPBYTE lpData, - LPDWORD lpcbData) -{ - TRACE("%p %s %p %p %p %p\n", hkey, lpValueName, lpReserved, lpType, lpData, lpcbData); - return RegQueryValueExA (hkey, lpValueName, lpReserved, lpType, lpData, lpcbData); -} - -/************************************************************************* - * SHRegQueryValueW [SHELL32.510] NT4.0 - * - */ -HRESULT WINAPI SHRegQueryValueW( - HKEY hkey, - LPWSTR lpszSubKey, - LPWSTR lpszData, - LPDWORD lpcbData ) -{ - WARN("%p %s %p %p semi-stub\n", - hkey, debugstr_w(lpszSubKey), lpszData, lpcbData); - return RegQueryValueW( hkey, lpszSubKey, lpszData, (LONG*)lpcbData ); -} - -/************************************************************************* - * SHRegQueryValueExW [SHELL32.511] NT4.0 - * - * FIXME - * if the datatype REG_EXPAND_SZ then expand the string and change - * *pdwType to REG_SZ. - */ -HRESULT WINAPI SHRegQueryValueExW ( - HKEY hkey, - LPWSTR pszValue, - LPDWORD pdwReserved, - LPDWORD pdwType, - LPVOID pvData, - LPDWORD pcbData) -{ - DWORD ret; - WARN("%p %s %p %p %p %p semi-stub\n", - hkey, debugstr_w(pszValue), pdwReserved, pdwType, pvData, pcbData); - ret = RegQueryValueExW ( hkey, pszValue, pdwReserved, pdwType, pvData, pcbData); - return ret; -} - -/************************************************************************* - * SHRegDeleteKeyA [SHELL32.?] - */ -HRESULT WINAPI SHRegDeleteKeyA( - HKEY hkey, - LPCSTR pszSubKey) -{ - FIXME("hkey=%p, %s\n", hkey, debugstr_a(pszSubKey)); - return 0; -} - -/************************************************************************* - * SHRegDeleteKeyW [SHELL32.512] - */ -HRESULT WINAPI SHRegDeleteKeyW( - HKEY hkey, - LPCWSTR pszSubKey) -{ - FIXME("hkey=%p, %s\n", hkey, debugstr_w(pszSubKey)); - return 0; -} - -/************************************************************************* - * SHRegCloseKey [SHELL32.505] NT 4.0 - * - */ -HRESULT WINAPI SHRegCloseKey (HKEY hkey) -{ - TRACE("%p\n",hkey); - return RegCloseKey( hkey ); -} diff --git a/reactos/dll/win32/shell32/shfldr_admintools.c b/reactos/dll/win32/shell32/shfldr_admintools.c deleted file mode 100644 index df02e28a1fa..00000000000 --- a/reactos/dll/win32/shell32/shfldr_admintools.c +++ /dev/null @@ -1,775 +0,0 @@ -/* - * Virtual Admin Tools Folder - * - * Copyright 2008 Johannes Anderwald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL (shell); - - -/* List shortcuts of - * CSIDL_COMMON_ADMINTOOLS - * Note: CSIDL_ADMINTOOLS is ignored, tested with Window XP SP3+ - */ - -/*********************************************************************** - * AdminTools folder implementation - */ - -typedef struct { - IShellFolder2Vtbl *lpVtbl; - IPersistFolder2Vtbl *lpVtblPersistFolder2; - - LONG ref; - - CLSID *pclsid; - - LPITEMIDLIST pidlRoot; /* absolute pidl */ - LPWSTR szTarget; - - int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */ -} IGenericSFImpl; - -static const shvheader AdminToolsSFHeader[] = { - {IDS_SHV_COLUMN8, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15}, - {IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10}, - {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10}, - {IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12} -}; - -#define COLUMN_NAME 0 -#define COLUMN_SIZE 1 -#define COLUMN_TYPE 2 -#define COLUMN_DATE 3 - -#define AdminToolsHELLVIEWCOLUMNS (4) - - -#define _IPersistFolder2_Offset ((INT_PTR)(&(((IGenericSFImpl*)0)->lpVtblPersistFolder2))) -#define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder2_Offset); - -#define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl) -#define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl) - -#define _IPersist_(This) (IPersist*)&(This->lpVtblPersistFolder2) -#define _IPersistFolder_(This) (IPersistFolder*)&(This->lpVtblPersistFolder2) -#define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpVtblPersistFolder2) - -/************************************************************************** - * ISF_AdminTools_fnQueryInterface - * - * NOTE does not support IPersist/IPersistFolder - */ -static HRESULT WINAPI ISF_AdminTools_fnQueryInterface( - IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj); - - *ppvObj = NULL; - - if (IsEqualIID (riid, &IID_IUnknown) || - IsEqualIID (riid, &IID_IShellFolder) || - IsEqualIID (riid, &IID_IShellFolder2)) - { - *ppvObj = This; - } - - else if (IsEqualIID (riid, &IID_IPersist) || - IsEqualIID (riid, &IID_IPersistFolder) || - IsEqualIID (riid, &IID_IPersistFolder2)) - { - *ppvObj = _IPersistFolder2_ (This); - } - - if (*ppvObj) - { - IUnknown_AddRef ((IUnknown *) (*ppvObj)); - TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj); - return S_OK; - } - TRACE ("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -static ULONG WINAPI ISF_AdminTools_fnAddRef (IShellFolder2 * iface) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE ("(%p)->(count=%lu)\n", This, refCount - 1); - - return refCount; -} - -static ULONG WINAPI ISF_AdminTools_fnRelease (IShellFolder2 * iface) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE ("(%p)->(count=%lu)\n", This, refCount + 1); - - if (!refCount) - { - TRACE ("-- destroying IShellFolder(%p)\n", This); - if (This->pidlRoot) - SHFree (This->pidlRoot); - HeapFree(GetProcessHeap(), 0, This->szTarget); - HeapFree(GetProcessHeap(), 0, This); - return 0; - } - return refCount; -} - -/************************************************************************** - * ISF_AdminTools_fnParseDisplayName - * - */ -static HRESULT WINAPI ISF_AdminTools_fnParseDisplayName (IShellFolder2 * iface, - HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, - DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", - This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName), - pchEaten, ppidl, pdwAttributes); - - *ppidl = 0; - if (pchEaten) - *pchEaten = 0; - - MessageBoxW(NULL, lpszDisplayName, L"ParseDisplayName", MB_OK); - - return E_NOTIMPL; -} - -/************************************************************************** - * CreateAdminToolsEnumList() - */ -static BOOL CreateAdminToolsEnumList(IEnumIDList *list, IGenericSFImpl *This, DWORD dwFlags) -{ - TRACE("(%p)->(flags=0x%08x)\n", list, dwFlags); - /* enumerate the elements in %windir%\desktop */ - return CreateFolderEnumList(list, This->szTarget, dwFlags); -} - -/************************************************************************** - * ISF_AdminTools_fnEnumObjects - */ -static HRESULT WINAPI ISF_AdminTools_fnEnumObjects (IShellFolder2 * iface, - HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", - This, hwndOwner, dwFlags, ppEnumIDList); - - if(!ppEnumIDList) return E_OUTOFMEMORY; - *ppEnumIDList = IEnumIDList_Constructor(); - if (*ppEnumIDList) - CreateAdminToolsEnumList(*ppEnumIDList, This, dwFlags); - - TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList); - - return (*ppEnumIDList) ? S_OK : E_OUTOFMEMORY; -} - -/************************************************************************** - * ISF_AdminTools_fnBindToObject - */ -static HRESULT WINAPI ISF_AdminTools_fnBindToObject (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, - pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); - - return SHELL32_BindToChild (This->pidlRoot, NULL, pidl, riid, ppvOut); -} - -/************************************************************************** - * ISF_AdminTools_fnBindToStorage - */ -static HRESULT WINAPI ISF_AdminTools_fnBindToStorage (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", - This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); - - *ppvOut = NULL; - return E_NOTIMPL; -} - -/************************************************************************** - * ISF_AdminTools_fnCompareIDs - */ -static HRESULT WINAPI ISF_AdminTools_fnCompareIDs (IShellFolder2 * iface, - LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - int nReturn; - - TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2); - nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2); - TRACE ("-- %i\n", nReturn); - return nReturn; -} - -/************************************************************************** - * ISF_AdminTools_fnCreateViewObject - */ -static HRESULT WINAPI ISF_AdminTools_fnCreateViewObject (IShellFolder2 * iface, - HWND hwndOwner, REFIID riid, LPVOID * ppvOut) -{ - - LPSHELLVIEW pShellView; - HRESULT hr = E_INVALIDARG; - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This, - hwndOwner, shdebugstr_guid (riid), ppvOut); - - if (!ppvOut) - return hr; - - *ppvOut = NULL; - - if (IsEqualIID (riid, &IID_IDropTarget)) - { - WARN ("IDropTarget not implemented\n"); - hr = E_NOTIMPL; - } - else if (IsEqualIID (riid, &IID_IShellView)) - { - pShellView = IShellView_Constructor ((IShellFolder *) iface); - if (pShellView) - { - hr = IShellView_QueryInterface (pShellView, riid, ppvOut); - IShellView_Release (pShellView); - } - } - TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut); - return hr; -} - -/************************************************************************** - * ISF_AdminTools_fnGetAttributesOf - */ -static HRESULT WINAPI ISF_AdminTools_fnGetAttributesOf (IShellFolder2 * iface, - UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - HRESULT hr = S_OK; - static const DWORD dwAdminToolsAttributes = - SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR | - SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM; - - TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n", - This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0); - - if (!rgfInOut) - return E_INVALIDARG; - if (cidl && !apidl) - return E_INVALIDARG; - - if (*rgfInOut == 0) - *rgfInOut = ~0; - - if(cidl == 0) { - *rgfInOut &= dwAdminToolsAttributes; - } else { - while (cidl > 0 && *apidl) { - pdump (*apidl); - if (_ILIsAdminTools(*apidl)) { - *rgfInOut &= dwAdminToolsAttributes; - } else { - SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut); - } - apidl++; - cidl--; - } - } - /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */ - *rgfInOut &= ~SFGAO_VALIDATE; - - TRACE ("-- result=0x%08x\n", *rgfInOut); - - return hr; -} - -/************************************************************************** - * ISF_AdminTools_fnGetUIObjectOf - * - * PARAMETERS - * HWND hwndOwner, //[in ] Parent window for any output - * UINT cidl, //[in ] array size - * LPCITEMIDLIST* apidl, //[in ] simple pidl array - * REFIID riid, //[in ] Requested Interface - * UINT* prgfInOut, //[ ] reserved - * LPVOID* ppvObject) //[out] Resulting Interface - * - */ -static HRESULT WINAPI ISF_AdminTools_fnGetUIObjectOf (IShellFolder2 * iface, - HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, - REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - LPITEMIDLIST pidl; - IUnknown *pObj = NULL; - HRESULT hr = E_INVALIDARG; - - TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", - This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut); - - if (!ppvOut) - return hr; - - *ppvOut = NULL; - - if (IsEqualIID (riid, &IID_IContextMenu)) - { - hr = CDefFolderMenu_Create2(This->pidlRoot, hwndOwner, cidl, apidl, (IShellFolder*)iface, NULL, 0, NULL, (IContextMenu**)&pObj); - } - else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) - { - pObj = (LPUNKNOWN) IDataObject_Constructor( hwndOwner, - This->pidlRoot, apidl, cidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) - { - hr = IShellFolder_QueryInterface (iface, - &IID_IDropTarget, (LPVOID *) & pObj); - } - else if ((IsEqualIID(riid,&IID_IShellLinkW) || - IsEqualIID(riid,&IID_IShellLinkA)) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj); - SHFree (pidl); - } - else - hr = E_NOINTERFACE; - - if (SUCCEEDED(hr) && !pObj) - hr = E_OUTOFMEMORY; - - *ppvOut = pObj; - TRACE ("(%p)->hr=0x%08x\n", This, hr); - return hr; -} - -/************************************************************************** - * ISF_AdminTools_fnGetDisplayNameOf - * - */ -static HRESULT WINAPI ISF_AdminTools_fnGetDisplayNameOf (IShellFolder2 * iface, - LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - HRESULT hr = S_OK; - LPWSTR pszPath, pOffset; - - - TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet); - pdump (pidl); - - if (!strRet) - return E_INVALIDARG; - - pszPath = CoTaskMemAlloc((MAX_PATH +1) * sizeof(WCHAR)); - if (!pszPath) - return E_OUTOFMEMORY; - - ZeroMemory(pszPath, (MAX_PATH +1) * sizeof(WCHAR)); - - if (_ILIsAdminTools (pidl)) - { - if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && - (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING)) - wcscpy(pszPath, This->szTarget); - else if (!HCR_GetClassNameW(&CLSID_AdminFolderShortcut, pszPath, MAX_PATH)) - hr = E_FAIL; - } - else if (_ILIsPidlSimple(pidl)) - { - if ((GET_SHGDN_FOR(dwFlags) & SHGDN_FORPARSING) && - (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER) && - This->szTarget) - { - wcscpy(pszPath, This->szTarget); - pOffset = PathAddBackslashW(pszPath); - if (pOffset) - { - if (!_ILSimpleGetTextW(pidl, pOffset, MAX_PATH + 1 - (pOffset - pszPath))) - hr = E_FAIL; - } - else - hr = E_FAIL; - } - else - { - if (_ILSimpleGetTextW(pidl, pszPath, MAX_PATH + 1)) - { - if (SHELL_FS_HideExtension(pszPath)) - PathRemoveExtensionW(pszPath); - } - else - hr = E_FAIL; - } - } - else if (_ILIsSpecialFolder(pidl)) - { - BOOL bSimplePidl = _ILIsPidlSimple(pidl); - - if (bSimplePidl) - { - if (!_ILSimpleGetTextW(pidl, pszPath, MAX_PATH)) - hr = E_FAIL; - } - else if ((dwFlags & SHGDN_FORPARSING) && !bSimplePidl) - { - int len = 0; - - wcscpy(pszPath, This->szTarget); - PathAddBackslashW(pszPath); - len = wcslen(pszPath); - - if (!SUCCEEDED(SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags | SHGDN_INFOLDER, pszPath + len, MAX_PATH + 1 - len))) - { - CoTaskMemFree(pszPath); - return E_OUTOFMEMORY; - } - - } - } - - if (SUCCEEDED(hr)) - { - strRet->uType = STRRET_WSTR; - strRet->u.pOleStr = pszPath; - TRACE ("-- (%p)->(%s,0x%08x)\n", This, debugstr_w(strRet->u.pOleStr), hr); - } - else - CoTaskMemFree(pszPath); - - return hr; -} - -/************************************************************************** - * ISF_AdminTools_fnSetNameOf - * Changes the name of a file object or subfolder, possibly changing its item - * identifier in the process. - * - * PARAMETERS - * HWND hwndOwner, //[in ] Owner window for output - * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change - * LPCOLESTR lpszName, //[in ] the items new display name - * DWORD dwFlags, //[in ] SHGNO formatting flags - * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned - */ -static HRESULT WINAPI ISF_AdminTools_fnSetNameOf (IShellFolder2 * iface, - HWND hwndOwner, LPCITEMIDLIST pidl, /* simple pidl */ - LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, - debugstr_w (lpName), dwFlags, pPidlOut); - - return E_FAIL; -} - -static HRESULT WINAPI ISF_AdminTools_fnGetDefaultSearchGUID(IShellFolder2 *iface, - GUID * pguid) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_AdminTools_fnEnumSearches (IShellFolder2 *iface, - IEnumExtraSearch ** ppenum) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_AdminTools_fnGetDefaultColumn (IShellFolder2 * iface, - DWORD dwRes, ULONG * pSort, ULONG * pDisplay) -{ - if (pSort) - *pSort = 0; - if (pDisplay) - *pDisplay = 0; - - return S_OK; -} -static HRESULT WINAPI ISF_AdminTools_fnGetDefaultColumnState ( - IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags) -{ - if (!pcsFlags || iColumn >= AdminToolsHELLVIEWCOLUMNS) - return E_INVALIDARG; - *pcsFlags = AdminToolsSFHeader[iColumn].pcsFlags; - return S_OK; - -} - -static HRESULT WINAPI ISF_AdminTools_fnGetDetailsEx (IShellFolder2 * iface, - LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p): stub\n", This); - - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_AdminTools_fnGetDetailsOf (IShellFolder2 * iface, - LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - WCHAR buffer[MAX_PATH] = {0}; - HRESULT hr = E_FAIL; - - TRACE("(%p)->(%p %i %p): stub\n", This, pidl, iColumn, psd); - - if (iColumn >= AdminToolsHELLVIEWCOLUMNS) - return E_FAIL; - - psd->fmt = AdminToolsSFHeader[iColumn].fmt; - psd->cxChar = AdminToolsSFHeader[iColumn].cxChar; - if (pidl == NULL) - { - psd->str.uType = STRRET_WSTR; - if (LoadStringW(shell32_hInstance, AdminToolsSFHeader[iColumn].colnameid, buffer, MAX_PATH)) - hr = SHStrDupW(buffer, &psd->str.u.pOleStr); - - return hr; - } - - psd->str.uType = STRRET_CSTR; - switch (iColumn) - { - case COLUMN_NAME: - psd->str.uType = STRRET_WSTR; - hr = IShellFolder_GetDisplayNameOf(iface, pidl, - SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); - break; - case COLUMN_SIZE: - _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH); - break; - case COLUMN_TYPE: - _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH); - break; - case COLUMN_DATE: - _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH); - break; - } - - return hr; -} - -static HRESULT WINAPI ISF_AdminTools_fnMapColumnToSCID ( - IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p): stub\n", This); - return E_NOTIMPL; -} - -static IShellFolder2Vtbl vt_ShellFolder2 = -{ - ISF_AdminTools_fnQueryInterface, - ISF_AdminTools_fnAddRef, - ISF_AdminTools_fnRelease, - ISF_AdminTools_fnParseDisplayName, - ISF_AdminTools_fnEnumObjects, - ISF_AdminTools_fnBindToObject, - ISF_AdminTools_fnBindToStorage, - ISF_AdminTools_fnCompareIDs, - ISF_AdminTools_fnCreateViewObject, - ISF_AdminTools_fnGetAttributesOf, - ISF_AdminTools_fnGetUIObjectOf, - ISF_AdminTools_fnGetDisplayNameOf, - ISF_AdminTools_fnSetNameOf, - /* ShellFolder2 */ - ISF_AdminTools_fnGetDefaultSearchGUID, - ISF_AdminTools_fnEnumSearches, - ISF_AdminTools_fnGetDefaultColumn, - ISF_AdminTools_fnGetDefaultColumnState, - ISF_AdminTools_fnGetDetailsEx, - ISF_AdminTools_fnGetDetailsOf, - ISF_AdminTools_fnMapColumnToSCID -}; - -/************************************************************************ - * IPF_AdminTools_QueryInterface - */ -static HRESULT WINAPI IPF_AdminTools_QueryInterface ( - IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObj) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)\n", This); - - return IUnknown_QueryInterface (_IUnknown_ (This), iid, ppvObj); -} - -/************************************************************************ - * IPF_AdminTools_AddRef - */ -static ULONG WINAPI IPF_AdminTools_AddRef (IPersistFolder2 * iface) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)->(count=%lu)\n", This, This->ref); - - return IUnknown_AddRef (_IUnknown_ (This)); -} - -/************************************************************************ - * IPF_AdminTools_Release - */ -static ULONG WINAPI IPF_AdminTools_Release (IPersistFolder2 * iface) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)->(count=%lu)\n", This, This->ref); - - return IUnknown_Release (_IUnknown_ (This)); -} - -/************************************************************************ - * IPF_AdminTools_GetClassID - */ -static HRESULT WINAPI IPF_AdminTools_GetClassID ( - IPersistFolder2 * iface, CLSID * lpClassId) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)\n", This); - - memcpy(lpClassId, &CLSID_AdminFolderShortcut, sizeof(CLSID)); - - return S_OK; -} - -/************************************************************************ - * IPF_AdminTools_Initialize - * - */ -static HRESULT WINAPI IPF_AdminTools_Initialize ( - IPersistFolder2 * iface, LPCITEMIDLIST pidl) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - if (This->pidlRoot) - SHFree((LPVOID)This->pidlRoot); - - This->pidlRoot = ILClone(pidl); - return S_OK; -} - -/************************************************************************** - * IPF_AdminTools_fnGetCurFolder - */ -static HRESULT WINAPI IPF_AdminTools_GetCurFolder ( - IPersistFolder2 * iface, LPITEMIDLIST * pidl) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)->(%p)\n", This, pidl); - - *pidl = ILClone (This->pidlRoot); - return S_OK; -} - -static IPersistFolder2Vtbl vt_PersistFolder2 = -{ - IPF_AdminTools_QueryInterface, - IPF_AdminTools_AddRef, - IPF_AdminTools_Release, - IPF_AdminTools_GetClassID, - IPF_AdminTools_Initialize, - IPF_AdminTools_GetCurFolder -}; - -/************************************************************************** - * ISF_AdminTools_Constructor - */ -HRESULT WINAPI ISF_AdminTools_Constructor ( - IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) -{ - IGenericSFImpl *sf; - HRESULT hr; - - TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid)); - - if (pUnkOuter) - return CLASS_E_NOAGGREGATION; - - sf = HeapAlloc( GetProcessHeap(), 0, sizeof(*sf) ); - if (!sf) - return E_OUTOFMEMORY; - - sf->szTarget = HeapAlloc( GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR) ); - if (!sf->szTarget) - { - HeapFree(GetProcessHeap(), 0, sf); - return E_OUTOFMEMORY; - } - if (!SHGetSpecialFolderPathW(NULL, sf->szTarget, CSIDL_COMMON_ADMINTOOLS, FALSE)) - { - HeapFree(GetProcessHeap(), 0, sf->szTarget); - HeapFree(GetProcessHeap(), 0, sf); - return E_FAIL; - } - - sf->ref = 1; - sf->lpVtbl = &vt_ShellFolder2; - sf->lpVtblPersistFolder2 = &vt_PersistFolder2; - sf->pidlRoot = _ILCreateAdminTools(); /* my qualified pidl */ - - hr = IUnknown_QueryInterface( _IUnknown_(sf), riid, ppv ); - IUnknown_Release( _IUnknown_(sf) ); - - TRACE ("--(%p)\n", *ppv); - return hr; -} diff --git a/reactos/dll/win32/shell32/shfldr_cpanel.c b/reactos/dll/win32/shell32/shfldr_cpanel.c deleted file mode 100644 index c9f5b932de6..00000000000 --- a/reactos/dll/win32/shell32/shfldr_cpanel.c +++ /dev/null @@ -1,1413 +0,0 @@ -/* - * Control panel folder - * - * Copyright 2003 Martin Fuchs - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - - -#include - - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -/*********************************************************************** -* control panel implementation in shell namespace -*/ - -typedef struct { - const IShellFolder2Vtbl *lpVtbl; - LONG ref; - const IPersistFolder2Vtbl *lpVtblPersistFolder2; - const IShellExecuteHookWVtbl *lpVtblShellExecuteHookW; - const IShellExecuteHookAVtbl *lpVtblShellExecuteHookA; - const IContextMenu2Vtbl *lpVtblContextMenu; - IUnknown *pUnkOuter; /* used for aggregation */ - - /* both paths are parsible from the desktop */ - LPITEMIDLIST pidlRoot; /* absolute pidl */ - int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */ - LPCITEMIDLIST *apidl; - UINT cidl; -} ICPanelImpl, *LPICPanelImpl; - -static const IShellFolder2Vtbl vt_ShellFolder2; -static const IPersistFolder2Vtbl vt_PersistFolder2; -static const IShellExecuteHookWVtbl vt_ShellExecuteHookW; -static const IShellExecuteHookAVtbl vt_ShellExecuteHookA; -static const IContextMenu2Vtbl vt_ContextMenu; - -static LPICPanelImpl __inline impl_from_IPersistFolder2( IPersistFolder2 *iface ) -{ - return (LPICPanelImpl)((char*)iface - FIELD_OFFSET(ICPanelImpl, lpVtblPersistFolder2)); -} - -static LPICPanelImpl __inline impl_from_IContextMenu( IContextMenu2 *iface ) -{ - return (LPICPanelImpl)((char*)iface - FIELD_OFFSET(ICPanelImpl, lpVtblContextMenu)); -} - - -static LPICPanelImpl __inline impl_from_IShellExecuteHookW( IShellExecuteHookW *iface ) -{ - return (LPICPanelImpl)((char*)iface - FIELD_OFFSET(ICPanelImpl, lpVtblShellExecuteHookW)); -} - -static LPICPanelImpl __inline impl_from_IShellExecuteHookA( IShellExecuteHookA *iface ) -{ - return (LPICPanelImpl)((char*)iface - FIELD_OFFSET(ICPanelImpl, lpVtblShellExecuteHookA)); -} - - -/* - converts This to an interface pointer -*/ -#define _IUnknown_(This) (IUnknown*)&(This->lpVtbl) -#define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl) -#define _IShellFolder2_(This) (IShellFolder2*)&(This->lpVtbl) - -#define _IPersist_(This) (IPersist*)&(This->lpVtblPersistFolder2) -#define _IPersistFolder_(This) (IPersistFolder*)&(This->lpVtblPersistFolder2) -#define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpVtblPersistFolder2) -#define _IShellExecuteHookW_(This) (IShellExecuteHookW*)&(This->lpVtblShellExecuteHookW) -#define _IShellExecuteHookA_(This) (IShellExecuteHookA*)&(This->lpVtblShellExecuteHookA) - - -/*********************************************************************** -* IShellFolder [ControlPanel] implementation -*/ - -static const shvheader ControlPanelSFHeader[] = { - {IDS_SHV_COLUMN8, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},/*FIXME*/ - {IDS_SHV_COLUMN9, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 200},/*FIXME*/ -}; - -#define CONROLPANELSHELLVIEWCOLUMNS 2 - -/************************************************************************** -* IControlPanel_Constructor -*/ -HRESULT WINAPI IControlPanel_Constructor(IUnknown* pUnkOuter, REFIID riid, LPVOID * ppv) -{ - ICPanelImpl *sf; - - TRACE("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid(riid)); - - if (!ppv) - return E_POINTER; - if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown)) - return CLASS_E_NOAGGREGATION; - - sf = (ICPanelImpl *) LocalAlloc(LMEM_ZEROINIT, sizeof(ICPanelImpl)); - if (!sf) - return E_OUTOFMEMORY; - - sf->ref = 0; - sf->apidl = NULL; - sf->cidl = 0; - sf->lpVtbl = &vt_ShellFolder2; - sf->lpVtblPersistFolder2 = &vt_PersistFolder2; - sf->lpVtblShellExecuteHookW = &vt_ShellExecuteHookW; - sf->lpVtblShellExecuteHookA = &vt_ShellExecuteHookA; - sf->lpVtblContextMenu = &vt_ContextMenu; - sf->pidlRoot = _ILCreateControlPanel(); /* my qualified pidl */ - sf->pUnkOuter = pUnkOuter ? pUnkOuter : _IUnknown_ (sf); - - if (!SUCCEEDED(IUnknown_QueryInterface(_IUnknown_(sf), riid, ppv))) { - IUnknown_Release(_IUnknown_(sf)); - return E_NOINTERFACE; - } - - TRACE("--(%p)\n", sf); - return S_OK; -} - -/************************************************************************** - * ISF_ControlPanel_fnQueryInterface - * - * NOTES supports not IPersist/IPersistFolder - */ -static HRESULT WINAPI ISF_ControlPanel_fnQueryInterface(IShellFolder2 * iface, REFIID riid, LPVOID * ppvObject) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - - TRACE("(%p)->(%s,%p)\n", This, shdebugstr_guid(riid), ppvObject); - - *ppvObject = NULL; - - if (IsEqualIID(riid, &IID_IUnknown) || - IsEqualIID(riid, &IID_IShellFolder) || IsEqualIID(riid, &IID_IShellFolder2)) - *ppvObject = This; - else if (IsEqualIID(riid, &IID_IPersist) || - IsEqualIID(riid, &IID_IPersistFolder) || IsEqualIID(riid, &IID_IPersistFolder2)) - *ppvObject = _IPersistFolder2_(This); - else if (IsEqualIID(riid, &IID_IShellExecuteHookW)) - *ppvObject = _IShellExecuteHookW_(This); - else if (IsEqualIID(riid, &IID_IShellExecuteHookA)) - *ppvObject = _IShellExecuteHookA_(This); - - if (*ppvObject) { - IUnknown_AddRef((IUnknown *)(*ppvObject)); - TRACE("-- Interface:(%p)->(%p)\n", ppvObject, *ppvObject); - return S_OK; - } - TRACE("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -static ULONG WINAPI ISF_ControlPanel_fnAddRef(IShellFolder2 * iface) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE("(%p)->(count=%u)\n", This, refCount - 1); - - return refCount; -} - -static ULONG WINAPI ISF_ControlPanel_fnRelease(IShellFolder2 * iface) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(count=%u)\n", This, refCount + 1); - - if (!refCount) { - TRACE("-- destroying IShellFolder(%p)\n", This); - SHFree(This->pidlRoot); - LocalFree((HLOCAL) This); - } - return refCount; -} - -/************************************************************************** -* ISF_ControlPanel_fnParseDisplayName -*/ -static HRESULT WINAPI -ISF_ControlPanel_fnParseDisplayName(IShellFolder2 * iface, - HWND hwndOwner, - LPBC pbc, - LPOLESTR lpszDisplayName, - DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - WCHAR szElement[MAX_PATH]; - LPCWSTR szNext = NULL; - LPITEMIDLIST pidlTemp = NULL; - HRESULT hr = S_OK; - CLSID clsid; - - TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", - This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName), - pchEaten, ppidl, pdwAttributes); - - if (!lpszDisplayName || !ppidl) - return E_INVALIDARG; - - *ppidl = 0; - - if (pchEaten) - *pchEaten = 0; /* strange but like the original */ - - if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') - { - szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH); - TRACE ("-- element: %s\n", debugstr_w (szElement)); - CLSIDFromString (szElement + 2, &clsid); - pidlTemp = _ILCreateGuid (PT_GUID, &clsid); - } - else if( (pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, lpszDisplayName)) ) - { - *ppidl = pidlTemp; - return S_OK; - } - - if (SUCCEEDED(hr) && pidlTemp) - { - if (szNext && *szNext) - { - hr = SHELL32_ParseNextElement(iface, hwndOwner, pbc, - &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes); - } - else - { - if (pdwAttributes && *pdwAttributes) - hr = SHELL32_GetItemAttributes(_IShellFolder_ (This), - pidlTemp, pdwAttributes); - } - } - - *ppidl = pidlTemp; - - TRACE ("(%p)->(-- ret=0x%08x)\n", This, hr); - - return hr; -} - -static LPITEMIDLIST _ILCreateCPanelApplet(LPCSTR name, LPCSTR displayName, - LPCSTR comment, int iconIdx) -{ - PIDLCPanelStruct *p; - LPITEMIDLIST pidl; - PIDLDATA tmp; - int size0 = (char*)&tmp.u.cpanel.szName-(char*)&tmp.u.cpanel; - int size = size0; - int l; - - tmp.type = PT_CPLAPPLET; - tmp.u.cpanel.dummy = 0; - tmp.u.cpanel.iconIdx = iconIdx; - - l = strlen(name); - size += l+1; - - tmp.u.cpanel.offsDispName = l+1; - l = strlen(displayName); - size += l+1; - - tmp.u.cpanel.offsComment = tmp.u.cpanel.offsDispName+1+l; - l = strlen(comment); - size += l+1; - - pidl = SHAlloc(size+4); - if (!pidl) - return NULL; - - pidl->mkid.cb = size+2; - memcpy(pidl->mkid.abID, &tmp, 2+size0); - - p = &((PIDLDATA*)pidl->mkid.abID)->u.cpanel; - strcpy(p->szName, name); - strcpy(p->szName+tmp.u.cpanel.offsDispName, displayName); - strcpy(p->szName+tmp.u.cpanel.offsComment, comment); - - *(WORD*)((char*)pidl+(size+2)) = 0; - - pcheck(pidl); - - return pidl; -} - -/************************************************************************** - * _ILGetCPanelPointer() - * gets a pointer to the control panel struct stored in the pidl - */ -static PIDLCPanelStruct* _ILGetCPanelPointer(LPCITEMIDLIST pidl) -{ - LPPIDLDATA pdata = _ILGetDataPointer(pidl); - - if (pdata && pdata->type==PT_CPLAPPLET) - return (PIDLCPanelStruct*)&(pdata->u.cpanel); - - return NULL; -} - -static BOOL SHELL_RegisterCPanelApp(IEnumIDList* list, LPCSTR path) -{ - LPITEMIDLIST pidl; - CPlApplet* applet; - CPanel panel; - CPLINFO info; - unsigned i; - int iconIdx; - - char displayName[MAX_PATH]; - char comment[MAX_PATH]; - - WCHAR wpath[MAX_PATH]; - - MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, MAX_PATH); - - panel.first = NULL; - applet = Control_LoadApplet(0, wpath, &panel); - - if (applet) - { - for(i=0; icount; ++i) - { - WideCharToMultiByte(CP_ACP, 0, applet->info[i].szName, -1, displayName, MAX_PATH, 0, 0); - WideCharToMultiByte(CP_ACP, 0, applet->info[i].szInfo, -1, comment, MAX_PATH, 0, 0); - - applet->proc(0, CPL_INQUIRE, i, (LPARAM)&info); - - if (info.idIcon > 0) - iconIdx = -info.idIcon; /* negative icon index instead of icon number */ - else - iconIdx = 0; - - pidl = _ILCreateCPanelApplet(path, displayName, comment, iconIdx); - - if (pidl) - AddToEnumList(list, pidl); - } - Control_UnloadApplet(applet); - } - return TRUE; -} - -static int SHELL_RegisterRegistryCPanelApps(IEnumIDList* list, HKEY hkey_root, LPCSTR szRepPath) -{ - char name[MAX_PATH]; - char value[MAX_PATH]; - HKEY hkey; - - int cnt = 0; - - if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS) - { - int idx = 0; - - for(;; ++idx) - { - DWORD nameLen = MAX_PATH; - DWORD valueLen = MAX_PATH; - - if (RegEnumValueA(hkey, idx, name, &nameLen, NULL, NULL, (LPBYTE)&value, &valueLen) != ERROR_SUCCESS) - break; - - if (SHELL_RegisterCPanelApp(list, value)) - ++cnt; - } - RegCloseKey(hkey); - } - - return cnt; -} - -static int SHELL_RegisterCPanelFolders(IEnumIDList* list, HKEY hkey_root, LPCSTR szRepPath) -{ - char name[MAX_PATH]; - HKEY hkey; - - int cnt = 0; - - if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS) - { - int idx = 0; - for(;; ++idx) - { - if (RegEnumKeyA(hkey, idx, name, MAX_PATH) != ERROR_SUCCESS) - break; - - if (*name == '{') - { - LPITEMIDLIST pidl = _ILCreateGuidFromStrA(name); - - if (pidl && AddToEnumList(list, pidl)) - ++cnt; - } - } - - RegCloseKey(hkey); - } - - return cnt; -} - -/************************************************************************** - * CreateCPanelEnumList() - */ -static BOOL CreateCPanelEnumList( - IEnumIDList * iface, - DWORD dwFlags) -{ - CHAR szPath[MAX_PATH]; - WIN32_FIND_DATAA wfd; - HANDLE hFile; - - TRACE("(%p)->(flags=0x%08x)\n", iface, dwFlags); - - /* enumerate control panel folders */ - if (dwFlags & SHCONTF_FOLDERS) - SHELL_RegisterCPanelFolders(iface, HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace"); - - /* enumerate the control panel applets */ - if (dwFlags & SHCONTF_NONFOLDERS) - { - LPSTR p; - - GetSystemDirectoryA(szPath, MAX_PATH); - p = PathAddBackslashA(szPath); - strcpy(p, "*.cpl"); - - TRACE("-- (%p)-> enumerate SHCONTF_NONFOLDERS of %s\n",iface,debugstr_a(szPath)); - hFile = FindFirstFileA(szPath, &wfd); - - if (hFile != INVALID_HANDLE_VALUE) - { - do - { - if (!(dwFlags & SHCONTF_INCLUDEHIDDEN) && (wfd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)) - continue; - - if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - strcpy(p, wfd.cFileName); - if (strcmp(wfd.cFileName, "ncpa.cpl")) - SHELL_RegisterCPanelApp((IEnumIDList*)iface, szPath); - } - } while(FindNextFileA(hFile, &wfd)); - FindClose(hFile); - } - - SHELL_RegisterRegistryCPanelApps((IEnumIDList*)iface, HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls"); - SHELL_RegisterRegistryCPanelApps((IEnumIDList*)iface, HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls"); - } - return TRUE; -} - -/************************************************************************** -* ISF_ControlPanel_fnEnumObjects -*/ -static HRESULT WINAPI -ISF_ControlPanel_fnEnumObjects(IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - - TRACE("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList); - - *ppEnumIDList = IEnumIDList_Constructor(); - if (*ppEnumIDList) - CreateCPanelEnumList(*ppEnumIDList, dwFlags); - - TRACE("--(%p)->(new ID List: %p)\n", This, *ppEnumIDList); - - return(*ppEnumIDList) ? S_OK : E_OUTOFMEMORY; -} - -/************************************************************************** -* ISF_ControlPanel_fnBindToObject -*/ -static HRESULT WINAPI -ISF_ControlPanel_fnBindToObject(IShellFolder2 * iface, LPCITEMIDLIST pidl, - LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - - TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid(riid), ppvOut); - - return SHELL32_BindToChild(This->pidlRoot, NULL, pidl, riid, ppvOut); -} - -/************************************************************************** -* ISF_ControlPanel_fnBindToStorage -*/ -static HRESULT WINAPI -ISF_ControlPanel_fnBindToStorage(IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - - FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid(riid), ppvOut); - - *ppvOut = NULL; - return E_NOTIMPL; -} - -/************************************************************************** -* ISF_ControlPanel_fnCompareIDs -*/ - -static HRESULT WINAPI -ISF_ControlPanel_fnCompareIDs(IShellFolder2 * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - - int nReturn; - - TRACE("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2); - nReturn = SHELL32_CompareIDs(_IShellFolder_(This), lParam, pidl1, pidl2); - TRACE("-- %i\n", nReturn); - return nReturn; -} - -/************************************************************************** -* ISF_ControlPanel_fnCreateViewObject -*/ -static HRESULT WINAPI -ISF_ControlPanel_fnCreateViewObject(IShellFolder2 * iface, HWND hwndOwner, REFIID riid, LPVOID * ppvOut) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - - LPSHELLVIEW pShellView; - HRESULT hr = E_INVALIDARG; - - TRACE("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid(riid), ppvOut); - - if (ppvOut) { - *ppvOut = NULL; - - if (IsEqualIID(riid, &IID_IDropTarget)) { - WARN("IDropTarget not implemented\n"); - hr = E_NOTIMPL; - } else if (IsEqualIID(riid, &IID_IContextMenu)) { - WARN("IContextMenu not implemented\n"); - hr = E_NOTIMPL; - } else if (IsEqualIID(riid, &IID_IShellView)) { - pShellView = IShellView_Constructor((IShellFolder *) iface); - if (pShellView) { - hr = IShellView_QueryInterface(pShellView, riid, ppvOut); - IShellView_Release(pShellView); - } - } - } - TRACE("--(%p)->(interface=%p)\n", This, ppvOut); - return hr; -} - -/************************************************************************** -* ISF_ControlPanel_fnGetAttributesOf -*/ -static HRESULT WINAPI -ISF_ControlPanel_fnGetAttributesOf(IShellFolder2 * iface, UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - - HRESULT hr = S_OK; - - TRACE("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n", - This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0); - - if (!rgfInOut) - return E_INVALIDARG; - if (cidl && !apidl) - return E_INVALIDARG; - - if (*rgfInOut == 0) - *rgfInOut = ~0; - - while(cidl > 0 && *apidl) { - pdump(*apidl); - SHELL32_GetItemAttributes(_IShellFolder_(This), *apidl, rgfInOut); - apidl++; - cidl--; - } - /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */ - *rgfInOut &= ~SFGAO_VALIDATE; - - TRACE("-- result=0x%08x\n", *rgfInOut); - return hr; -} - -/************************************************************************** -* ISF_ControlPanel_fnGetUIObjectOf -* -* PARAMETERS -* HWND hwndOwner, //[in ] Parent window for any output -* UINT cidl, //[in ] array size -* LPCITEMIDLIST* apidl, //[in ] simple pidl array -* REFIID riid, //[in ] Requested Interface -* UINT* prgfInOut, //[ ] reserved -* LPVOID* ppvObject) //[out] Resulting Interface -* -*/ -static HRESULT WINAPI -ISF_ControlPanel_fnGetUIObjectOf(IShellFolder2 * iface, - HWND hwndOwner, - UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - - LPITEMIDLIST pidl; - IUnknown *pObj = NULL; - HRESULT hr = E_INVALIDARG; - - TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", - This, hwndOwner, cidl, apidl, shdebugstr_guid(riid), prgfInOut, ppvOut); - - if (ppvOut) { - *ppvOut = NULL; - - if (IsEqualIID(riid, &IID_IContextMenu) &&(cidl >= 1)) { - // TODO - // create a seperate item struct - // - pObj = (IUnknown*)(&This->lpVtblContextMenu); - This->apidl = apidl; - This->cidl = cidl; - IUnknown_AddRef(pObj); - hr = S_OK; - } else if (IsEqualIID(riid, &IID_IDataObject) &&(cidl >= 1)) { - pObj = (LPUNKNOWN) IDataObject_Constructor(hwndOwner, This->pidlRoot, apidl, cidl); - hr = S_OK; - } else if (IsEqualIID(riid, &IID_IExtractIconA) &&(cidl == 1)) { - pidl = ILCombine(This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconA_Constructor(pidl); - SHFree(pidl); - hr = S_OK; - } else if (IsEqualIID(riid, &IID_IExtractIconW) &&(cidl == 1)) { - pidl = ILCombine(This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconW_Constructor(pidl); - SHFree(pidl); - hr = S_OK; - } else if ((IsEqualIID(riid,&IID_IShellLinkW) || IsEqualIID(riid,&IID_IShellLinkA)) - && (cidl == 1)) { - pidl = ILCombine(This->pidlRoot, apidl[0]); - hr = IShellLink_ConstructFromFile(NULL, riid, pidl,(LPVOID*)&pObj); - SHFree(pidl); - } else { - hr = E_NOINTERFACE; - } - - if (SUCCEEDED(hr) && !pObj) - hr = E_OUTOFMEMORY; - - *ppvOut = pObj; - } - TRACE("(%p)->hr=0x%08x\n", This, hr); - return hr; -} - -/************************************************************************** -* ISF_ControlPanel_fnGetDisplayNameOf -*/ -static HRESULT WINAPI ISF_ControlPanel_fnGetDisplayNameOf(IShellFolder2 * iface, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - - CHAR szPath[MAX_PATH]; - WCHAR wszPath[MAX_PATH+1]; /* +1 for potential backslash */ - PIDLCPanelStruct* pcpanel; - - *szPath = '\0'; - - TRACE("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet); - pdump(pidl); - - if (!pidl || !strRet) - return E_INVALIDARG; - - pcpanel = _ILGetCPanelPointer(pidl); - - if (pcpanel) { - lstrcpyA(szPath, pcpanel->szName+pcpanel->offsDispName); - - if (!(dwFlags & SHGDN_FORPARSING)) - FIXME("retrieve display name from control panel app\n"); - } - /* take names of special folders only if it's only this folder */ - else if (_ILIsSpecialFolder(pidl)) { - BOOL bSimplePidl = _ILIsPidlSimple(pidl); - - if (bSimplePidl) { - _ILSimpleGetTextW(pidl, wszPath, MAX_PATH); /* append my own path */ - } else { - FIXME("special pidl\n"); - } - - if ((dwFlags & SHGDN_FORPARSING) && !bSimplePidl) { /* go deeper if needed */ - int len = 0; - - PathAddBackslashW(wszPath); - len = wcslen(wszPath); - - if (!SUCCEEDED - (SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, wszPath + len, MAX_PATH + 1 - len))) - return E_OUTOFMEMORY; - if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, szPath, MAX_PATH, NULL, NULL)) - wszPath[0] = '\0'; - } else { - if (bSimplePidl) { - if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, szPath, MAX_PATH, NULL, NULL)) - wszPath[0] = '\0'; - } - } - } - - strRet->uType = STRRET_CSTR; - lstrcpynA(strRet->u.cStr, szPath, MAX_PATH); - - TRACE("--(%p)->(%s)\n", This, szPath); - return S_OK; -} - -/************************************************************************** -* ISF_ControlPanel_fnSetNameOf -* Changes the name of a file object or subfolder, possibly changing its item -* identifier in the process. -* -* PARAMETERS -* HWND hwndOwner, //[in ] Owner window for output -* LPCITEMIDLIST pidl, //[in ] simple pidl of item to change -* LPCOLESTR lpszName, //[in ] the items new display name -* DWORD dwFlags, //[in ] SHGNO formatting flags -* LPITEMIDLIST* ppidlOut) //[out] simple pidl returned -*/ -static HRESULT WINAPI ISF_ControlPanel_fnSetNameOf(IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */ - LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - FIXME("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This, hwndOwner, pidl, debugstr_w(lpName), dwFlags, pPidlOut); - return E_FAIL; -} - -static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultSearchGUID(IShellFolder2 * iface, GUID * pguid) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - FIXME("(%p)\n", This); - return E_NOTIMPL; -} -static HRESULT WINAPI ISF_ControlPanel_fnEnumSearches(IShellFolder2 * iface, IEnumExtraSearch ** ppenum) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - FIXME("(%p)\n", This); - return E_NOTIMPL; -} -static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultColumn(IShellFolder2 * iface, DWORD dwRes, ULONG * pSort, ULONG * pDisplay) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - - TRACE("(%p)\n", This); - - if (pSort) *pSort = 0; - if (pDisplay) *pDisplay = 0; - return S_OK; -} -static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultColumnState(IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - - TRACE("(%p)\n", This); - - if (!pcsFlags || iColumn >= CONROLPANELSHELLVIEWCOLUMNS) return E_INVALIDARG; - *pcsFlags = ControlPanelSFHeader[iColumn].pcsFlags; - return S_OK; -} -static HRESULT WINAPI ISF_ControlPanel_fnGetDetailsEx(IShellFolder2 * iface, LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - FIXME("(%p)\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_ControlPanel_fnGetDetailsOf(IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - HRESULT hr; - - TRACE("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd); - - if (!psd || iColumn >= CONROLPANELSHELLVIEWCOLUMNS) - return E_INVALIDARG; - - if (!pidl) { - psd->fmt = ControlPanelSFHeader[iColumn].fmt; - psd->cxChar = ControlPanelSFHeader[iColumn].cxChar; - psd->str.uType = STRRET_CSTR; - LoadStringA(shell32_hInstance, ControlPanelSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH); - return S_OK; - } else { - psd->str.u.cStr[0] = 0x00; - psd->str.uType = STRRET_CSTR; - switch(iColumn) { - case 0: /* name */ - hr = IShellFolder_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); - break; - case 1: /* comment */ - _ILGetFileType(pidl, psd->str.u.cStr, MAX_PATH); - break; - } - hr = S_OK; - } - - return hr; -} -static HRESULT WINAPI ISF_ControlPanel_fnMapColumnToSCID(IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - FIXME("(%p)\n", This); - return E_NOTIMPL; -} - -static const IShellFolder2Vtbl vt_ShellFolder2 = -{ - - ISF_ControlPanel_fnQueryInterface, - ISF_ControlPanel_fnAddRef, - ISF_ControlPanel_fnRelease, - ISF_ControlPanel_fnParseDisplayName, - ISF_ControlPanel_fnEnumObjects, - ISF_ControlPanel_fnBindToObject, - ISF_ControlPanel_fnBindToStorage, - ISF_ControlPanel_fnCompareIDs, - ISF_ControlPanel_fnCreateViewObject, - ISF_ControlPanel_fnGetAttributesOf, - ISF_ControlPanel_fnGetUIObjectOf, - ISF_ControlPanel_fnGetDisplayNameOf, - ISF_ControlPanel_fnSetNameOf, - - /* ShellFolder2 */ - ISF_ControlPanel_fnGetDefaultSearchGUID, - ISF_ControlPanel_fnEnumSearches, - ISF_ControlPanel_fnGetDefaultColumn, - ISF_ControlPanel_fnGetDefaultColumnState, - ISF_ControlPanel_fnGetDetailsEx, - ISF_ControlPanel_fnGetDetailsOf, - ISF_ControlPanel_fnMapColumnToSCID -}; - -/************************************************************************ - * ICPanel_PersistFolder2_QueryInterface - */ -static HRESULT WINAPI ICPanel_PersistFolder2_QueryInterface(IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObject) -{ - ICPanelImpl *This = impl_from_IPersistFolder2(iface); - - TRACE("(%p)\n", This); - - return IUnknown_QueryInterface(_IUnknown_(This), iid, ppvObject); -} - -/************************************************************************ - * ICPanel_PersistFolder2_AddRef - */ -static ULONG WINAPI ICPanel_PersistFolder2_AddRef(IPersistFolder2 * iface) -{ - ICPanelImpl *This = impl_from_IPersistFolder2(iface); - - TRACE("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_AddRef(_IUnknown_(This)); -} - -/************************************************************************ - * ISFPersistFolder_Release - */ -static ULONG WINAPI ICPanel_PersistFolder2_Release(IPersistFolder2 * iface) -{ - ICPanelImpl *This = impl_from_IPersistFolder2(iface); - - TRACE("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_Release(_IUnknown_(This)); -} - -/************************************************************************ - * ICPanel_PersistFolder2_GetClassID - */ -static HRESULT WINAPI ICPanel_PersistFolder2_GetClassID(IPersistFolder2 * iface, CLSID * lpClassId) -{ - ICPanelImpl *This = impl_from_IPersistFolder2(iface); - - TRACE("(%p)\n", This); - - if (!lpClassId) - return E_POINTER; - *lpClassId = CLSID_ControlPanel; - - return S_OK; -} - -/************************************************************************ - * ICPanel_PersistFolder2_Initialize - * - * NOTES: it makes no sense to change the pidl - */ -static HRESULT WINAPI ICPanel_PersistFolder2_Initialize(IPersistFolder2 * iface, LPCITEMIDLIST pidl) -{ - ICPanelImpl *This = impl_from_IPersistFolder2(iface); - if (This->pidlRoot) - SHFree((LPVOID)This->pidlRoot); - - This->pidlRoot = ILClone(pidl); - return S_OK; -} - -/************************************************************************** - * IPersistFolder2_fnGetCurFolder - */ -static HRESULT WINAPI ICPanel_PersistFolder2_GetCurFolder(IPersistFolder2 * iface, LPITEMIDLIST * pidl) -{ - ICPanelImpl *This = impl_from_IPersistFolder2(iface); - - TRACE("(%p)->(%p)\n", This, pidl); - - if (!pidl) - return E_POINTER; - *pidl = ILClone(This->pidlRoot); - return S_OK; -} - -static const IPersistFolder2Vtbl vt_PersistFolder2 = -{ - - ICPanel_PersistFolder2_QueryInterface, - ICPanel_PersistFolder2_AddRef, - ICPanel_PersistFolder2_Release, - ICPanel_PersistFolder2_GetClassID, - ICPanel_PersistFolder2_Initialize, - ICPanel_PersistFolder2_GetCurFolder -}; - -HRESULT CPanel_GetIconLocationW(LPCITEMIDLIST pidl, - LPWSTR szIconFile, UINT cchMax, int* piIndex) -{ - PIDLCPanelStruct* pcpanel = _ILGetCPanelPointer(pidl); - - if (!pcpanel) - return E_INVALIDARG; - - MultiByteToWideChar(CP_ACP, 0, pcpanel->szName, -1, szIconFile, cchMax); - *piIndex = pcpanel->iconIdx!=-1? pcpanel->iconIdx: 0; - - return S_OK; -} - - -/************************************************************************** -* IShellExecuteHookW Implementation -*/ - -static HRESULT WINAPI IShellExecuteHookW_fnQueryInterface( - IShellExecuteHookW* iface, REFIID riid, void** ppvObject) -{ - ICPanelImpl *This = impl_from_IShellExecuteHookW(iface); - - TRACE("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject); -} - -static ULONG STDMETHODCALLTYPE IShellExecuteHookW_fnAddRef(IShellExecuteHookW* iface) -{ - ICPanelImpl *This = impl_from_IShellExecuteHookW(iface); - - TRACE("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_AddRef(This->pUnkOuter); -} - -static ULONG STDMETHODCALLTYPE IShellExecuteHookW_fnRelease(IShellExecuteHookW* iface) -{ - ICPanelImpl *This = impl_from_IShellExecuteHookW(iface); - - TRACE("(%p)\n", This); - - return IUnknown_Release(This->pUnkOuter); -} - -HRESULT -ExecuteAppletFromCLSID(LPOLESTR pOleStr) -{ - WCHAR szCmd[MAX_PATH]; - WCHAR szExpCmd[MAX_PATH]; - PROCESS_INFORMATION pi; - STARTUPINFOW si; - WCHAR szBuffer[90] = { 'C', 'L', 'S', 'I', 'D', '\\', 0 }; - DWORD dwType, dwSize; - - wcscpy(&szBuffer[6], pOleStr); - wcscat(szBuffer, L"\\shell\\open\\command"); - - dwSize = sizeof(szCmd); - if (RegGetValueW(HKEY_CLASSES_ROOT, szBuffer, NULL, RRF_RT_REG_SZ, &dwType, (PVOID)szCmd, &dwSize) != ERROR_SUCCESS) - { - wcscpy(szCmd, L"%SystemRoot%\\Explorer.exe ::"); - wcscat(szCmd, pOleStr); - } - -#if 0 - if (dwType != RRF_RT_REG_SZ && dwType != RRF_RT_REG_EXPAND_SZ) - return E_FAIL; -#endif - - if (!ExpandEnvironmentStringsW(szCmd, szExpCmd, sizeof(szExpCmd)/sizeof(WCHAR))) - return E_FAIL; - - ZeroMemory(&si, sizeof(si)); - si.cb = sizeof(si); - if (!CreateProcessW(NULL, szExpCmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) - return E_FAIL; - - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - return S_OK; -} - - -static HRESULT WINAPI IShellExecuteHookW_fnExecute(IShellExecuteHookW* iface, LPSHELLEXECUTEINFOW psei) -{ - static const WCHAR wCplopen[] = {'c','p','l','o','p','e','n','\0'}; - ICPanelImpl *This = (ICPanelImpl *)iface; - - SHELLEXECUTEINFOW sei_tmp; - PIDLCPanelStruct* pcpanel; - WCHAR path[MAX_PATH]; - WCHAR params[MAX_PATH]; - BOOL ret; - HRESULT hr; - int l; - - TRACE("(%p)->execute(%p)\n", This, psei); - - if (!psei) - return E_INVALIDARG; - - pcpanel = _ILGetCPanelPointer(ILFindLastID(psei->lpIDList)); - - if (!pcpanel) - { - LPOLESTR pOleStr; - - IID * iid = _ILGetGUIDPointer(ILFindLastID(psei->lpIDList)); - if (!iid) - return E_INVALIDARG; - if (StringFromCLSID(iid, &pOleStr) == S_OK) - { - - hr = ExecuteAppletFromCLSID(pOleStr); - CoTaskMemFree(pOleStr); - return hr; - } - - return E_INVALIDARG; - } - path[0] = '\"'; - /* Return value from MultiByteToWideChar includes terminating NUL, which - * compensates for the starting double quote we just put in */ - l = MultiByteToWideChar(CP_ACP, 0, pcpanel->szName, -1, path+1, MAX_PATH); - - /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */ - path[l++] = '"'; - path[l] = '\0'; - - MultiByteToWideChar(CP_ACP, 0, pcpanel->szName+pcpanel->offsDispName, -1, params, MAX_PATH); - - memcpy(&sei_tmp, psei, sizeof(sei_tmp)); - sei_tmp.lpFile = path; - sei_tmp.lpParameters = params; - sei_tmp.fMask &= ~SEE_MASK_INVOKEIDLIST; - sei_tmp.lpVerb = wCplopen; - - ret = ShellExecuteExW(&sei_tmp); - if (ret) - return S_OK; - else - return S_FALSE; -} - -static const IShellExecuteHookWVtbl vt_ShellExecuteHookW = -{ - - IShellExecuteHookW_fnQueryInterface, - IShellExecuteHookW_fnAddRef, - IShellExecuteHookW_fnRelease, - - IShellExecuteHookW_fnExecute -}; - - -/************************************************************************** -* IShellExecuteHookA Implementation -*/ - -static HRESULT WINAPI IShellExecuteHookA_fnQueryInterface(IShellExecuteHookA* iface, REFIID riid, void** ppvObject) -{ - ICPanelImpl *This = impl_from_IShellExecuteHookA(iface); - - TRACE("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject); -} - -static ULONG STDMETHODCALLTYPE IShellExecuteHookA_fnAddRef(IShellExecuteHookA* iface) -{ - ICPanelImpl *This = impl_from_IShellExecuteHookA(iface); - - TRACE("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_AddRef(This->pUnkOuter); -} - -static ULONG STDMETHODCALLTYPE IShellExecuteHookA_fnRelease(IShellExecuteHookA* iface) -{ - ICPanelImpl *This = impl_from_IShellExecuteHookA(iface); - - TRACE("(%p)\n", This); - - return IUnknown_Release(This->pUnkOuter); -} - -static HRESULT WINAPI IShellExecuteHookA_fnExecute(IShellExecuteHookA* iface, LPSHELLEXECUTEINFOA psei) -{ - ICPanelImpl *This = (ICPanelImpl *)iface; - - SHELLEXECUTEINFOA sei_tmp; - PIDLCPanelStruct* pcpanel; - char path[MAX_PATH]; - BOOL ret; - - TRACE("(%p)->execute(%p)\n", This, psei); - - if (!psei) - return E_INVALIDARG; - - pcpanel = _ILGetCPanelPointer(ILFindLastID(psei->lpIDList)); - - if (!pcpanel) - return E_INVALIDARG; - - path[0] = '\"'; - lstrcpyA(path+1, pcpanel->szName); - - /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */ - lstrcatA(path, "\" "); - lstrcatA(path, pcpanel->szName+pcpanel->offsDispName); - - memcpy(&sei_tmp, psei, sizeof(sei_tmp)); - sei_tmp.lpFile = path; - sei_tmp.fMask &= ~SEE_MASK_INVOKEIDLIST; - - ret = ShellExecuteExA(&sei_tmp); - if (ret) - return S_OK; - else - return S_FALSE; -} - -static const IShellExecuteHookAVtbl vt_ShellExecuteHookA = -{ - IShellExecuteHookA_fnQueryInterface, - IShellExecuteHookA_fnAddRef, - IShellExecuteHookA_fnRelease, - IShellExecuteHookA_fnExecute -}; - -/************************************************************************** -* IContextMenu2 Implementation -*/ - -/************************************************************************ - * ICPanel_IContextMenu_QueryInterface - */ -static HRESULT WINAPI ICPanel_IContextMenu2_QueryInterface(IContextMenu2 * iface, REFIID iid, LPVOID * ppvObject) -{ - ICPanelImpl *This = impl_from_IContextMenu(iface); - - TRACE("(%p)\n", This); - - return IUnknown_QueryInterface(_IUnknown_(This), iid, ppvObject); -} - -/************************************************************************ - * ICPanel_IContextMenu_AddRef - */ -static ULONG WINAPI ICPanel_IContextMenu2_AddRef(IContextMenu2 * iface) -{ - ICPanelImpl *This = impl_from_IContextMenu(iface); - - TRACE("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_AddRef(_IUnknown_(This)); -} - -/************************************************************************ - * ICPanel_IContextMenu_Release - */ -static ULONG WINAPI ICPanel_IContextMenu2_Release(IContextMenu2 * iface) -{ - ICPanelImpl *This = impl_from_IContextMenu(iface); - - TRACE("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_Release(_IUnknown_(This)); -} - -/************************************************************************** -* ICPanel_IContextMenu_QueryContextMenu() -*/ -static HRESULT WINAPI ICPanel_IContextMenu2_QueryContextMenu( - IContextMenu2 *iface, - HMENU hMenu, - UINT indexMenu, - UINT idCmdFirst, - UINT idCmdLast, - UINT uFlags) -{ - WCHAR szBuffer[30] = {0}; - ULONG Count = 1; - - ICPanelImpl *This = impl_from_IContextMenu(iface); - - TRACE("(%p)->(hmenu=%p indexmenu=%x cmdfirst=%x cmdlast=%x flags=%x )\n", - This, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags); - - if (LoadStringW(shell32_hInstance, IDS_OPEN, szBuffer, sizeof(szBuffer)/sizeof(WCHAR))) - { - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_OPEN, MFT_STRING, szBuffer, MFS_DEFAULT); //FIXME identifier - Count++; - } - - if (LoadStringW(shell32_hInstance, IDS_CREATELINK, szBuffer, sizeof(szBuffer)/sizeof(WCHAR))) - { - if (Count) - { - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count, MFT_SEPARATOR, NULL, MFS_ENABLED); - } - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - - _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_CREATELINK, MFT_STRING, szBuffer, MFS_ENABLED); //FIXME identifier - Count++; - } - return MAKE_HRESULT(SEVERITY_SUCCESS, 0, Count); -} - - -/************************************************************************** -* ICPanel_IContextMenu_InvokeCommand() -*/ -static HRESULT WINAPI ICPanel_IContextMenu2_InvokeCommand( - IContextMenu2 *iface, - LPCMINVOKECOMMANDINFO lpcmi) -{ - SHELLEXECUTEINFOW sei; - WCHAR szPath[MAX_PATH]; - char szTarget[MAX_PATH]; - STRRET strret; - WCHAR* pszPath; - INT Length, cLength; - PIDLCPanelStruct *pcpanel; - IPersistFile * ppf; - IShellLinkA * isl; - ICPanelImpl *This = impl_from_IContextMenu(iface); - - TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n",This,lpcmi,lpcmi->lpVerb, lpcmi->hwnd); - - if (lpcmi->lpVerb == MAKEINTRESOURCEA(IDS_OPEN)) //FIXME - { - ZeroMemory(&sei, sizeof(sei)); - sei.cbSize = sizeof(sei); - sei.fMask = SEE_MASK_INVOKEIDLIST; - sei.lpIDList = ILCombine(This->pidlRoot, This->apidl[0]); - sei.hwnd = lpcmi->hwnd; - sei.nShow = SW_SHOWNORMAL; - sei.lpVerb = L"open"; - - if (ShellExecuteExW(&sei) == FALSE) - return E_FAIL; - } - else if (lpcmi->lpVerb == MAKEINTRESOURCEA(IDS_CREATELINK)) //FIXME - { - if (!SHGetSpecialFolderPathW(NULL, szPath, CSIDL_DESKTOPDIRECTORY, FALSE)) - return E_FAIL; - - pszPath = PathAddBackslashW(szPath); - if (!pszPath) - return E_FAIL; - - if (IShellFolder_GetDisplayNameOf((IShellFolder*)This, This->apidl[0], SHGDN_FORPARSING, &strret) != S_OK) - return E_FAIL; - - Length = MAX_PATH - (pszPath - szPath); - cLength = strlen(strret.u.cStr); - if (Length < cLength + 5) - { - FIXME("\n"); - return E_FAIL; - } - - if (MultiByteToWideChar(CP_ACP, 0, strret.u.cStr, cLength +1, pszPath, Length)) - { - pszPath += cLength; - Length -= cLength; - } - - if (Length > 10) - { - wcscpy(pszPath, L" - "); - cLength = LoadStringW(shell32_hInstance, IDS_LNK_FILE, &pszPath[3], Length -4) + 3; - if (cLength + 5 > Length) - cLength = Length - 5; - Length -= cLength; - pszPath += cLength; - } - wcscpy(pszPath, L".lnk"); - - pcpanel = _ILGetCPanelPointer(ILFindLastID(This->apidl[0])); - if (pcpanel) - { - strncpy(szTarget, pcpanel->szName, MAX_PATH); - } - else - { - FIXME("Couldn't retrieve pointer to cpl structure\n"); - return E_FAIL; - } - if (SUCCEEDED(IShellLink_Constructor(NULL, &IID_IShellLinkA, (LPVOID*)&isl))) - { - IShellLinkA_SetPath(isl, szTarget); - if (SUCCEEDED(IShellLinkA_QueryInterface(isl, &IID_IPersistFile, (LPVOID*)&ppf))) - { - IPersistFile_Save(ppf, szPath, TRUE); - IPersistFile_Release(ppf); - } - IShellLinkA_Release(isl); - } - return NOERROR; - } - return S_OK; -} - -/************************************************************************** - * ICPanel_IContextMenu_GetCommandString() - * - */ -static HRESULT WINAPI ICPanel_IContextMenu2_GetCommandString( - IContextMenu2 *iface, - UINT_PTR idCommand, - UINT uFlags, - UINT* lpReserved, - LPSTR lpszName, - UINT uMaxNameLen) -{ - ICPanelImpl *This = impl_from_IContextMenu(iface); - - TRACE("(%p)->(idcom=%lx flags=%x %p name=%p len=%x)\n",This, idCommand, uFlags, lpReserved, lpszName, uMaxNameLen); - - - FIXME("unknown command string\n"); - return E_FAIL; -} - - - -/************************************************************************** -* ICPanel_IContextMenu_HandleMenuMsg() -*/ -static HRESULT WINAPI ICPanel_IContextMenu2_HandleMenuMsg( - IContextMenu2 *iface, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) -{ - ICPanelImpl *This = impl_from_IContextMenu(iface); - - TRACE("ICPanel_IContextMenu_HandleMenuMsg (%p)->(msg=%x wp=%lx lp=%lx)\n",This, uMsg, wParam, lParam); - - return E_NOTIMPL; -} - -static const IContextMenu2Vtbl vt_ContextMenu = -{ - ICPanel_IContextMenu2_QueryInterface, - ICPanel_IContextMenu2_AddRef, - ICPanel_IContextMenu2_Release, - ICPanel_IContextMenu2_QueryContextMenu, - ICPanel_IContextMenu2_InvokeCommand, - ICPanel_IContextMenu2_GetCommandString, - ICPanel_IContextMenu2_HandleMenuMsg -}; - diff --git a/reactos/dll/win32/shell32/shfldr_desktop.c b/reactos/dll/win32/shell32/shfldr_desktop.c deleted file mode 100644 index cdcae285023..00000000000 --- a/reactos/dll/win32/shell32/shfldr_desktop.c +++ /dev/null @@ -1,1487 +0,0 @@ - -/* - * Virtual Desktop Folder - * - * Copyright 1997 Marcus Meissner - * Copyright 1998, 1999, 2002 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL (shell); - -/*********************************************************************** -* Desktopfolder implementation -*/ - -typedef struct { - const IShellFolder2Vtbl *lpVtbl; - const IPersistFolder2Vtbl *lpPF2; - const ISFHelperVtbl *lpvtblSFHelper; - LONG ref; - - /* both paths are parsible from the desktop */ - LPWSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */ - LPITEMIDLIST pidlRoot; /* absolute pidl */ - - UINT cfShellIDList; /* clipboardformat for IDropTarget */ - BOOL fAcceptFmt; /* flag for pending Drop */ -} IGenericSFImpl, *LPIGenericSFImpl; - -WCHAR *build_paths_list(LPCWSTR wszBasePath, int cidl, LPCITEMIDLIST *pidls); -int SHELL_ConfirmMsgBox(HWND hWnd, LPWSTR lpszText, LPWSTR lpszCaption, HICON hIcon, BOOL bYesToAll); - -#define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl) -#define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl) - -static const shvheader DesktopSFHeader[] = { - {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15}, - {IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10}, - {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10}, - {IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12}, - {IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5} -}; - -#define DESKTOPSHELLVIEWCOLUMNS 5 - -/************************************************************************** - * ISF_Desktop_fnQueryInterface - * - * NOTES supports not IPersist/IPersistFolder - */ -static HRESULT WINAPI ISF_Desktop_fnQueryInterface( - IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj); - - *ppvObj = NULL; - - if (IsEqualIID (riid, &IID_IUnknown) || - IsEqualIID (riid, &IID_IShellFolder) || - IsEqualIID (riid, &IID_IShellFolder2)) - { - *ppvObj = This; - } - else if (IsEqualIID (riid, &IID_IPersistFolder) || - IsEqualIID (riid, &IID_IPersistFolder2)) - { - *ppvObj = (void *)&This->lpPF2; - } - else if (IsEqualIID(riid, &IID_ISFHelper)) - { - *ppvObj = (void *)&This->lpvtblSFHelper; - } - if (*ppvObj) - { - IUnknown_AddRef ((IUnknown *) (*ppvObj)); - TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj); - return S_OK; - } - TRACE ("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -static LPIGenericSFImpl __inline impl_from_ISFHelper( ISFHelper *iface ) -{ - return (IGenericSFImpl *)((char*)iface - FIELD_OFFSET(IGenericSFImpl, lpvtblSFHelper)); -} - -static ULONG WINAPI ISF_Desktop_fnAddRef (IShellFolder2 * iface) -{ - return 2; /* non-heap based object */ -} - -static ULONG WINAPI ISF_Desktop_fnRelease (IShellFolder2 * iface) -{ - return 1; /* non-heap based object */ -} - -/************************************************************************** - * ISF_Desktop_fnParseDisplayName - * - * NOTES - * "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds - * to MyComputer - */ -static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface, - HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, - DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - WCHAR szElement[MAX_PATH]; - LPCWSTR szNext = NULL; - LPITEMIDLIST pidlTemp = NULL; - HRESULT hr = S_OK; - CLSID clsid; - - TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", - This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName), - pchEaten, ppidl, pdwAttributes); - - if (!lpszDisplayName || !ppidl) - return E_INVALIDARG; - - *ppidl = 0; - - if (pchEaten) - *pchEaten = 0; /* strange but like the original */ - - if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') - { - szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH); - TRACE ("-- element: %s\n", debugstr_w (szElement)); - CLSIDFromString (szElement + 2, &clsid); - pidlTemp = _ILCreateGuid (PT_GUID, &clsid); - } - else if (PathGetDriveNumberW (lpszDisplayName) >= 0) - { - /* it's a filesystem path with a drive. Let MyComputer/UnixDosFolder parse it */ -#if 0 - if (UNIXFS_is_rooted_at_desktop()) - pidlTemp = _ILCreateGuid(PT_GUID, &CLSID_UnixDosFolder); - else -#endif - pidlTemp = _ILCreateMyComputer (); - szNext = lpszDisplayName; - } - else if (PathIsUNCW(lpszDisplayName)) - { - pidlTemp = _ILCreateNetwork(); - szNext = lpszDisplayName; - } - else if( (pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, lpszDisplayName)) ) - { - *ppidl = pidlTemp; - return S_OK; - } - else - { - /* it's a filesystem path on the desktop. Let a FSFolder parse it */ - - if (*lpszDisplayName) - { - WCHAR szPath[MAX_PATH]; - LPWSTR pathPtr; - - /* build a complete path to create a simple pidl */ - lstrcpynW(szPath, This->sPathTarget, MAX_PATH); - pathPtr = PathAddBackslashW(szPath); - if (pathPtr) - { - lstrcpynW(pathPtr, lpszDisplayName, MAX_PATH - (pathPtr - szPath)); - hr = _ILCreateFromPathW(szPath, &pidlTemp); - } - else - { - /* should never reach here, but for completeness */ - hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - } - } - else - pidlTemp = _ILCreateMyComputer(); - - szNext = NULL; - } - - if (SUCCEEDED(hr) && pidlTemp) - { - if (szNext && *szNext) - { - hr = SHELL32_ParseNextElement(iface, hwndOwner, pbc, - &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes); - } - else - { - if (pdwAttributes && *pdwAttributes) - hr = SHELL32_GetItemAttributes(_IShellFolder_ (This), - pidlTemp, pdwAttributes); - } - } - - *ppidl = pidlTemp; - - TRACE ("(%p)->(-- ret=0x%08x)\n", This, hr); - - return hr; -} - -static const WCHAR ClassicStartMenuW[] = {'S','O','F','T','W','A','R','E','\\', - 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\', - 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r', - '\\','H','i','d','e','D','e','s','k','t','o','p','I','c','o','n','s','\\', - 'C','l','a','s','s','i','c','S','t','a','r','t','M','e','n','u','\0' }; - -INT -IsNamespaceExtensionHidden(WCHAR *iid) -{ - DWORD Result, dwResult; - dwResult = sizeof(DWORD); - - if (RegGetValueW(HKEY_CURRENT_USER, /* FIXME use NewStartPanel when activated */ - ClassicStartMenuW, - iid, - RRF_RT_DWORD, - NULL, - &Result, - &dwResult) != ERROR_SUCCESS) - { - return -1; - } - - return Result; -} - -static -VOID -SetNamespaceExtensionVisibleStatus(WCHAR * iid, DWORD dwStatus) -{ - HKEY hKey; - - if (RegOpenKeyExW(HKEY_CURRENT_USER, ClassicStartMenuW, 0, KEY_WRITE, &hKey) == ERROR_SUCCESS) - { - RegSetValueExW(hKey, iid, 0, REG_DWORD, (LPBYTE)&dwStatus, sizeof(DWORD)); - RegCloseKey(hKey); - } -} - - - -/************************************************************************** - * CreateDesktopEnumList() - */ -static const WCHAR Desktop_NameSpaceW[] = { 'S','O','F','T','W','A','R','E', - '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\', - 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l', - 'o','r','e','r','\\','D','e','s','k','t','o','p','\\','N','a','m','e','s','p', - 'a','c','e','\0' }; - -static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags) -{ - BOOL ret = TRUE; - WCHAR szPath[MAX_PATH]; - - static WCHAR MyDocumentsClassString[] = L"{450D8FBA-AD25-11D0-98A8-0800361B1103}"; - - - TRACE("(%p)->(flags=0x%08x)\n", list, dwFlags); - - /* enumerate the root folders */ - if (dwFlags & SHCONTF_FOLDERS) - { - HKEY hkey; - UINT i; - DWORD dwResult; - - /* create the pidl for This item */ - if (IsNamespaceExtensionHidden(MyDocumentsClassString) < 1) - { - ret = AddToEnumList(list, _ILCreateMyDocuments()); - } - ret = AddToEnumList(list, _ILCreateMyComputer()); - - for (i = 0; i < 2; i++) - { - if (i == 0) - dwResult = RegOpenKeyExW(HKEY_LOCAL_MACHINE, Desktop_NameSpaceW, 0, KEY_READ, &hkey); - else - dwResult = RegOpenKeyExW(HKEY_CURRENT_USER, Desktop_NameSpaceW, 0, KEY_READ, &hkey); - - if (dwResult == ERROR_SUCCESS) - { - WCHAR iid[50]; - LPITEMIDLIST pidl; - int i=0; - - while (ret) - { - DWORD size; - LONG r; - - size = sizeof (iid) / sizeof (iid[0]); - r = RegEnumKeyExW(hkey, i, iid, &size, 0, NULL, NULL, NULL); - if (ERROR_SUCCESS == r) - { - if (IsNamespaceExtensionHidden(iid) < 1) - { - pidl = _ILCreateGuidFromStrW(iid); - if (!HasItemWithCLSID(list, pidl)) - { - ret = AddToEnumList(list, pidl); - } - else - { - SHFree(pidl); - } - } - } - else if (ERROR_NO_MORE_ITEMS == r) - break; - else - ret = FALSE; - i++; - } - RegCloseKey(hkey); - } - } - for (i = 0; i < 2; i++) - { - if (i == 0) - dwResult = RegOpenKeyExW(HKEY_LOCAL_MACHINE, ClassicStartMenuW, 0, KEY_READ, &hkey); - else - dwResult = RegOpenKeyExW(HKEY_CURRENT_USER, ClassicStartMenuW, 0, KEY_READ, &hkey); - - if (dwResult == ERROR_SUCCESS) - { - DWORD j = 0, dwVal, Val, dwType, dwIID; - LONG r; - WCHAR iid[50]; - - while(ret) - { - dwVal = sizeof(Val); - dwIID = sizeof(iid) / sizeof(WCHAR); - - r = RegEnumValueW(hkey, j++, iid, &dwIID, NULL, &dwType, (LPBYTE)&Val, &dwVal); - if (r == ERROR_SUCCESS) - { - if (Val == 0 && dwType == REG_DWORD) - { - LPITEMIDLIST pidl = _ILCreateGuidFromStrW(iid); - if (!HasItemWithCLSID(list, pidl)) - { - AddToEnumList(list, pidl); - } - else - { - SHFree(pidl); - } - } - } - else if (ERROR_NO_MORE_ITEMS == r) - break; - else - ret = FALSE; - } - } - - } - } - - /* enumerate the elements in %windir%\desktop */ - ret = ret && SHGetSpecialFolderPathW(0, szPath, CSIDL_DESKTOPDIRECTORY, FALSE); - ret = ret && CreateFolderEnumList(list, szPath, dwFlags); - - ret = ret && SHGetSpecialFolderPathW(0, szPath, CSIDL_COMMON_DESKTOPDIRECTORY, FALSE); - ret = ret && CreateFolderEnumList(list, szPath, dwFlags); - - return ret; -} - -/************************************************************************** - * ISF_Desktop_fnEnumObjects - */ -static HRESULT WINAPI ISF_Desktop_fnEnumObjects (IShellFolder2 * iface, - HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", - This, hwndOwner, dwFlags, ppEnumIDList); - - *ppEnumIDList = IEnumIDList_Constructor(); - if (*ppEnumIDList) - CreateDesktopEnumList(*ppEnumIDList, dwFlags); - - TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList); - - return *ppEnumIDList ? S_OK : E_OUTOFMEMORY; -} - -/************************************************************************** - * ISF_Desktop_fnBindToObject - */ -static HRESULT WINAPI ISF_Desktop_fnBindToObject (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", - This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); - - return SHELL32_BindToChild( This->pidlRoot, This->sPathTarget, pidl, riid, ppvOut ); -} - -/************************************************************************** - * ISF_Desktop_fnBindToStorage - */ -static HRESULT WINAPI ISF_Desktop_fnBindToStorage (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", - This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); - - *ppvOut = NULL; - return E_NOTIMPL; -} - -/************************************************************************** - * ISF_Desktop_fnCompareIDs - */ -static HRESULT WINAPI ISF_Desktop_fnCompareIDs (IShellFolder2 * iface, - LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - int nReturn; - - TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2); - nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2); - TRACE ("-- %i\n", nReturn); - return nReturn; -} - -/************************************************************************** - * ISF_Desktop_fnCreateViewObject - */ -static HRESULT WINAPI ISF_Desktop_fnCreateViewObject (IShellFolder2 * iface, - HWND hwndOwner, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - LPSHELLVIEW pShellView; - HRESULT hr = E_INVALIDARG; - - TRACE ("(%p)->(hwnd=%p,%s,%p)\n", - This, hwndOwner, shdebugstr_guid (riid), ppvOut); - - if (!ppvOut) - return hr; - - *ppvOut = NULL; - - if (IsEqualIID (riid, &IID_IDropTarget)) - { - WARN ("IDropTarget not implemented\n"); - hr = E_NOTIMPL; - } - else if (IsEqualIID (riid, &IID_IContextMenu)) - { - WARN ("IContextMenu not implemented\n"); - hr = E_NOTIMPL; - } - else if (IsEqualIID (riid, &IID_IShellView)) - { - pShellView = IShellView_Constructor ((IShellFolder *) iface); - if (pShellView) - { - hr = IShellView_QueryInterface (pShellView, riid, ppvOut); - IShellView_Release (pShellView); - } - } - TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut); - return hr; -} - -/************************************************************************** - * ISF_Desktop_fnGetAttributesOf - */ -static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf (IShellFolder2 * iface, - UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - HRESULT hr = S_OK; - static const DWORD dwDesktopAttributes = - SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR | - SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER; - static const DWORD dwMyComputerAttributes = - SFGAO_CANRENAME | SFGAO_CANDELETE | SFGAO_HASPROPSHEET | - SFGAO_DROPTARGET | SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_HASSUBFOLDER; - - TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n", - This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0); - - if (!rgfInOut) - return E_INVALIDARG; - if (cidl && !apidl) - return E_INVALIDARG; - - if (*rgfInOut == 0) - *rgfInOut = ~0; - - if(cidl == 0) { - *rgfInOut &= dwDesktopAttributes; - } else { - while (cidl > 0 && *apidl) { - pdump (*apidl); - if (_ILIsDesktop(*apidl)) { - *rgfInOut &= dwDesktopAttributes; - } else if (_ILIsMyComputer(*apidl)) { - *rgfInOut &= dwMyComputerAttributes; - } else { - SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut); - } - apidl++; - cidl--; - } - } - /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */ - *rgfInOut &= ~SFGAO_VALIDATE; - - TRACE ("-- result=0x%08x\n", *rgfInOut); - - return hr; -} - -/************************************************************************** - * ISF_Desktop_fnGetUIObjectOf - * - * PARAMETERS - * HWND hwndOwner, //[in ] Parent window for any output - * UINT cidl, //[in ] array size - * LPCITEMIDLIST* apidl, //[in ] simple pidl array - * REFIID riid, //[in ] Requested Interface - * UINT* prgfInOut, //[ ] reserved - * LPVOID* ppvObject) //[out] Resulting Interface - * - */ -static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface, - HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, - REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - LPITEMIDLIST pidl; - IUnknown *pObj = NULL; - HRESULT hr = E_INVALIDARG; - - TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", - This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut); - - if (!ppvOut) - return hr; - - *ppvOut = NULL; - - if (IsEqualIID (riid, &IID_IContextMenu)) - { - hr = CDefFolderMenu_Create2(This->pidlRoot, hwndOwner, cidl, apidl, (IShellFolder*)iface, NULL, 0, NULL, (IContextMenu**)&pObj); - } - else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) - { - pObj = (LPUNKNOWN) IDataObject_Constructor( hwndOwner, - This->pidlRoot, apidl, cidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) - { - hr = IShellFolder_QueryInterface (iface, - &IID_IDropTarget, (LPVOID *) & pObj); - } - else if ((IsEqualIID(riid,&IID_IShellLinkW) || - IsEqualIID(riid,&IID_IShellLinkA)) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj); - SHFree (pidl); - } - else - hr = E_NOINTERFACE; - - if (SUCCEEDED(hr) && !pObj) - hr = E_OUTOFMEMORY; - - *ppvOut = pObj; - TRACE ("(%p)->hr=0x%08x\n", This, hr); - return hr; -} - -/************************************************************************** - * ISF_Desktop_fnGetDisplayNameOf - * - * NOTES - * special case: pidl = null gives desktop-name back - */ -static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface, - LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - HRESULT hr = S_OK; - LPWSTR pszPath; - - TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet); - pdump (pidl); - - if (!strRet) - return E_INVALIDARG; - - pszPath = CoTaskMemAlloc((MAX_PATH +1) * sizeof(WCHAR)); - if (!pszPath) - return E_OUTOFMEMORY; - - if (_ILIsDesktop (pidl)) - { - if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && - (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING)) - wcscpy(pszPath, This->sPathTarget); - else - HCR_GetClassNameW(&CLSID_ShellDesktop, pszPath, MAX_PATH); - } - else if (_ILIsPidlSimple (pidl)) - { - GUID const *clsid; - - if ((clsid = _ILGetGUIDPointer (pidl))) - { - if (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING) - { - int bWantsForParsing; - - /* - * We can only get a filesystem path from a shellfolder if the - * value WantsFORPARSING in CLSID\\{...}\\shellfolder exists. - * - * Exception: The MyComputer folder doesn't have this key, - * but any other filesystem backed folder it needs it. - */ - if (IsEqualIID (clsid, &CLSID_MyComputer)) - { - bWantsForParsing = TRUE; - } - else - { - /* get the "WantsFORPARSING" flag from the registry */ - static const WCHAR clsidW[] = - { 'C','L','S','I','D','\\',0 }; - static const WCHAR shellfolderW[] = - { '\\','s','h','e','l','l','f','o','l','d','e','r',0 }; - static const WCHAR wantsForParsingW[] = - { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n', - 'g',0 }; - WCHAR szRegPath[100]; - LONG r; - - wcscpy (szRegPath, clsidW); - SHELL32_GUIDToStringW (clsid, &szRegPath[6]); - wcscat (szRegPath, shellfolderW); - r = SHGetValueW(HKEY_CLASSES_ROOT, szRegPath, - wantsForParsingW, NULL, NULL, NULL); - if (r == ERROR_SUCCESS) - bWantsForParsing = TRUE; - else - bWantsForParsing = FALSE; - } - - if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && - bWantsForParsing) - { - /* - * we need the filesystem path to the destination folder. - * Only the folder itself can know it - */ - hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, - pszPath, - MAX_PATH); - } - else - { - /* parsing name like ::{...} */ - pszPath[0] = ':'; - pszPath[1] = ':'; - SHELL32_GUIDToStringW (clsid, &pszPath[2]); - } - } - else - { - /* user friendly name */ - HCR_GetClassNameW (clsid, pszPath, MAX_PATH); - } - } - else - { - int cLen = 0; - - /* file system folder or file rooted at the desktop */ - if ((GET_SHGDN_FOR(dwFlags) == SHGDN_FORPARSING) && - (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER)) - { - lstrcpynW(pszPath, This->sPathTarget, MAX_PATH - 1); - PathAddBackslashW(pszPath); - cLen = wcslen(pszPath); - } - - _ILSimpleGetTextW(pidl, pszPath + cLen, MAX_PATH - cLen); - if (!_ILIsFolder(pidl)) - SHELL_FS_ProcessDisplayFilename(pszPath, dwFlags); - - if (GetFileAttributes(pszPath) == INVALID_FILE_ATTRIBUTES) - { - /* file system folder or file rooted at the AllUsers desktop */ - if ((GET_SHGDN_FOR(dwFlags) == SHGDN_FORPARSING) && - (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER)) - { - SHGetSpecialFolderPathW(0, pszPath, CSIDL_COMMON_DESKTOPDIRECTORY, FALSE); - PathAddBackslashW(pszPath); - cLen = wcslen(pszPath); - } - - _ILSimpleGetTextW(pidl, pszPath + cLen, MAX_PATH - cLen); - if (!_ILIsFolder(pidl)) - SHELL_FS_ProcessDisplayFilename(pszPath, dwFlags); - } - } - } - else - { - /* a complex pidl, let the subfolder do the work */ - hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, - pszPath, MAX_PATH); - } - - if (SUCCEEDED(hr)) - { - /* Win9x always returns ANSI strings, NT always returns Unicode strings */ - if (GetVersion() & 0x80000000) - { - strRet->uType = STRRET_CSTR; - if (!WideCharToMultiByte(CP_ACP, 0, pszPath, -1, strRet->u.cStr, MAX_PATH, - NULL, NULL)) - strRet->u.cStr[0] = '\0'; - CoTaskMemFree(pszPath); - } - else - { - strRet->uType = STRRET_WSTR; - strRet->u.pOleStr = pszPath; - } - } - else - CoTaskMemFree(pszPath); - - TRACE ("-- (%p)->(%s,0x%08x)\n", This, - strRet->uType == STRRET_CSTR ? strRet->u.cStr : - debugstr_w(strRet->u.pOleStr), hr); - return hr; -} - -/************************************************************************** - * ISF_Desktop_fnSetNameOf - * Changes the name of a file object or subfolder, possibly changing its item - * identifier in the process. - * - * PARAMETERS - * HWND hwndOwner, //[in ] Owner window for output - * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change - * LPCOLESTR lpszName, //[in ] the items new display name - * DWORD dwFlags, //[in ] SHGNO formatting flags - * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned - */ -static HRESULT WINAPI ISF_Desktop_fnSetNameOf (IShellFolder2 * iface, - HWND hwndOwner, LPCITEMIDLIST pidl, /* simple pidl */ - LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - IShellFolder2 * psf; - HRESULT hr; - WCHAR szSrc[MAX_PATH + 1], szDest[MAX_PATH + 1]; - LPWSTR ptr; - BOOL bIsFolder = _ILIsFolder (ILFindLastID (pidl)); - - TRACE ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This, hwndOwner, pidl, - debugstr_w (lpName), dwFlags, pPidlOut); - - if (_ILGetGUIDPointer(pidl)) - { - if (SUCCEEDED(IShellFolder2_BindToObject(iface, pidl, NULL, &IID_IShellFolder2, (LPVOID*)&psf))) - { - hr = IShellFolder2_SetNameOf(psf, hwndOwner, pidl, lpName, dwFlags, pPidlOut); - IShellFolder2_Release(psf); - return hr; - } - } - - /* build source path */ - lstrcpynW(szSrc, This->sPathTarget, MAX_PATH); - ptr = PathAddBackslashW (szSrc); - if (ptr) - _ILSimpleGetTextW (pidl, ptr, MAX_PATH + 1 - (ptr - szSrc)); - - /* build destination path */ - if (dwFlags == SHGDN_NORMAL || dwFlags & SHGDN_INFOLDER) { - lstrcpynW(szDest, This->sPathTarget, MAX_PATH); - ptr = PathAddBackslashW (szDest); - if (ptr) - lstrcpynW(ptr, lpName, MAX_PATH + 1 - (ptr - szDest)); - } else - lstrcpynW(szDest, lpName, MAX_PATH); - - if(!(dwFlags & SHGDN_FORPARSING) && SHELL_FS_HideExtension(szSrc)) { - WCHAR *ext = PathFindExtensionW(szSrc); - if(*ext != '\0') { - INT len = wcslen(szDest); - lstrcpynW(szDest + len, ext, MAX_PATH - len); - } - } - - if (!memcmp(szSrc, szDest, (wcslen(szDest)+1) * sizeof(WCHAR))) - { - /* src and destination is the same */ - hr = S_OK; - if (pPidlOut) - hr = _ILCreateFromPathW(szDest, pPidlOut); - - return hr; - } - - TRACE ("src=%s dest=%s\n", debugstr_w(szSrc), debugstr_w(szDest)); - if (MoveFileW (szSrc, szDest)) - { - hr = S_OK; - - if (pPidlOut) - hr = _ILCreateFromPathW(szDest, pPidlOut); - - SHChangeNotify (bIsFolder ? SHCNE_RENAMEFOLDER : SHCNE_RENAMEITEM, - SHCNF_PATHW, szSrc, szDest); - - return hr; - } - return E_FAIL; -} -static HRESULT WINAPI ISF_Desktop_fnGetDefaultSearchGUID(IShellFolder2 *iface, - GUID * pguid) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_Desktop_fnEnumSearches (IShellFolder2 *iface, - IEnumExtraSearch ** ppenum) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumn (IShellFolder2 * iface, - DWORD dwRes, ULONG * pSort, ULONG * pDisplay) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)\n", This); - - if (pSort) - *pSort = 0; - if (pDisplay) - *pDisplay = 0; - - return S_OK; -} -static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumnState ( - IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)\n", This); - - if (!pcsFlags || iColumn >= DESKTOPSHELLVIEWCOLUMNS) - return E_INVALIDARG; - - *pcsFlags = DesktopSFHeader[iColumn].pcsFlags; - - return S_OK; -} - -static HRESULT WINAPI ISF_Desktop_fnGetDetailsEx (IShellFolder2 * iface, - LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface, - LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - HRESULT hr = S_OK; - - TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd); - - if (!psd || iColumn >= DESKTOPSHELLVIEWCOLUMNS) - return E_INVALIDARG; - - if (!pidl) - { - psd->fmt = DesktopSFHeader[iColumn].fmt; - psd->cxChar = DesktopSFHeader[iColumn].cxChar; - psd->str.uType = STRRET_CSTR; - LoadStringA (shell32_hInstance, DesktopSFHeader[iColumn].colnameid, - psd->str.u.cStr, MAX_PATH); - return S_OK; - } - - /* the data from the pidl */ - psd->str.uType = STRRET_CSTR; - switch (iColumn) - { - case 0: /* name */ - hr = IShellFolder_GetDisplayNameOf(iface, pidl, - SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); - break; - case 1: /* size */ - _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 2: /* type */ - _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 3: /* date */ - _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 4: /* attributes */ - _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH); - break; - } - - return hr; -} - -static HRESULT WINAPI ISF_Desktop_fnMapColumnToSCID ( - IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static const IShellFolder2Vtbl vt_MCFldr_ShellFolder2 = -{ - ISF_Desktop_fnQueryInterface, - ISF_Desktop_fnAddRef, - ISF_Desktop_fnRelease, - ISF_Desktop_fnParseDisplayName, - ISF_Desktop_fnEnumObjects, - ISF_Desktop_fnBindToObject, - ISF_Desktop_fnBindToStorage, - ISF_Desktop_fnCompareIDs, - ISF_Desktop_fnCreateViewObject, - ISF_Desktop_fnGetAttributesOf, - ISF_Desktop_fnGetUIObjectOf, - ISF_Desktop_fnGetDisplayNameOf, - ISF_Desktop_fnSetNameOf, - /* ShellFolder2 */ - ISF_Desktop_fnGetDefaultSearchGUID, - ISF_Desktop_fnEnumSearches, - ISF_Desktop_fnGetDefaultColumn, - ISF_Desktop_fnGetDefaultColumnState, - ISF_Desktop_fnGetDetailsEx, - ISF_Desktop_fnGetDetailsOf, - ISF_Desktop_fnMapColumnToSCID -}; - -static LPIGenericSFImpl __inline impl_from_IPersistFolder2( IPersistFolder2 *iface ) -{ - return (IGenericSFImpl *)((char*)iface - FIELD_OFFSET(IGenericSFImpl, lpPF2)); -} - -static HRESULT WINAPI -ISF_Desktop_PersistFolder2_fnQueryInterface (IPersistFolder2 * iface, REFIID iid, - LPVOID * ppvObj) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)\n", This); - - return ISF_Desktop_fnQueryInterface ((IShellFolder2*)This, iid, ppvObj); -} - -static ULONG WINAPI -ISF_Desktop_PersistFolder2_fnAddRef (IPersistFolder2 * iface) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return ISF_Desktop_fnAddRef((IShellFolder2*)This); -} - -static ULONG WINAPI -ISF_Desktop_PersistFolder2_fnRelease (IPersistFolder2 * iface) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return ISF_Desktop_fnRelease ((IShellFolder2*)This); -} - -static HRESULT WINAPI -ISF_Desktop_PersistFolder2_fnGetClassID (IPersistFolder2 * iface, CLSID * lpClassId) -{ - static GUID const CLSID_Desktop = - { 0x00021400, 0x0000, 0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46} }; - - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)\n", This); - - if (!lpClassId) - return E_POINTER; - - memcpy(lpClassId, &CLSID_Desktop, sizeof(GUID)); - - return S_OK; -} -static HRESULT WINAPI -ISF_Desktop_PersistFolder2_fnInitialize (IPersistFolder2 * iface, LPCITEMIDLIST pidl) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)->(%p)\n", This, pidl); - - return E_NOTIMPL; -} - -static HRESULT WINAPI -ISF_Desktop_PersistFolder2_fnGetCurFolder (IPersistFolder2 * iface, - LPITEMIDLIST * pidl) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)->(%p)\n", This, pidl); - - if (!pidl) return E_POINTER; - *pidl = ILClone (This->pidlRoot); - return S_OK; -} - -static const IPersistFolder2Vtbl vt_FSFldr_PersistFolder2 = -{ - ISF_Desktop_PersistFolder2_fnQueryInterface, - ISF_Desktop_PersistFolder2_fnAddRef, - ISF_Desktop_PersistFolder2_fnRelease, - ISF_Desktop_PersistFolder2_fnGetClassID, - ISF_Desktop_PersistFolder2_fnInitialize, - ISF_Desktop_PersistFolder2_fnGetCurFolder, -}; - -static HRESULT WINAPI -ISF_Desktop_ISFHelper_fnQueryInterface (ISFHelper * iface, REFIID riid, LPVOID * ppvObj) -{ - IGenericSFImpl *This = impl_from_ISFHelper(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return ISF_Desktop_fnQueryInterface ((IShellFolder2*)This, riid, ppvObj); -} - -static ULONG WINAPI -ISF_Desktop_ISFHelper_fnAddRef (ISFHelper * iface) -{ - IGenericSFImpl *This = impl_from_ISFHelper(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return ISF_Desktop_fnAddRef((IShellFolder2*)This); -} - -static ULONG WINAPI -ISF_Desktop_ISFHelper_fnRelease (ISFHelper * iface) -{ - IGenericSFImpl *This = impl_from_ISFHelper(iface); - - TRACE ("(%p)\n", This); - - return ISF_Desktop_fnRelease ((IShellFolder2*)This); -} - -static HRESULT WINAPI -ISF_Desktop_ISFHelper_fnGetUniqueName (ISFHelper * iface, LPWSTR pwszName, UINT uLen) -{ - IGenericSFImpl *This = impl_from_ISFHelper(iface); - IEnumIDList *penum; - HRESULT hr; - WCHAR wszText[MAX_PATH]; - WCHAR wszNewFolder[25]; - const WCHAR wszFormat[] = {'%','s',' ','%','d',0 }; - - LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, sizeof(wszNewFolder)/sizeof(WCHAR)); - - TRACE ("(%p)(%p %u)\n", This, pwszName, uLen); - - if (uLen < sizeof(wszNewFolder)/sizeof(WCHAR) + 3) - return E_POINTER; - - lstrcpynW (pwszName, wszNewFolder, uLen); - - hr = IShellFolder_EnumObjects ((IShellFolder2*)This, 0, - SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &penum); - if (penum) { - LPITEMIDLIST pidl; - DWORD dwFetched; - int i = 1; - -next: - IEnumIDList_Reset (penum); - while (S_OK == IEnumIDList_Next (penum, 1, &pidl, &dwFetched) && - dwFetched) { - _ILSimpleGetTextW (pidl, wszText, MAX_PATH); - if (0 == lstrcmpiW (wszText, pwszName)) { - _snwprintf (pwszName, uLen, wszFormat, wszNewFolder, i++); - if (i > 99) { - hr = E_FAIL; - break; - } - goto next; - } - } - - IEnumIDList_Release (penum); - } - return hr; -} - -static HRESULT WINAPI -ISF_Desktop_ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCWSTR pwszName, - LPITEMIDLIST * ppidlOut) -{ - IGenericSFImpl *This = impl_from_ISFHelper(iface); - WCHAR wszNewDir[MAX_PATH]; - DWORD bRes; - HRESULT hres = E_FAIL; - - TRACE ("(%p)(%s %p)\n", This, debugstr_w(pwszName), ppidlOut); - - wszNewDir[0] = 0; - if (This->sPathTarget) - lstrcpynW(wszNewDir, This->sPathTarget, MAX_PATH); - PathAppendW(wszNewDir, pwszName); - bRes = CreateDirectoryW (wszNewDir, NULL); - if (bRes) - { - SHChangeNotify (SHCNE_MKDIR, SHCNF_PATHW, wszNewDir, NULL); - hres = S_OK; - if (ppidlOut) - hres = _ILCreateFromPathW(wszNewDir, ppidlOut); - } - - return hres; -} -static HRESULT WINAPI -ISF_Desktop_ISFHelper_fnDeleteItems (ISFHelper * iface, UINT cidl, LPCITEMIDLIST * apidl) -{ - IGenericSFImpl *This = impl_from_ISFHelper(iface); - UINT i; - SHFILEOPSTRUCTW op; - WCHAR wszPath[MAX_PATH]; - WCHAR wszCaption[50]; - WCHAR *wszPathsList; - HRESULT ret; - WCHAR *wszCurrentPath; - UINT bRestoreWithDeskCpl = FALSE; - int res; - - TRACE ("(%p)(%u %p)\n", This, cidl, apidl); - if (cidl==0) return S_OK; - - for(i = 0; i < cidl; i++) - { - if (_ILIsMyComputer(apidl[i])) - bRestoreWithDeskCpl++; - else if (_ILIsNetHood(apidl[i])) - bRestoreWithDeskCpl++; - else if (_ILIsMyDocuments(apidl[i])) - bRestoreWithDeskCpl++; - } - - if (bRestoreWithDeskCpl) - { - /* FIXME use FormatMessage - * use a similar message resource as in windows - */ - LoadStringW(shell32_hInstance, IDS_DELETEMULTIPLE_TEXT, wszPath, sizeof(wszPath)/sizeof(WCHAR)); - wszPath[(sizeof(wszPath)/sizeof(WCHAR))-1] = 0; - - LoadStringW(shell32_hInstance, IDS_DELETEITEM_CAPTION, wszCaption, sizeof(wszCaption)/sizeof(WCHAR)); - wszCaption[(sizeof(wszCaption)/sizeof(WCHAR))-1] = 0; - - res = SHELL_ConfirmMsgBox(GetActiveWindow(), wszPath, wszCaption, NULL, cidl > 1); - if (res == IDD_YESTOALL || res == IDYES) - { - for(i = 0; i < cidl; i++) - { - if (_ILIsMyComputer(apidl[i])) - SetNamespaceExtensionVisibleStatus(L"{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 0x1); - else if (_ILIsNetHood(apidl[i])) - SetNamespaceExtensionVisibleStatus(L"{208D2C60-3AEA-1069-A2D7-08002B30309D}", 0x1); - else if (_ILIsMyDocuments(apidl[i])) - SetNamespaceExtensionVisibleStatus(L"{450D8FBA-AD25-11D0-98A8-0800361B1103}", 0x1); - } - } - } - if (This->sPathTarget) - lstrcpynW(wszPath, This->sPathTarget, MAX_PATH); - else - wszPath[0] = '\0'; - - PathAddBackslashW(wszPath); - wszPathsList = build_paths_list(wszPath, cidl, apidl); - - ZeroMemory(&op, sizeof(op)); - op.hwnd = GetActiveWindow(); - op.wFunc = FO_DELETE; - op.pFrom = wszPathsList; - op.fFlags = FOF_ALLOWUNDO; - if (SHFileOperationW(&op)) - { - WARN("SHFileOperation failed\n"); - ret = E_FAIL; - } - else - ret = S_OK; - - /* we currently need to manually send the notifies */ - wszCurrentPath = wszPathsList; - for (i = 0; i < cidl; i++) - { - LONG wEventId; - - if (_ILIsFolder(apidl[i])) - wEventId = SHCNE_RMDIR; - else if (_ILIsValue(apidl[i])) - wEventId = SHCNE_DELETE; - else - continue; - - /* check if file exists */ - if (GetFileAttributesW(wszCurrentPath) == INVALID_FILE_ATTRIBUTES) - { - LPITEMIDLIST pidl = ILCombine(This->pidlRoot, apidl[i]); - SHChangeNotify(wEventId, SHCNF_IDLIST, pidl, NULL); - SHFree(pidl); - } - - wszCurrentPath += wcslen(wszCurrentPath)+1; - } - HeapFree(GetProcessHeap(), 0, wszPathsList); - return ret; -} - -static HRESULT WINAPI -ISF_Desktop_ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl, LPCITEMIDLIST * apidl) -{ - IPersistFolder2 *ppf2 = NULL; - WCHAR szSrcPath[MAX_PATH]; - WCHAR szTargetPath[MAX_PATH]; - SHFILEOPSTRUCTW op; - LPITEMIDLIST pidl; - LPWSTR pszSrc, pszTarget, pszSrcList, pszTargetList, pszFileName; - int res, length; - STRRET strRet; - IGenericSFImpl *This = impl_from_ISFHelper(iface); - - TRACE ("(%p)->(%p,%u,%p)\n", This, pSFFrom, cidl, apidl); - - IShellFolder_QueryInterface (pSFFrom, &IID_IPersistFolder2, (LPVOID *) & ppf2); - if (ppf2) - { - if (FAILED(IPersistFolder2_GetCurFolder (ppf2, &pidl))) - { - IPersistFolder2_Release(ppf2); - return E_FAIL; - } - IPersistFolder2_Release(ppf2); - - if (FAILED(IShellFolder_GetDisplayNameOf(pSFFrom, pidl, SHGDN_FORPARSING, &strRet))) - { - SHFree (pidl); - return E_FAIL; - } - - if (FAILED(StrRetToBufW(&strRet, pidl, szSrcPath, MAX_PATH))) - { - SHFree (pidl); - return E_FAIL; - } - SHFree (pidl); - - pszSrc = PathAddBackslashW (szSrcPath); - - wcscpy(szTargetPath, This->sPathTarget); - pszTarget = PathAddBackslashW (szTargetPath); - - pszSrcList = build_paths_list(szSrcPath, cidl, apidl); - pszTargetList = build_paths_list(szTargetPath, cidl, apidl); - - if (!pszSrcList || !pszTargetList) - { - if (pszSrcList) - HeapFree(GetProcessHeap(), 0, pszSrcList); - - if (pszTargetList) - HeapFree(GetProcessHeap(), 0, pszTargetList); - - SHFree (pidl); - IPersistFolder2_Release (ppf2); - return E_OUTOFMEMORY; - } - ZeroMemory(&op, sizeof(op)); - if (!pszSrcList[0]) - { - /* remove trailing backslash */ - pszSrc--; - pszSrc[0] = L'\0'; - op.pFrom = szSrcPath; - } - else - { - op.pFrom = pszSrcList; - } - - if (!pszTargetList[0]) - { - /* remove trailing backslash */ - if (pszTarget - szTargetPath > 3) - { - pszTarget--; - pszTarget[0] = L'\0'; - } - else - { - pszTarget[1] = L'\0'; - } - - op.pTo = szTargetPath; - } - else - { - op.pTo = pszTargetList; - } - op.hwnd = GetActiveWindow(); - op.wFunc = FO_COPY; - op.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMMKDIR; - - res = SHFileOperationW(&op); - - if (res == DE_SAMEFILE) - { - length = wcslen(szTargetPath); - - - pszFileName = wcsrchr(pszSrcList, '\\'); - pszFileName++; - - if (LoadStringW(shell32_hInstance, IDS_COPY_OF, pszTarget, MAX_PATH - length)) - { - wcscat(szTargetPath, L" "); - } - - wcscat(szTargetPath, pszFileName); - op.pTo = szTargetPath; - - res = SHFileOperationW(&op); - } - - - HeapFree(GetProcessHeap(), 0, pszSrcList); - HeapFree(GetProcessHeap(), 0, pszTargetList); - - if (res) - return E_FAIL; - else - return S_OK; - } - return E_FAIL; -} - -static const ISFHelperVtbl vt_FSFldr_ISFHelper = -{ - ISF_Desktop_ISFHelper_fnQueryInterface, - ISF_Desktop_ISFHelper_fnAddRef, - ISF_Desktop_ISFHelper_fnRelease, - ISF_Desktop_ISFHelper_fnGetUniqueName, - ISF_Desktop_ISFHelper_fnAddFolder, - ISF_Desktop_ISFHelper_fnDeleteItems, - ISF_Desktop_ISFHelper_fnCopyItems -}; - - -/************************************************************************** - * ISF_Desktop_Constructor - */ -HRESULT WINAPI ISF_Desktop_Constructor ( - IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) -{ - static IGenericSFImpl *cached_sf; - WCHAR szMyPath[MAX_PATH]; - - TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid)); - - if (!ppv) - return E_POINTER; - if (pUnkOuter) - return CLASS_E_NOAGGREGATION; - - if (!cached_sf) - { - IGenericSFImpl *sf; - - if (!SHGetSpecialFolderPathW( 0, szMyPath, CSIDL_DESKTOPDIRECTORY, TRUE )) - return E_UNEXPECTED; - - sf = LocalAlloc( LMEM_ZEROINIT, sizeof (IGenericSFImpl) ); - if (!sf) - return E_OUTOFMEMORY; - - sf->ref = 1; - sf->lpVtbl = &vt_MCFldr_ShellFolder2; - sf->lpPF2 = &vt_FSFldr_PersistFolder2; - sf->lpvtblSFHelper = &vt_FSFldr_ISFHelper; - sf->pidlRoot = _ILCreateDesktop(); /* my qualified pidl */ - sf->sPathTarget = SHAlloc( (wcslen(szMyPath) + 1)*sizeof(WCHAR) ); - wcscpy( sf->sPathTarget, szMyPath ); - - if (InterlockedCompareExchangePointer((void *)&cached_sf, sf, NULL) != NULL) - { - /* some other thread already been here */ - SHFree( sf->pidlRoot ); - SHFree( sf->sPathTarget ); - LocalFree( sf ); - } - } - - return IUnknown_QueryInterface( _IUnknown_(cached_sf), riid, ppv ); -} diff --git a/reactos/dll/win32/shell32/shfldr_fonts.c b/reactos/dll/win32/shell32/shfldr_fonts.c deleted file mode 100644 index 4ec244f00ab..00000000000 --- a/reactos/dll/win32/shell32/shfldr_fonts.c +++ /dev/null @@ -1,1057 +0,0 @@ -/* - * Fonts folder - * - * Copyright 2008 Johannes Anderwald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL (shell); - -/*********************************************************************** -* IShellFolder implementation -*/ - -typedef struct { - const IShellFolder2Vtbl *lpVtbl; - LONG ref; - const IContextMenu2Vtbl *lpVtblContextMenuFontItem; - const IPersistFolder2Vtbl *lpVtblPersistFolder2; - - /* both paths are parsible from the desktop */ - LPITEMIDLIST pidlRoot; /* absolute pidl */ - LPCITEMIDLIST apidl; /* currently focused font item */ -} IGenericSFImpl, *LPIGenericSFImpl; - -static const IShellFolder2Vtbl vt_ShellFolder2; -static const IPersistFolder2Vtbl vt_NP_PersistFolder2; -static const IContextMenu2Vtbl vt_ContextMenu2FontItem; - -#define _IPersistFolder2_Offset ((INT_PTR)(&(((IGenericSFImpl*)0)->lpVtblPersistFolder2))) -#define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder2_Offset); -#define _IContextMenuFontItem_Offset ((INT_PTR)(&(((IGenericSFImpl*)0)->lpVtblContextMenuFontItem))) -#define _ICOM_THIS_From_IContextMenu2FontItem(class, name) class* This = (class*)(((char*)name)-_IContextMenuFontItem_Offset); - -#define _IUnknown_(This) (IUnknown*)&(This->lpVtbl) -#define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl) -#define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpVtblPersistFolder2) - -static shvheader FontsSFHeader[] = { - {IDS_SHV_COLUMN8, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15}, - {IDS_SHV_COLUMN_FONTTYPE , SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15}, - {IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15}, - {IDS_SHV_COLUMN12, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15} -}; - -#define COLUMN_NAME 0 -#define COLUMN_TYPE 1 -#define COLUMN_SIZE 2 -#define COLUMN_FILENAME 3 - -#define FontsSHELLVIEWCOLUMNS (4) - - -static LPIGenericSFImpl __inline impl_from_IPersistFolder2( IPersistFolder2 *iface ) -{ - return (LPIGenericSFImpl)((char*)iface - FIELD_OFFSET(IGenericSFImpl, lpVtblPersistFolder2)); -} - -static LPIGenericSFImpl __inline impl_from_IContextMenu2(IContextMenu2 *iface) -{ - return (LPIGenericSFImpl)((char *)iface - FIELD_OFFSET(IGenericSFImpl, lpVtblContextMenuFontItem)); -} - -/************************************************************************** -* ISF_Fonts_Constructor -*/ -HRESULT WINAPI ISF_Fonts_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) -{ - IGenericSFImpl *sf; - - TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid)); - - if (!ppv) - return E_POINTER; - if (pUnkOuter) - return CLASS_E_NOAGGREGATION; - - sf = (IGenericSFImpl *) HeapAlloc ( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof (IGenericSFImpl)); - if (!sf) - return E_OUTOFMEMORY; - - sf->ref = 0; - sf->lpVtbl = &vt_ShellFolder2; - sf->lpVtblPersistFolder2 = &vt_NP_PersistFolder2; - sf->lpVtblContextMenuFontItem = &vt_ContextMenu2FontItem; - sf->pidlRoot = _ILCreateFont(); /* my qualified pidl */ - - if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) - { - IUnknown_Release (_IUnknown_ (sf)); - return E_NOINTERFACE; - } - - TRACE ("--(%p)\n", sf); - return S_OK; -} - -/************************************************************************** - * ISF_Fonts_fnQueryInterface - * - * NOTE - * supports not IPersist/IPersistFolder - */ -static HRESULT WINAPI ISF_Fonts_fnQueryInterface (IShellFolder2 *iface, REFIID riid, LPVOID *ppvObj) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj); - - *ppvObj = NULL; - - if (IsEqualIID (riid, &IID_IUnknown) || - IsEqualIID (riid, &IID_IShellFolder) || - IsEqualIID (riid, &IID_IShellFolder2)) - { - *ppvObj = This; - } - else if (IsEqualIID (riid, &IID_IPersist) || - IsEqualIID (riid, &IID_IPersistFolder) || - IsEqualIID (riid, &IID_IPersistFolder2)) - { - *ppvObj = _IPersistFolder2_ (This); - } - - if (*ppvObj) - { - IUnknown_AddRef ((IUnknown *) (*ppvObj)); - TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj); - return S_OK; - } - TRACE ("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -static ULONG WINAPI ISF_Fonts_fnAddRef (IShellFolder2 * iface) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE ("(%p)->(count=%u)\n", This, refCount - 1); - - return refCount; -} - -static ULONG WINAPI ISF_Fonts_fnRelease (IShellFolder2 * iface) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE ("(%p)->(count=%u)\n", This, refCount + 1); - - if (!refCount) { - TRACE ("-- destroying IShellFolder(%p)\n", This); - SHFree (This->pidlRoot); - HeapFree (GetProcessHeap(), 0, This); - } - return refCount; -} - -/************************************************************************** -* ISF_Fonts_fnParseDisplayName -*/ -static HRESULT WINAPI ISF_Fonts_fnParseDisplayName (IShellFolder2 * iface, - HWND hwndOwner, LPBC pbcReserved, LPOLESTR lpszDisplayName, - DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - HRESULT hr = E_UNEXPECTED; - - TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", This, - hwndOwner, pbcReserved, lpszDisplayName, debugstr_w (lpszDisplayName), - pchEaten, ppidl, pdwAttributes); - - *ppidl = 0; - if (pchEaten) - *pchEaten = 0; /* strange but like the original */ - - TRACE ("(%p)->(-- ret=0x%08x)\n", This, hr); - - return hr; -} - -static LPITEMIDLIST _ILCreateFontItem(LPWSTR pszFont, LPWSTR pszFile) -{ - PIDLDATA tmp; - LPITEMIDLIST pidl; - PIDLFontStruct * p; - int size0 = (char*)&tmp.u.cfont.szName-(char*)&tmp.u.cfont; - int size = size0; - - tmp.type = 0x00; - tmp.u.cfont.dummy = 0xFF; - tmp.u.cfont.offsFile = wcslen(pszFont) + 1; - - size += (tmp.u.cfont.offsFile + wcslen(pszFile) + 1) * sizeof(WCHAR); - - pidl = (LPITEMIDLIST)SHAlloc(size + 4); - if (!pidl) - return pidl; - - pidl->mkid.cb = size+2; - memcpy(pidl->mkid.abID, &tmp, 2+size0); - - p = &((PIDLDATA*)pidl->mkid.abID)->u.cfont; - wcscpy(p->szName, pszFont); - wcscpy(p->szName + tmp.u.cfont.offsFile, pszFile); - - *(WORD*)((char*)pidl+(size+2)) = 0; - return pidl; -} - -static PIDLFontStruct * _ILGetFontStruct(LPCITEMIDLIST pidl) -{ - LPPIDLDATA pdata = _ILGetDataPointer(pidl); - - if (pdata && pdata->type==0x00) - return (PIDLFontStruct*)&(pdata->u.cfont); - - return NULL; -} - - - -/************************************************************************** - * CreateFontsEnumListss() - */ -static BOOL CreateFontsEnumList(IEnumIDList *list, DWORD dwFlags) -{ - WCHAR szPath[MAX_PATH]; - WCHAR szName[LF_FACESIZE+20]; - WCHAR szFile[MAX_PATH]; - LPWSTR pszPath; - UINT Length; - LONG ret; - DWORD dwType, dwName, dwFile, dwIndex; - LPITEMIDLIST pidl; - HKEY hKey; - - if (dwFlags & SHCONTF_NONFOLDERS) - { - if (!SHGetSpecialFolderPathW(NULL, szPath, CSIDL_FONTS, FALSE)) - return FALSE; - - pszPath = PathAddBackslashW(szPath); - if (!pszPath) - return FALSE; - if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts", 0, KEY_READ, &hKey)!= ERROR_SUCCESS) - return FALSE; - - Length = pszPath - szPath; - dwIndex = 0; - do - { - dwName = sizeof(szName)/sizeof(WCHAR); - dwFile = sizeof(szFile)/sizeof(WCHAR); - ret = RegEnumValueW(hKey, dwIndex++, szName, &dwName, NULL, &dwType, (LPVOID)szFile, &dwFile); - if (ret == ERROR_SUCCESS) - { - szFile[(sizeof(szFile)/sizeof(WCHAR))-1] = L'\0'; - if (dwType == REG_SZ && wcslen(szFile) + Length + 1< (sizeof(szPath)/sizeof(WCHAR))) - { - wcscpy(&szPath[Length], szFile); - pidl = _ILCreateFontItem(szName, szPath); - TRACE("pidl %p name %s path %s\n", pidl, debugstr_w(szName), debugstr_w(szPath)); - if (pidl) - { - if (!AddToEnumList(list, pidl)) - SHFree(pidl); - } - } - } - }while(ret != ERROR_NO_MORE_ITEMS); - RegCloseKey(hKey); - - } - return TRUE; -} - -/************************************************************************** -* ISF_Fonts_fnEnumObjects -*/ -static HRESULT WINAPI ISF_Fonts_fnEnumObjects (IShellFolder2 * iface, - HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", This, - hwndOwner, dwFlags, ppEnumIDList); - - *ppEnumIDList = IEnumIDList_Constructor(); - if(*ppEnumIDList) - CreateFontsEnumList(*ppEnumIDList, dwFlags); - - TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList); - - return (*ppEnumIDList) ? S_OK : E_OUTOFMEMORY; -} - -/************************************************************************** -* ISF_Fonts_fnBindToObject -*/ -static HRESULT WINAPI ISF_Fonts_fnBindToObject (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, - pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); - - return SHELL32_BindToChild (This->pidlRoot, NULL, pidl, riid, ppvOut); -} - -/************************************************************************** -* ISF_Fonts_fnBindToStorage -*/ -static HRESULT WINAPI ISF_Fonts_fnBindToStorage (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, - pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); - - *ppvOut = NULL; - return E_NOTIMPL; -} - -/************************************************************************** -* ISF_Fonts_fnCompareIDs -*/ - -static HRESULT WINAPI ISF_Fonts_fnCompareIDs (IShellFolder2 * iface, - LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - int nReturn; - - TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2); - nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2); - TRACE ("-- %i\n", nReturn); - return nReturn; -} - -/************************************************************************** -* ISF_Fonts_fnCreateViewObject -*/ -static HRESULT WINAPI ISF_Fonts_fnCreateViewObject (IShellFolder2 * iface, - HWND hwndOwner, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - LPSHELLVIEW pShellView; - HRESULT hr = E_INVALIDARG; - - TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This, - hwndOwner, shdebugstr_guid (riid), ppvOut); - - if (!ppvOut) - return hr; - - *ppvOut = NULL; - - if (IsEqualIID (riid, &IID_IDropTarget)) - { - WARN ("IDropTarget not implemented\n"); - hr = E_NOTIMPL; - } - else if (IsEqualIID (riid, &IID_IContextMenu)) - { - WARN ("IContextMenu not implemented\n"); - hr = E_NOTIMPL; - } - else if (IsEqualIID (riid, &IID_IShellView)) - { - pShellView = IShellView_Constructor ((IShellFolder *) iface); - if (pShellView) - { - hr = IShellView_QueryInterface (pShellView, riid, ppvOut); - IShellView_Release (pShellView); - } - } - TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut); - return hr; -} - -/************************************************************************** -* ISF_Fonts_fnGetAttributesOf -*/ -static HRESULT WINAPI ISF_Fonts_fnGetAttributesOf (IShellFolder2 * iface, - UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - HRESULT hr = S_OK; - - TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n", This, - cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0); - - if (!rgfInOut) - return E_INVALIDARG; - if (cidl && !apidl) - return E_INVALIDARG; - - if (*rgfInOut == 0) - *rgfInOut = ~0; - - if (cidl == 0) - { - IShellFolder *psfParent = NULL; - LPCITEMIDLIST rpidl = NULL; - - hr = SHBindToParent(This->pidlRoot, &IID_IShellFolder, (LPVOID*)&psfParent, (LPCITEMIDLIST*)&rpidl); - if(SUCCEEDED(hr)) - { - SHELL32_GetItemAttributes (psfParent, rpidl, rgfInOut); - IShellFolder_Release(psfParent); - } - } - else - { - while (cidl > 0 && *apidl) - { - pdump (*apidl); - SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut); - apidl++; - cidl--; - } - } - - /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */ - *rgfInOut &= ~SFGAO_VALIDATE; - - TRACE ("-- result=0x%08x\n", *rgfInOut); - return hr; -} - -/************************************************************************** -* ISF_Fonts_fnGetUIObjectOf -* -* PARAMETERS -* hwndOwner [in] Parent window for any output -* cidl [in] array size -* apidl [in] simple pidl array -* riid [in] Requested Interface -* prgfInOut [ ] reserved -* ppvObject [out] Resulting Interface -* -*/ -static HRESULT WINAPI ISF_Fonts_fnGetUIObjectOf (IShellFolder2 * iface, - HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, - UINT * prgfInOut, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - LPITEMIDLIST pidl; - IUnknown *pObj = NULL; - HRESULT hr = E_INVALIDARG; - - TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", This, - hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut); - - if (!ppvOut) - return hr; - - *ppvOut = NULL; - - if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) - { - pObj = (IUnknown*)(&This->lpVtblContextMenuFontItem); - This->apidl = apidl[0]; - IUnknown_AddRef(pObj); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) - { - pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) - { - hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj); - } - else - hr = E_NOINTERFACE; - - if (SUCCEEDED(hr) && !pObj) - hr = E_OUTOFMEMORY; - - *ppvOut = pObj; - TRACE ("(%p)->hr=0x%08x\n", This, hr); - return hr; -} - -/************************************************************************** -* ISF_Fonts_fnGetDisplayNameOf -* -*/ -static HRESULT WINAPI ISF_Fonts_fnGetDisplayNameOf (IShellFolder2 * iface, - LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - PIDLFontStruct * pfont; - - TRACE("ISF_Fonts_fnGetDisplayNameOf (%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet); - pdump (pidl); - - if (!strRet) - return E_INVALIDARG; - - pfont = _ILGetFontStruct(pidl); - if (!pfont) - return E_INVALIDARG; - - strRet->u.pOleStr = CoTaskMemAlloc((wcslen(pfont->szName)+1) * sizeof(WCHAR)); - if (!strRet->u.pOleStr) - return E_OUTOFMEMORY; - - wcscpy(strRet->u.pOleStr, pfont->szName); - strRet->uType = STRRET_WSTR; - - return S_OK; -} - -/************************************************************************** -* ISF_Fonts_fnSetNameOf -* Changes the name of a file object or subfolder, possibly changing its item -* identifier in the process. -* -* PARAMETERS -* hwndOwner [in] Owner window for output -* pidl [in] simple pidl of item to change -* lpszName [in] the items new display name -* dwFlags [in] SHGNO formatting flags -* ppidlOut [out] simple pidl returned -*/ -static HRESULT WINAPI ISF_Fonts_fnSetNameOf (IShellFolder2 * iface, - HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */ - LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This, - hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut); - return E_FAIL; -} - -static HRESULT WINAPI ISF_Fonts_fnGetDefaultSearchGUID ( - IShellFolder2 * iface, GUID * pguid) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_Fonts_fnEnumSearches (IShellFolder2 * iface, - IEnumExtraSearch ** ppenum) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_Fonts_fnGetDefaultColumn (IShellFolder2 * iface, - DWORD dwRes, ULONG * pSort, ULONG * pDisplay) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)\n", This); - - if (pSort) - *pSort = 0; - if (pDisplay) - *pDisplay = 0; - - return S_OK; -} - -static HRESULT WINAPI ISF_Fonts_fnGetDefaultColumnState ( - IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)\n", This); - - if (!pcsFlags || iColumn >= FontsSHELLVIEWCOLUMNS) - return E_INVALIDARG; - *pcsFlags = FontsSFHeader[iColumn].pcsFlags; - return S_OK; -} - -static HRESULT WINAPI ISF_Fonts_fnGetDetailsEx (IShellFolder2 * iface, - LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_Fonts_fnGetDetailsOf (IShellFolder2 * iface, - LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - WCHAR buffer[MAX_PATH] = {0}; - HRESULT hr = E_FAIL; - PIDLFontStruct * pfont; - HANDLE hFile; - LARGE_INTEGER FileSize; - SHFILEINFOW fi; - - TRACE("(%p, %p, %d, %p)\n", This, pidl, iColumn, psd); - - if (iColumn >= FontsSHELLVIEWCOLUMNS) - return E_FAIL; - - psd->fmt = FontsSFHeader[iColumn].fmt; - psd->cxChar = FontsSFHeader[iColumn].cxChar; - if (pidl == NULL) - { - psd->str.uType = STRRET_WSTR; - if (LoadStringW(shell32_hInstance, FontsSFHeader[iColumn].colnameid, buffer, MAX_PATH)) - hr = SHStrDupW(buffer, &psd->str.u.pOleStr); - - return hr; - } - - if (iColumn == COLUMN_NAME) - { - psd->str.uType = STRRET_WSTR; - return IShellFolder2_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL, &psd->str); - } - - psd->str.uType = STRRET_CSTR; - psd->str.u.cStr[0] = '\0'; - - switch(iColumn) - { - case COLUMN_TYPE: - pfont = _ILGetFontStruct(pidl); - if (pfont) - { - if (SHGetFileInfoW(pfont->szName + pfont->offsFile, 0, &fi, sizeof(fi), SHGFI_TYPENAME)) - { - psd->str.u.pOleStr = CoTaskMemAlloc((wcslen(fi.szTypeName)+1) * sizeof(WCHAR)); - if (!psd->str.u.pOleStr) - return E_OUTOFMEMORY; - wcscpy(psd->str.u.pOleStr, fi.szTypeName); - psd->str.uType = STRRET_WSTR; - return S_OK; - } - } - break; - case COLUMN_SIZE: - pfont = _ILGetFontStruct(pidl); - if (pfont) - { - hFile = CreateFileW(pfont->szName + pfont->offsFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (hFile != INVALID_HANDLE_VALUE) - { - if (GetFileSizeEx(hFile, &FileSize)) - { - if (StrFormatByteSizeW(FileSize.QuadPart, buffer, sizeof(buffer)/sizeof(WCHAR))) - { - psd->str.u.pOleStr = CoTaskMemAlloc(wcslen(buffer) + 1); - if (!psd->str.u.pOleStr) - return E_OUTOFMEMORY; - wcscpy(psd->str.u.pOleStr, buffer); - psd->str.uType = STRRET_WSTR; - CloseHandle(hFile); - return S_OK; - } - } - CloseHandle(hFile); - } - } - break; - case COLUMN_FILENAME: - pfont = _ILGetFontStruct(pidl); - if (pfont) - { - psd->str.u.pOleStr = CoTaskMemAlloc((wcslen(pfont->szName + pfont->offsFile) + 1) * sizeof(WCHAR)); - if (psd->str.u.pOleStr) - { - psd->str.uType = STRRET_WSTR; - wcscpy(psd->str.u.pOleStr, pfont->szName + pfont->offsFile); - return S_OK; - } - else - return E_OUTOFMEMORY; - } - break; - } - - return E_FAIL; -} - -static HRESULT WINAPI ISF_Fonts_fnMapColumnToSCID (IShellFolder2 * iface, - UINT column, SHCOLUMNID * pscid) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)\n", This); - - return E_NOTIMPL; -} - -static const IShellFolder2Vtbl vt_ShellFolder2 = { - ISF_Fonts_fnQueryInterface, - ISF_Fonts_fnAddRef, - ISF_Fonts_fnRelease, - ISF_Fonts_fnParseDisplayName, - ISF_Fonts_fnEnumObjects, - ISF_Fonts_fnBindToObject, - ISF_Fonts_fnBindToStorage, - ISF_Fonts_fnCompareIDs, - ISF_Fonts_fnCreateViewObject, - ISF_Fonts_fnGetAttributesOf, - ISF_Fonts_fnGetUIObjectOf, - ISF_Fonts_fnGetDisplayNameOf, - ISF_Fonts_fnSetNameOf, - /* ShellFolder2 */ - ISF_Fonts_fnGetDefaultSearchGUID, - ISF_Fonts_fnEnumSearches, - ISF_Fonts_fnGetDefaultColumn, - ISF_Fonts_fnGetDefaultColumnState, - ISF_Fonts_fnGetDetailsEx, - ISF_Fonts_fnGetDetailsOf, - ISF_Fonts_fnMapColumnToSCID -}; - -/************************************************************************ - * INPFldr_PersistFolder2_QueryInterface - */ -static HRESULT WINAPI INPFldr_PersistFolder2_QueryInterface (IPersistFolder2 * iface, - REFIID iid, LPVOID * ppvObj) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)\n", This); - - return IUnknown_QueryInterface (_IUnknown_ (This), iid, ppvObj); -} - -/************************************************************************ - * INPFldr_PersistFolder2_AddRef - */ -static ULONG WINAPI INPFldr_PersistFolder2_AddRef (IPersistFolder2 * iface) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_AddRef (_IUnknown_ (This)); -} - -/************************************************************************ - * ISFPersistFolder_Release - */ -static ULONG WINAPI INPFldr_PersistFolder2_Release (IPersistFolder2 * iface) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_Release (_IUnknown_ (This)); -} - -/************************************************************************ - * INPFldr_PersistFolder2_GetClassID - */ -static HRESULT WINAPI INPFldr_PersistFolder2_GetClassID ( - IPersistFolder2 * iface, CLSID * lpClassId) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)\n", This); - - if (!lpClassId) - return E_POINTER; - - *lpClassId = CLSID_FontsFolderShortcut; - - return S_OK; -} - -/************************************************************************ - * INPFldr_PersistFolder2_Initialize - * - * NOTES: it makes no sense to change the pidl - */ -static HRESULT WINAPI INPFldr_PersistFolder2_Initialize ( - IPersistFolder2 * iface, LPCITEMIDLIST pidl) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)->(%p)\n", This, pidl); - - return E_NOTIMPL; -} - -/************************************************************************** - * IPersistFolder2_fnGetCurFolder - */ -static HRESULT WINAPI INPFldr_PersistFolder2_GetCurFolder ( - IPersistFolder2 * iface, LPITEMIDLIST * pidl) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)->(%p)\n", This, pidl); - - if (!pidl) - return E_POINTER; - - *pidl = ILClone (This->pidlRoot); - - return S_OK; -} - -static const IPersistFolder2Vtbl vt_NP_PersistFolder2 = -{ - INPFldr_PersistFolder2_QueryInterface, - INPFldr_PersistFolder2_AddRef, - INPFldr_PersistFolder2_Release, - INPFldr_PersistFolder2_GetClassID, - INPFldr_PersistFolder2_Initialize, - INPFldr_PersistFolder2_GetCurFolder -}; - -/************************************************************************** -* IContextMenu2 Implementation -*/ - -/************************************************************************ - * ISF_Fonts_IContextMenu_QueryInterface - */ -static HRESULT WINAPI ISF_Fonts_IContextMenu2_QueryInterface(IContextMenu2 * iface, REFIID iid, LPVOID * ppvObject) -{ - _ICOM_THIS_From_IContextMenu2FontItem(IGenericSFImpl, iface); - - TRACE("(%p)\n", This); - - return IUnknown_QueryInterface(_IUnknown_(This), iid, ppvObject); -} - -/************************************************************************ - * ISF_Fonts_IContextMenu_AddRef - */ -static ULONG WINAPI ISF_Fonts_IContextMenu2_AddRef(IContextMenu2 * iface) -{ - _ICOM_THIS_From_IContextMenu2FontItem(IGenericSFImpl, iface); - - TRACE("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_AddRef(_IUnknown_(This)); -} - -/************************************************************************ - * ISF_Fonts_IContextMenu_Release - */ -static ULONG WINAPI ISF_Fonts_IContextMenu2_Release(IContextMenu2 * iface) -{ - _ICOM_THIS_From_IContextMenu2FontItem(IGenericSFImpl, iface); - - TRACE("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_Release(_IUnknown_(This)); -} - -/************************************************************************** -* ISF_Fonts_IContextMenu_QueryContextMenu() -*/ -static HRESULT WINAPI ISF_Fonts_IContextMenu2_QueryContextMenu( - IContextMenu2 *iface, - HMENU hMenu, - UINT indexMenu, - UINT idCmdFirst, - UINT idCmdLast, - UINT uFlags) -{ - WCHAR szBuffer[30] = {0}; - ULONG Count = 1; - - _ICOM_THIS_From_IContextMenu2FontItem(IGenericSFImpl, iface); - - TRACE("(%p)->(hmenu=%p indexmenu=%x cmdfirst=%x cmdlast=%x flags=%x )\n", - This, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags); - - if (LoadStringW(shell32_hInstance, IDS_OPEN, szBuffer, sizeof(szBuffer)/sizeof(WCHAR))) - { - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count, MFT_STRING, szBuffer, MFS_DEFAULT); - Count++; - } - - if (LoadStringW(shell32_hInstance, IDS_PRINT_VERB, szBuffer, sizeof(szBuffer)/sizeof(WCHAR))) - { - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count++, MFT_STRING, szBuffer, MFS_ENABLED); - } - - if (LoadStringW(shell32_hInstance, IDS_COPY, szBuffer, sizeof(szBuffer)/sizeof(WCHAR))) - { - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count++, MFT_SEPARATOR, NULL, MFS_ENABLED); - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count++, MFT_STRING, szBuffer, MFS_ENABLED); - } - - if (LoadStringW(shell32_hInstance, IDS_DELETE, szBuffer, sizeof(szBuffer)/sizeof(WCHAR))) - { - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count++, MFT_SEPARATOR, NULL, MFS_ENABLED); - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count, MFT_STRING, szBuffer, MFS_ENABLED); - } - - if (LoadStringW(shell32_hInstance, IDS_PROPERTIES, szBuffer, sizeof(szBuffer)/sizeof(WCHAR))) - { - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count++, MFT_SEPARATOR, NULL, MFS_ENABLED); - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count, MFT_STRING, szBuffer, MFS_ENABLED); - } - - return MAKE_HRESULT(SEVERITY_SUCCESS, 0, Count); -} - - -/************************************************************************** -* ISF_Fonts_IContextMenu_InvokeCommand() -*/ -static HRESULT WINAPI ISF_Fonts_IContextMenu2_InvokeCommand( - IContextMenu2 *iface, - LPCMINVOKECOMMANDINFO lpcmi) -{ - SHELLEXECUTEINFOW sei; - PIDLFontStruct * pfont; - SHFILEOPSTRUCTW op; - IGenericSFImpl * This = impl_from_IContextMenu2(iface); - - - TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n",This,lpcmi,lpcmi->lpVerb, lpcmi->hwnd); - - if (lpcmi->lpVerb == MAKEINTRESOURCEA(1) || lpcmi->lpVerb == MAKEINTRESOURCEA(2) || lpcmi->lpVerb == MAKEINTRESOURCEA(7)) - { - ZeroMemory(&sei, sizeof(sei)); - sei.cbSize = sizeof(sei); - sei.hwnd = lpcmi->hwnd; - sei.nShow = SW_SHOWNORMAL; - if (lpcmi->lpVerb == MAKEINTRESOURCEA(1)) - sei.lpVerb = L"open"; - else if (lpcmi->lpVerb == MAKEINTRESOURCEA(2)) - sei.lpVerb = L"print"; - else if (lpcmi->lpVerb == MAKEINTRESOURCEA(7)) - sei.lpVerb = L"properties"; - - pfont = _ILGetFontStruct(This->apidl); - sei.lpFile = pfont->szName + pfont->offsFile; - - if (ShellExecuteExW(&sei) == FALSE) - return E_FAIL; - } - else if (lpcmi->lpVerb == MAKEINTRESOURCEA(4)) - { - FIXME("implement font copying\n"); - return E_NOTIMPL; - } - else if (lpcmi->lpVerb == MAKEINTRESOURCEA(6)) - { - ZeroMemory(&op, sizeof(op)); - op.hwnd = lpcmi->hwnd; - op.wFunc = FO_DELETE; - op.fFlags = FOF_ALLOWUNDO; - pfont = _ILGetFontStruct(This->apidl); - op.pFrom = pfont->szName + pfont->offsFile; - SHFileOperationW(&op); - } - - return S_OK; -} - -/************************************************************************** - * ISF_Fonts_IContextMenu_GetCommandString() - * - */ -static HRESULT WINAPI ISF_Fonts_IContextMenu2_GetCommandString( - IContextMenu2 *iface, - UINT_PTR idCommand, - UINT uFlags, - UINT* lpReserved, - LPSTR lpszName, - UINT uMaxNameLen) -{ - _ICOM_THIS_From_IContextMenu2FontItem(IGenericSFImpl, iface); - - TRACE("(%p)->(idcom=%lx flags=%x %p name=%p len=%x)\n",This, idCommand, uFlags, lpReserved, lpszName, uMaxNameLen); - - - return E_FAIL; -} - - - -/************************************************************************** -* ISF_Fonts_IContextMenu_HandleMenuMsg() -*/ -static HRESULT WINAPI ISF_Fonts_IContextMenu2_HandleMenuMsg( - IContextMenu2 *iface, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) -{ - _ICOM_THIS_From_IContextMenu2FontItem(IGenericSFImpl, iface); - - TRACE("ISF_Fonts_IContextMenu_HandleMenuMsg (%p)->(msg=%x wp=%lx lp=%lx)\n",This, uMsg, wParam, lParam); - - return E_NOTIMPL; -} - -static const IContextMenu2Vtbl vt_ContextMenu2FontItem = -{ - ISF_Fonts_IContextMenu2_QueryInterface, - ISF_Fonts_IContextMenu2_AddRef, - ISF_Fonts_IContextMenu2_Release, - ISF_Fonts_IContextMenu2_QueryContextMenu, - ISF_Fonts_IContextMenu2_InvokeCommand, - ISF_Fonts_IContextMenu2_GetCommandString, - ISF_Fonts_IContextMenu2_HandleMenuMsg -}; - - - - - - diff --git a/reactos/dll/win32/shell32/shfldr_fs.c b/reactos/dll/win32/shell32/shfldr_fs.c deleted file mode 100644 index 6a0c9537f2f..00000000000 --- a/reactos/dll/win32/shell32/shfldr_fs.c +++ /dev/null @@ -1,1715 +0,0 @@ - -/* - * file system folder - * - * Copyright 1997 Marcus Meissner - * Copyright 1998, 1999, 2002 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL (shell); - -/*********************************************************************** -* IShellFolder implementation -*/ - -typedef struct { - const IUnknownVtbl *lpVtbl; - LONG ref; - const IShellFolder2Vtbl *lpvtblShellFolder; - const IPersistFolder3Vtbl *lpvtblPersistFolder3; - const IDropTargetVtbl *lpvtblDropTarget; - const ISFHelperVtbl *lpvtblSFHelper; - - IUnknown *pUnkOuter; /* used for aggregation */ - - CLSID *pclsid; - - /* both paths are parsible from the desktop */ - LPWSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */ - - LPITEMIDLIST pidlRoot; /* absolute pidl */ - - UINT cfShellIDList; /* clipboardformat for IDropTarget */ - BOOL fAcceptFmt; /* flag for pending Drop */ -} IGenericSFImpl, *LPIGenericSFImpl; - -static const IUnknownVtbl unkvt; -static const IShellFolder2Vtbl sfvt; -static const IPersistFolder3Vtbl vt_FSFldr_PersistFolder3; /* IPersistFolder3 for a FS_Folder */ -static const IDropTargetVtbl dtvt; -static const ISFHelperVtbl shvt; - -static LPIGenericSFImpl __inline impl_from_IShellFolder2( IShellFolder2 *iface ) -{ - return (LPIGenericSFImpl)((char*)iface - FIELD_OFFSET(IGenericSFImpl, lpvtblShellFolder)); -} - -static LPIGenericSFImpl __inline impl_from_IPersistFolder3( IPersistFolder3 *iface ) -{ - return (LPIGenericSFImpl)((char*)iface - FIELD_OFFSET(IGenericSFImpl, lpvtblPersistFolder3)); -} - -static LPIGenericSFImpl __inline impl_from_IDropTarget( IDropTarget *iface ) -{ - return (LPIGenericSFImpl)((char*)iface - FIELD_OFFSET(IGenericSFImpl, lpvtblDropTarget)); -} - -static LPIGenericSFImpl __inline impl_from_ISFHelper( ISFHelper *iface ) -{ - return (LPIGenericSFImpl)((char*)iface - FIELD_OFFSET(IGenericSFImpl, lpvtblSFHelper)); -} - - -/* - converts This to an interface pointer -*/ -#define _IUnknown_(This) (IUnknown*)&(This->lpVtbl) -#define _IShellFolder_(This) (IShellFolder*)&(This->lpvtblShellFolder) -#define _IShellFolder2_(This) (IShellFolder2*)&(This->lpvtblShellFolder) -#define _IPersist_(This) (IPersist*)&(This->lpvtblPersistFolder3) -#define _IPersistFolder_(This) (IPersistFolder*)&(This->lpvtblPersistFolder3) -#define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpvtblPersistFolder3) -#define _IPersistFolder3_(This) (IPersistFolder3*)&(This->lpvtblPersistFolder3) -#define _IDropTarget_(This) (IDropTarget*)&(This->lpvtblDropTarget) -#define _ISFHelper_(This) (ISFHelper*)&(This->lpvtblSFHelper) - -/************************************************************************** -* registers clipboardformat once -*/ -static void SF_RegisterClipFmt (IGenericSFImpl * This) -{ - TRACE ("(%p)\n", This); - - if (!This->cfShellIDList) { - This->cfShellIDList = RegisterClipboardFormatW (CFSTR_SHELLIDLIST); - } -} - -/************************************************************************** -* we need a separate IUnknown to handle aggregation -* (inner IUnknown) -*/ -static HRESULT WINAPI IUnknown_fnQueryInterface (IUnknown * iface, REFIID riid, LPVOID * ppvObj) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj); - - *ppvObj = NULL; - - if (IsEqualIID (riid, &IID_IUnknown)) - *ppvObj = _IUnknown_ (This); - else if (IsEqualIID (riid, &IID_IShellFolder)) - *ppvObj = _IShellFolder_ (This); - else if (IsEqualIID (riid, &IID_IShellFolder2)) - *ppvObj = _IShellFolder_ (This); - else if (IsEqualIID (riid, &IID_IPersist)) - *ppvObj = _IPersist_ (This); - else if (IsEqualIID (riid, &IID_IPersistFolder)) - *ppvObj = _IPersistFolder_ (This); - else if (IsEqualIID (riid, &IID_IPersistFolder2)) - *ppvObj = _IPersistFolder2_ (This); - else if (IsEqualIID (riid, &IID_IPersistFolder3)) - *ppvObj = _IPersistFolder3_ (This); - else if (IsEqualIID (riid, &IID_ISFHelper)) - *ppvObj = _ISFHelper_ (This); - else if (IsEqualIID (riid, &IID_IDropTarget)) { - *ppvObj = _IDropTarget_ (This); - SF_RegisterClipFmt (This); - } - - if (*ppvObj) { - IUnknown_AddRef ((IUnknown *) (*ppvObj)); - TRACE ("-- Interface = %p\n", *ppvObj); - return S_OK; - } - TRACE ("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -static ULONG WINAPI IUnknown_fnAddRef (IUnknown * iface) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE ("(%p)->(count=%u)\n", This, refCount - 1); - - return refCount; -} - -static ULONG WINAPI IUnknown_fnRelease (IUnknown * iface) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE ("(%p)->(count=%u)\n", This, refCount + 1); - - if (!refCount) { - TRACE ("-- destroying IShellFolder(%p)\n", This); - - SHFree (This->pidlRoot); - SHFree (This->sPathTarget); - LocalFree ((HLOCAL) This); - } - return refCount; -} - -static const IUnknownVtbl unkvt = -{ - IUnknown_fnQueryInterface, - IUnknown_fnAddRef, - IUnknown_fnRelease, -}; - -static const shvheader GenericSFHeader[] = { - {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15}, - {IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10}, - {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10}, - {IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12}, - {IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5} -}; - -#define GENERICSHELLVIEWCOLUMNS 5 - -/************************************************************************** -* IFSFolder_Constructor -* -* NOTES -* creating undocumented ShellFS_Folder as part of an aggregation -* {F3364BA0-65B9-11CE-A9BA-00AA004AE837} -* -*/ -HRESULT WINAPI -IFSFolder_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) -{ - IGenericSFImpl *sf; - - TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid)); - - if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown)) - return CLASS_E_NOAGGREGATION; - sf = (IGenericSFImpl *) LocalAlloc (LMEM_ZEROINIT, sizeof (IGenericSFImpl)); - if (!sf) - return E_OUTOFMEMORY; - - sf->ref = 0; - sf->lpVtbl = &unkvt; - sf->lpvtblShellFolder = &sfvt; - sf->lpvtblPersistFolder3 = &vt_FSFldr_PersistFolder3; - sf->lpvtblDropTarget = &dtvt; - sf->lpvtblSFHelper = &shvt; - sf->pclsid = (CLSID *) & CLSID_ShellFSFolder; - sf->pUnkOuter = pUnkOuter ? pUnkOuter : _IUnknown_ (sf); - - if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) { - IUnknown_Release (_IUnknown_ (sf)); - return E_NOINTERFACE; - } - - TRACE ("--%p\n", *ppv); - return S_OK; -} - -/************************************************************************** - * IShellFolder_fnQueryInterface - * - * PARAMETERS - * REFIID riid [in ] Requested InterfaceID - * LPVOID* ppvObject [out] Interface* to hold the result - */ -static HRESULT WINAPI -IShellFolder_fnQueryInterface (IShellFolder2 * iface, REFIID riid, - LPVOID * ppvObj) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - - TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj); - - return IUnknown_QueryInterface (This->pUnkOuter, riid, ppvObj); -} - -/************************************************************************** -* IShellFolder_AddRef -*/ - -static ULONG WINAPI IShellFolder_fnAddRef (IShellFolder2 * iface) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_AddRef (This->pUnkOuter); -} - -/************************************************************************** - * IShellFolder_fnRelease - */ -static ULONG WINAPI IShellFolder_fnRelease (IShellFolder2 * iface) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_Release (This->pUnkOuter); -} - -/************************************************************************** - * SHELL32_CreatePidlFromBindCtx [internal] - * - * If the caller bound File System Bind Data, assume it is the - * find data for the path. - * This allows binding of paths that don't exist. - */ -LPITEMIDLIST SHELL32_CreatePidlFromBindCtx(IBindCtx *pbc, LPCWSTR path) -{ - static WCHAR szfsbc[] = { - 'F','i','l','e',' ','S','y','s','t','e','m',' ', - 'B','i','n','d',' ','D','a','t','a',0 }; - IFileSystemBindData *fsbd = NULL; - LPITEMIDLIST pidl = NULL; - IUnknown *param = NULL; - WIN32_FIND_DATAW wfd; - HRESULT r; - - TRACE("%p %s\n", pbc, debugstr_w(path)); - - if (!pbc) - return NULL; - - /* see if the caller bound File System Bind Data */ - r = IBindCtx_GetObjectParam( pbc, (LPOLESTR) szfsbc, ¶m ); - if (FAILED(r)) - return NULL; - - r = IUnknown_QueryInterface( param, &IID_IFileSystemBindData, - (LPVOID*) &fsbd ); - if (SUCCEEDED(r)) - { - r = IFileSystemBindData_GetFindData( fsbd, &wfd ); - if (SUCCEEDED(r)) - { - lstrcpynW( &wfd.cFileName[0], path, MAX_PATH ); - pidl = _ILCreateFromFindDataW( &wfd ); - } - IFileSystemBindData_Release( fsbd ); - } - - return pidl; -} - -/************************************************************************** -* IShellFolder_ParseDisplayName {SHELL32} -* -* Parse a display name. -* -* PARAMS -* hwndOwner [in] Parent window for any message's -* pbc [in] optional FileSystemBindData context -* lpszDisplayName [in] Unicode displayname. -* pchEaten [out] (unicode) characters processed -* ppidl [out] complex pidl to item -* pdwAttributes [out] items attributes -* -* NOTES -* Every folder tries to parse only its own (the leftmost) pidl and creates a -* subfolder to evaluate the remaining parts. -* Now we can parse into namespaces implemented by shell extensions -* -* Behaviour on win98: lpszDisplayName=NULL -> crash -* lpszDisplayName="" -> returns mycoputer-pidl -* -* FIXME -* pdwAttributes is not set -* pchEaten is not set like in windows -*/ -static HRESULT WINAPI -IShellFolder_fnParseDisplayName (IShellFolder2 * iface, - HWND hwndOwner, - LPBC pbc, - LPOLESTR lpszDisplayName, - DWORD * pchEaten, LPITEMIDLIST * ppidl, - DWORD * pdwAttributes) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - - HRESULT hr = E_INVALIDARG; - LPCWSTR szNext = NULL; - WCHAR szElement[MAX_PATH]; - WCHAR szPath[MAX_PATH]; - LPITEMIDLIST pidlTemp = NULL; - DWORD len; - - TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", - This, hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName), - pchEaten, ppidl, pdwAttributes); - - if (!lpszDisplayName || !ppidl) - return E_INVALIDARG; - - if (pchEaten) - *pchEaten = 0; /* strange but like the original */ - - pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, lpszDisplayName); - if (!pidlTemp && *lpszDisplayName) - { - /* get the next element */ - szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH); - - /* build the full pathname to the element */ - lstrcpynW(szPath, This->sPathTarget, MAX_PATH - 1); - PathAddBackslashW(szPath); - len = wcslen(szPath); - lstrcpynW(szPath + len, szElement, MAX_PATH - len); - - /* get the pidl */ - hr = _ILCreateFromPathW(szPath, &pidlTemp); - - if (SUCCEEDED(hr)) { - if (szNext && *szNext) { - /* try to analyse the next element */ - hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, - &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes); - } else { - /* it's the last element */ - if (pdwAttributes && *pdwAttributes) { - hr = SHELL32_GetItemAttributes (_IShellFolder_ (This), - pidlTemp, pdwAttributes); - } - } - } - } - - if (SUCCEEDED(hr)) - *ppidl = pidlTemp; - else - *ppidl = NULL; - - TRACE ("(%p)->(-- pidl=%p ret=0x%08x)\n", This, ppidl ? *ppidl : 0, hr); - - return hr; -} - -/************************************************************************** -* IShellFolder_fnEnumObjects -* PARAMETERS -* HWND hwndOwner, //[in ] Parent Window -* DWORD grfFlags, //[in ] SHCONTF enumeration mask -* LPENUMIDLIST* ppenumIDList //[out] IEnumIDList interface -*/ -static HRESULT WINAPI -IShellFolder_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, - DWORD dwFlags, LPENUMIDLIST * ppEnumIDList) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - - TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", This, hwndOwner, - dwFlags, ppEnumIDList); - - *ppEnumIDList = IEnumIDList_Constructor(); - if (*ppEnumIDList) - CreateFolderEnumList(*ppEnumIDList, This->sPathTarget, dwFlags); - - TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList); - - return *ppEnumIDList ? S_OK : E_OUTOFMEMORY; -} - -/************************************************************************** -* IShellFolder_fnBindToObject -* PARAMETERS -* LPCITEMIDLIST pidl, //[in ] relative pidl to open -* LPBC pbc, //[in ] optional FileSystemBindData context -* REFIID riid, //[in ] Initial Interface -* LPVOID* ppvObject //[out] Interface* -*/ -static HRESULT WINAPI -IShellFolder_fnBindToObject (IShellFolder2 * iface, LPCITEMIDLIST pidl, - LPBC pbc, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - - TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbc, - shdebugstr_guid (riid), ppvOut); - - return SHELL32_BindToChild (This->pidlRoot, This->sPathTarget, pidl, riid, - ppvOut); -} - -/************************************************************************** -* IShellFolder_fnBindToStorage -* PARAMETERS -* LPCITEMIDLIST pidl, //[in ] complex pidl to store -* LPBC pbc, //[in ] reserved -* REFIID riid, //[in ] Initial storage interface -* LPVOID* ppvObject //[out] Interface* returned -*/ -static HRESULT WINAPI -IShellFolder_fnBindToStorage (IShellFolder2 * iface, LPCITEMIDLIST pidl, - LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - - FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, - shdebugstr_guid (riid), ppvOut); - - *ppvOut = NULL; - return E_NOTIMPL; -} - -/************************************************************************** -* IShellFolder_fnCompareIDs -*/ - -static HRESULT WINAPI -IShellFolder_fnCompareIDs (IShellFolder2 * iface, LPARAM lParam, - LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - - int nReturn; - - TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2); - nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2); - TRACE ("-- %i\n", nReturn); - return nReturn; -} - -/************************************************************************** -* IShellFolder_fnCreateViewObject -*/ -static HRESULT WINAPI -IShellFolder_fnCreateViewObject (IShellFolder2 * iface, HWND hwndOwner, - REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - - LPSHELLVIEW pShellView; - HRESULT hr = E_INVALIDARG; - - TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid (riid), - ppvOut); - - if (ppvOut) { - *ppvOut = NULL; - - if (IsEqualIID (riid, &IID_IDropTarget)) { - hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, ppvOut); - } else if (IsEqualIID (riid, &IID_IContextMenu)) { - FIXME ("IContextMenu not implemented\n"); - hr = E_NOTIMPL; - } else if (IsEqualIID (riid, &IID_IShellView)) { - pShellView = IShellView_Constructor ((IShellFolder *) iface); - if (pShellView) { - hr = IShellView_QueryInterface (pShellView, riid, ppvOut); - IShellView_Release (pShellView); - } - } - } - TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut); - return hr; -} - -/************************************************************************** -* IShellFolder_fnGetAttributesOf -* -* PARAMETERS -* UINT cidl, //[in ] num elements in pidl array -* LPCITEMIDLIST* apidl, //[in ] simple pidl array -* ULONG* rgfInOut) //[out] result array -* -*/ -static HRESULT WINAPI -IShellFolder_fnGetAttributesOf (IShellFolder2 * iface, UINT cidl, - LPCITEMIDLIST * apidl, DWORD * rgfInOut) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - - HRESULT hr = S_OK; - - TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n", This, cidl, apidl, - rgfInOut, rgfInOut ? *rgfInOut : 0); - - if (!rgfInOut) - return E_INVALIDARG; - if (cidl && !apidl) - return E_INVALIDARG; - - if (*rgfInOut == 0) - *rgfInOut = ~0; - - if(cidl == 0){ - IShellFolder *psfParent = NULL; - LPCITEMIDLIST rpidl = NULL; - - hr = SHBindToParent(This->pidlRoot, &IID_IShellFolder, (LPVOID*)&psfParent, (LPCITEMIDLIST*)&rpidl); - if(SUCCEEDED(hr)) { - SHELL32_GetItemAttributes (psfParent, rpidl, rgfInOut); - IShellFolder_Release(psfParent); - } - } - else { - while (cidl > 0 && *apidl) { - pdump (*apidl); - SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut); - apidl++; - cidl--; - } - } - /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */ - *rgfInOut &= ~SFGAO_VALIDATE; - - TRACE ("-- result=0x%08x\n", *rgfInOut); - - return hr; -} - -/************************************************************************** -* IShellFolder_fnGetUIObjectOf -* -* PARAMETERS -* HWND hwndOwner, //[in ] Parent window for any output -* UINT cidl, //[in ] array size -* LPCITEMIDLIST* apidl, //[in ] simple pidl array -* REFIID riid, //[in ] Requested Interface -* UINT* prgfInOut, //[ ] reserved -* LPVOID* ppvObject) //[out] Resulting Interface -* -* NOTES -* This function gets asked to return "view objects" for one or more (multiple -* select) items: -* The viewobject typically is an COM object with one of the following -* interfaces: -* IExtractIcon,IDataObject,IContextMenu -* In order to support icon positions in the default Listview your DataObject -* must implement the SetData method (in addition to GetData :) - the shell -* passes a barely documented "Icon positions" structure to SetData when the -* drag starts, and GetData's it if the drop is in another explorer window that -* needs the positions. -*/ -static HRESULT WINAPI -IShellFolder_fnGetUIObjectOf (IShellFolder2 * iface, - HWND hwndOwner, - UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, - UINT * prgfInOut, LPVOID * ppvOut) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - - LPITEMIDLIST pidl; - IUnknown *pObj = NULL; - HRESULT hr = E_INVALIDARG; - - TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", - This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut); - - if (ppvOut) { - *ppvOut = NULL; - - if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) { - hr = CDefFolderMenu_Create2(This->pidlRoot, hwndOwner, cidl, apidl, (IShellFolder*)iface, NULL, 0, NULL, (IContextMenu**)&pObj); - } else if (IsEqualIID (riid, &IID_IDataObject)){ - if (cidl >= 1) { - pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, - This->pidlRoot, apidl, cidl); - hr = S_OK; - } - else - { - pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, (LPCITEMIDLIST*)&This->pidlRoot, 1); - hr = S_OK; - } - } else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) { - hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, - (LPVOID *) & pObj); - } else if ((IsEqualIID(riid,&IID_IShellLinkW) || - IsEqualIID(riid,&IID_IShellLinkA)) && (cidl == 1)) { - pidl = ILCombine (This->pidlRoot, apidl[0]); - hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj); - SHFree (pidl); - } else { - hr = E_NOINTERFACE; - } - - if (SUCCEEDED(hr) && !pObj) - hr = E_OUTOFMEMORY; - - *ppvOut = pObj; - } - TRACE ("(%p)->hr=0x%08x\n", This, hr); - return hr; -} - -static const WCHAR AdvancedW[] = { 'S','O','F','T','W','A','R','E', - '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\', - 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l', - 'o','r','e','r','\\','A','d','v','a','n','c','e','d',0 }; -static const WCHAR HideFileExtW[] = { 'H','i','d','e','F','i','l','e','E','x', - 't',0 }; -static const WCHAR NeverShowExtW[] = { 'N','e','v','e','r','S','h','o','w','E', - 'x','t',0 }; - -/****************************************************************************** - * SHELL_FS_HideExtension [Internal] - * - * Query the registry if the filename extension of a given path should be - * hidden. - * - * PARAMS - * szPath [I] Relative or absolute path of a file - * - * RETURNS - * TRUE, if the filename's extension should be hidden - * FALSE, otherwise. - */ -BOOL SHELL_FS_HideExtension(LPWSTR szPath) -{ - HKEY hKey; - DWORD dwData; - DWORD dwDataSize = sizeof (DWORD); - BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */ - - if (!RegCreateKeyExW(HKEY_CURRENT_USER, AdvancedW, 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0)) { - if (!RegQueryValueExW(hKey, HideFileExtW, 0, 0, (LPBYTE) &dwData, &dwDataSize)) - doHide = dwData; - RegCloseKey (hKey); - } - - if (!doHide) { - LPWSTR ext = PathFindExtensionW(szPath); - - if (*ext != '\0') { - WCHAR classname[MAX_PATH]; - LONG classlen = sizeof(classname); - - if (!RegQueryValueW(HKEY_CLASSES_ROOT, ext, classname, &classlen)) - if (!RegOpenKeyW(HKEY_CLASSES_ROOT, classname, &hKey)) { - if (!RegQueryValueExW(hKey, NeverShowExtW, 0, NULL, NULL, NULL)) - doHide = TRUE; - RegCloseKey(hKey); - } - } - } - return doHide; -} - -void SHELL_FS_ProcessDisplayFilename(LPWSTR szPath, DWORD dwFlags) -{ - /*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */ - if (!(dwFlags & SHGDN_FORPARSING) && - ((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) { - if (SHELL_FS_HideExtension(szPath) && szPath[0] != '.') - PathRemoveExtensionW(szPath); - } -} - -/************************************************************************** -* IShellFolder_fnGetDisplayNameOf -* Retrieves the display name for the specified file object or subfolder -* -* PARAMETERS -* LPCITEMIDLIST pidl, //[in ] complex pidl to item -* DWORD dwFlags, //[in ] SHGNO formatting flags -* LPSTRRET lpName) //[out] Returned display name -* -* FIXME -* if the name is in the pidl the ret value should be a STRRET_OFFSET -*/ - -static HRESULT WINAPI -IShellFolder_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, - DWORD dwFlags, LPSTRRET strRet) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - LPWSTR pszPath; - - HRESULT hr = S_OK; - int len = 0; - - TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet); - pdump (pidl); - - if (!pidl || !strRet) - return E_INVALIDARG; - - pszPath = CoTaskMemAlloc((MAX_PATH +1) * sizeof(WCHAR)); - if (!pszPath) - return E_OUTOFMEMORY; - - if (_ILIsDesktop(pidl)) { /* empty pidl */ - if ((GET_SHGDN_FOR(dwFlags) & SHGDN_FORPARSING) && - (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER)) - { - if (This->sPathTarget) - lstrcpynW(pszPath, This->sPathTarget, MAX_PATH); - } else { - /* pidl has to contain exactly one non null SHITEMID */ - hr = E_INVALIDARG; - } - } else if (_ILIsPidlSimple(pidl)) { - if ((GET_SHGDN_FOR(dwFlags) & SHGDN_FORPARSING) && - (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER) && - This->sPathTarget) - { - lstrcpynW(pszPath, This->sPathTarget, MAX_PATH); - PathAddBackslashW(pszPath); - len = wcslen(pszPath); - } - _ILSimpleGetTextW(pidl, pszPath + len, MAX_PATH + 1 - len); - if (!_ILIsFolder(pidl)) SHELL_FS_ProcessDisplayFilename(pszPath, dwFlags); - } else { - hr = SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, pszPath, MAX_PATH); - } - - if (SUCCEEDED(hr)) { - /* Win9x always returns ANSI strings, NT always returns Unicode strings */ - if (GetVersion() & 0x80000000) { - strRet->uType = STRRET_CSTR; - if (!WideCharToMultiByte(CP_ACP, 0, pszPath, -1, strRet->u.cStr, MAX_PATH, - NULL, NULL)) - strRet->u.cStr[0] = '\0'; - CoTaskMemFree(pszPath); - } else { - strRet->uType = STRRET_WSTR; - strRet->u.pOleStr = pszPath; - } - } else - CoTaskMemFree(pszPath); - - TRACE ("-- (%p)->(%s)\n", This, strRet->uType == STRRET_CSTR ? strRet->u.cStr : debugstr_w(strRet->u.pOleStr)); - return hr; -} - -/************************************************************************** -* IShellFolder_fnSetNameOf -* Changes the name of a file object or subfolder, possibly changing its item -* identifier in the process. -* -* PARAMETERS -* HWND hwndOwner, //[in ] Owner window for output -* LPCITEMIDLIST pidl, //[in ] simple pidl of item to change -* LPCOLESTR lpszName, //[in ] the items new display name -* DWORD dwFlags, //[in ] SHGNO formatting flags -* LPITEMIDLIST* ppidlOut) //[out] simple pidl returned -*/ -static HRESULT WINAPI IShellFolder_fnSetNameOf (IShellFolder2 * iface, - HWND hwndOwner, - LPCITEMIDLIST pidl, - LPCOLESTR lpName, - DWORD dwFlags, - LPITEMIDLIST * pPidlOut) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - WCHAR szSrc[MAX_PATH + 1], szDest[MAX_PATH + 1]; - LPWSTR ptr; - BOOL bIsFolder = _ILIsFolder (ILFindLastID (pidl)); - - TRACE ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This, hwndOwner, pidl, - debugstr_w (lpName), dwFlags, pPidlOut); - - /* build source path */ - lstrcpynW(szSrc, This->sPathTarget, MAX_PATH); - ptr = PathAddBackslashW (szSrc); - if (ptr) - _ILSimpleGetTextW (pidl, ptr, MAX_PATH + 1 - (ptr - szSrc)); - - /* build destination path */ - if (dwFlags == SHGDN_NORMAL || dwFlags & SHGDN_INFOLDER) { - lstrcpynW(szDest, This->sPathTarget, MAX_PATH); - ptr = PathAddBackslashW (szDest); - if (ptr) - lstrcpynW(ptr, lpName, MAX_PATH + 1 - (ptr - szDest)); - } else - lstrcpynW(szDest, lpName, MAX_PATH); - - if(!(dwFlags & SHGDN_FORPARSING) && SHELL_FS_HideExtension(szSrc)) { - WCHAR *ext = PathFindExtensionW(szSrc); - if(*ext != '\0') { - INT len = wcslen(szDest); - lstrcpynW(szDest + len, ext, MAX_PATH - len); - } - } - - TRACE ("src=%s dest=%s\n", debugstr_w(szSrc), debugstr_w(szDest)); - if (!memcmp(szSrc, szDest, (wcslen(szDest)+1) * sizeof(WCHAR))) - { - /* src and destination is the same */ - HRESULT hr = S_OK; - if (pPidlOut) - hr = _ILCreateFromPathW(szDest, pPidlOut); - - return hr; - } - - - if (MoveFileW (szSrc, szDest)) { - HRESULT hr = S_OK; - - if (pPidlOut) - hr = _ILCreateFromPathW(szDest, pPidlOut); - - SHChangeNotify (bIsFolder ? SHCNE_RENAMEFOLDER : SHCNE_RENAMEITEM, - SHCNF_PATHW, szSrc, szDest); - - return hr; - } - - return E_FAIL; -} - -static HRESULT WINAPI IShellFolder_fnGetDefaultSearchGUID (IShellFolder2 *iface, - GUID * pguid) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} -static HRESULT WINAPI IShellFolder_fnEnumSearches (IShellFolder2 * iface, - IEnumExtraSearch ** ppenum) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI -IShellFolder_fnGetDefaultColumn (IShellFolder2 * iface, DWORD dwRes, - ULONG * pSort, ULONG * pDisplay) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - - TRACE ("(%p)\n", This); - - if (pSort) - *pSort = 0; - if (pDisplay) - *pDisplay = 0; - - return S_OK; -} - -static HRESULT WINAPI -IShellFolder_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, - DWORD * pcsFlags) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - - TRACE ("(%p)\n", This); - - if (!pcsFlags || iColumn >= GENERICSHELLVIEWCOLUMNS) - return E_INVALIDARG; - - *pcsFlags = GenericSFHeader[iColumn].pcsFlags; - - return S_OK; -} - -static HRESULT WINAPI -IShellFolder_fnGetDetailsEx (IShellFolder2 * iface, LPCITEMIDLIST pidl, - const SHCOLUMNID * pscid, VARIANT * pv) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - FIXME ("(%p)\n", This); - - return E_NOTIMPL; -} - -static HRESULT WINAPI -IShellFolder_fnGetDetailsOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, - UINT iColumn, SHELLDETAILS * psd) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - HRESULT hr = E_FAIL; - - TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd); - - if (!psd || iColumn >= GENERICSHELLVIEWCOLUMNS) - return E_INVALIDARG; - - if (!pidl) { - /* the header titles */ - psd->fmt = GenericSFHeader[iColumn].fmt; - psd->cxChar = GenericSFHeader[iColumn].cxChar; - psd->str.uType = STRRET_CSTR; - LoadStringA (shell32_hInstance, GenericSFHeader[iColumn].colnameid, - psd->str.u.cStr, MAX_PATH); - return S_OK; - } else { - hr = S_OK; - psd->str.uType = STRRET_CSTR; - /* the data from the pidl */ - switch (iColumn) { - case 0: /* name */ - hr = IShellFolder_GetDisplayNameOf (iface, pidl, - SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); - break; - case 1: /* size */ - _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 2: /* type */ - _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 3: /* date */ - _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 4: /* attributes */ - _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH); - break; - } - } - - return hr; -} - -static HRESULT WINAPI -IShellFolder_fnMapColumnToSCID (IShellFolder2 * iface, UINT column, - SHCOLUMNID * pscid) -{ - IGenericSFImpl *This = impl_from_IShellFolder2(iface); - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static const IShellFolder2Vtbl sfvt = -{ - IShellFolder_fnQueryInterface, - IShellFolder_fnAddRef, - IShellFolder_fnRelease, - IShellFolder_fnParseDisplayName, - IShellFolder_fnEnumObjects, - IShellFolder_fnBindToObject, - IShellFolder_fnBindToStorage, - IShellFolder_fnCompareIDs, - IShellFolder_fnCreateViewObject, - IShellFolder_fnGetAttributesOf, - IShellFolder_fnGetUIObjectOf, - IShellFolder_fnGetDisplayNameOf, - IShellFolder_fnSetNameOf, - /* ShellFolder2 */ - IShellFolder_fnGetDefaultSearchGUID, - IShellFolder_fnEnumSearches, - IShellFolder_fnGetDefaultColumn, - IShellFolder_fnGetDefaultColumnState, - IShellFolder_fnGetDetailsEx, - IShellFolder_fnGetDetailsOf, - IShellFolder_fnMapColumnToSCID -}; - -/**************************************************************************** - * ISFHelper for IShellFolder implementation - */ - -static HRESULT WINAPI -ISFHelper_fnQueryInterface (ISFHelper * iface, REFIID riid, LPVOID * ppvObj) -{ - IGenericSFImpl *This = impl_from_ISFHelper(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_QueryInterface (This->pUnkOuter, riid, ppvObj); -} - -static ULONG WINAPI ISFHelper_fnAddRef (ISFHelper * iface) -{ - IGenericSFImpl *This = impl_from_ISFHelper(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_AddRef (This->pUnkOuter); -} - -static ULONG WINAPI ISFHelper_fnRelease (ISFHelper * iface) -{ - IGenericSFImpl *This = impl_from_ISFHelper(iface); - - TRACE ("(%p)\n", This); - - return IUnknown_Release (This->pUnkOuter); -} - -/**************************************************************************** - * ISFHelper_fnAddFolder - * - * creates a unique folder name - */ - -static HRESULT WINAPI -ISFHelper_fnGetUniqueName (ISFHelper * iface, LPWSTR pwszName, UINT uLen) -{ - IGenericSFImpl *This = impl_from_ISFHelper(iface); - IEnumIDList *penum; - HRESULT hr; - WCHAR wszText[MAX_PATH]; - WCHAR wszNewFolder[25]; - const WCHAR wszFormat[] = {'%','s',' ','%','d',0 }; - - LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, sizeof(wszNewFolder)/sizeof(WCHAR)); - - TRACE ("(%p)(%p %u)\n", This, pwszName, uLen); - - if (uLen < sizeof(wszNewFolder)/sizeof(WCHAR) + 3) - return E_POINTER; - - lstrcpynW (pwszName, wszNewFolder, uLen); - - hr = IShellFolder_fnEnumObjects (_IShellFolder2_ (This), 0, - SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &penum); - if (penum) { - LPITEMIDLIST pidl; - DWORD dwFetched; - int i = 1; - -next: - IEnumIDList_Reset (penum); - while (S_OK == IEnumIDList_Next (penum, 1, &pidl, &dwFetched) && - dwFetched) { - _ILSimpleGetTextW (pidl, wszText, MAX_PATH); - if (0 == lstrcmpiW (wszText, pwszName)) { - _snwprintf (pwszName, uLen, wszFormat, wszNewFolder, i++); - if (i > 99) { - hr = E_FAIL; - break; - } - goto next; - } - } - - IEnumIDList_Release (penum); - } - return hr; -} - -/**************************************************************************** - * ISFHelper_fnAddFolder - * - * adds a new folder. - */ - -static HRESULT WINAPI -ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCWSTR pwszName, - LPITEMIDLIST * ppidlOut) -{ - IGenericSFImpl *This = impl_from_ISFHelper(iface); - WCHAR wszNewDir[MAX_PATH]; - DWORD bRes; - HRESULT hres = E_FAIL; - - TRACE ("(%p)(%s %p)\n", This, debugstr_w(pwszName), ppidlOut); - - wszNewDir[0] = 0; - if (This->sPathTarget) - lstrcpynW(wszNewDir, This->sPathTarget, MAX_PATH); - PathAppendW(wszNewDir, pwszName); - - bRes = CreateDirectoryW (wszNewDir, NULL); - if (bRes) { - SHChangeNotify (SHCNE_MKDIR, SHCNF_PATHW, wszNewDir, NULL); - - hres = S_OK; - - if (ppidlOut) - hres = _ILCreateFromPathW(wszNewDir, ppidlOut); - } else { - WCHAR wszText[128 + MAX_PATH]; - WCHAR wszTempText[128]; - WCHAR wszCaption[256]; - - /* Cannot Create folder because of permissions */ - LoadStringW (shell32_hInstance, IDS_CREATEFOLDER_DENIED, wszTempText, - sizeof (wszTempText)); - LoadStringW (shell32_hInstance, IDS_CREATEFOLDER_CAPTION, wszCaption, - sizeof (wszCaption)); - swprintf (wszText, wszTempText, wszNewDir); - MessageBoxW (hwnd, wszText, wszCaption, MB_OK | MB_ICONEXCLAMATION); - } - - return hres; -} - -/**************************************************************************** - * build_paths_list - * - * Builds a list of paths like the one used in SHFileOperation from a table of - * PIDLs relative to the given base folder - */ -WCHAR *build_paths_list(LPCWSTR wszBasePath, int cidl, LPCITEMIDLIST *pidls) -{ - WCHAR *wszPathsList; - WCHAR *wszListPos; - int iPathLen; - int i; - - iPathLen = wcslen(wszBasePath); - wszPathsList = HeapAlloc(GetProcessHeap(), 0, MAX_PATH*sizeof(WCHAR)*cidl+1); - wszListPos = wszPathsList; - - for (i = 0; i < cidl; i++) { - if (!_ILIsFolder(pidls[i]) && !_ILIsValue(pidls[i])) - continue; - - lstrcpynW(wszListPos, wszBasePath, MAX_PATH); - /* FIXME: abort if path too long */ - _ILSimpleGetTextW(pidls[i], wszListPos+iPathLen, MAX_PATH-iPathLen); - wszListPos += wcslen(wszListPos)+1; - } - *wszListPos=0; - return wszPathsList; -} - -/**************************************************************************** - * ISFHelper_fnDeleteItems - * - * deletes items in folder - */ -static HRESULT WINAPI -ISFHelper_fnDeleteItems (ISFHelper * iface, UINT cidl, LPCITEMIDLIST * apidl) -{ - IGenericSFImpl *This = impl_from_ISFHelper(iface); - UINT i; - SHFILEOPSTRUCTW op; - WCHAR wszPath[MAX_PATH]; - WCHAR *wszPathsList; - HRESULT ret; - WCHAR *wszCurrentPath; - - TRACE ("(%p)(%u %p)\n", This, cidl, apidl); - if (cidl==0) return S_OK; - - if (This->sPathTarget) - lstrcpynW(wszPath, This->sPathTarget, MAX_PATH); - else - wszPath[0] = '\0'; - PathAddBackslashW(wszPath); - wszPathsList = build_paths_list(wszPath, cidl, apidl); - - ZeroMemory(&op, sizeof(op)); - op.hwnd = GetActiveWindow(); - op.wFunc = FO_DELETE; - op.pFrom = wszPathsList; - op.fFlags = FOF_ALLOWUNDO; - if (SHFileOperationW(&op)) - { - WARN("SHFileOperation failed\n"); - ret = E_FAIL; - } - else - ret = S_OK; - - /* we currently need to manually send the notifies */ - wszCurrentPath = wszPathsList; - for (i = 0; i < cidl; i++) - { - LONG wEventId; - - if (_ILIsFolder(apidl[i])) - wEventId = SHCNE_RMDIR; - else if (_ILIsValue(apidl[i])) - wEventId = SHCNE_DELETE; - else - continue; - - /* check if file exists */ - if (GetFileAttributesW(wszCurrentPath) == INVALID_FILE_ATTRIBUTES) - { - LPITEMIDLIST pidl = ILCombine(This->pidlRoot, apidl[i]); - SHChangeNotify(wEventId, SHCNF_IDLIST, pidl, NULL); - SHFree(pidl); - } - - wszCurrentPath += wcslen(wszCurrentPath)+1; - } - HeapFree(GetProcessHeap(), 0, wszPathsList); - return ret; -} - -/**************************************************************************** - * ISFHelper_fnCopyItems - * - * copies items to this folder - */ -static HRESULT WINAPI -ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl, - LPCITEMIDLIST * apidl) -{ - IPersistFolder2 *ppf2 = NULL; - WCHAR szSrcPath[MAX_PATH]; - WCHAR szTargetPath[MAX_PATH]; - SHFILEOPSTRUCTW op; - LPITEMIDLIST pidl; - LPWSTR pszSrc, pszTarget, pszSrcList, pszTargetList, pszFileName; - int res, length; - HRESULT hr; - STRRET strRet; - - IGenericSFImpl *This = impl_from_ISFHelper(iface); - - TRACE ("(%p)->(%p,%u,%p)\n", This, pSFFrom, cidl, apidl); - - hr = IShellFolder_QueryInterface (pSFFrom, &IID_IPersistFolder2, (LPVOID *) & ppf2); - if (SUCCEEDED(hr)) - { - if (FAILED(IPersistFolder2_GetCurFolder (ppf2, &pidl))) - { - IPersistFolder2_Release(ppf2); - return E_FAIL; - } - IPersistFolder2_Release(ppf2); - - if (FAILED(IShellFolder_GetDisplayNameOf(pSFFrom, pidl, SHGDN_FORPARSING, &strRet))) - { - SHFree (pidl); - return E_FAIL; - } - - if (FAILED(StrRetToBufW(&strRet, pidl, szSrcPath, MAX_PATH))) - { - SHFree (pidl); - return E_FAIL; - } - SHFree (pidl); - - pszSrc = PathAddBackslashW (szSrcPath); - - wcscpy(szTargetPath, This->sPathTarget); - pszTarget = PathAddBackslashW (szTargetPath); - - pszSrcList = build_paths_list(szSrcPath, cidl, apidl); - pszTargetList = build_paths_list(szTargetPath, cidl, apidl); - - if (!pszSrcList || !pszTargetList) - { - if (pszSrcList) - HeapFree(GetProcessHeap(), 0, pszSrcList); - - if (pszTargetList) - HeapFree(GetProcessHeap(), 0, pszTargetList); - - SHFree (pidl); - IPersistFolder2_Release (ppf2); - return E_OUTOFMEMORY; - } - ZeroMemory(&op, sizeof(op)); - if (!pszSrcList[0]) - { - /* remove trailing backslash */ - pszSrc--; - pszSrc[0] = L'\0'; - op.pFrom = szSrcPath; - } - else - { - op.pFrom = pszSrcList; - } - - if (!pszTargetList[0]) - { - /* remove trailing backslash */ - if (pszTarget - szTargetPath > 3) - { - pszTarget--; - pszTarget[0] = L'\0'; - } - else - { - pszTarget[1] = L'\0'; - } - - op.pTo = szTargetPath; - } - else - { - op.pTo = pszTargetList; - } - op.hwnd = GetActiveWindow(); - op.wFunc = FO_COPY; - op.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMMKDIR; - - res = SHFileOperationW(&op); - - if (res == DE_SAMEFILE) - { - length = wcslen(szTargetPath); - - pszFileName = wcsrchr(pszSrcList, '\\'); - pszFileName++; - - if (LoadStringW(shell32_hInstance, IDS_COPY_OF, pszTarget, MAX_PATH - length)) - { - wcscat(szTargetPath, L" "); - } - - wcscat(szTargetPath, pszFileName); - op.pTo = szTargetPath; - - res = SHFileOperationW(&op); - } - - HeapFree(GetProcessHeap(), 0, pszSrcList); - HeapFree(GetProcessHeap(), 0, pszTargetList); - - if (res) - return E_FAIL; - else - return S_OK; - } - return E_FAIL; -} - -static const ISFHelperVtbl shvt = -{ - ISFHelper_fnQueryInterface, - ISFHelper_fnAddRef, - ISFHelper_fnRelease, - ISFHelper_fnGetUniqueName, - ISFHelper_fnAddFolder, - ISFHelper_fnDeleteItems, - ISFHelper_fnCopyItems -}; - -/************************************************************************ - * IFSFldr_PersistFolder3_QueryInterface - * - */ -static HRESULT WINAPI -IFSFldr_PersistFolder3_QueryInterface (IPersistFolder3 * iface, REFIID iid, - LPVOID * ppvObj) -{ - IGenericSFImpl *This = impl_from_IPersistFolder3(iface); - - TRACE ("(%p)\n", This); - - return IUnknown_QueryInterface (This->pUnkOuter, iid, ppvObj); -} - -/************************************************************************ - * IFSFldr_PersistFolder3_AddRef - * - */ -static ULONG WINAPI -IFSFldr_PersistFolder3_AddRef (IPersistFolder3 * iface) -{ - IGenericSFImpl *This = impl_from_IPersistFolder3(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_AddRef (This->pUnkOuter); -} - -/************************************************************************ - * IFSFldr_PersistFolder3_Release - * - */ -static ULONG WINAPI -IFSFldr_PersistFolder3_Release (IPersistFolder3 * iface) -{ - IGenericSFImpl *This = impl_from_IPersistFolder3(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_Release (This->pUnkOuter); -} - -/************************************************************************ - * IFSFldr_PersistFolder3_GetClassID - */ -static HRESULT WINAPI -IFSFldr_PersistFolder3_GetClassID (IPersistFolder3 * iface, CLSID * lpClassId) -{ - IGenericSFImpl *This = impl_from_IPersistFolder3(iface); - - TRACE ("(%p)\n", This); - - if (!lpClassId) - return E_POINTER; - *lpClassId = *This->pclsid; - - return S_OK; -} - -/************************************************************************ - * IFSFldr_PersistFolder3_Initialize - * - * NOTES - * sPathTarget is not set. Don't know how to handle in a non rooted environment. - */ -static HRESULT WINAPI -IFSFldr_PersistFolder3_Initialize (IPersistFolder3 * iface, LPCITEMIDLIST pidl) -{ - WCHAR wszTemp[MAX_PATH]; - - IGenericSFImpl *This = impl_from_IPersistFolder3(iface); - - TRACE ("(%p)->(%p)\n", This, pidl); - - SHFree (This->pidlRoot); /* free the old pidl */ - This->pidlRoot = ILClone (pidl); /* set my pidl */ - - SHFree (This->sPathTarget); - This->sPathTarget = NULL; - - /* set my path */ - if (SHGetPathFromIDListW (pidl, wszTemp)) { - int len = wcslen(wszTemp); - This->sPathTarget = SHAlloc((len + 1) * sizeof(WCHAR)); - if (!This->sPathTarget) - return E_OUTOFMEMORY; - memcpy(This->sPathTarget, wszTemp, (len + 1) * sizeof(WCHAR)); - } - - TRACE ("--(%p)->(%s)\n", This, debugstr_w(This->sPathTarget)); - return S_OK; -} - -/************************************************************************** - * IFSFldr_PersistFolder3_GetCurFolder - */ -static HRESULT WINAPI -IFSFldr_PersistFolder3_fnGetCurFolder (IPersistFolder3 * iface, - LPITEMIDLIST * pidl) -{ - IGenericSFImpl *This = impl_from_IPersistFolder3(iface); - - TRACE ("(%p)->(%p)\n", This, pidl); - - if (!pidl) return E_POINTER; - *pidl = ILClone (This->pidlRoot); - return S_OK; -} - -/************************************************************************** - * IFSFldr_PersistFolder3_InitializeEx - * - * FIXME: error handling - */ -static HRESULT WINAPI -IFSFldr_PersistFolder3_InitializeEx (IPersistFolder3 * iface, - IBindCtx * pbc, LPCITEMIDLIST pidlRoot, - const PERSIST_FOLDER_TARGET_INFO * ppfti) -{ - WCHAR wszTemp[MAX_PATH]; - - IGenericSFImpl *This = impl_from_IPersistFolder3(iface); - - TRACE ("(%p)->(%p,%p,%p)\n", This, pbc, pidlRoot, ppfti); - if (ppfti) - TRACE ("--%p %s %s 0x%08x 0x%08x\n", - ppfti->pidlTargetFolder, debugstr_w (ppfti->szTargetParsingName), - debugstr_w (ppfti->szNetworkProvider), ppfti->dwAttributes, - ppfti->csidl); - - pdump (pidlRoot); - if (ppfti && ppfti->pidlTargetFolder) - pdump (ppfti->pidlTargetFolder); - - if (This->pidlRoot) - __SHFreeAndNil (&This->pidlRoot); /* free the old */ - if (This->sPathTarget) - __SHFreeAndNil (&This->sPathTarget); - - /* - * Root path and pidl - */ - This->pidlRoot = ILClone (pidlRoot); - - /* - * the target folder is spezified in csidl OR pidlTargetFolder OR - * szTargetParsingName - */ - if (ppfti) { - if (ppfti->csidl != -1) { - if (SHGetSpecialFolderPathW (0, wszTemp, ppfti->csidl, - ppfti->csidl & CSIDL_FLAG_CREATE)) { - int len = wcslen(wszTemp); - This->sPathTarget = SHAlloc((len + 1) * sizeof(WCHAR)); - if (!This->sPathTarget) - return E_OUTOFMEMORY; - memcpy(This->sPathTarget, wszTemp, (len + 1) * sizeof(WCHAR)); - } - } else if (ppfti->szTargetParsingName[0]) { - int len = wcslen(ppfti->szTargetParsingName); - This->sPathTarget = SHAlloc((len + 1) * sizeof(WCHAR)); - if (!This->sPathTarget) - return E_OUTOFMEMORY; - memcpy(This->sPathTarget, ppfti->szTargetParsingName, - (len + 1) * sizeof(WCHAR)); - } else if (ppfti->pidlTargetFolder) { - if (SHGetPathFromIDListW(ppfti->pidlTargetFolder, wszTemp)) { - int len = wcslen(wszTemp); - This->sPathTarget = SHAlloc((len + 1) * sizeof(WCHAR)); - if (!This->sPathTarget) - return E_OUTOFMEMORY; - memcpy(This->sPathTarget, wszTemp, (len + 1) * sizeof(WCHAR)); - } - } - } - - TRACE ("--(%p)->(target=%s)\n", This, debugstr_w(This->sPathTarget)); - pdump (This->pidlRoot); - return (This->sPathTarget) ? S_OK : E_FAIL; -} - -static HRESULT WINAPI -IFSFldr_PersistFolder3_GetFolderTargetInfo (IPersistFolder3 * iface, - PERSIST_FOLDER_TARGET_INFO * ppfti) -{ - IGenericSFImpl *This = impl_from_IPersistFolder3(iface); - FIXME ("(%p)->(%p)\n", This, ppfti); - ZeroMemory (ppfti, sizeof (*ppfti)); - return E_NOTIMPL; -} - -static const IPersistFolder3Vtbl vt_FSFldr_PersistFolder3 = -{ - IFSFldr_PersistFolder3_QueryInterface, - IFSFldr_PersistFolder3_AddRef, - IFSFldr_PersistFolder3_Release, - IFSFldr_PersistFolder3_GetClassID, - IFSFldr_PersistFolder3_Initialize, - IFSFldr_PersistFolder3_fnGetCurFolder, - IFSFldr_PersistFolder3_InitializeEx, - IFSFldr_PersistFolder3_GetFolderTargetInfo -}; - -/**************************************************************************** - * ISFDropTarget implementation - */ -static BOOL -ISFDropTarget_QueryDrop (IDropTarget * iface, DWORD dwKeyState, - LPDWORD pdwEffect) -{ - DWORD dwEffect = *pdwEffect; - - IGenericSFImpl *This = impl_from_IDropTarget(iface); - - *pdwEffect = DROPEFFECT_NONE; - - if (This->fAcceptFmt) { /* Does our interpretation of the keystate ... */ - *pdwEffect = KeyStateToDropEffect (dwKeyState); - - /* ... matches the desired effect ? */ - if (dwEffect & *pdwEffect) { - return TRUE; - } - } - return FALSE; -} - -static HRESULT WINAPI -ISFDropTarget_QueryInterface (IDropTarget * iface, REFIID riid, LPVOID * ppvObj) -{ - IGenericSFImpl *This = impl_from_IDropTarget(iface); - - TRACE ("(%p)\n", This); - - return IUnknown_QueryInterface (This->pUnkOuter, riid, ppvObj); -} - -static ULONG WINAPI ISFDropTarget_AddRef (IDropTarget * iface) -{ - IGenericSFImpl *This = impl_from_IDropTarget(iface); - - TRACE ("(%p)\n", This); - - return IUnknown_AddRef (This->pUnkOuter); -} - -static ULONG WINAPI ISFDropTarget_Release (IDropTarget * iface) -{ - IGenericSFImpl *This = impl_from_IDropTarget(iface); - - TRACE ("(%p)\n", This); - - return IUnknown_Release (This->pUnkOuter); -} - -static HRESULT WINAPI -ISFDropTarget_DragEnter (IDropTarget * iface, IDataObject * pDataObject, - DWORD dwKeyState, POINTL pt, DWORD * pdwEffect) -{ - FORMATETC fmt; - - IGenericSFImpl *This = impl_from_IDropTarget(iface); - - TRACE ("(%p)->(DataObject=%p)\n", This, pDataObject); - - InitFormatEtc (fmt, This->cfShellIDList, TYMED_HGLOBAL); - - This->fAcceptFmt = (S_OK == IDataObject_QueryGetData (pDataObject, &fmt)) ? - TRUE : FALSE; - - ISFDropTarget_QueryDrop (iface, dwKeyState, pdwEffect); - - return S_OK; -} - -static HRESULT WINAPI -ISFDropTarget_DragOver (IDropTarget * iface, DWORD dwKeyState, POINTL pt, - DWORD * pdwEffect) -{ - IGenericSFImpl *This = impl_from_IDropTarget(iface); - - TRACE ("(%p)\n", This); - - if (!pdwEffect) - return E_INVALIDARG; - - ISFDropTarget_QueryDrop (iface, dwKeyState, pdwEffect); - - return S_OK; -} - -static HRESULT WINAPI ISFDropTarget_DragLeave (IDropTarget * iface) -{ - IGenericSFImpl *This = impl_from_IDropTarget(iface); - - TRACE ("(%p)\n", This); - - This->fAcceptFmt = FALSE; - - return S_OK; -} - -static HRESULT WINAPI -ISFDropTarget_Drop (IDropTarget * iface, IDataObject * pDataObject, - DWORD dwKeyState, POINTL pt, DWORD * pdwEffect) -{ - IGenericSFImpl *This = impl_from_IDropTarget(iface); - - FIXME ("(%p) object dropped\n", This); - - return E_NOTIMPL; -} - -static const IDropTargetVtbl dtvt = { - ISFDropTarget_QueryInterface, - ISFDropTarget_AddRef, - ISFDropTarget_Release, - ISFDropTarget_DragEnter, - ISFDropTarget_DragOver, - ISFDropTarget_DragLeave, - ISFDropTarget_Drop -}; diff --git a/reactos/dll/win32/shell32/shfldr_mycomp.c b/reactos/dll/win32/shell32/shfldr_mycomp.c deleted file mode 100644 index 8a80035db23..00000000000 --- a/reactos/dll/win32/shell32/shfldr_mycomp.c +++ /dev/null @@ -1,1038 +0,0 @@ -/* - * Virtual Workplace folder - * - * Copyright 1997 Marcus Meissner - * Copyright 1998, 1999, 2002 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL (shell); - -/*********************************************************************** -* IShellFolder implementation -*/ - -typedef struct { - const IShellFolder2Vtbl *lpVtbl; - LONG ref; - const IPersistFolder2Vtbl *lpVtblPersistFolder2; - - /* both paths are parsible from the desktop */ - LPITEMIDLIST pidlRoot; /* absolute pidl */ - LPWSTR sName; -} IGenericSFImpl, *LPIGenericSFImpl; - -static const IShellFolder2Vtbl vt_ShellFolder2; -static const IPersistFolder2Vtbl vt_PersistFolder2; - -static LPIGenericSFImpl __inline impl_from_IPersistFolder2( IPersistFolder2 *iface ) -{ - return (LPIGenericSFImpl)((char*)iface - FIELD_OFFSET(IGenericSFImpl, lpVtblPersistFolder2)); -} - - -/* - converts This to an interface pointer -*/ -#define _IUnknown_(This) (IUnknown*)&(This->lpVtbl) -#define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl) -#define _IShellFolder2_(This) (IShellFolder2*)&(This->lpVtbl) - -#define _IPersist_(This) (IPersist*)&(This->lpVtblPersistFolder2) -#define _IPersistFolder_(This) (IPersistFolder*)&(This->lpVtblPersistFolder2) -#define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpVtblPersistFolder2) - -/*********************************************************************** -* IShellFolder [MyComputer] implementation -*/ - -static const shvheader MyComputerSFHeader[] = { - {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15}, - {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10}, - {IDS_SHV_COLUMN6, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10}, - {IDS_SHV_COLUMN7, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10}, -}; - -#define MYCOMPUTERSHELLVIEWCOLUMNS 4 - -/************************************************************************** -* ISF_MyComputer_Constructor -*/ -HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) -{ - IGenericSFImpl *sf; - DWORD dwSize; - WCHAR szName[MAX_PATH]; - TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid)); - - if (!ppv) - return E_POINTER; - if (pUnkOuter) - return CLASS_E_NOAGGREGATION; - - sf = LocalAlloc (LMEM_ZEROINIT, sizeof (IGenericSFImpl)); - if (!sf) - return E_OUTOFMEMORY; - - sf->ref = 0; - sf->lpVtbl = &vt_ShellFolder2; - sf->lpVtblPersistFolder2 = &vt_PersistFolder2; - sf->pidlRoot = _ILCreateMyComputer (); /* my qualified pidl */ - - if (FAILED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) - { - IUnknown_Release (_IUnknown_ (sf)); - return E_NOINTERFACE; - } - - dwSize = sizeof(szName); - if (RegGetValueW(HKEY_CURRENT_USER, - L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}", - NULL, - RRF_RT_REG_SZ, - NULL, - szName, - &dwSize) == ERROR_SUCCESS) - { - szName[MAX_PATH-1] = 0; - sf->sName = SHAlloc((wcslen(szName)+1) * sizeof(WCHAR)); - if (sf->sName) - { - wcscpy( sf->sName, szName ); - } - TRACE("sName %s\n", debugstr_w(sf->sName)); - } - - TRACE ("--(%p)\n", sf); - return S_OK; -} - -/************************************************************************** - * ISF_MyComputer_fnQueryInterface - * - * NOTES supports not IPersist/IPersistFolder - */ -static HRESULT WINAPI ISF_MyComputer_fnQueryInterface (IShellFolder2 *iface, - REFIID riid, LPVOID *ppvObj) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj); - - *ppvObj = NULL; - - if (IsEqualIID (riid, &IID_IUnknown) || - IsEqualIID (riid, &IID_IShellFolder) || - IsEqualIID (riid, &IID_IShellFolder2)) - { - *ppvObj = This; - } - else if (IsEqualIID (riid, &IID_IPersist) || - IsEqualIID (riid, &IID_IPersistFolder) || - IsEqualIID (riid, &IID_IPersistFolder2)) - { - *ppvObj = _IPersistFolder2_ (This); - } - - if (*ppvObj) - { - IUnknown_AddRef ((IUnknown *) (*ppvObj)); - TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj); - return S_OK; - } - TRACE ("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -static ULONG WINAPI ISF_MyComputer_fnAddRef (IShellFolder2 * iface) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE ("(%p)->(count=%u)\n", This, refCount - 1); - - return refCount; -} - -static ULONG WINAPI ISF_MyComputer_fnRelease (IShellFolder2 * iface) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE ("(%p)->(count=%u)\n", This, refCount + 1); - - if (!refCount) - { - TRACE ("-- destroying IShellFolder(%p)\n", This); - SHFree (This->pidlRoot); - LocalFree (This); - } - return refCount; -} - -/************************************************************************** -* ISF_MyComputer_fnParseDisplayName -*/ -static HRESULT WINAPI ISF_MyComputer_fnParseDisplayName (IShellFolder2 *iface, - HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, - DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - HRESULT hr = E_INVALIDARG; - LPCWSTR szNext = NULL; - WCHAR szElement[MAX_PATH]; - LPITEMIDLIST pidlTemp = NULL; - CLSID clsid; - - TRACE("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", This, - hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName), - pchEaten, ppidl, pdwAttributes); - - *ppidl = 0; - if (pchEaten) - *pchEaten = 0; /* strange but like the original */ - - /* handle CLSID paths */ - if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') - { - szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH); - TRACE ("-- element: %s\n", debugstr_w (szElement)); - CLSIDFromString (szElement + 2, &clsid); - pidlTemp = _ILCreateGuid (PT_GUID, &clsid); - } - /* do we have an absolute path name ? */ - else if (PathGetDriveNumberW (lpszDisplayName) >= 0 && - lpszDisplayName[2] == (WCHAR) '\\') - { - szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH); - /* make drive letter uppercase to enable PIDL comparison */ - szElement[0] = toupper(szElement[0]); - pidlTemp = _ILCreateDrive (szElement); - } - - if (szNext && *szNext) - { - hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, - (LPOLESTR) szNext, pchEaten, pdwAttributes); - } - else - { - if (pdwAttributes && *pdwAttributes) - SHELL32_GetItemAttributes (_IShellFolder_ (This), - pidlTemp, pdwAttributes); - hr = S_OK; - } - - *ppidl = pidlTemp; - - TRACE ("(%p)->(-- ret=0x%08x)\n", This, hr); - - return hr; -} - -/************************************************************************** - * CreateMyCompEnumList() - */ -static const WCHAR MyComputer_NameSpaceW[] = { 'S','O','F','T','W','A','R','E', - '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\', - 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l', - 'o','r','e','r','\\','M','y','C','o','m','p','u','t','e','r','\\','N','a','m', - 'e','s','p','a','c','e','\0' }; - -static BOOL CreateMyCompEnumList(IEnumIDList *list, DWORD dwFlags) -{ - BOOL ret = TRUE; - - TRACE("(%p)->(flags=0x%08x)\n", list, dwFlags); - - /* enumerate the folders */ - if (dwFlags & SHCONTF_FOLDERS) - { - WCHAR wszDriveName[] = {'A', ':', '\\', '\0'}; - DWORD dwDrivemap = GetLogicalDrives(); - HKEY hkey; - UINT i; - - while (ret && wszDriveName[0]<='Z') - { - if(dwDrivemap & 0x00000001L) - ret = AddToEnumList(list, _ILCreateDrive(wszDriveName)); - wszDriveName[0]++; - dwDrivemap = dwDrivemap >> 1; - } - - TRACE("-- (%p)-> enumerate (mycomputer shell extensions)\n",list); - for (i=0; i<2; i++) { - if (ret && !RegOpenKeyExW(i == 0 ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, - MyComputer_NameSpaceW, 0, KEY_READ, &hkey)) - { - WCHAR iid[50]; - int i=0; - - while (ret) - { - DWORD size; - LONG r; - - size = sizeof(iid) / sizeof(iid[0]); - r = RegEnumKeyExW(hkey, i, iid, &size, 0, NULL, NULL, NULL); - if (ERROR_SUCCESS == r) - { - /* FIXME: shell extensions, shouldn't the type be - * PT_SHELLEXT? */ - ret = AddToEnumList(list, _ILCreateGuidFromStrW(iid)); - i++; - } - else if (ERROR_NO_MORE_ITEMS == r) - break; - else - ret = FALSE; - } - RegCloseKey(hkey); - } - } - } - return ret; -} - -/************************************************************************** -* ISF_MyComputer_fnEnumObjects -*/ -static HRESULT WINAPI ISF_MyComputer_fnEnumObjects (IShellFolder2 *iface, - HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", This, - hwndOwner, dwFlags, ppEnumIDList); - - *ppEnumIDList = IEnumIDList_Constructor(); - if (*ppEnumIDList) - CreateMyCompEnumList(*ppEnumIDList, dwFlags); - - TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList); - - return (*ppEnumIDList) ? S_OK : E_OUTOFMEMORY; -} - -/************************************************************************** -* ISF_MyComputer_fnBindToObject -*/ -static HRESULT WINAPI ISF_MyComputer_fnBindToObject (IShellFolder2 *iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", This, - pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); - - return SHELL32_BindToChild (This->pidlRoot, NULL, pidl, riid, ppvOut); -} - -/************************************************************************** -* ISF_MyComputer_fnBindToStorage -*/ -static HRESULT WINAPI ISF_MyComputer_fnBindToStorage (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, - pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); - - *ppvOut = NULL; - return E_NOTIMPL; -} - -/************************************************************************** -* ISF_MyComputer_fnCompareIDs -*/ - -static HRESULT WINAPI ISF_MyComputer_fnCompareIDs (IShellFolder2 *iface, - LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - int nReturn; - - TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2); - nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2); - TRACE ("-- %i\n", nReturn); - return nReturn; -} - -/************************************************************************** -* ISF_MyComputer_fnCreateViewObject -*/ -static HRESULT WINAPI ISF_MyComputer_fnCreateViewObject (IShellFolder2 *iface, - HWND hwndOwner, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - LPSHELLVIEW pShellView; - HRESULT hr = E_INVALIDARG; - - TRACE("(%p)->(hwnd=%p,%s,%p)\n", This, - hwndOwner, shdebugstr_guid (riid), ppvOut); - - if (!ppvOut) - return hr; - - *ppvOut = NULL; - - if (IsEqualIID (riid, &IID_IDropTarget)) - { - WARN ("IDropTarget not implemented\n"); - hr = E_NOTIMPL; - } - else if (IsEqualIID (riid, &IID_IContextMenu)) - { - WARN ("IContextMenu not implemented\n"); - hr = E_NOTIMPL; - } - else if (IsEqualIID (riid, &IID_IShellView)) - { - pShellView = IShellView_Constructor ((IShellFolder *) iface); - if (pShellView) - { - hr = IShellView_QueryInterface (pShellView, riid, ppvOut); - IShellView_Release (pShellView); - } - } - TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut); - return hr; -} - -/************************************************************************** -* ISF_MyComputer_fnGetAttributesOf -*/ -static HRESULT WINAPI ISF_MyComputer_fnGetAttributesOf (IShellFolder2 * iface, - UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - HRESULT hr = S_OK; - static const DWORD dwComputerAttributes = - SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR | SFGAO_CANCOPY | - SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER | SFGAO_CANRENAME | SFGAO_CANDELETE; - - TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n", - This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0); - - if (!rgfInOut) - return E_INVALIDARG; - if (cidl && !apidl) - return E_INVALIDARG; - - if (*rgfInOut == 0) - *rgfInOut = ~0; - - if(cidl == 0) { - *rgfInOut &= dwComputerAttributes; - } else { - while (cidl > 0 && *apidl) { - pdump (*apidl); - SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut); - apidl++; - cidl--; - } - } - /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */ - *rgfInOut &= ~SFGAO_VALIDATE; - - TRACE ("-- result=0x%08x\n", *rgfInOut); - return hr; -} - -/************************************************************************** -* ISF_MyComputer_fnGetUIObjectOf -* -* PARAMETERS -* hwndOwner [in] Parent window for any output -* cidl [in] array size -* apidl [in] simple pidl array -* riid [in] Requested Interface -* prgfInOut [ ] reserved -* ppvObject [out] Resulting Interface -* -*/ -static HRESULT WINAPI ISF_MyComputer_fnGetUIObjectOf (IShellFolder2 * iface, - HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, - UINT * prgfInOut, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - LPITEMIDLIST pidl; - IUnknown *pObj = NULL; - HRESULT hr = E_INVALIDARG; - - TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", This, - hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut); - - if (!ppvOut) - return hr; - - *ppvOut = NULL; - - if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) - { - hr = CDefFolderMenu_Create2(This->pidlRoot, hwndOwner, cidl, apidl, (IShellFolder*)iface, NULL, 0, NULL, (IContextMenu**)&pObj); - } - else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) - { - pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, - This->pidlRoot, apidl, cidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) - { - hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, - (LPVOID *) &pObj); - } - else if ((IsEqualIID(riid,&IID_IShellLinkW) || - IsEqualIID(riid,&IID_IShellLinkA)) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*) &pObj); - SHFree (pidl); - } - else - hr = E_NOINTERFACE; - - if (SUCCEEDED(hr) && !pObj) - hr = E_OUTOFMEMORY; - - *ppvOut = pObj; - TRACE ("(%p)->hr=0x%08x\n", This, hr); - return hr; -} - -/************************************************************************** -* ISF_MyComputer_fnGetDisplayNameOf -*/ -static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 *iface, - LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - LPWSTR pszPath; - HRESULT hr = S_OK; - - TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet); - pdump (pidl); - - if (!strRet) - return E_INVALIDARG; - - pszPath = CoTaskMemAlloc((MAX_PATH +1) * sizeof(WCHAR)); - if (!pszPath) - return E_OUTOFMEMORY; - - pszPath[0] = 0; - - if (!pidl->mkid.cb) - { - /* parsing name like ::{...} */ - pszPath[0] = ':'; - pszPath[1] = ':'; - SHELL32_GUIDToStringW(&CLSID_MyComputer, &pszPath[2]); - } - else if (_ILIsPidlSimple(pidl)) - { - /* take names of special folders only if its only this folder */ - if (_ILIsSpecialFolder(pidl)) - { - GUID const *clsid; - - clsid = _ILGetGUIDPointer (pidl); - if (clsid) - { - if (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING) - { - static const WCHAR clsidW[] = - { 'C','L','S','I','D','\\',0 }; - static const WCHAR shellfolderW[] = - { '\\','s','h','e','l','l','f','o','l','d','e','r',0 }; - static const WCHAR wantsForParsingW[] = - { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n', - 'g',0 }; - int bWantsForParsing = FALSE; - WCHAR szRegPath[100]; - LONG r; - - /* - * We can only get a filesystem path from a shellfolder - * if the value WantsFORPARSING exists in - * CLSID\\{...}\\shellfolder - * exception: the MyComputer folder has this keys not - * but like any filesystem backed - * folder it needs these behaviour - * - * Get the "WantsFORPARSING" flag from the registry - */ - - wcscpy (szRegPath, clsidW); - SHELL32_GUIDToStringW (clsid, &szRegPath[6]); - wcscat (szRegPath, shellfolderW); - r = SHGetValueW (HKEY_CLASSES_ROOT, szRegPath, - wantsForParsingW, NULL, NULL, NULL); - if (r == ERROR_SUCCESS) - bWantsForParsing = TRUE; - - if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && - bWantsForParsing) - { - /* - * We need the filesystem path to the destination folder - * Only the folder itself can know it - */ - hr = SHELL32_GetDisplayNameOfChild (iface, pidl, - dwFlags, pszPath, MAX_PATH); - } - else - { - LPWSTR p = pszPath; - - /* parsing name like ::{...} */ - p[0] = ':'; - p[1] = ':'; - p += 2; - p += SHELL32_GUIDToStringW(&CLSID_MyComputer, p); - - /* \:: */ - p[0] = '\\'; - p[1] = ':'; - p[2] = ':'; - p += 3; - SHELL32_GUIDToStringW(clsid, p); - } - } - else - { - /* user friendly name */ - - if (_ILIsMyComputer(pidl) && This->sName) - wcscpy(pszPath, This->sName); - else - HCR_GetClassNameW (clsid, pszPath, MAX_PATH); - - TRACE("pszPath %s\n", debugstr_w(pszPath)); - } - } - else - { - /* append my own path */ - _ILSimpleGetTextW (pidl, pszPath, MAX_PATH); - } - } - else if (_ILIsDrive(pidl)) - { - - _ILSimpleGetTextW (pidl, pszPath, MAX_PATH); /* append my own path */ - /* long view "lw_name (C:)" */ - if (!(dwFlags & SHGDN_FORPARSING)) - { - WCHAR wszDrive[18] = {0}; - DWORD dwVolumeSerialNumber, dwMaximumComponentLength, dwFileSystemFlags; - static const WCHAR wszOpenBracket[] = {' ','(',0}; - static const WCHAR wszCloseBracket[] = {')',0}; - - lstrcpynW(wszDrive, pszPath, 4); - pszPath[0] = L'\0'; - GetVolumeInformationW (wszDrive, pszPath, - MAX_PATH - 7, - &dwVolumeSerialNumber, - &dwMaximumComponentLength, &dwFileSystemFlags, NULL, 0); - pszPath[MAX_PATH-1] = L'\0'; - if (!wcslen(pszPath)) - { - UINT DriveType, ResourceId; - DriveType = GetDriveTypeW(wszDrive); - switch(DriveType) - { - case DRIVE_FIXED: - ResourceId = IDS_DRIVE_FIXED; - break; - case DRIVE_REMOTE: - ResourceId = IDS_DRIVE_NETWORK; - break; - case DRIVE_CDROM: - ResourceId = IDS_DRIVE_CDROM; - break; - default: - ResourceId = 0; - } - if (ResourceId) - { - dwFileSystemFlags = LoadStringW(shell32_hInstance, ResourceId, pszPath, MAX_PATH); - if (dwFileSystemFlags > MAX_PATH - 7) - pszPath[MAX_PATH-7] = L'\0'; - } - } - wcscat (pszPath, wszOpenBracket); - wszDrive[2] = L'\0'; - wcscat (pszPath, wszDrive); - wcscat (pszPath, wszCloseBracket); - } - } - else - { - /* Neither a shell namespace extension nor a drive letter. */ - ERR("Wrong pidl type\n"); - CoTaskMemFree(pszPath); - return E_INVALIDARG; - } - } - else - { - /* Complex pidl. Let the child folder do the work */ - hr = SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, pszPath, MAX_PATH); - } - - if (SUCCEEDED (hr)) - { - strRet->uType = STRRET_WSTR; - strRet->u.pOleStr = pszPath; - } - else - CoTaskMemFree(pszPath); - - TRACE ("-- (%p)->(%s)\n", This, strRet->uType == STRRET_CSTR ? strRet->u.cStr : debugstr_w(strRet->u.pOleStr)); - return hr; -} - -/************************************************************************** -* ISF_MyComputer_fnSetNameOf -* Changes the name of a file object or subfolder, possibly changing its item -* identifier in the process. -* -* PARAMETERS -* hwndOwner [in] Owner window for output -* pidl [in] simple pidl of item to change -* lpszName [in] the items new display name -* dwFlags [in] SHGNO formatting flags -* ppidlOut [out] simple pidl returned -*/ -static HRESULT WINAPI ISF_MyComputer_fnSetNameOf ( - IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, - LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - LPWSTR sName; - HKEY hKey; - UINT length; - WCHAR szName[30]; - - TRACE ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This, - hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut); - - if (_ILIsDrive(pidl)) - { - if (_ILSimpleGetTextW(pidl, szName, sizeof(szName)/sizeof(WCHAR))) - { - SetVolumeLabelW(szName, lpName); - } - if (pPidlOut) - *pPidlOut = _ILCreateDrive(szName); - return S_OK; - } - - - if (pPidlOut != NULL) - { - *pPidlOut = _ILCreateMyComputer(); - } - - length = (wcslen(lpName)+1) * sizeof(WCHAR); - sName = SHAlloc(length); - - if (!sName) - { - return E_OUTOFMEMORY; - } - - if (RegOpenKeyExW(HKEY_CURRENT_USER, - L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}", - 0, - KEY_WRITE, - &hKey) != ERROR_SUCCESS) - { - WARN("Error: failed to open registry key\n"); - } - else - { - RegSetValueExW(hKey, NULL, 0, REG_SZ, (const LPBYTE)lpName, length); - RegCloseKey(hKey); - } - - wcscpy(sName, lpName); - SHFree(This->sName); - This->sName = sName; - TRACE("result %s\n", debugstr_w(This->sName)); - return S_OK; -} - -static HRESULT WINAPI ISF_MyComputer_fnGetDefaultSearchGUID ( - IShellFolder2 * iface, GUID * pguid) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} -static HRESULT WINAPI ISF_MyComputer_fnEnumSearches ( - IShellFolder2 * iface, IEnumExtraSearch ** ppenum) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} -static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumn ( - IShellFolder2 *iface, DWORD dwRes, ULONG *pSort, ULONG *pDisplay) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)\n", This); - - if (pSort) - *pSort = 0; - if (pDisplay) - *pDisplay = 0; - return S_OK; -} -static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumnState ( - IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)\n", This); - - if (!pcsFlags || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS) - return E_INVALIDARG; - *pcsFlags = MyComputerSFHeader[iColumn].pcsFlags; - return S_OK; -} - -static HRESULT WINAPI ISF_MyComputer_fnGetDetailsEx (IShellFolder2 * iface, - LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -/* FIXME: drive size >4GB is rolling over */ -static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 * iface, - LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - HRESULT hr; - - TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd); - - if (!psd || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS) - return E_INVALIDARG; - - if (!pidl) - { - psd->fmt = MyComputerSFHeader[iColumn].fmt; - psd->cxChar = MyComputerSFHeader[iColumn].cxChar; - psd->str.uType = STRRET_CSTR; - LoadStringA (shell32_hInstance, MyComputerSFHeader[iColumn].colnameid, - psd->str.u.cStr, MAX_PATH); - return S_OK; - } - else - { - char szPath[MAX_PATH]; - ULARGE_INTEGER ulBytes; - - psd->str.u.cStr[0] = 0x00; - psd->str.uType = STRRET_CSTR; - switch (iColumn) - { - case 0: /* name */ - hr = IShellFolder_GetDisplayNameOf (iface, pidl, - SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); - break; - case 1: /* type */ - _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 2: /* total size */ - if (_ILIsDrive (pidl)) - { - _ILSimpleGetText (pidl, szPath, MAX_PATH); - GetDiskFreeSpaceExA (szPath, NULL, &ulBytes, NULL); - StrFormatByteSizeA (ulBytes.u.LowPart, psd->str.u.cStr, MAX_PATH); - } - break; - case 3: /* free size */ - if (_ILIsDrive (pidl)) - { - _ILSimpleGetText (pidl, szPath, MAX_PATH); - GetDiskFreeSpaceExA (szPath, &ulBytes, NULL, NULL); - StrFormatByteSizeA (ulBytes.u.LowPart, psd->str.u.cStr, MAX_PATH); - } - break; - } - hr = S_OK; - } - - return hr; -} - -static HRESULT WINAPI ISF_MyComputer_fnMapColumnToSCID ( - IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static const IShellFolder2Vtbl vt_ShellFolder2 = -{ - ISF_MyComputer_fnQueryInterface, - ISF_MyComputer_fnAddRef, - ISF_MyComputer_fnRelease, - ISF_MyComputer_fnParseDisplayName, - ISF_MyComputer_fnEnumObjects, - ISF_MyComputer_fnBindToObject, - ISF_MyComputer_fnBindToStorage, - ISF_MyComputer_fnCompareIDs, - ISF_MyComputer_fnCreateViewObject, - ISF_MyComputer_fnGetAttributesOf, - ISF_MyComputer_fnGetUIObjectOf, - ISF_MyComputer_fnGetDisplayNameOf, - ISF_MyComputer_fnSetNameOf, - /* ShellFolder2 */ - ISF_MyComputer_fnGetDefaultSearchGUID, - ISF_MyComputer_fnEnumSearches, - ISF_MyComputer_fnGetDefaultColumn, - ISF_MyComputer_fnGetDefaultColumnState, - ISF_MyComputer_fnGetDetailsEx, - ISF_MyComputer_fnGetDetailsOf, - ISF_MyComputer_fnMapColumnToSCID -}; - -/************************************************************************ - * IMCFldr_PersistFolder2_QueryInterface - */ -static HRESULT WINAPI IMCFldr_PersistFolder2_QueryInterface ( - IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObj) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)\n", This); - - return IUnknown_QueryInterface (_IUnknown_ (This), iid, ppvObj); -} - -/************************************************************************ - * IMCFldr_PersistFolder2_AddRef - */ -static ULONG WINAPI IMCFldr_PersistFolder2_AddRef (IPersistFolder2 * iface) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_AddRef (_IUnknown_ (This)); -} - -/************************************************************************ - * ISFPersistFolder_Release - */ -static ULONG WINAPI IMCFldr_PersistFolder2_Release (IPersistFolder2 * iface) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_Release (_IUnknown_ (This)); -} - -/************************************************************************ - * IMCFldr_PersistFolder2_GetClassID - */ -static HRESULT WINAPI IMCFldr_PersistFolder2_GetClassID ( - IPersistFolder2 * iface, CLSID * lpClassId) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)\n", This); - - if (!lpClassId) - return E_POINTER; - *lpClassId = CLSID_MyComputer; - - return S_OK; -} - -/************************************************************************ - * IMCFldr_PersistFolder2_Initialize - * - * NOTES: it makes no sense to change the pidl - */ -static HRESULT WINAPI IMCFldr_PersistFolder2_Initialize ( - IPersistFolder2 * iface, LPCITEMIDLIST pidl) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - TRACE ("(%p)->(%p)\n", This, pidl); - - if (This->pidlRoot) - SHFree((LPVOID)This->pidlRoot); - - This->pidlRoot = ILClone(pidl); - return S_OK; -} - -/************************************************************************** - * IPersistFolder2_fnGetCurFolder - */ -static HRESULT WINAPI IMCFldr_PersistFolder2_GetCurFolder ( - IPersistFolder2 * iface, LPITEMIDLIST * pidl) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)->(%p)\n", This, pidl); - - if (!pidl) - return E_POINTER; - *pidl = ILClone (This->pidlRoot); - return S_OK; -} - -static const IPersistFolder2Vtbl vt_PersistFolder2 = -{ - IMCFldr_PersistFolder2_QueryInterface, - IMCFldr_PersistFolder2_AddRef, - IMCFldr_PersistFolder2_Release, - IMCFldr_PersistFolder2_GetClassID, - IMCFldr_PersistFolder2_Initialize, - IMCFldr_PersistFolder2_GetCurFolder -}; diff --git a/reactos/dll/win32/shell32/shfldr_mydocuments.c b/reactos/dll/win32/shell32/shfldr_mydocuments.c deleted file mode 100644 index 8290a411e02..00000000000 --- a/reactos/dll/win32/shell32/shfldr_mydocuments.c +++ /dev/null @@ -1,889 +0,0 @@ - -/* - * Virtual MyDocuments Folder - * - * Copyright 2007 Johannes Anderwald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL (mydocs); - -/*********************************************************************** -* MyDocumentsfolder implementation -*/ - -typedef struct { - const IShellFolder2Vtbl *lpVtbl; - const IPersistFolder2Vtbl *lpPF2; - LONG ref; - - /* both paths are parsible from the MyDocuments */ - LPWSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */ - LPITEMIDLIST pidlRoot; /* absolute pidl */ - - UINT cfShellIDList; /* clipboardformat for IDropTarget */ - BOOL fAcceptFmt; /* flag for pending Drop */ -} IGenericSFImpl, *LPIGenericSFImpl; - -#define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl) -#define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl) - -static const shvheader MyDocumentsSFHeader[] = { - {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15}, - {IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10}, - {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10}, - {IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12}, - {IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5} -}; - -#define MYDOCUMENTSSHELLVIEWCOLUMNS 5 - -/************************************************************************** - * ISF_MyDocuments_fnQueryInterface - * - * NOTES supports not IPersist/IPersistFolder - */ -static HRESULT WINAPI ISF_MyDocuments_fnQueryInterface( - IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj); - - *ppvObj = NULL; - - if (IsEqualIID (riid, &IID_IUnknown) || - IsEqualIID (riid, &IID_IShellFolder) || - IsEqualIID (riid, &IID_IShellFolder2)) - { - *ppvObj = This; - } - else if (IsEqualIID (riid, &IID_IPersistFolder) || - IsEqualIID (riid, &IID_IPersistFolder2)) - { - *ppvObj = (void *)&This->lpPF2; - } - if (*ppvObj) - { - IUnknown_AddRef ((IUnknown *) (*ppvObj)); - TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj); - return S_OK; - } - TRACE ("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -static ULONG WINAPI ISF_MyDocuments_fnAddRef (IShellFolder2 * iface) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE ("(%p)->(count=%u)\n", This, refCount - 1); - - return refCount; -} - -static ULONG WINAPI ISF_MyDocuments_fnRelease (IShellFolder2 * iface) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE ("(%p)->(count=%u)\n", This, refCount + 1); - - if (!refCount) - { - TRACE ("-- destroying IShellFolder(%p)\n", This); - SHFree (This->pidlRoot); - HeapFree(GetProcessHeap(), 0, This->sPathTarget); - HeapFree(GetProcessHeap(), 0, This); - } - return refCount; -} - -static -HRESULT -WINAPI ISF_MyDocuments_fnParseDisplayName (IShellFolder2 * iface, - HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, - DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - WCHAR szElement[MAX_PATH]; - LPCWSTR szNext = NULL; - LPITEMIDLIST pidlTemp = NULL; - HRESULT hr = S_OK; - CLSID clsid; - - TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", - This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName), - pchEaten, ppidl, pdwAttributes); - - if (!lpszDisplayName || !ppidl) - return E_INVALIDARG; - - *ppidl = 0; - - if (pchEaten) - *pchEaten = 0; /* strange but like the original */ - - if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') - { - szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH); - TRACE ("-- element: %s\n", debugstr_w (szElement)); - CLSIDFromString (szElement + 2, &clsid); - pidlTemp = _ILCreateGuid (PT_GUID, &clsid); - } - else if( (pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, lpszDisplayName)) ) - { - *ppidl = pidlTemp; - return S_OK; - } - else - { - /* it's a filesystem path on the desktop. Let a FSFolder parse it */ - - if (*lpszDisplayName) - { - WCHAR szPath[MAX_PATH]; - LPWSTR pathPtr; - - /* build a complete path to create a simple pidl */ - lstrcpynW(szPath, This->sPathTarget, MAX_PATH); - pathPtr = PathAddBackslashW(szPath); - if (pathPtr) - { - lstrcpynW(pathPtr, lpszDisplayName, MAX_PATH - (pathPtr - szPath)); - hr = _ILCreateFromPathW(szPath, &pidlTemp); - } - else - { - /* should never reach here, but for completeness */ - hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - } - } - else - pidlTemp = _ILCreateMyDocuments(); - - szNext = NULL; - } - - if (SUCCEEDED(hr) && pidlTemp) - { - if (szNext && *szNext) - { - hr = SHELL32_ParseNextElement(iface, hwndOwner, pbc, - &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes); - } - else - { - if (pdwAttributes && *pdwAttributes) - hr = SHELL32_GetItemAttributes(_IShellFolder_ (This), - pidlTemp, pdwAttributes); - } - } - - *ppidl = pidlTemp; - - TRACE ("(%p)->(-- ret=0x%08x)\n", This, hr); - - return hr; -} - -/************************************************************************** - * CreateMyDocumentsEnumList() - */ -static BOOL CreateMyDocumentsEnumList(IEnumIDList *list, DWORD dwFlags) -{ - BOOL ret = TRUE; - WCHAR szPath[MAX_PATH] = {0}; - - TRACE("(%p)->(flags=0x%08x)\n", list, dwFlags); - - /* enumerate the elements in %windir%\desktop */ - ret = SHGetSpecialFolderPathW(0, szPath, CSIDL_PERSONAL, FALSE); - ret = ret && CreateFolderEnumList(list, szPath, dwFlags); - - return ret; -} - -/************************************************************************** - * ISF_MyDocuments_fnEnumObjects - */ -static HRESULT WINAPI ISF_MyDocuments_fnEnumObjects (IShellFolder2 * iface, - HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", - This, hwndOwner, dwFlags, ppEnumIDList); - - *ppEnumIDList = IEnumIDList_Constructor(); - if (*ppEnumIDList) - CreateMyDocumentsEnumList(*ppEnumIDList, dwFlags); - - TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList); - - return *ppEnumIDList ? S_OK : E_OUTOFMEMORY; -} - -/************************************************************************** - * ISF_MyDocuments_fnBindToObject - */ -static HRESULT WINAPI ISF_MyDocuments_fnBindToObject (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", - This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); - - return SHELL32_BindToChild( This->pidlRoot, This->sPathTarget, pidl, riid, ppvOut ); -} - -/************************************************************************** - * ISF_MyDocuments_fnBindToStorage - */ -static -HRESULT -WINAPI -ISF_MyDocuments_fnBindToStorage (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", - This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); - - *ppvOut = NULL; - return E_NOTIMPL; -} - -/************************************************************************** - * ISF_MyDocuments_fnCompareIDs - */ -static HRESULT WINAPI ISF_MyDocuments_fnCompareIDs (IShellFolder2 * iface, - LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - int nReturn; - - TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2); - nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2); - TRACE ("-- %i\n", nReturn); - return nReturn; -} - -/************************************************************************** - * ISF_MyDocuments_fnCreateViewObject - */ -static HRESULT WINAPI ISF_MyDocuments_fnCreateViewObject (IShellFolder2 * iface, - HWND hwndOwner, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - LPSHELLVIEW pShellView; - HRESULT hr = E_INVALIDARG; - - TRACE ("(%p)->(hwnd=%p,%s,%p)\n", - This, hwndOwner, shdebugstr_guid (riid), ppvOut); - - if (!ppvOut) - return hr; - - *ppvOut = NULL; - - if (IsEqualIID (riid, &IID_IDropTarget)) - { - WARN ("IDropTarget not implemented\n"); - hr = E_NOTIMPL; - } - else if (IsEqualIID (riid, &IID_IContextMenu)) - { - WARN ("IContextMenu not implemented\n"); - hr = E_NOTIMPL; - } - else if (IsEqualIID (riid, &IID_IShellView)) - { - pShellView = IShellView_Constructor ((IShellFolder *) iface); - if (pShellView) - { - hr = IShellView_QueryInterface (pShellView, riid, ppvOut); - IShellView_Release (pShellView); - } - } - TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut); - return hr; -} - -/************************************************************************** - * ISF_MyDocuments_fnGetAttributesOf - */ -static HRESULT WINAPI ISF_MyDocuments_fnGetAttributesOf (IShellFolder2 * iface, - UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - HRESULT hr = S_OK; - static const DWORD dwMyDocumentsAttributes = - SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR | SFGAO_CANCOPY | - SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER | SFGAO_CANRENAME | SFGAO_CANDELETE; - - TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n", - This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0); - - if (!rgfInOut) - return E_INVALIDARG; - if (cidl && !apidl) - return E_INVALIDARG; - - if (*rgfInOut == 0) - *rgfInOut = ~0; - - if(cidl == 0) { - *rgfInOut &= dwMyDocumentsAttributes; - } else { - while (cidl > 0 && *apidl) { - pdump (*apidl); - if (_ILIsMyDocuments(*apidl)) { - *rgfInOut &= dwMyDocumentsAttributes; - } else { - SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut); - } - apidl++; - cidl--; - } - } - /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */ - *rgfInOut &= ~SFGAO_VALIDATE; - - TRACE ("-- result=0x%08x\n", *rgfInOut); - - return hr; -} - -/************************************************************************** - * ISF_MyDocuments_fnGetUIObjectOf - * - * PARAMETERS - * HWND hwndOwner, //[in ] Parent window for any output - * UINT cidl, //[in ] array size - * LPCITEMIDLIST* apidl, //[in ] simple pidl array - * REFIID riid, //[in ] Requested Interface - * UINT* prgfInOut, //[ ] reserved - * LPVOID* ppvObject) //[out] Resulting Interface - * - */ -static HRESULT WINAPI ISF_MyDocuments_fnGetUIObjectOf (IShellFolder2 * iface, - HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, - REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - LPITEMIDLIST pidl; - IUnknown *pObj = NULL; - HRESULT hr = E_INVALIDARG; - - TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", - This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut); - - if (!ppvOut) - return hr; - - *ppvOut = NULL; - - if (IsEqualIID (riid, &IID_IContextMenu)) - { - hr = CDefFolderMenu_Create2(This->pidlRoot, hwndOwner, cidl, apidl, (IShellFolder*)iface, NULL, 0, NULL, (IContextMenu**)&pObj); - } - else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) - { - pObj = (LPUNKNOWN) IDataObject_Constructor( hwndOwner, - This->pidlRoot, apidl, cidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) - { - hr = IShellFolder_QueryInterface (iface, - &IID_IDropTarget, (LPVOID *) & pObj); - } - else if ((IsEqualIID(riid,&IID_IShellLinkW) || - IsEqualIID(riid,&IID_IShellLinkA)) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj); - SHFree (pidl); - } - else - hr = E_NOINTERFACE; - - if (SUCCEEDED(hr) && !pObj) - hr = E_OUTOFMEMORY; - - *ppvOut = pObj; - TRACE ("(%p)->hr=0x%08x\n", This, hr); - return hr; -} - -static -HRESULT -WINAPI ISF_MyDocuments_fnGetDisplayNameOf (IShellFolder2 * iface, - LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - HRESULT hr = S_OK; - LPWSTR pszPath; - - TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet); - pdump (pidl); - - if (!strRet) - return E_INVALIDARG; - - pszPath = CoTaskMemAlloc((MAX_PATH +1) * sizeof(WCHAR)); - if (!pszPath) - return E_OUTOFMEMORY; - - ZeroMemory(pszPath, (MAX_PATH +1) * sizeof(WCHAR)); - - if (_ILIsMyDocuments (pidl)) - { - if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && - (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING)) - wcscpy(pszPath, This->sPathTarget); - else - HCR_GetClassNameW(&CLSID_MyDocuments, pszPath, MAX_PATH); - TRACE("CP\n"); - } - else if (_ILIsPidlSimple (pidl)) - { - GUID const *clsid; - - if ((clsid = _ILGetGUIDPointer (pidl))) - { - if (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING) - { - int bWantsForParsing; - - /* - * We can only get a filesystem path from a shellfolder if the - * value WantsFORPARSING in CLSID\\{...}\\shellfolder exists. - * - * Exception: The MyComputer folder doesn't have this key, - * but any other filesystem backed folder it needs it. - */ - if (IsEqualIID (clsid, &CLSID_MyDocuments)) - { - bWantsForParsing = TRUE; - } - else - { - /* get the "WantsFORPARSING" flag from the registry */ - static const WCHAR clsidW[] = - { 'C','L','S','I','D','\\',0 }; - static const WCHAR shellfolderW[] = - { '\\','s','h','e','l','l','f','o','l','d','e','r',0 }; - static const WCHAR wantsForParsingW[] = - { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n', - 'g',0 }; - WCHAR szRegPath[100]; - LONG r; - - wcscpy (szRegPath, clsidW); - SHELL32_GUIDToStringW (clsid, &szRegPath[6]); - wcscat (szRegPath, shellfolderW); - r = SHGetValueW(HKEY_CLASSES_ROOT, szRegPath, - wantsForParsingW, NULL, NULL, NULL); - if (r == ERROR_SUCCESS) - bWantsForParsing = TRUE; - else - bWantsForParsing = FALSE; - } - - if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && - bWantsForParsing) - { - /* - * we need the filesystem path to the destination folder. - * Only the folder itself can know it - */ - hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, - pszPath, - MAX_PATH); - TRACE("CP\n"); - } - else - { - /* parsing name like ::{...} */ - pszPath[0] = ':'; - pszPath[1] = ':'; - SHELL32_GUIDToStringW (clsid, &pszPath[2]); - TRACE("CP\n"); - } - } - else - { - /* user friendly name */ - HCR_GetClassNameW (clsid, pszPath, MAX_PATH); - TRACE("CP\n"); - } - } - else - { - int cLen = 0; - - /* file system folder or file rooted at the desktop */ - if ((GET_SHGDN_FOR(dwFlags) == SHGDN_FORPARSING) && - (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER)) - { - lstrcpynW(pszPath, This->sPathTarget, MAX_PATH - 1); - TRACE("CP %s\n", debugstr_w(pszPath)); - } - - if (!_ILIsDesktop(pidl)) - { - PathAddBackslashW(pszPath); - cLen = wcslen(pszPath); - _ILSimpleGetTextW(pidl, pszPath + cLen, MAX_PATH - cLen); - if (!_ILIsFolder(pidl)) - { - SHELL_FS_ProcessDisplayFilename(pszPath, dwFlags); - TRACE("CP\n"); - } - } - } - } - else - { - /* a complex pidl, let the subfolder do the work */ - hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, - pszPath, MAX_PATH); - TRACE("CP\n"); - } - - if (SUCCEEDED(hr)) - { - strRet->uType = STRRET_WSTR; - strRet->u.pOleStr = pszPath; - } - else - CoTaskMemFree(pszPath); - - TRACE ("-- (%p)->(%s,0x%08x)\n", This, debugstr_w(strRet->u.pOleStr), hr); - return hr; -} - -static HRESULT WINAPI ISF_MyDocuments_fnSetNameOf (IShellFolder2 * iface, - HWND hwndOwner, LPCITEMIDLIST pidl, /* simple pidl */ - LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This, hwndOwner, pidl, - debugstr_w (lpName), dwFlags, pPidlOut); - - return E_FAIL; -} - -static HRESULT WINAPI ISF_MyDocuments_fnGetDefaultSearchGUID(IShellFolder2 *iface, - GUID * pguid) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_MyDocuments_fnEnumSearches (IShellFolder2 *iface, - IEnumExtraSearch ** ppenum) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static -HRESULT -WINAPI -ISF_MyDocuments_fnGetDefaultColumn (IShellFolder2 * iface, - DWORD dwRes, ULONG * pSort, ULONG * pDisplay) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)\n", This); - - if (pSort) - *pSort = 0; - if (pDisplay) - *pDisplay = 0; - - return S_OK; -} -static -HRESULT -WINAPI -ISF_MyDocuments_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)\n", This); - - if (!pcsFlags || iColumn >= MYDOCUMENTSSHELLVIEWCOLUMNS) - return E_INVALIDARG; - - *pcsFlags = MyDocumentsSFHeader[iColumn].pcsFlags; - - return S_OK; -} - -static -HRESULT -WINAPI -ISF_MyDocuments_fnGetDetailsEx (IShellFolder2 * iface, LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - - return E_NOTIMPL; -} - -static -HRESULT -WINAPI -ISF_MyDocuments_fnGetDetailsOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - HRESULT hr = S_OK; - - TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd); - - if (!psd || iColumn >= MYDOCUMENTSSHELLVIEWCOLUMNS) - return E_INVALIDARG; - - if (!pidl) - { - psd->fmt = MyDocumentsSFHeader[iColumn].fmt; - psd->cxChar = MyDocumentsSFHeader[iColumn].cxChar; - psd->str.uType = STRRET_CSTR; - LoadStringA (shell32_hInstance, MyDocumentsSFHeader[iColumn].colnameid, - psd->str.u.cStr, MAX_PATH); - return S_OK; - } - - /* the data from the pidl */ - psd->str.uType = STRRET_CSTR; - switch (iColumn) - { - case 0: /* name */ - hr = IShellFolder_GetDisplayNameOf(iface, pidl, - SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); - break; - case 1: /* size */ - _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 2: /* type */ - _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 3: /* date */ - _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 4: /* attributes */ - _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH); - break; - } - - return hr; -} - -static -HRESULT -WINAPI -ISF_MyDocuments_fnMapColumnToSCID (IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static const IShellFolder2Vtbl vt_MCFldr_ShellFolder2 = -{ - ISF_MyDocuments_fnQueryInterface, - ISF_MyDocuments_fnAddRef, - ISF_MyDocuments_fnRelease, - ISF_MyDocuments_fnParseDisplayName, - ISF_MyDocuments_fnEnumObjects, - ISF_MyDocuments_fnBindToObject, - ISF_MyDocuments_fnBindToStorage, - ISF_MyDocuments_fnCompareIDs, - ISF_MyDocuments_fnCreateViewObject, - ISF_MyDocuments_fnGetAttributesOf, - ISF_MyDocuments_fnGetUIObjectOf, - ISF_MyDocuments_fnGetDisplayNameOf, - ISF_MyDocuments_fnSetNameOf, - /* ShellFolder2 */ - ISF_MyDocuments_fnGetDefaultSearchGUID, - ISF_MyDocuments_fnEnumSearches, - ISF_MyDocuments_fnGetDefaultColumn, - ISF_MyDocuments_fnGetDefaultColumnState, - ISF_MyDocuments_fnGetDetailsEx, - ISF_MyDocuments_fnGetDetailsOf, - ISF_MyDocuments_fnMapColumnToSCID -}; - -static LPIGenericSFImpl __inline impl_from_IPersistFolder2( IPersistFolder2 *iface ) -{ - return (LPIGenericSFImpl)((char*)iface - FIELD_OFFSET(IGenericSFImpl, lpPF2)); -} - -static HRESULT WINAPI -ISF_MyDocuments_PersistFolder2_fnQueryInterface (IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObj) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)\n", This); - - return ISF_MyDocuments_fnQueryInterface ((IShellFolder2*)This, iid, ppvObj); -} - -static ULONG WINAPI -ISF_MyDocuments_PersistFolder2_fnAddRef (IPersistFolder2 * iface) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return ISF_MyDocuments_fnAddRef((IShellFolder2*)This); -} - -static ULONG WINAPI -ISF_MyDocuments_PersistFolder2_fnRelease (IPersistFolder2 * iface) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return ISF_MyDocuments_fnRelease ((IShellFolder2*)This); -} - -static HRESULT WINAPI -ISF_MyDocuments_PersistFolder2_fnGetClassID (IPersistFolder2 * iface, CLSID * lpClassId) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - static GUID const CLSID_MyDocuments = - { 0x450d8fba, 0xad25, 0x11d0, {0x98,0xa8,0x08,0x00,0x36,0x1b,0x11,0x03} }; - - TRACE ("(%p)\n", This); - - if (!lpClassId) - return E_POINTER; - - memcpy(lpClassId, &CLSID_MyDocuments, sizeof(GUID)); - - return S_OK; -} -static HRESULT WINAPI -ISF_MyDocuments_PersistFolder2_fnInitialize (IPersistFolder2 * iface, LPCITEMIDLIST pidl) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)->(%p)\n", This, pidl); - - return E_NOTIMPL; -} - -static HRESULT WINAPI -ISF_MyDocuments_PersistFolder2_fnGetCurFolder (IPersistFolder2 * iface, - LPITEMIDLIST * pidl) -{ - IGenericSFImpl *This = impl_from_IPersistFolder2(iface); - - TRACE ("(%p)->(%p)\n", This, pidl); - - if (!pidl) return E_POINTER; - *pidl = ILClone (This->pidlRoot); - return S_OK; -} - -static const IPersistFolder2Vtbl vt_FSFldr_PersistFolder2 = -{ - ISF_MyDocuments_PersistFolder2_fnQueryInterface, - ISF_MyDocuments_PersistFolder2_fnAddRef, - ISF_MyDocuments_PersistFolder2_fnRelease, - ISF_MyDocuments_PersistFolder2_fnGetClassID, - ISF_MyDocuments_PersistFolder2_fnInitialize, - ISF_MyDocuments_PersistFolder2_fnGetCurFolder, -}; - - -/************************************************************************** - * ISF_MyDocuments_Constructor - */ -HRESULT WINAPI ISF_MyDocuments_Constructor ( - IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) -{ - static IGenericSFImpl *cached_sf; - WCHAR szMyPath[MAX_PATH]; - - TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid)); - - if (!ppv) - return E_POINTER; - if (pUnkOuter) - return CLASS_E_NOAGGREGATION; - - if (!cached_sf) - { - IGenericSFImpl *sf; - - if (!SHGetSpecialFolderPathW( 0, szMyPath, CSIDL_PERSONAL, TRUE )) - return E_UNEXPECTED; - - sf = LocalAlloc( LMEM_ZEROINIT, sizeof (IGenericSFImpl) ); - if (!sf) - return E_OUTOFMEMORY; - - sf->ref = 1; - sf->lpVtbl = &vt_MCFldr_ShellFolder2; - sf->lpPF2 = &vt_FSFldr_PersistFolder2; - sf->pidlRoot = _ILCreateMyDocuments(); /* my qualified pidl */ - sf->sPathTarget = SHAlloc( (wcslen(szMyPath) + 1)*sizeof(WCHAR) ); - wcscpy( sf->sPathTarget, szMyPath ); - - if (InterlockedCompareExchangePointer((void *)&cached_sf, sf, NULL) != NULL) - { - /* some other thread already been here */ - SHFree( sf->pidlRoot ); - SHFree( sf->sPathTarget ); - LocalFree( sf ); - } - } - - return IUnknown_QueryInterface( _IUnknown_(cached_sf), riid, ppv ); -} diff --git a/reactos/dll/win32/shell32/shfldr_netplaces.c b/reactos/dll/win32/shell32/shfldr_netplaces.c deleted file mode 100644 index 07811d0f0d0..00000000000 --- a/reactos/dll/win32/shell32/shfldr_netplaces.c +++ /dev/null @@ -1,651 +0,0 @@ -/* - * Network Places (Neighbourhood) folder - * - * Copyright 1997 Marcus Meissner - * Copyright 1998, 1999, 2002 Juergen Schmied - * Copyright 2003 Mike McCormack for Codeweavers - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL (shell); - -/*********************************************************************** -* IShellFolder implementation -*/ - -typedef struct { - const IShellFolder2Vtbl *lpVtbl; - LONG ref; - const IPersistFolder2Vtbl *lpVtblPersistFolder2; - - /* both paths are parsible from the desktop */ - LPITEMIDLIST pidlRoot; /* absolute pidl */ -} IGenericSFImpl; - -static const IShellFolder2Vtbl vt_ShellFolder2; -static const IPersistFolder2Vtbl vt_NP_PersistFolder2; - - -#define _IPersistFolder2_Offset ((INT_PTR)(&(((IGenericSFImpl*)0)->lpVtblPersistFolder2))) -#define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder2_Offset); - -#define _IUnknown_(This) ((IUnknown*)&(This)->lpVtbl) -#define _IShellFolder_(This) ((IShellFolder*)&(This)->lpVtbl) -#define _IPersistFolder2_(This) (&(This)->lpVtblPersistFolder2) - -static shvheader NetworkPlacesSFHeader[] = { - {IDS_SHV_COLUMN8, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15}, - {IDS_SHV_COLUMN13, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10}, - {IDS_SHV_COLUMN_WORKGROUP, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15}, - {IDS_SHV_NETWORKLOCATION, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15} -}; - -#define COLUMN_NAME 0 -#define COLUMN_CATEGORY 1 -#define COLUMN_WORKGROUP 2 -#define COLUMN_NETLOCATION 3 - -#define NETWORKPLACESSHELLVIEWCOLUMNS 4 - -/************************************************************************** -* ISF_NetworkPlaces_Constructor -*/ -HRESULT WINAPI ISF_NetworkPlaces_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) -{ - IGenericSFImpl *sf; - - TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid)); - - if (!ppv) - return E_POINTER; - if (pUnkOuter) - return CLASS_E_NOAGGREGATION; - - sf = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof (IGenericSFImpl)); - if (!sf) - return E_OUTOFMEMORY; - - sf->ref = 0; - sf->lpVtbl = &vt_ShellFolder2; - sf->lpVtblPersistFolder2 = &vt_NP_PersistFolder2; - sf->pidlRoot = _ILCreateNetHood(); /* my qualified pidl */ - - if (FAILED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) - { - IUnknown_Release (_IUnknown_ (sf)); - return E_NOINTERFACE; - } - - TRACE ("--(%p)\n", sf); - return S_OK; -} - -/************************************************************************** - * ISF_NetworkPlaces_fnQueryInterface - * - * NOTE - * supports not IPersist/IPersistFolder - */ -static HRESULT WINAPI ISF_NetworkPlaces_fnQueryInterface (IShellFolder2 *iface, REFIID riid, LPVOID *ppvObj) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj); - - *ppvObj = NULL; - - if (IsEqualIID (riid, &IID_IUnknown) || - IsEqualIID (riid, &IID_IShellFolder) || - IsEqualIID (riid, &IID_IShellFolder2)) - { - *ppvObj = This; - } - else if (IsEqualIID (riid, &IID_IPersist) || - IsEqualIID (riid, &IID_IPersistFolder) || - IsEqualIID (riid, &IID_IPersistFolder2)) - { - *ppvObj = (void *)_IPersistFolder2_ (This); - } - - if (*ppvObj) - { - IUnknown_AddRef ((IUnknown *) (*ppvObj)); - TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj); - return S_OK; - } - TRACE ("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -static ULONG WINAPI ISF_NetworkPlaces_fnAddRef (IShellFolder2 * iface) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE ("(%p)->(count=%u)\n", This, refCount - 1); - - return refCount; -} - -static ULONG WINAPI ISF_NetworkPlaces_fnRelease (IShellFolder2 * iface) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE ("(%p)->(count=%u)\n", This, refCount + 1); - - if (!refCount) { - TRACE ("-- destroying IShellFolder(%p)\n", This); - SHFree (This->pidlRoot); - HeapFree (GetProcessHeap(), 0, This); - } - return refCount; -} - -/************************************************************************** -* ISF_NetworkPlaces_fnParseDisplayName -*/ -static HRESULT WINAPI ISF_NetworkPlaces_fnParseDisplayName (IShellFolder2 * iface, - HWND hwndOwner, LPBC pbcReserved, LPOLESTR lpszDisplayName, - DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - HRESULT hr = E_UNEXPECTED; - - TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", This, - hwndOwner, pbcReserved, lpszDisplayName, debugstr_w (lpszDisplayName), - pchEaten, ppidl, pdwAttributes); - - *ppidl = 0; - if (pchEaten) - *pchEaten = 0; /* strange but like the original */ - - TRACE ("(%p)->(-- ret=0x%08x)\n", This, hr); - - return hr; -} - -/************************************************************************** -* ISF_NetworkPlaces_fnEnumObjects -*/ -static HRESULT WINAPI ISF_NetworkPlaces_fnEnumObjects (IShellFolder2 * iface, - HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", This, - hwndOwner, dwFlags, ppEnumIDList); - - *ppEnumIDList = NULL; //IEnumIDList_Constructor(); - - TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList); - return S_FALSE; - // return (*ppEnumIDList) ? S_OK : E_OUTOFMEMORY; -} - -/************************************************************************** -* ISF_NetworkPlaces_fnBindToObject -*/ -static HRESULT WINAPI ISF_NetworkPlaces_fnBindToObject (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, - pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); - - return SHELL32_BindToChild (This->pidlRoot, NULL, pidl, riid, ppvOut); -} - -/************************************************************************** -* ISF_NetworkPlaces_fnBindToStorage -*/ -static HRESULT WINAPI ISF_NetworkPlaces_fnBindToStorage (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, - pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); - - *ppvOut = NULL; - return E_NOTIMPL; -} - -/************************************************************************** -* ISF_NetworkPlaces_fnCompareIDs -*/ - -static HRESULT WINAPI ISF_NetworkPlaces_fnCompareIDs (IShellFolder2 * iface, - LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - int nReturn; - - TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2); - nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2); - TRACE ("-- %i\n", nReturn); - return nReturn; -} - -/************************************************************************** -* ISF_NetworkPlaces_fnCreateViewObject -*/ -static HRESULT WINAPI ISF_NetworkPlaces_fnCreateViewObject (IShellFolder2 * iface, - HWND hwndOwner, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - LPSHELLVIEW pShellView; - HRESULT hr = E_INVALIDARG; - - TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This, - hwndOwner, shdebugstr_guid (riid), ppvOut); - - if (!ppvOut) - return hr; - - *ppvOut = NULL; - - if (IsEqualIID (riid, &IID_IDropTarget)) - { - WARN ("IDropTarget not implemented\n"); - hr = E_NOTIMPL; - } - else if (IsEqualIID (riid, &IID_IContextMenu)) - { - WARN ("IContextMenu not implemented\n"); - hr = E_NOTIMPL; - } - else if (IsEqualIID (riid, &IID_IShellView)) - { - pShellView = IShellView_Constructor ((IShellFolder *) iface); - if (pShellView) - { - hr = IShellView_QueryInterface (pShellView, riid, ppvOut); - IShellView_Release (pShellView); - } - } - TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut); - return hr; -} - -/************************************************************************** -* ISF_NetworkPlaces_fnGetAttributesOf -*/ -static HRESULT WINAPI ISF_NetworkPlaces_fnGetAttributesOf (IShellFolder2 * iface, - UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - static const DWORD dwNethoodAttributes = - SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR | - SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER | SFGAO_CANRENAME | SFGAO_CANDELETE; - HRESULT hr = S_OK; - - TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n", This, - cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0); - - if (!rgfInOut) - return E_INVALIDARG; - if (cidl && !apidl) - return E_INVALIDARG; - - if (*rgfInOut == 0) - *rgfInOut = ~0; - - if(cidl == 0) { - *rgfInOut = dwNethoodAttributes; - } - else - { - while (cidl > 0 && *apidl) - { - pdump (*apidl); - SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut); - apidl++; - cidl--; - } - } - - /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */ - *rgfInOut &= ~SFGAO_VALIDATE; - - TRACE ("-- result=0x%08x\n", *rgfInOut); - return hr; -} - -/************************************************************************** -* ISF_NetworkPlaces_fnGetUIObjectOf -* -* PARAMETERS -* hwndOwner [in] Parent window for any output -* cidl [in] array size -* apidl [in] simple pidl array -* riid [in] Requested Interface -* prgfInOut [ ] reserved -* ppvObject [out] Resulting Interface -* -*/ -static HRESULT WINAPI ISF_NetworkPlaces_fnGetUIObjectOf (IShellFolder2 * iface, - HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, - UINT * prgfInOut, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - LPITEMIDLIST pidl; - IUnknown *pObj = NULL; - HRESULT hr = E_INVALIDARG; - - TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", This, - hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut); - - if (!ppvOut) - return hr; - - *ppvOut = NULL; - - if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) - { - hr = CDefFolderMenu_Create2(This->pidlRoot, hwndOwner, cidl, apidl, (IShellFolder*)iface, NULL, 0, NULL, (IContextMenu**)&pObj); - } - else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) - { - pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) - { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) - { - hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj); - } - else - hr = E_NOINTERFACE; - - if (SUCCEEDED(hr) && !pObj) - hr = E_OUTOFMEMORY; - - *ppvOut = pObj; - TRACE ("(%p)->hr=0x%08x\n", This, hr); - return hr; -} - -/************************************************************************** -* ISF_NetworkPlaces_fnGetDisplayNameOf -* -*/ -static HRESULT WINAPI ISF_NetworkPlaces_fnGetDisplayNameOf (IShellFolder2 * iface, - LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet); - pdump (pidl); - - if (!strRet) - return E_INVALIDARG; - - return E_NOTIMPL; -} - -/************************************************************************** -* ISF_NetworkPlaces_fnSetNameOf -* Changes the name of a file object or subfolder, possibly changing its item -* identifier in the process. -* -* PARAMETERS -* hwndOwner [in] Owner window for output -* pidl [in] simple pidl of item to change -* lpszName [in] the items new display name -* dwFlags [in] SHGNO formatting flags -* ppidlOut [out] simple pidl returned -*/ -static HRESULT WINAPI ISF_NetworkPlaces_fnSetNameOf (IShellFolder2 * iface, - HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */ - LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This, - hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut); - return E_FAIL; -} - -static HRESULT WINAPI ISF_NetworkPlaces_fnGetDefaultSearchGUID ( - IShellFolder2 * iface, GUID * pguid) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_NetworkPlaces_fnEnumSearches (IShellFolder2 * iface, - IEnumExtraSearch ** ppenum) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_NetworkPlaces_fnGetDefaultColumn (IShellFolder2 * iface, - DWORD dwRes, ULONG * pSort, ULONG * pDisplay) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)\n", This); - - if (pSort) - *pSort = 0; - if (pDisplay) - *pDisplay = 0; - - return S_OK; -} - -static HRESULT WINAPI ISF_NetworkPlaces_fnGetDefaultColumnState ( - IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)\n", This); - - if (!pcsFlags || iColumn >= NETWORKPLACESSHELLVIEWCOLUMNS) - return E_INVALIDARG; - *pcsFlags = NetworkPlacesSFHeader[iColumn].pcsFlags; - return S_OK; -} - -static HRESULT WINAPI ISF_NetworkPlaces_fnGetDetailsEx (IShellFolder2 * iface, - LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_NetworkPlaces_fnGetDetailsOf (IShellFolder2 * iface, - LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - WCHAR buffer[MAX_PATH] = {0}; - HRESULT hr = E_FAIL; - - if (iColumn >= NETWORKPLACESSHELLVIEWCOLUMNS) - return E_FAIL; - - psd->fmt = NetworkPlacesSFHeader[iColumn].fmt; - psd->cxChar = NetworkPlacesSFHeader[iColumn].cxChar; - if (pidl == NULL) - { - psd->str.uType = STRRET_WSTR; - if (LoadStringW(shell32_hInstance, NetworkPlacesSFHeader[iColumn].colnameid, buffer, MAX_PATH)) - hr = SHStrDupW(buffer, &psd->str.u.pOleStr); - - return hr; - } - - if (iColumn == COLUMN_NAME) - return IShellFolder2_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL, &psd->str); - - FIXME ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd); - - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_NetworkPlaces_fnMapColumnToSCID (IShellFolder2 * iface, - UINT column, SHCOLUMNID * pscid) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)\n", This); - - return E_NOTIMPL; -} - -static const IShellFolder2Vtbl vt_ShellFolder2 = { - ISF_NetworkPlaces_fnQueryInterface, - ISF_NetworkPlaces_fnAddRef, - ISF_NetworkPlaces_fnRelease, - ISF_NetworkPlaces_fnParseDisplayName, - ISF_NetworkPlaces_fnEnumObjects, - ISF_NetworkPlaces_fnBindToObject, - ISF_NetworkPlaces_fnBindToStorage, - ISF_NetworkPlaces_fnCompareIDs, - ISF_NetworkPlaces_fnCreateViewObject, - ISF_NetworkPlaces_fnGetAttributesOf, - ISF_NetworkPlaces_fnGetUIObjectOf, - ISF_NetworkPlaces_fnGetDisplayNameOf, - ISF_NetworkPlaces_fnSetNameOf, - /* ShellFolder2 */ - ISF_NetworkPlaces_fnGetDefaultSearchGUID, - ISF_NetworkPlaces_fnEnumSearches, - ISF_NetworkPlaces_fnGetDefaultColumn, - ISF_NetworkPlaces_fnGetDefaultColumnState, - ISF_NetworkPlaces_fnGetDetailsEx, - ISF_NetworkPlaces_fnGetDetailsOf, - ISF_NetworkPlaces_fnMapColumnToSCID -}; - -/************************************************************************ - * INPFldr_PersistFolder2_QueryInterface - */ -static HRESULT WINAPI INPFldr_PersistFolder2_QueryInterface (IPersistFolder2 * iface, - REFIID iid, LPVOID * ppvObj) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)\n", This); - - return IUnknown_QueryInterface (_IUnknown_ (This), iid, ppvObj); -} - -/************************************************************************ - * INPFldr_PersistFolder2_AddRef - */ -static ULONG WINAPI INPFldr_PersistFolder2_AddRef (IPersistFolder2 * iface) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_AddRef (_IUnknown_ (This)); -} - -/************************************************************************ - * ISFPersistFolder_Release - */ -static ULONG WINAPI INPFldr_PersistFolder2_Release (IPersistFolder2 * iface) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)->(count=%u)\n", This, This->ref); - - return IUnknown_Release (_IUnknown_ (This)); -} - -/************************************************************************ - * INPFldr_PersistFolder2_GetClassID - */ -static HRESULT WINAPI INPFldr_PersistFolder2_GetClassID ( - IPersistFolder2 * iface, CLSID * lpClassId) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)\n", This); - - if (!lpClassId) - return E_POINTER; - - *lpClassId = CLSID_NetworkPlaces; - - return S_OK; -} - -/************************************************************************ - * INPFldr_PersistFolder2_Initialize - * - * NOTES: it makes no sense to change the pidl - */ -static HRESULT WINAPI INPFldr_PersistFolder2_Initialize ( - IPersistFolder2 * iface, LPCITEMIDLIST pidl) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)->(%p)\n", This, pidl); - - return E_NOTIMPL; -} - -/************************************************************************** - * IPersistFolder2_fnGetCurFolder - */ -static HRESULT WINAPI INPFldr_PersistFolder2_GetCurFolder ( - IPersistFolder2 * iface, LPITEMIDLIST * pidl) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)->(%p)\n", This, pidl); - - if (!pidl) - return E_POINTER; - - *pidl = ILClone (This->pidlRoot); - - return S_OK; -} - -static const IPersistFolder2Vtbl vt_NP_PersistFolder2 = -{ - INPFldr_PersistFolder2_QueryInterface, - INPFldr_PersistFolder2_AddRef, - INPFldr_PersistFolder2_Release, - INPFldr_PersistFolder2_GetClassID, - INPFldr_PersistFolder2_Initialize, - INPFldr_PersistFolder2_GetCurFolder -}; diff --git a/reactos/dll/win32/shell32/shfldr_printers.c b/reactos/dll/win32/shell32/shfldr_printers.c deleted file mode 100644 index c7ffbfbc071..00000000000 --- a/reactos/dll/win32/shell32/shfldr_printers.c +++ /dev/null @@ -1,984 +0,0 @@ -/* - * Virtual Printers Folder - * - * Copyright 1997 Marcus Meissner - * Copyright 1998, 1999, 2002 Juergen Schmied - * Copyright 2005 Huw Davies - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL (shell); - -/*********************************************************************** - * Printers_IExtractIconW implementation - */ -typedef struct -{ - IExtractIconWVtbl *lpVtbl; - IExtractIconAVtbl *lpvtblExtractIconA; - volatile LONG ref; - LPITEMIDLIST pidl; -} IExtractIconWImpl; - -#define _IExtractIconA_Offset ((INT_PTR)(&(((IExtractIconWImpl*)0)->lpvtblExtractIconA))) -#define _ICOM_THIS_From_IExtractIconA(class, name) class* This = (class*)(((char*)name)-_IExtractIconA_Offset); - -static shvheader PrinterSFHeader[] = { - {IDS_SHV_COLUMN8, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15}, - {IDS_SHV_COLUMN_DOCUMENTS , SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15}, - {IDS_SHV_COLUMN_STATUS, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15}, - {IDS_SHV_COLUMN_COMMENTS, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15}, - {IDS_SHV_COLUMN_LOCATION, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15}, - {IDS_SHV_COLUMN_MODEL, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15} -}; - -#define COLUMN_NAME 0 -#define COLUMN_DOCUMENTS 1 -#define COLUMN_STATUS 2 -#define COLUMN_COMMENTS 3 -#define COLUMN_LOCATION 4 -#define COLUMN_MODEL 5 - - -#define PrinterSHELLVIEWCOLUMNS (6) - - -/************************************************************************** - * IExtractIconW_QueryInterface - */ -static HRESULT WINAPI IEI_Printers_fnQueryInterface(IExtractIconW *iface, REFIID riid, LPVOID *ppvObj) -{ - IExtractIconWImpl *This = (IExtractIconWImpl *)iface; - - TRACE("(%p)->(\n\tIID:\t%s,%p)\n", This, debugstr_guid(riid), ppvObj); - - *ppvObj = NULL; - - if (IsEqualIID(riid, &IID_IUnknown)) - { - *ppvObj = This; - } - else if (IsEqualIID(riid, &IID_IExtractIconW)) - { - *ppvObj = (IExtractIconW*)This; - } - else if (IsEqualIID(riid, &IID_IExtractIconA)) - { - *ppvObj = (IExtractIconA*)&(This->lpvtblExtractIconA); - } - - if(*ppvObj) - { - ((IExtractIconW*)*ppvObj)->lpVtbl->AddRef(*ppvObj); - TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj); - return S_OK; - } - TRACE("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -/************************************************************************** - * IExtractIconW_AddRef - */ -static ULONG WINAPI IEI_Printers_fnAddRef(IExtractIconW * iface) -{ - IExtractIconWImpl *This = (IExtractIconWImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE("(%p)->(count=%lu)\n", This, refCount - 1); - - return refCount; -} - -/************************************************************************** - * IExtractIconW_Release - */ -static ULONG WINAPI IEI_Printers_fnRelease(IExtractIconW * iface) -{ - IExtractIconWImpl *This = (IExtractIconWImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(count=%lu)\n", This, refCount + 1); - - if (!refCount) - { - TRACE(" destroying IExtractIcon(%p)\n",This); - SHFree(This->pidl); - HeapFree(GetProcessHeap(),0,This); - return 0; - } - return refCount; -} - -/************************************************************************** - * IExtractIconW_GetIconLocation - * - * mapping filetype to icon - */ -static HRESULT WINAPI IEI_Printers_fnGetIconLocation( - IExtractIconW * iface, - UINT uFlags, /* GIL_ flags */ - LPWSTR szIconFile, - UINT cchMax, - int *piIndex, - UINT *pwFlags) /* returned GIL_ flags */ -{ - IExtractIconWImpl *This = (IExtractIconWImpl *)iface; - - TRACE("(%p) (flags=%u %p %u %p %p)\n", This, uFlags, szIconFile, cchMax, piIndex, pwFlags); - - if (pwFlags) - *pwFlags = 0; - - lstrcpynW(szIconFile, swShell32Name, cchMax); - *piIndex = -IDI_SHELL_PRINTERS_FOLDER; /* FIXME: other icons for default, network, print to file */ - - TRACE("-- %s %x\n", debugstr_w(szIconFile), *piIndex); - return NOERROR; -} - -/************************************************************************** - * IExtractIconW_Extract - */ -static HRESULT WINAPI IEI_Printers_fnExtract(IExtractIconW *iface, LPCWSTR pszFile, - UINT nIconIndex, HICON *phiconLarge, - HICON *phiconSmall, UINT nIconSize) -{ - IExtractIconWImpl *This = (IExtractIconWImpl *)iface; - int index; - - FIXME("(%p) (file=%p index=%d %p %p size=%x) semi-stub\n", This, debugstr_w(pszFile), - (signed)nIconIndex, phiconLarge, phiconSmall, nIconSize); - - index = SIC_GetIconIndex(pszFile, nIconIndex, 0); - - if (phiconLarge) - *phiconLarge = ImageList_GetIcon(ShellBigIconList, index, ILD_TRANSPARENT); - - if (phiconSmall) - *phiconSmall = ImageList_GetIcon(ShellSmallIconList, index, ILD_TRANSPARENT); - - return S_OK; -} - -static struct IExtractIconWVtbl eivt = -{ - IEI_Printers_fnQueryInterface, - IEI_Printers_fnAddRef, - IEI_Printers_fnRelease, - IEI_Printers_fnGetIconLocation, - IEI_Printers_fnExtract -}; - -/************************************************************************** - * IExtractIconA_QueryInterface - */ -static HRESULT WINAPI IEIA_Printers_fnQueryInterface(IExtractIconA * iface, REFIID riid, LPVOID *ppvObj) -{ - _ICOM_THIS_From_IExtractIconA(IExtractIconW, iface); - - return This->lpVtbl->QueryInterface(This, riid, ppvObj); -} - -/************************************************************************** - * IExtractIconA_AddRef - */ -static ULONG WINAPI IEIA_Printers_fnAddRef(IExtractIconA * iface) -{ - _ICOM_THIS_From_IExtractIconA(IExtractIconW, iface); - - return This->lpVtbl->AddRef(This); -} -/************************************************************************** - * IExtractIconA_Release - */ -static ULONG WINAPI IEIA_Printers_fnRelease(IExtractIconA * iface) -{ - _ICOM_THIS_From_IExtractIconA(IExtractIconW, iface); - - return This->lpVtbl->AddRef(This); -} - -/************************************************************************** - * IExtractIconA_GetIconLocation - */ -static HRESULT WINAPI IEIA_Printers_fnGetIconLocation( - IExtractIconA * iface, - UINT uFlags, - LPSTR szIconFile, - UINT cchMax, - int * piIndex, - UINT * pwFlags) -{ - HRESULT ret; - LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, cchMax * sizeof(WCHAR)); - _ICOM_THIS_From_IExtractIconA(IExtractIconW, iface); - - TRACE("(%p) (flags=%u %p %u %p %p)\n", This, uFlags, szIconFile, cchMax, piIndex, pwFlags); - - ret = This->lpVtbl->GetIconLocation(This, uFlags, lpwstrFile, cchMax, piIndex, pwFlags); - WideCharToMultiByte(CP_ACP, 0, lpwstrFile, -1, szIconFile, cchMax, NULL, NULL); - HeapFree(GetProcessHeap(), 0, lpwstrFile); - - TRACE("-- %s %x\n", szIconFile, *piIndex); - return ret; -} -/************************************************************************** - * IExtractIconA_Extract - */ -static HRESULT WINAPI IEIA_Printers_fnExtract(IExtractIconA *iface, LPCSTR pszFile, - UINT nIconIndex, HICON *phiconLarge, - HICON *phiconSmall, UINT nIconSize) -{ - HRESULT ret; - INT len = MultiByteToWideChar(CP_ACP, 0, pszFile, -1, NULL, 0); - LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - _ICOM_THIS_From_IExtractIconA(IExtractIconW, iface); - - TRACE("(%p) (file=%p index=%u %p %p size=%u)\n", This, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize); - - MultiByteToWideChar(CP_ACP, 0, pszFile, -1, lpwstrFile, len); - ret = This->lpVtbl->Extract(This, lpwstrFile, nIconIndex, phiconLarge, phiconSmall, nIconSize); - HeapFree(GetProcessHeap(), 0, lpwstrFile); - return ret; -} - -static struct IExtractIconAVtbl eiavt = -{ - IEIA_Printers_fnQueryInterface, - IEIA_Printers_fnAddRef, - IEIA_Printers_fnRelease, - IEIA_Printers_fnGetIconLocation, - IEIA_Printers_fnExtract -}; - -/************************************************************************** - * IExtractIcon_Constructor - */ -static IUnknown *IEI_Printers_Constructor(LPCITEMIDLIST pidl) -{ - IExtractIconWImpl* ei; - - TRACE("%p\n", pidl); - - ei = HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconWImpl)); - ei->ref = 1; - ei->lpVtbl = &eivt; - ei->lpvtblExtractIconA = &eiavt; - ei->pidl=ILClone(pidl); - - pdump(pidl); - - TRACE("(%p)\n", ei); - return (IUnknown *)ei; -} - -/*********************************************************************** - * Printers folder implementation - */ - -typedef struct { - IShellFolder2Vtbl *lpVtbl; - IPersistFolder2Vtbl *lpVtblPersistFolder2; - - LONG ref; - - CLSID *pclsid; - - LPITEMIDLIST pidlRoot; /* absolute pidl */ - - int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */ -} IGenericSFImpl; - -#define _IPersistFolder2_Offset ((INT_PTR)(&(((IGenericSFImpl*)0)->lpVtblPersistFolder2))) -#define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder2_Offset); - -#define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl) -#define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl) - -#define _IPersist_(This) (IPersist*)&(This->lpVtblPersistFolder2) -#define _IPersistFolder_(This) (IPersistFolder*)&(This->lpVtblPersistFolder2) -#define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpVtblPersistFolder2) - -/************************************************************************** - * ISF_Printers_fnQueryInterface - * - * NOTE does not support IPersist/IPersistFolder - */ -static HRESULT WINAPI ISF_Printers_fnQueryInterface( - IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj); - - *ppvObj = NULL; - - if (IsEqualIID (riid, &IID_IUnknown) || - IsEqualIID (riid, &IID_IShellFolder) || - IsEqualIID (riid, &IID_IShellFolder2)) - { - *ppvObj = _IShellFolder_(This); - } - - else if (IsEqualIID (riid, &IID_IPersist) || - IsEqualIID (riid, &IID_IPersistFolder) || - IsEqualIID (riid, &IID_IPersistFolder2)) - { - *ppvObj = _IPersistFolder2_ (This); - } - - if (*ppvObj) - { - IUnknown_AddRef ((IUnknown *) (*ppvObj)); - TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj); - return S_OK; - } - TRACE ("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -static ULONG WINAPI ISF_Printers_fnAddRef (IShellFolder2 * iface) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE ("(%p)->(count=%lu)\n", This, refCount - 1); - - return refCount; -} - -static ULONG WINAPI ISF_Printers_fnRelease (IShellFolder2 * iface) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE ("(%p)->(count=%lu)\n", This, refCount + 1); - - if (!refCount) - { - TRACE ("-- destroying IShellFolder(%p)\n", This); - if (This->pidlRoot) - SHFree (This->pidlRoot); - LocalFree ((HLOCAL) This); - return 0; - } - return refCount; -} - -/************************************************************************** - * ISF_Printers_fnParseDisplayName - * - * This is E_NOTIMPL in Windows too. - */ -static HRESULT WINAPI ISF_Printers_fnParseDisplayName (IShellFolder2 * iface, - HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, - DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", - This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName), - pchEaten, ppidl, pdwAttributes); - - *ppidl = 0; - if (pchEaten) - *pchEaten = 0; - - return E_NOTIMPL; -} - -static LPITEMIDLIST _ILCreatePrinterItem(PRINTER_INFO_4W *pi) -{ - PIDLDATA tmp; - LPITEMIDLIST pidl; - PIDLPrinterStruct * p; - int size0 = (char*)&tmp.u.cprinter.szName-(char*)&tmp.u.cprinter; - int size = size0; - - tmp.type = 0x00; - tmp.u.cprinter.dummy = 0xFF; - if (pi->pPrinterName) - tmp.u.cprinter.offsServer = wcslen(pi->pPrinterName) + 1; - else - tmp.u.cprinter.offsServer = 1; - - size += tmp.u.cprinter.offsServer * sizeof(WCHAR); - if (pi->pServerName) - size += ( + wcslen(pi->pServerName) + 1) * sizeof(WCHAR); - else - size += sizeof(WCHAR); - - pidl = (LPITEMIDLIST)SHAlloc(size + 4); - if (!pidl) - return pidl; - - pidl->mkid.cb = size+2; - memcpy(pidl->mkid.abID, &tmp, 2+size0); - - p = &((PIDLDATA*)pidl->mkid.abID)->u.cprinter; - - p->Attributes = pi->Attributes; - if (pi->pPrinterName) - wcscpy(p->szName, pi->pPrinterName); - else - p->szName[0] = L'\0'; - - if (pi->pServerName) - wcscpy(p->szName + p->offsServer, pi->pServerName); - else - p->szName[p->offsServer] = L'\0'; - - *(WORD*)((char*)pidl+(size+2)) = 0; - return pidl; -} - -static PIDLPrinterStruct * _ILGetPrinterStruct(LPCITEMIDLIST pidl) -{ - LPPIDLDATA pdata = _ILGetDataPointer(pidl); - - if (pdata && pdata->type==0x00) - return (PIDLPrinterStruct*)&(pdata->u.cfont); - - return NULL; -} - -/************************************************************************** - * CreatePrintersEnumList() - */ -static BOOL CreatePrintersEnumList(IEnumIDList *list, DWORD dwFlags) -{ - BOOL ret = TRUE; - - TRACE("(%p)->(flags=0x%08lx) \n",list,dwFlags); - - /* enumerate the folders */ - if (dwFlags & SHCONTF_NONFOLDERS) - { - DWORD needed = 0, num = 0, i; - PRINTER_INFO_4W *pi; - - EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, 4, NULL, 0, &needed, &num); - if (!needed) - return ret; - - pi = HeapAlloc(GetProcessHeap(), 0, needed); - if(!EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, 4, (LPBYTE)pi, needed, &needed, &num)) { - HeapFree(GetProcessHeap(), 0, pi); - return FALSE; - } - - for(i = 0; i < num; i++) { - LPITEMIDLIST pidl = _ILCreatePrinterItem(&pi[i]); - if (pidl) - { - if (!AddToEnumList(list, pidl)) - SHFree(pidl); - } - } - HeapFree(GetProcessHeap(), 0, pi); - } - return ret; -} - -/************************************************************************** - * ISF_Printers_fnEnumObjects - */ -static HRESULT WINAPI ISF_Printers_fnEnumObjects (IShellFolder2 * iface, - HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", - This, hwndOwner, dwFlags, ppEnumIDList); - - if(!ppEnumIDList) return E_OUTOFMEMORY; - *ppEnumIDList = IEnumIDList_Constructor(); - if (*ppEnumIDList) - CreatePrintersEnumList(*ppEnumIDList, dwFlags); - - TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList); - - return (*ppEnumIDList) ? S_OK : E_OUTOFMEMORY; -} - -/************************************************************************** - * ISF_Printers_fnBindToObject - */ -static HRESULT WINAPI ISF_Printers_fnBindToObject (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, - pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); - - return SHELL32_BindToChild (This->pidlRoot, NULL, pidl, riid, ppvOut); -} - -/************************************************************************** - * ISF_Printers_fnBindToStorage - */ -static HRESULT WINAPI ISF_Printers_fnBindToStorage (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", - This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); - - *ppvOut = NULL; - return E_NOTIMPL; -} - -/************************************************************************** - * ISF_Printers_fnCompareIDs - */ -static HRESULT WINAPI ISF_Printers_fnCompareIDs (IShellFolder2 * iface, - LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - int nReturn; - - TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2); - nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2); - TRACE ("-- %i\n", nReturn); - return nReturn; -} - -/************************************************************************** - * ISF_Printers_fnCreateViewObject - */ -static HRESULT WINAPI ISF_Printers_fnCreateViewObject (IShellFolder2 * iface, - HWND hwndOwner, REFIID riid, LPVOID * ppvOut) -{ - - LPSHELLVIEW pShellView; - HRESULT hr = E_INVALIDARG; - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This, - hwndOwner, shdebugstr_guid (riid), ppvOut); - - if (!ppvOut) - return hr; - - *ppvOut = NULL; - - if (IsEqualIID (riid, &IID_IDropTarget)) - { - WARN ("IDropTarget not implemented\n"); - hr = E_NOTIMPL; - } - else if (IsEqualIID (riid, &IID_IContextMenu)) - { - WARN ("IContextMenu not implemented\n"); - hr = E_NOTIMPL; - } - else if (IsEqualIID (riid, &IID_IShellView)) - { - pShellView = IShellView_Constructor ((IShellFolder *) iface); - if (pShellView) - { - hr = IShellView_QueryInterface (pShellView, riid, ppvOut); - IShellView_Release (pShellView); - } - } - TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut); - return hr; -} - -/************************************************************************** - * ISF_Printers_fnGetAttributesOf - */ -static HRESULT WINAPI ISF_Printers_fnGetAttributesOf (IShellFolder2 * iface, - UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut) -{ - static const DWORD dwPrintersAttributes = - SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR | SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_CANRENAME | SFGAO_CANDELETE; - HRESULT hr = S_OK; - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)->(cidl=%d apidl=%p mask=0x%08lx): stub\n", - This, cidl, apidl, *rgfInOut); - - *rgfInOut &= dwPrintersAttributes; - - *rgfInOut &= ~SFGAO_VALIDATE; - - TRACE ("-- result=0x%08x\n", *rgfInOut); - return hr; -} - -/************************************************************************** - * ISF_Printers_fnGetUIObjectOf - * - * PARAMETERS - * HWND hwndOwner, //[in ] Parent window for any output - * UINT cidl, //[in ] array size - * LPCITEMIDLIST* apidl, //[in ] simple pidl array - * REFIID riid, //[in ] Requested Interface - * UINT* prgfInOut, //[ ] reserved - * LPVOID* ppvObject) //[out] Resulting Interface - * - */ -static HRESULT WINAPI ISF_Printers_fnGetUIObjectOf (IShellFolder2 * iface, - HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, - REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - IUnknown *pObj = NULL; - HRESULT hr = E_INVALIDARG; - - TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", - This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut); - - if (!ppvOut) - return hr; - - *ppvOut = NULL; - - if ((IsEqualIID (riid, &IID_IExtractIconA) || IsEqualIID(riid, &IID_IExtractIconW)) && (cidl == 1)) - { - IUnknown *pUnk = IEI_Printers_Constructor(apidl[0]); - hr = IUnknown_QueryInterface(pUnk, riid, (void**)&pObj); - IUnknown_Release(pUnk); - } - else - hr = E_NOINTERFACE; - - if (SUCCEEDED(hr) && !pObj) - hr = E_OUTOFMEMORY; - - *ppvOut = pObj; - TRACE ("(%p)->hr=0x%08lx\n", This, hr); - return hr; -} - -/************************************************************************** - * ISF_Printers_fnGetDisplayNameOf - * - */ -static HRESULT WINAPI ISF_Printers_fnGetDisplayNameOf (IShellFolder2 * iface, - LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet) -{ - LPWSTR pszName; - IGenericSFImpl *This = (IGenericSFImpl *)iface; - PIDLPrinterStruct * p; - - TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet); - pdump (pidl); - - if (!strRet) - { - WARN("no strRet\n"); - return E_INVALIDARG; - } - - if (_ILIsPrinter(pidl)) - { - pszName = CoTaskMemAlloc(MAX_PATH * sizeof(WCHAR)); - if (!pszName) - return E_OUTOFMEMORY; - - if (LoadStringW(shell32_hInstance, IDS_PRINTERS, pszName, MAX_PATH)) - { - pszName[MAX_PATH-1] = L'\0'; - strRet->uType = STRRET_WSTR; - strRet->u.pOleStr = pszName; - return S_OK; - } - CoTaskMemFree(pszName); - return E_FAIL; - } - - p = _ILGetPrinterStruct(pidl); - if (!p) - { - WARN("no printer struct\n"); - return E_INVALIDARG; - } - strRet->u.pOleStr = SHAlloc(p->offsServer * sizeof(WCHAR)); - if (!strRet->u.pOleStr) - return E_OUTOFMEMORY; - - memcpy((LPVOID)strRet->u.pOleStr, (LPVOID)p->szName, p->offsServer * sizeof(WCHAR)); - TRACE("ret %s\n", debugstr_w(strRet->u.pOleStr)); - - return S_OK; -} - -/************************************************************************** - * ISF_Printers_fnSetNameOf - * Changes the name of a file object or subfolder, possibly changing its item - * identifier in the process. - * - * PARAMETERS - * HWND hwndOwner, //[in ] Owner window for output - * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change - * LPCOLESTR lpszName, //[in ] the items new display name - * DWORD dwFlags, //[in ] SHGNO formatting flags - * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned - */ -static HRESULT WINAPI ISF_Printers_fnSetNameOf (IShellFolder2 * iface, - HWND hwndOwner, LPCITEMIDLIST pidl, /* simple pidl */ - LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, - debugstr_w (lpName), dwFlags, pPidlOut); - - return E_FAIL; -} - -static HRESULT WINAPI ISF_Printers_fnGetDefaultSearchGUID(IShellFolder2 *iface, - GUID * pguid) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_Printers_fnEnumSearches (IShellFolder2 *iface, - IEnumExtraSearch ** ppenum) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_Printers_fnGetDefaultColumn (IShellFolder2 * iface, - DWORD dwRes, ULONG * pSort, ULONG * pDisplay) -{ - if (pSort) - *pSort = 0; - if (pDisplay) - *pDisplay = 0; - - return S_OK; -} -static HRESULT WINAPI ISF_Printers_fnGetDefaultColumnState ( - IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags) -{ - if (!pcsFlags || iColumn >= PrinterSHELLVIEWCOLUMNS) - return E_INVALIDARG; - *pcsFlags = PrinterSFHeader[iColumn].pcsFlags; - return S_OK; - -} - -static HRESULT WINAPI ISF_Printers_fnGetDetailsEx (IShellFolder2 * iface, - LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p): stub\n", This); - - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_Printers_fnGetDetailsOf (IShellFolder2 * iface, - LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - WCHAR buffer[MAX_PATH] = {0}; - HRESULT hr = E_FAIL; - - TRACE("(%p)->(%p %i %p): stub\n", This, pidl, iColumn, psd); - - if (iColumn >= PrinterSHELLVIEWCOLUMNS) - return E_FAIL; - - psd->fmt = PrinterSFHeader[iColumn].fmt; - psd->cxChar = PrinterSFHeader[iColumn].cxChar; - if (pidl == NULL) - { - psd->str.uType = STRRET_WSTR; - if (LoadStringW(shell32_hInstance, PrinterSFHeader[iColumn].colnameid, buffer, MAX_PATH)) - hr = SHStrDupW(buffer, &psd->str.u.pOleStr); - - return hr; - } - - if (iColumn == COLUMN_NAME) - { - psd->str.uType = STRRET_WSTR; - return IShellFolder2_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL, &psd->str); - } - - psd->str.uType = STRRET_CSTR; - psd->str.u.cStr[0] = '\0'; - - return E_NOTIMPL; -} - -static HRESULT WINAPI ISF_Printers_fnMapColumnToSCID ( - IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid) -{ - IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p): stub\n", This); - return E_NOTIMPL; -} - -static IShellFolder2Vtbl vt_ShellFolder2 = -{ - ISF_Printers_fnQueryInterface, - ISF_Printers_fnAddRef, - ISF_Printers_fnRelease, - ISF_Printers_fnParseDisplayName, - ISF_Printers_fnEnumObjects, - ISF_Printers_fnBindToObject, - ISF_Printers_fnBindToStorage, - ISF_Printers_fnCompareIDs, - ISF_Printers_fnCreateViewObject, - ISF_Printers_fnGetAttributesOf, - ISF_Printers_fnGetUIObjectOf, - ISF_Printers_fnGetDisplayNameOf, - ISF_Printers_fnSetNameOf, - /* ShellFolder2 */ - ISF_Printers_fnGetDefaultSearchGUID, - ISF_Printers_fnEnumSearches, - ISF_Printers_fnGetDefaultColumn, - ISF_Printers_fnGetDefaultColumnState, - ISF_Printers_fnGetDetailsEx, - ISF_Printers_fnGetDetailsOf, - ISF_Printers_fnMapColumnToSCID -}; - -/************************************************************************ - * IPF_Printers_QueryInterface - */ -static HRESULT WINAPI IPF_Printers_QueryInterface ( - IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObj) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)\n", This); - - return IUnknown_QueryInterface (_IUnknown_ (This), iid, ppvObj); -} - -/************************************************************************ - * IPF_Printers_AddRef - */ -static ULONG WINAPI IPF_Printers_AddRef (IPersistFolder2 * iface) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)->(count=%lu)\n", This, This->ref); - - return IUnknown_AddRef (_IUnknown_ (This)); -} - -/************************************************************************ - * IPF_Printers_Release - */ -static ULONG WINAPI IPF_Printers_Release (IPersistFolder2 * iface) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)->(count=%lu)\n", This, This->ref); - - return IUnknown_Release (_IUnknown_ (This)); -} - -/************************************************************************ - * IPF_Printers_GetClassID - */ -static HRESULT WINAPI IPF_Printers_GetClassID ( - IPersistFolder2 * iface, CLSID * lpClassId) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)\n", This); - - *lpClassId = CLSID_Printers; - - return S_OK; -} - -/************************************************************************ - * IPF_Printers_Initialize - * - */ -static HRESULT WINAPI IPF_Printers_Initialize ( - IPersistFolder2 * iface, LPCITEMIDLIST pidl) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - if (This->pidlRoot) - SHFree((LPVOID)This->pidlRoot); - - This->pidlRoot = ILClone(pidl); - return S_OK; -} - -/************************************************************************** - * IPF_Printers_fnGetCurFolder - */ -static HRESULT WINAPI IPF_Printers_GetCurFolder ( - IPersistFolder2 * iface, LPITEMIDLIST * pidl) -{ - _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); - - TRACE ("(%p)->(%p)\n", This, pidl); - - *pidl = ILClone (This->pidlRoot); - return S_OK; -} - -static IPersistFolder2Vtbl vt_PersistFolder2 = -{ - IPF_Printers_QueryInterface, - IPF_Printers_AddRef, - IPF_Printers_Release, - IPF_Printers_GetClassID, - IPF_Printers_Initialize, - IPF_Printers_GetCurFolder -}; - -/************************************************************************** - * ISF_Printers_Constructor - */ -HRESULT WINAPI ISF_Printers_Constructor ( - IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) -{ - IGenericSFImpl *sf; - HRESULT hr; - - TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid)); - - if (pUnkOuter) - return CLASS_E_NOAGGREGATION; - - sf = HeapAlloc( GetProcessHeap(), 0, sizeof(*sf) ); - if (!sf) - return E_OUTOFMEMORY; - - sf->ref = 1; - sf->lpVtbl = &vt_ShellFolder2; - sf->lpVtblPersistFolder2 = &vt_PersistFolder2; - - sf->pidlRoot = _ILCreatePrinters(); /* my qualified pidl */ - - hr = IUnknown_QueryInterface( _IUnknown_(sf), riid, ppv ); - IUnknown_Release( _IUnknown_(sf) ); - - TRACE ("--(%p)\n", *ppv); - return hr; -} diff --git a/reactos/dll/win32/shell32/shfldr_recyclebin.c b/reactos/dll/win32/shell32/shfldr_recyclebin.c deleted file mode 100644 index 855f4accd1e..00000000000 --- a/reactos/dll/win32/shell32/shfldr_recyclebin.c +++ /dev/null @@ -1,1614 +0,0 @@ -/* - * Trash virtual folder support. The trashing engine is implemented in trash.c - * - * Copyright (C) 2006 Mikolaj Zalewski - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define MAX_PROPERTY_SHEET_PAGE 32 - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(recyclebin); - -typedef struct -{ - int column_name_id; - const GUID *fmtId; - DWORD pid; - int pcsFlags; - int fmt; - int cxChars; -} columninfo; - -static const columninfo RecycleBinColumns[] = -{ - {IDS_SHV_COLUMN1, &FMTID_Storage, PID_STG_NAME, SHCOLSTATE_TYPE_STR|SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 30}, - {IDS_SHV_COLUMN_DELFROM, &FMTID_Displaced, PID_DISPLACED_FROM, SHCOLSTATE_TYPE_STR|SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 30}, - {IDS_SHV_COLUMN_DELDATE, &FMTID_Displaced, PID_DISPLACED_DATE, SHCOLSTATE_TYPE_DATE|SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20}, - {IDS_SHV_COLUMN2, &FMTID_Storage, PID_STG_SIZE, SHCOLSTATE_TYPE_INT|SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 20}, - {IDS_SHV_COLUMN3, &FMTID_Storage, PID_STG_STORAGETYPE,SHCOLSTATE_TYPE_INT|SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20}, - {IDS_SHV_COLUMN4, &FMTID_Storage, PID_STG_WRITETIME, SHCOLSTATE_TYPE_DATE|SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20}, -/* {"creation time", &FMTID_Storage, PID_STG_CREATETIME, SHCOLSTATE_TYPE_DATE, LVCFMT_LEFT, 20}, */ -/* {"attribs", &FMTID_Storage, PID_STG_ATTRIBUTES, SHCOLSTATE_TYPE_STR, LVCFMT_LEFT, 20}, */ -}; - -#define COLUMN_NAME 0 -#define COLUMN_DELFROM 1 -#define COLUMN_DATEDEL 2 -#define COLUMN_SIZE 3 -#define COLUMN_TYPE 4 -#define COLUMN_MTIME 5 - -#define COLUMNS_COUNT 6 - -/* - * Recycle Bin folder - */ - -typedef struct tagRecycleBin -{ - const IShellFolder2Vtbl *lpVtbl; - const IPersistFolder2Vtbl *lpPersistFolderVtbl; - const IContextMenu2Vtbl *lpContextMenu2; - const IShellExtInitVtbl *lpSEI; - LONG refCount; - INT iIdEmpty; - LPITEMIDLIST pidl; - LPCITEMIDLIST apidl; -} RecycleBin, *LPRecycleBin; - -typedef struct -{ - PIDLRecycleStruct *pFileDetails; - HANDLE hDeletedFile; - BOOL bFound; -}SEARCH_CONTEXT, *PSEARCH_CONTEXT; - -typedef struct -{ - DWORD dwNukeOnDelete; - DWORD dwSerial; - DWORD dwMaxCapacity; -}DRIVE_ITEM_CONTEXT, *PDRIVE_ITEM_CONTEXT; - - -static const IContextMenu2Vtbl recycleBincmVtblFolder; -static const IContextMenu2Vtbl recycleBincmVtblBitbucketItem; -static const IShellFolder2Vtbl recycleBinVtbl; -static const IPersistFolder2Vtbl recycleBinPersistVtbl; -static const IShellExtInitVtbl eivt; - -static LPRecycleBin __inline impl_from_IContextMenu2(IContextMenu2 *iface) -{ - return (RecycleBin *)((char *)iface - FIELD_OFFSET(RecycleBin, lpContextMenu2)); -} - -static LPRecycleBin __inline impl_from_IPersistFolder(IPersistFolder2 *iface) -{ - return (RecycleBin *)((char *)iface - FIELD_OFFSET(RecycleBin, lpPersistFolderVtbl)); -} - -static LPRecycleBin __inline impl_from_IShellExtInit( IShellExtInit *iface ) -{ - return (RecycleBin *)((char*)iface - FIELD_OFFSET(RecycleBin, lpSEI)); -} - -static void RecycleBin_Destructor(RecycleBin *This); - -HRESULT WINAPI RecycleBin_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppOutput) -{ - RecycleBin *obj; - HRESULT ret; - if (pUnkOuter) - return CLASS_E_NOAGGREGATION; - - obj = SHAlloc(sizeof(RecycleBin)); - if (obj == NULL) - return E_OUTOFMEMORY; - ZeroMemory(obj, sizeof(RecycleBin)); - obj->lpVtbl = &recycleBinVtbl; - obj->lpSEI = &eivt; - obj->lpPersistFolderVtbl = &recycleBinPersistVtbl; - obj->lpContextMenu2 = NULL; - if (FAILED(ret = IUnknown_QueryInterface((IUnknown *)obj, riid, ppOutput))) - { - RecycleBin_Destructor(obj); - return ret; - } -/* InterlockedIncrement(&objCount);*/ - return S_OK; -} - -static void RecycleBin_Destructor(RecycleBin *This) -{ -/* InterlockedDecrement(&objCount);*/ - SHFree(This->pidl); - SHFree(This); -} - -static HRESULT WINAPI RecycleBin_QueryInterface(IShellFolder2 *iface, REFIID riid, void **ppvObject) -{ - RecycleBin *This = (RecycleBin *)iface; - TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppvObject); - - *ppvObject = NULL; - if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IShellFolder) - || IsEqualGUID(riid, &IID_IShellFolder2)) - *ppvObject = This; - - if (IsEqualGUID(riid, &IID_IPersist) || IsEqualGUID(riid, &IID_IPersistFolder) - || IsEqualGUID(riid, &IID_IPersistFolder2)) - *ppvObject = (void *)&This->lpPersistFolderVtbl; - - else if (IsEqualIID(riid, &IID_IContextMenu) || IsEqualGUID(riid, &IID_IContextMenu2)) - { - This->lpContextMenu2 = &recycleBincmVtblFolder; - *ppvObject = (void *)&This->lpContextMenu2; - } - else if(IsEqualIID(riid, &IID_IShellExtInit)) - { - *ppvObject = (void *)&(This->lpSEI); - } - - if (*ppvObject != NULL) - { - IUnknown_AddRef((IUnknown *)*ppvObject); - return S_OK; - } - WARN("no interface %s\n", debugstr_guid(riid)); - return E_NOINTERFACE; -} - -static ULONG WINAPI RecycleBin_AddRef(IShellFolder2 *iface) -{ - RecycleBin *This = (RecycleBin *)iface; - TRACE("(%p)\n", This); - return InterlockedIncrement(&This->refCount); -} - -static ULONG WINAPI RecycleBin_Release(IShellFolder2 *iface) -{ - RecycleBin *This = (RecycleBin *)iface; - LONG result; - - TRACE("(%p)\n", This); - result = InterlockedDecrement(&This->refCount); - if (result == 0) - { - TRACE("Destroy object\n"); - RecycleBin_Destructor(This); - } - return result; -} - -static HRESULT WINAPI RecycleBin_ParseDisplayName(IShellFolder2 *This, HWND hwnd, LPBC pbc, - LPOLESTR pszDisplayName, ULONG *pchEaten, LPITEMIDLIST *ppidl, - ULONG *pdwAttributes) -{ - FIXME("stub\n"); - return E_NOTIMPL; -} - - -PDELETED_FILE_DETAILS_W -UnpackDetailsFromPidl(LPCITEMIDLIST pidl) -{ - return (PDELETED_FILE_DETAILS_W)&pidl->mkid.abID; -} - -static LPITEMIDLIST _ILCreateRecycleItem(PDELETED_FILE_DETAILS_W pFileDetails) -{ - PIDLDATA tmp; - LPITEMIDLIST pidl; - PIDLRecycleStruct * p; - int size0 = (char*)&tmp.u.crecycle.szName-(char*)&tmp.u.crecycle; - int size = size0; - - tmp.type = 0x00; - size += (wcslen(pFileDetails->FileName) + 1) * sizeof(WCHAR); - - pidl = (LPITEMIDLIST)SHAlloc(size + 4); - if (!pidl) - return pidl; - - pidl->mkid.cb = size+2; - memcpy(pidl->mkid.abID, &tmp, 2+size0); - - p = &((PIDLDATA*)pidl->mkid.abID)->u.crecycle; - RtlCopyMemory(p, pFileDetails, sizeof(DELETED_FILE_DETAILS_W)); - wcscpy(p->szName, pFileDetails->FileName); - *(WORD*)((char*)pidl+(size+2)) = 0; - return pidl; -} - -static PIDLRecycleStruct * _ILGetRecycleStruct(LPCITEMIDLIST pidl) -{ - LPPIDLDATA pdata = _ILGetDataPointer(pidl); - - if (pdata && pdata->type==0x00) - return (PIDLRecycleStruct*)&(pdata->u.crecycle); - - return NULL; -} - -BOOL -WINAPI -CBSearchBitBucket(IN PVOID Context, IN HANDLE hDeletedFile) -{ - PSEARCH_CONTEXT pContext = (PSEARCH_CONTEXT)Context; - - PDELETED_FILE_DETAILS_W pFileDetails; - DWORD dwSize; - BOOL ret; - - if (!GetDeletedFileDetailsW(hDeletedFile, - 0, - NULL, - &dwSize) && - GetLastError() != ERROR_INSUFFICIENT_BUFFER) - { - ERR("GetDeletedFileDetailsW failed\n"); - return FALSE; - } - - pFileDetails = SHAlloc(dwSize); - if (!pFileDetails) - { - ERR("No memory\n"); - return FALSE; - } - - if (!GetDeletedFileDetailsW(hDeletedFile, - dwSize, - pFileDetails, - NULL)) - { - ERR("GetDeletedFileDetailsW failed\n"); - SHFree(pFileDetails); - return FALSE; - } - - ret = memcmp(pFileDetails, pContext->pFileDetails, dwSize); - if (!ret) - { - pContext->hDeletedFile = hDeletedFile; - pContext->bFound = TRUE; - } - else - CloseRecycleBinHandle(hDeletedFile); - - SHFree(pFileDetails); - return ret; -} - - - -BOOL -WINAPI -CBEnumBitBucket(IN PVOID Context, IN HANDLE hDeletedFile) -{ - PDELETED_FILE_DETAILS_W pFileDetails; - DWORD dwSize; - LPITEMIDLIST pidl = NULL; - BOOL ret; - - if (!GetDeletedFileDetailsW(hDeletedFile, - 0, - NULL, - &dwSize) && - GetLastError() != ERROR_INSUFFICIENT_BUFFER) - { - ERR("GetDeletedFileDetailsW failed\n"); - return FALSE; - } - - pFileDetails = SHAlloc(dwSize); - if (!pFileDetails) - { - ERR("No memory\n"); - return FALSE; - } - - if (!GetDeletedFileDetailsW(hDeletedFile, - dwSize, - pFileDetails, - NULL)) - { - ERR("GetDeletedFileDetailsW failed\n"); - SHFree(pFileDetails); - return FALSE; - } - - pidl = _ILCreateRecycleItem(pFileDetails); - if (!pidl) - { - SHFree(pFileDetails); - return FALSE; - } - - ret = AddToEnumList((IEnumIDList*)Context, pidl); - - if (!ret) - SHFree(pidl); - SHFree(pFileDetails); - TRACE("Returning %d\n", ret); - CloseRecycleBinHandle(hDeletedFile); - return ret; -} - -static HRESULT WINAPI RecycleBin_EnumObjects(IShellFolder2 *iface, HWND hwnd, SHCONTF grfFlags, IEnumIDList **ppenumIDList) -{ - RecycleBin *This = (RecycleBin *)iface; - IEnumIDList *list; - static LPCWSTR szDrive = L"C:\\"; - - TRACE("(%p, %p, %x, %p)\n", This, hwnd, (unsigned int)grfFlags, ppenumIDList); - - if (grfFlags & SHCONTF_NONFOLDERS) - { - TRACE("Starting Enumeration\n"); - *ppenumIDList = NULL; - list = IEnumIDList_Constructor(); - if (list == NULL) - return E_OUTOFMEMORY; - - if (!EnumerateRecycleBinW(szDrive, //FIXME - CBEnumBitBucket, - (PVOID)list)) - { - WARN("Error: EnumerateRecycleBinW failed\n"); - } - *ppenumIDList = list; - } - else - { - *ppenumIDList = IEnumIDList_Constructor(); - if (*ppenumIDList == NULL) - return E_OUTOFMEMORY; - } - - return S_OK; - -} - -static HRESULT WINAPI RecycleBin_BindToObject(IShellFolder2 *This, LPCITEMIDLIST pidl, LPBC pbc, REFIID riid, void **ppv) -{ - FIXME("(%p, %p, %p, %s, %p) - stub\n", This, pidl, pbc, debugstr_guid(riid), ppv); - return E_NOTIMPL; -} - -static HRESULT WINAPI RecycleBin_BindToStorage(IShellFolder2 *This, LPCITEMIDLIST pidl, LPBC pbc, REFIID riid, void **ppv) -{ - FIXME("(%p, %p, %p, %s, %p) - stub\n", This, pidl, pbc, debugstr_guid(riid), ppv); - return E_NOTIMPL; -} - -static HRESULT WINAPI RecycleBin_CompareIDs(IShellFolder2 *iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - RecycleBin *This = (RecycleBin *)iface; - - /* TODO */ - TRACE("(%p, %p, %p, %p)\n", This, (void *)lParam, pidl1, pidl2); - if (pidl1->mkid.cb != pidl2->mkid.cb) - return MAKE_HRESULT(SEVERITY_SUCCESS, 0, pidl1->mkid.cb - pidl2->mkid.cb); - return MAKE_HRESULT(SEVERITY_SUCCESS, 0, (unsigned short)memcmp(pidl1->mkid.abID, pidl2->mkid.abID, pidl1->mkid.cb)); -} - -static HRESULT WINAPI RecycleBin_CreateViewObject(IShellFolder2 *iface, HWND hwndOwner, REFIID riid, void **ppv) -{ - RecycleBin *This = (RecycleBin *)iface; - LPSHELLVIEW pShellView; - HRESULT hr = E_NOINTERFACE; - - TRACE("(%p, %p, %s, %p)\n", This, hwndOwner, debugstr_guid(riid), ppv); - - if (!ppv) - return hr; - - *ppv = NULL; - - if (IsEqualIID (riid, &IID_IDropTarget)) - { - WARN ("IDropTarget not implemented\n"); - hr = E_NOTIMPL; - } - else if (IsEqualIID (riid, &IID_IContextMenu) || IsEqualIID (riid, &IID_IContextMenu2)) - { - This->lpContextMenu2 = &recycleBincmVtblFolder; - *ppv = (void *)&This->lpContextMenu2; - This->refCount++; - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IShellView)) - { - pShellView = IShellView_Constructor ((IShellFolder *) iface); - if (pShellView) - { - hr = IShellView_QueryInterface (pShellView, riid, ppv); - IShellView_Release (pShellView); - } - } - else - return hr; - TRACE ("-- (%p)->(interface=%p)\n", This, ppv); - return hr; - -} - -static HRESULT WINAPI RecycleBin_GetAttributesOf(IShellFolder2 *This, UINT cidl, LPCITEMIDLIST *apidl, - SFGAOF *rgfInOut) -{ - TRACE("(%p, %d, {%p, ...}, {%x})\n", This, cidl, apidl[0], (unsigned int)*rgfInOut); - *rgfInOut &= SFGAO_CANMOVE|SFGAO_CANDELETE|SFGAO_HASPROPSHEET|SFGAO_FILESYSTEM; - return S_OK; -} - -static HRESULT WINAPI RecycleBin_GetUIObjectOf(IShellFolder2 *iface, HWND hwndOwner, UINT cidl, LPCITEMIDLIST *apidl, - REFIID riid, UINT *prgfInOut, void **ppv) -{ - IUnknown *pObj = NULL; - HRESULT hr = E_INVALIDARG; - RecycleBin * This = (RecycleBin*)iface; - - TRACE ("(%p)->(%p,%u,apidl=%p, %p %p)\n", This, - hwndOwner, cidl, apidl, prgfInOut, ppv); - - if (!ppv) - return hr; - - *ppv = NULL; - - if ((IsEqualIID (riid, &IID_IContextMenu) || IsEqualIID(riid, &IID_IContextMenu2)) && (cidl >= 1)) - { - This->lpContextMenu2 = &recycleBincmVtblBitbucketItem; - pObj = (IUnknown*)(&This->lpContextMenu2); - This->apidl = apidl[0]; - IUnknown_AddRef(pObj); - hr = S_OK; - } - else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) - { - hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj); - } - else - hr = E_NOINTERFACE; - - if (SUCCEEDED(hr) && !pObj) - hr = E_OUTOFMEMORY; - - *ppv = pObj; - TRACE ("(%p)->hr=0x%08x\n", This, hr); - return hr; -} - -static HRESULT WINAPI RecycleBin_GetDisplayNameOf(IShellFolder2 *This, LPCITEMIDLIST pidl, SHGDNF uFlags, STRRET *pName) -{ - PIDLRecycleStruct *pFileDetails; - LPWSTR pFileName; - - TRACE("(%p, %p, %x, %p)\n", This, pidl, (unsigned int)uFlags, pName); - - - if (_ILIsBitBucket (pidl)) - { - WCHAR pszPath[100]; - - if (HCR_GetClassNameW(&CLSID_RecycleBin, pszPath, MAX_PATH)) - { - pName->uType = STRRET_WSTR; - pName->u.pOleStr = StrDupW(pszPath); - return S_OK; - } - } - - pFileDetails = _ILGetRecycleStruct(pidl); - if (!pFileDetails) - { - pName->u.cStr[0] = 0; - pName->uType = STRRET_CSTR; - return E_INVALIDARG; - } - - pFileName = wcsrchr(pFileDetails->szName, L'\\'); - if (!pFileName) - { - pName->u.cStr[0] = 0; - pName->uType = STRRET_CSTR; - return E_UNEXPECTED; - } - - pName->u.pOleStr = StrDupW(pFileName + 1); - if (pName->u.pOleStr == NULL) - return E_OUTOFMEMORY; - - pName->uType = STRRET_WSTR; - return S_OK; -} - -static HRESULT WINAPI RecycleBin_SetNameOf(IShellFolder2 *This, HWND hwnd, LPCITEMIDLIST pidl, LPCOLESTR pszName, - SHGDNF uFlags, LPITEMIDLIST *ppidlOut) -{ - TRACE("\n"); - return E_FAIL; /* not supported */ -} - -static HRESULT WINAPI RecycleBin_GetDefaultSearchGUID(IShellFolder2 *iface, GUID *pguid) -{ - FIXME("stub\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI RecycleBin_EnumSearches(IShellFolder2 *iface, IEnumExtraSearch **ppEnum) -{ - FIXME("stub\n"); - *ppEnum = NULL; - return E_NOTIMPL; -} - -static HRESULT WINAPI RecycleBin_GetDefaultColumn(IShellFolder2 *iface, DWORD dwReserved, ULONG *pSort, ULONG *pDisplay) -{ - RecycleBin *This = (RecycleBin *)iface; - TRACE("(%p, %x, %p, %p)\n", This, (unsigned int)dwReserved, pSort, pDisplay); - *pSort = 0; - *pDisplay = 0; - return S_OK; -} - -static HRESULT WINAPI RecycleBin_GetDefaultColumnState(IShellFolder2 *iface, UINT iColumn, SHCOLSTATEF *pcsFlags) -{ - RecycleBin *This = (RecycleBin *)iface; - TRACE("(%p, %d, %p)\n", This, iColumn, pcsFlags); - if (iColumn >= COLUMNS_COUNT) - return E_INVALIDARG; - *pcsFlags = RecycleBinColumns[iColumn].pcsFlags; - return S_OK; -} - -static HRESULT WINAPI RecycleBin_GetDetailsEx(IShellFolder2 *iface, LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, VARIANT *pv) -{ - FIXME("stub\n"); - return E_NOTIMPL; -} - -static HRESULT FormatDateTime(LPWSTR buffer, int size, FILETIME * ft) -{ - FILETIME lft; - SYSTEMTIME time; - int ret; - - FileTimeToLocalFileTime(ft, &lft); - FileTimeToSystemTime(&lft, &time); - - ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &time, NULL, buffer, size); - if (ret>0 && ret= COLUMNS_COUNT) - return E_FAIL; - pDetails->fmt = RecycleBinColumns[iColumn].fmt; - pDetails->cxChar = RecycleBinColumns[iColumn].cxChars; - if (pidl == NULL) - { - pDetails->str.uType = STRRET_WSTR; - LoadStringW(shell32_hInstance, RecycleBinColumns[iColumn].column_name_id, buffer, MAX_PATH); - return SHStrDupW(buffer, &pDetails->str.u.pOleStr); - } - - if (iColumn == COLUMN_NAME) - return RecycleBin_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL, &pDetails->str); - - pFileDetails = _ILGetRecycleStruct(pidl); - switch (iColumn) - { - case COLUMN_DATEDEL: - FormatDateTime(buffer, MAX_PATH, &pFileDetails->DeletionTime); - break; - case COLUMN_DELFROM: - pszBackslash = wcsrchr(pFileDetails->szName, L'\\'); - Length = (pszBackslash - pFileDetails->szName); - memcpy((LPVOID)buffer, pFileDetails->szName, Length * sizeof(WCHAR)); - buffer[Length] = L'\0'; - break; - case COLUMN_SIZE: - StrFormatKBSizeW(pFileDetails->FileSize.QuadPart, buffer, MAX_PATH); - break; - case COLUMN_MTIME: - FormatDateTime(buffer, MAX_PATH, &pFileDetails->LastModification); - break; - case COLUMN_TYPE: - szTypeName[0] = L'\0'; - wcscpy(buffer,PathFindExtensionW(pFileDetails->szName)); - if (!( HCR_MapTypeToValueW(buffer, buffer, sizeof(buffer)/sizeof(WCHAR), TRUE) && - HCR_MapTypeToValueW(buffer, szTypeName, sizeof(szTypeName)/sizeof(WCHAR), FALSE ))) - { - wcscpy (szTypeName, PathFindExtensionW(pFileDetails->szName)); - wcscat(szTypeName, L"-"); - Length = wcslen(szTypeName); - if (LoadStringW(shell32_hInstance, IDS_SHV_COLUMN1, &szTypeName[Length], (sizeof(szTypeName)/sizeof(WCHAR))- Length)) - szTypeName[(sizeof(szTypeName)/sizeof(WCHAR))-1] = L'\0'; - } - pDetails->str.uType = STRRET_WSTR; - return SHStrDupW(szTypeName, &pDetails->str.u.pOleStr); - break; - default: - return E_FAIL; - } - - pDetails->str.uType = STRRET_WSTR; - return SHStrDupW(buffer, &pDetails->str.u.pOleStr); -} - -static HRESULT WINAPI RecycleBin_MapColumnToSCID(IShellFolder2 *iface, UINT iColumn, SHCOLUMNID *pscid) -{ - RecycleBin *This = (RecycleBin *)iface; - TRACE("(%p, %d, %p)\n", This, iColumn, pscid); - if (iColumn>=COLUMNS_COUNT) - return E_INVALIDARG; - pscid->fmtid = *RecycleBinColumns[iColumn].fmtId; - pscid->pid = RecycleBinColumns[iColumn].pid; - return S_OK; -} - -static const IShellFolder2Vtbl recycleBinVtbl = -{ - /* IUnknown */ - RecycleBin_QueryInterface, - RecycleBin_AddRef, - RecycleBin_Release, - - /* IShellFolder */ - RecycleBin_ParseDisplayName, - RecycleBin_EnumObjects, - RecycleBin_BindToObject, - RecycleBin_BindToStorage, - RecycleBin_CompareIDs, - RecycleBin_CreateViewObject, - RecycleBin_GetAttributesOf, - RecycleBin_GetUIObjectOf, - RecycleBin_GetDisplayNameOf, - RecycleBin_SetNameOf, - - /* IShellFolder2 */ - RecycleBin_GetDefaultSearchGUID, - RecycleBin_EnumSearches, - RecycleBin_GetDefaultColumn, - RecycleBin_GetDefaultColumnState, - RecycleBin_GetDetailsEx, - RecycleBin_GetDetailsOf, - RecycleBin_MapColumnToSCID -}; - -static HRESULT WINAPI RecycleBin_IPersistFolder2_GetClassID(IPersistFolder2 *This, CLSID *pClassID) -{ - TRACE("(%p, %p)\n", This, pClassID); - if (This == NULL || pClassID == NULL) - return E_INVALIDARG; - memcpy(pClassID, &CLSID_RecycleBin, sizeof(CLSID)); - return S_OK; -} - -static HRESULT WINAPI RecycleBin_IPersistFolder2_Initialize(IPersistFolder2 *iface, LPCITEMIDLIST pidl) -{ - RecycleBin *This = impl_from_IPersistFolder(iface); - TRACE("(%p, %p)\n", This, pidl); - - SHFree((LPVOID)This->pidl); - This->pidl = ILClone(pidl); - if (This->pidl == NULL) - return E_OUTOFMEMORY; - return S_OK; -} - -static HRESULT WINAPI RecycleBin_IPersistFolder2_GetCurFolder(IPersistFolder2 *iface, LPITEMIDLIST *ppidl) -{ - RecycleBin *This = impl_from_IPersistFolder(iface); - TRACE("\n"); - *ppidl = ILClone(This->pidl); - return S_OK; -} - -static HRESULT WINAPI RecycleBin_IPersistFolder2_QueryInterface(IPersistFolder2 *This, REFIID riid, void **ppvObject) -{ - return RecycleBin_QueryInterface((IShellFolder2 *)impl_from_IPersistFolder(This), riid, ppvObject); -} - -static ULONG WINAPI RecycleBin_IPersistFolder2_AddRef(IPersistFolder2 *This) -{ - return RecycleBin_AddRef((IShellFolder2 *)impl_from_IPersistFolder(This)); -} - -static ULONG WINAPI RecycleBin_IPersistFolder2_Release(IPersistFolder2 *This) -{ - return RecycleBin_Release((IShellFolder2 *)impl_from_IPersistFolder(This)); -} - -static const IPersistFolder2Vtbl recycleBinPersistVtbl = -{ - /* IUnknown */ - RecycleBin_IPersistFolder2_QueryInterface, - RecycleBin_IPersistFolder2_AddRef, - RecycleBin_IPersistFolder2_Release, - - /* IPersist */ - RecycleBin_IPersistFolder2_GetClassID, - /* IPersistFolder */ - RecycleBin_IPersistFolder2_Initialize, - /* IPersistFolder2 */ - RecycleBin_IPersistFolder2_GetCurFolder -}; - -/************************************************************************* - * BitBucket IShellExtInit interface - */ - -static HRESULT WINAPI -RecycleBin_ExtInit_QueryInterface( IShellExtInit* iface, REFIID riid, void** ppvObject ) -{ - return RecycleBin_QueryInterface((IShellFolder2 *)impl_from_IShellExtInit(iface), riid, ppvObject); -} - -static ULONG WINAPI -RecycleBin_ExtInit_AddRef( IShellExtInit* iface ) -{ - return RecycleBin_AddRef((IShellFolder2 *)impl_from_IShellExtInit(iface)); -} - -static ULONG WINAPI -RecycleBin_ExtInit_Release( IShellExtInit* iface ) -{ - return RecycleBin_Release((IShellFolder2 *)impl_from_IShellExtInit(iface)); -} - -static HRESULT WINAPI -RecycleBin_ExtInit_Initialize( IShellExtInit* iface, LPCITEMIDLIST pidlFolder, - IDataObject *pdtobj, HKEY hkeyProgID ) -{ - RecycleBin *This = impl_from_IShellExtInit(iface); - - TRACE("%p %p %p %p\n", This, pidlFolder, pdtobj, hkeyProgID ); - return S_OK; -} - - -static const IShellExtInitVtbl eivt = -{ - RecycleBin_ExtInit_QueryInterface, - RecycleBin_ExtInit_AddRef, - RecycleBin_ExtInit_Release, - RecycleBin_ExtInit_Initialize -}; - - -/************************************************************************* - * BitBucket context menu - * - */ - -static HRESULT WINAPI -RecycleBin_IContextMenu2Folder_QueryInterface( IContextMenu2* iface, REFIID riid, void** ppvObject ) -{ - return RecycleBin_QueryInterface((IShellFolder2 *)impl_from_IContextMenu2(iface), riid, ppvObject); -} - -static ULONG WINAPI -RecycleBin_IContextMenu2Folder_AddRef( IContextMenu2* iface ) -{ - return RecycleBin_AddRef((IShellFolder2 *)impl_from_IContextMenu2(iface)); -} - -static ULONG WINAPI -RecycleBin_IContextMenu2Folder_Release( IContextMenu2* iface ) -{ - return RecycleBin_Release((IShellFolder2 *)impl_from_IContextMenu2(iface)); -} - -static HRESULT WINAPI -RecycleBin_IContextMenu2Folder_QueryContextMenu( IContextMenu2* iface, HMENU hmenu, UINT indexMenu, - UINT idCmdFirst, UINT idCmdLast, UINT uFlags ) -{ - WCHAR szBuffer[100]; - MENUITEMINFOW mii; - int id = 1; - RecycleBin * This = impl_from_IContextMenu2(iface); - - TRACE("%p %p %u %u %u %u\n", This, - hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags ); - - if ( !hmenu ) - return E_INVALIDARG; - - memset( &mii, 0, sizeof(mii) ); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE; - mii.fState = MFS_ENABLED; - szBuffer[0] = L'\0'; - LoadStringW(shell32_hInstance, IDS_EMPTY_BITBUCKET, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)); - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - mii.dwTypeData = szBuffer; - mii.cch = wcslen( mii.dwTypeData ); - mii.wID = idCmdFirst + id++; - mii.fType = MFT_STRING; - This->iIdEmpty = 1; - - if (!InsertMenuItemW( hmenu, indexMenu, TRUE, &mii )) - return E_FAIL; - - return MAKE_HRESULT( SEVERITY_SUCCESS, 0, id ); -} - -static HRESULT WINAPI -RecycleBin_IContextMenu2Folder_InvokeCommand( IContextMenu2* iface, LPCMINVOKECOMMANDINFO lpici ) -{ - HRESULT hr; - LPSHELLBROWSER lpSB; - LPSHELLVIEW lpSV = NULL; - RecycleBin * This = impl_from_IContextMenu2(iface); - - TRACE("%p %p verb %p\n", This, lpici, lpici->lpVerb); - - if ( LOWORD(lpici->lpVerb) == This->iIdEmpty) - { - // FIXME - // path & flags - hr = SHEmptyRecycleBinW(lpici->hwnd, L"C:\\", 0); - TRACE("result %x\n", hr); - if (hr != S_OK) - { - return hr; - } - - if((lpSB = (LPSHELLBROWSER)SendMessageA(lpici->hwnd, CWM_GETISHELLBROWSER,0,0))) - { - if(SUCCEEDED(IShellBrowser_QueryActiveShellView(lpSB, &lpSV))) - { - IShellView_Refresh(lpSV); - } - } - } - return S_OK; -} - -static HRESULT WINAPI -RecycleBin_IContextMenu2Folder_GetCommandString( IContextMenu2* iface, UINT_PTR idCmd, UINT uType, - UINT* pwReserved, LPSTR pszName, UINT cchMax ) -{ - RecycleBin * This = impl_from_IContextMenu2(iface); - - FIXME("%p %lu %u %p %p %u\n", This, - idCmd, uType, pwReserved, pszName, cchMax ); - - return E_NOTIMPL; -} - -/************************************************************************** -* RecycleBin_IContextMenu2Item_HandleMenuMsg() -*/ -static HRESULT WINAPI RecycleBin_IContextMenu2Folder_HandleMenuMsg( - IContextMenu2 *iface, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) -{ - RecycleBin * This = impl_from_IContextMenu2(iface); - - TRACE("RecycleBin_IContextMenu2Item_IContextMenu2Folder_HandleMenuMsg (%p)->(msg=%x wp=%lx lp=%lx)\n",This, uMsg, wParam, lParam); - - return E_NOTIMPL; -} - - -static const IContextMenu2Vtbl recycleBincmVtblFolder = -{ - RecycleBin_IContextMenu2Folder_QueryInterface, - RecycleBin_IContextMenu2Folder_AddRef, - RecycleBin_IContextMenu2Folder_Release, - RecycleBin_IContextMenu2Folder_QueryContextMenu, - RecycleBin_IContextMenu2Folder_InvokeCommand, - RecycleBin_IContextMenu2Folder_GetCommandString, - RecycleBin_IContextMenu2Folder_HandleMenuMsg -}; - - -/************************************************************************** -* IContextMenu2 Bitbucket Item Implementation -*/ - -/************************************************************************ - * RecycleBin_IContextMenu2Item_QueryInterface - */ -static HRESULT WINAPI RecycleBin_IContextMenu2Item_QueryInterface(IContextMenu2 * iface, REFIID iid, LPVOID * ppvObject) -{ - RecycleBin * This = impl_from_IContextMenu2(iface); - - TRACE("(%p)\n", This); - - return RecycleBin_QueryInterface((IShellFolder2*)This, iid, ppvObject); -} - -/************************************************************************ - * RecycleBin_IContextMenu2Item_AddRef - */ -static ULONG WINAPI RecycleBin_IContextMenu2Item_AddRef(IContextMenu2 * iface) -{ - RecycleBin * This = impl_from_IContextMenu2(iface); - - TRACE("(%p)->(count=%u)\n", This, This->refCount); - - return RecycleBin_AddRef((IShellFolder2*)This); -} - -/************************************************************************ - * RecycleBin_IContextMenu2Item_Release - */ -static ULONG WINAPI RecycleBin_IContextMenu2Item_Release(IContextMenu2 * iface) -{ - RecycleBin * This = impl_from_IContextMenu2(iface); - - TRACE("(%p)->(count=%u)\n", This, This->refCount); - - return RecycleBin_Release((IShellFolder2*)This); -} - -/************************************************************************** -* RecycleBin_IContextMenu2Item_QueryContextMenu() -*/ -static HRESULT WINAPI RecycleBin_IContextMenu2Item_QueryContextMenu( - IContextMenu2 *iface, - HMENU hMenu, - UINT indexMenu, - UINT idCmdFirst, - UINT idCmdLast, - UINT uFlags) -{ - WCHAR szBuffer[30] = {0}; - ULONG Count = 1; - - RecycleBin * This = impl_from_IContextMenu2(iface); - - TRACE("(%p)->(hmenu=%p indexmenu=%x cmdfirst=%x cmdlast=%x flags=%x )\n", - This, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags); - - if (LoadStringW(shell32_hInstance, IDS_RESTORE, szBuffer, sizeof(szBuffer)/sizeof(WCHAR))) - { - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count, MFT_STRING, szBuffer, MFS_ENABLED); - Count++; - } - - if (LoadStringW(shell32_hInstance, IDS_CUT, szBuffer, sizeof(szBuffer)/sizeof(WCHAR))) - { - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count++, MFT_SEPARATOR, NULL, MFS_ENABLED); - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count++, MFT_STRING, szBuffer, MFS_ENABLED); - } - - if (LoadStringW(shell32_hInstance, IDS_DELETE, szBuffer, sizeof(szBuffer)/sizeof(WCHAR))) - { - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count++, MFT_SEPARATOR, NULL, MFS_ENABLED); - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count++, MFT_STRING, szBuffer, MFS_ENABLED); - } - - if (LoadStringW(shell32_hInstance, IDS_PROPERTIES, szBuffer, sizeof(szBuffer)/sizeof(WCHAR))) - { - szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0'; - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count++, MFT_SEPARATOR, NULL, MFS_ENABLED); - _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count, MFT_STRING, szBuffer, MFS_DEFAULT); - } - - return MAKE_HRESULT(SEVERITY_SUCCESS, 0, Count); -} - - -/************************************************************************** -* RecycleBin_IContextMenu2Item_InvokeCommand() -*/ -static HRESULT WINAPI RecycleBin_IContextMenu2Item_InvokeCommand( - IContextMenu2 *iface, - LPCMINVOKECOMMANDINFO lpcmi) -{ - - SEARCH_CONTEXT Context; - RecycleBin * This = impl_from_IContextMenu2(iface); - static LPCWSTR szDrive = L"C:\\"; - - TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n",This,lpcmi,lpcmi->lpVerb, lpcmi->hwnd); - - if (lpcmi->lpVerb == MAKEINTRESOURCEA(1) || lpcmi->lpVerb == MAKEINTRESOURCEA(5)) - { - Context.pFileDetails = _ILGetRecycleStruct(This->apidl); - Context.bFound = FALSE; - - EnumerateRecycleBinW(szDrive, CBSearchBitBucket, (PVOID)&Context); - if (!Context.bFound) - return E_FAIL; - - if (lpcmi->lpVerb == MAKEINTRESOURCEA(1)) - { - /* restore file */ - if (RestoreFile(Context.hDeletedFile)) - return S_OK; - else - return E_FAIL; - } - else - { - DeleteFileHandleToRecycleBin(Context.hDeletedFile); - return E_NOTIMPL; - } - } - else if (lpcmi->lpVerb == MAKEINTRESOURCEA(3)) - { - FIXME("implement cut\n"); - return E_NOTIMPL; - } - else if (lpcmi->lpVerb == MAKEINTRESOURCEA(7)) - { - FIXME("implement properties\n"); - return E_NOTIMPL; - } - - return S_OK; -} - -/************************************************************************** - * RecycleBin_IContextMenu2Item_GetCommandString() - * - */ -static HRESULT WINAPI RecycleBin_IContextMenu2Item_GetCommandString( - IContextMenu2 *iface, - UINT_PTR idCommand, - UINT uFlags, - UINT* lpReserved, - LPSTR lpszName, - UINT uMaxNameLen) -{ - RecycleBin * This = impl_from_IContextMenu2(iface); - - TRACE("(%p)->(idcom=%lx flags=%x %p name=%p len=%x)\n",This, idCommand, uFlags, lpReserved, lpszName, uMaxNameLen); - - - return E_FAIL; -} - - - -/************************************************************************** -* RecycleBin_IContextMenu2Item_HandleMenuMsg() -*/ -static HRESULT WINAPI RecycleBin_IContextMenu2Item_HandleMenuMsg( - IContextMenu2 *iface, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) -{ - RecycleBin * This = impl_from_IContextMenu2(iface); - - TRACE("RecycleBin_IContextMenu2Item_HandleMenuMsg (%p)->(msg=%x wp=%lx lp=%lx)\n",This, uMsg, wParam, lParam); - - return E_NOTIMPL; -} - -static const IContextMenu2Vtbl recycleBincmVtblBitbucketItem = -{ - RecycleBin_IContextMenu2Item_QueryInterface, - RecycleBin_IContextMenu2Item_AddRef, - RecycleBin_IContextMenu2Item_Release, - RecycleBin_IContextMenu2Item_QueryContextMenu, - RecycleBin_IContextMenu2Item_InvokeCommand, - RecycleBin_IContextMenu2Item_GetCommandString, - RecycleBin_IContextMenu2Item_HandleMenuMsg -}; - - -void toggleNukeOnDeleteOption(HWND hwndDlg, BOOL bEnable) -{ - if (bEnable) - { - SendDlgItemMessage(hwndDlg, 14001, BM_SETCHECK, BST_UNCHECKED, 0); - EnableWindow(GetDlgItem(hwndDlg, 14002), FALSE); - SendDlgItemMessage(hwndDlg, 14003, BM_SETCHECK, BST_CHECKED, 0); - } - else - { - SendDlgItemMessage(hwndDlg, 14001, BM_SETCHECK, BST_CHECKED, 0); - EnableWindow(GetDlgItem(hwndDlg, 14002), TRUE); - SendDlgItemMessage(hwndDlg, 14003, BM_SETCHECK, BST_UNCHECKED, 0); - } -} - - -void -InitializeBitBucketDlg(HWND hwndDlg, WCHAR DefaultDrive) -{ - WCHAR CurDrive = L'A'; - WCHAR szDrive[] = L"A:\\"; - DWORD dwDrives; - WCHAR szName[100]; - WCHAR szVolume[100]; - DWORD MaxComponent, Flags; - DWORD dwSerial; - LVCOLUMNW lc; - HWND hDlgCtrl; - LVITEMW li; - INT itemCount; - ULARGE_INTEGER TotalNumberOfFreeBytes, TotalNumberOfBytes, FreeBytesAvailable; - RECT rect; - int columnSize; - int defIndex = 0; - DWORD dwSize; - PDRIVE_ITEM_CONTEXT pItem = NULL, pDefault = NULL, pFirst = NULL; - - hDlgCtrl = GetDlgItem(hwndDlg, 14000); - - if (!LoadStringW(shell32_hInstance, IDS_RECYCLEBIN_LOCATION, szVolume, sizeof(szVolume) / sizeof(WCHAR))) - szVolume[0] = 0; - - GetClientRect(hDlgCtrl, &rect); - - memset(&lc, 0, sizeof(LV_COLUMN) ); - lc.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT; - - columnSize = 140; //FIXME - lc.iSubItem = 0; - lc.fmt = LVCFMT_FIXED_WIDTH; - lc.cx = columnSize; - lc.cchTextMax = wcslen(szVolume); - lc.pszText = szVolume; - (void)SendMessageW(hDlgCtrl, LVM_INSERTCOLUMNW, 0, (LPARAM)&lc); - - if (!LoadStringW(shell32_hInstance, IDS_RECYCLEBIN_DISKSPACE, szVolume, sizeof(szVolume) / sizeof(WCHAR))) - szVolume[0] = 0; - - lc.iSubItem = 1; - lc.cx = rect.right - rect.left - columnSize; - lc.cchTextMax = wcslen(szVolume); - lc.pszText = szVolume; - (void)SendMessageW(hDlgCtrl, LVM_INSERTCOLUMNW, 1, (LPARAM)&lc); - - dwDrives = GetLogicalDrives(); - itemCount = 0; - do - { - if ((dwDrives & 0x1)) - { - UINT Type = GetDriveTypeW(szDrive); - if (Type == DRIVE_FIXED) //FIXME - { - if (!GetVolumeInformationW(szDrive, szName, sizeof(szName) / sizeof(WCHAR), &dwSerial, &MaxComponent, &Flags, NULL, 0)) - { - szName[0] = 0; - dwSerial = -1; - } - - swprintf(szVolume, L"%s (%c)", szName, szDrive[0]); - memset(&li, 0x0, sizeof(LVITEMW)); - li.mask = LVIF_TEXT | LVIF_PARAM; - li.iSubItem = 0; - li.pszText = szVolume; - li.iItem = itemCount; - (void)SendMessageW(hDlgCtrl, LVM_INSERTITEMW, 0, (LPARAM)&li); - if (GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailable , &TotalNumberOfBytes, &TotalNumberOfFreeBytes)) - { - if (StrFormatByteSizeW(TotalNumberOfFreeBytes.QuadPart, szVolume, sizeof(szVolume) / sizeof(WCHAR))) - { - - pItem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DRIVE_ITEM_CONTEXT)); - if (pItem) - { - swprintf(szName, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Bitbucket\\Volume\\%04X-%04X", LOWORD(dwSerial), HIWORD(dwSerial)); - dwSize = sizeof(DWORD); - RegGetValueW(HKEY_CURRENT_USER, szName, L"MaxCapacity", RRF_RT_DWORD, NULL, &pItem->dwMaxCapacity, &dwSize); - dwSize = sizeof(DWORD); - RegGetValueW(HKEY_CURRENT_USER, szName, L"NukeOnDelete", RRF_RT_DWORD, NULL, &pItem->dwNukeOnDelete, &dwSize); - pItem->dwSerial = dwSerial; - li.mask = LVIF_PARAM; - li.lParam = (LPARAM)pItem; - (void)SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li); - if (CurDrive == DefaultDrive) - { - defIndex = itemCount; - pDefault = pItem; - } - } - if (!pFirst) - pFirst = pItem; - - li.mask = LVIF_TEXT; - li.iSubItem = 1; - li.pszText = szVolume; - li.iItem = itemCount; - (void)SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li); - } - } - itemCount++; - } - } - CurDrive++; - szDrive[0] = CurDrive; - dwDrives = (dwDrives >> 1); - }while(dwDrives); - - if (!pDefault) - pDefault = pFirst; - if (pDefault) - { - toggleNukeOnDeleteOption(hwndDlg, pDefault->dwNukeOnDelete); - SetDlgItemInt(hwndDlg, 14002, pDefault->dwMaxCapacity, FALSE); - } - ZeroMemory(&li, sizeof(li)); - li.mask = LVIF_STATE; - li.stateMask = (UINT)-1; - li.state = LVIS_FOCUSED|LVIS_SELECTED; - li.iItem = defIndex; - (void)SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li); - -} - -static BOOL StoreDriveSettings(HWND hwndDlg) -{ - int iCount, iIndex; - HWND hDlgCtrl = GetDlgItem(hwndDlg, 14000); - LVITEMW li; - PDRIVE_ITEM_CONTEXT pItem; - HKEY hKey, hSubKey; - WCHAR szSerial[20]; - DWORD dwSize; - - - if (RegCreateKeyExW(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Bitbucket\\Volume", 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS) - return FALSE; - - iCount = ListView_GetItemCount(hDlgCtrl); - - ZeroMemory(&li, sizeof(li)); - li.mask = LVIF_PARAM; - - for(iIndex = 0; iIndex < iCount; iIndex++) - { - li.iItem = iIndex; - if (SendMessageW(hDlgCtrl, LVM_GETITEMW, 0, (LPARAM)&li)) - { - pItem = (PDRIVE_ITEM_CONTEXT)li.lParam; - swprintf(szSerial, L"%04X-%04X", LOWORD(pItem->dwSerial), HIWORD(pItem->dwSerial)); - if (RegCreateKeyExW(hKey, szSerial, 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) - { - dwSize = sizeof(DWORD); - RegSetValueExW(hSubKey, L"NukeOnDelete", 0, REG_DWORD, (LPVOID)&pItem->dwNukeOnDelete, dwSize); - dwSize = sizeof(DWORD); - RegSetValueExW(hSubKey, L"MaxCapacity", 0, REG_DWORD, (LPVOID)&pItem->dwMaxCapacity, dwSize); - RegCloseKey(hSubKey); - } - } - } - RegCloseKey(hKey); - return TRUE; - -} - -static VOID FreeDriveItemContext(HWND hwndDlg) -{ - int iCount, iIndex; - HWND hDlgCtrl = GetDlgItem(hwndDlg, 14000); - LVITEMW li; - - iCount = ListView_GetItemCount(hDlgCtrl); - - ZeroMemory(&li, sizeof(li)); - li.mask = LVIF_PARAM; - - for(iIndex = 0; iIndex < iCount; iIndex++) - { - li.iItem = iIndex; - if (SendMessageW(hDlgCtrl, LVM_GETITEMW, 0, (LPARAM)&li)) - { - HeapFree(GetProcessHeap(), 0, (LPVOID)li.lParam); - } - } -} - -INT -GetDefaultItem(HWND hwndDlg, LVITEMW * li) -{ - HWND hDlgCtrl; - UINT iItemCount, iIndex; - - hDlgCtrl = GetDlgItem(hwndDlg, 14000); - if (!hDlgCtrl) - return -1; - - iItemCount = ListView_GetItemCount(hDlgCtrl); - if (!iItemCount) - return -1; - - ZeroMemory(li, sizeof(LVITEMW)); - li->mask = LVIF_PARAM | LVIF_STATE; - li->stateMask = (UINT)-1; - for (iIndex = 0; iIndex < iItemCount; iIndex++) - { - li->iItem = iIndex; - if (SendMessageW(hDlgCtrl, LVM_GETITEMW, 0, (LPARAM)li)) - { - if (li->state & LVIS_SELECTED) - return iIndex; - } - } - return -1; - -} - -INT_PTR -CALLBACK -BitBucketDlg( - HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam -) -{ - LPPSHNOTIFY lppsn; - LPNMLISTVIEW lppl; - LVITEMW li; - PDRIVE_ITEM_CONTEXT pItem; - BOOL bSuccess; - UINT uResult; - PROPSHEETPAGE * page; - DWORD dwStyle; - - switch(uMsg) - { - case WM_INITDIALOG: - page = (PROPSHEETPAGE*)lParam; - InitializeBitBucketDlg(hwndDlg, (WCHAR)page->lParam); - dwStyle = (DWORD) SendDlgItemMessage(hwndDlg, 14000, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0); - dwStyle = dwStyle | LVS_EX_FULLROWSELECT; - SendDlgItemMessage(hwndDlg, 14000, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dwStyle); - if (GetDlgCtrlID((HWND)wParam) != 14000) - { - SetFocus(GetDlgItem(hwndDlg, 14000)); - return FALSE; - } - return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case 14001: - toggleNukeOnDeleteOption(hwndDlg, FALSE); - PropSheet_Changed(GetParent(hwndDlg), hwndDlg); - break; - case 14003: - toggleNukeOnDeleteOption(hwndDlg, TRUE); - PropSheet_Changed(GetParent(hwndDlg), hwndDlg); - break; - case 14004: - PropSheet_Changed(GetParent(hwndDlg), hwndDlg); - break; - } - break; - case WM_NOTIFY: - lppsn = (LPPSHNOTIFY) lParam; - lppl = (LPNMLISTVIEW) lParam; - if (lppsn->hdr.code == PSN_APPLY) - { - if (GetDefaultItem(hwndDlg, &li) > -1) - { - pItem = (PDRIVE_ITEM_CONTEXT)li.lParam; - if (pItem) - { - uResult = GetDlgItemInt(hwndDlg, 14002, &bSuccess, FALSE); - if (bSuccess) - pItem->dwMaxCapacity = uResult; - if (SendDlgItemMessageW(hwndDlg, 14003, BM_GETCHECK, 0, 0) == BST_CHECKED) - pItem->dwNukeOnDelete = TRUE; - else - pItem->dwNukeOnDelete = FALSE; - } - } - if (StoreDriveSettings(hwndDlg)) - { - SetWindowLongPtr( hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR ); - return TRUE; - } - } - else if (lppl->hdr.code == LVN_ITEMCHANGING) - { - ZeroMemory(&li, sizeof(li)); - li.mask = LVIF_PARAM; - li.iItem = lppl->iItem; - if (!SendMessageW(lppl->hdr.hwndFrom, LVM_GETITEMW, 0, (LPARAM)&li)) - return TRUE; - - pItem = (PDRIVE_ITEM_CONTEXT)li.lParam; - if (!pItem) - return TRUE; - - if (!(lppl->uOldState & LVIS_FOCUSED) && (lppl->uNewState & LVIS_FOCUSED)) - { - /* new focused item */ - toggleNukeOnDeleteOption(lppl->hdr.hwndFrom, pItem->dwNukeOnDelete); - SetDlgItemInt(hwndDlg, 14002, pItem->dwMaxCapacity, FALSE); - } - else if ((lppl->uOldState & LVIS_FOCUSED) && !(lppl->uNewState & LVIS_FOCUSED)) - { - /* kill focus */ - uResult = GetDlgItemInt(hwndDlg, 14002, &bSuccess, FALSE); - if (bSuccess) - pItem->dwMaxCapacity = uResult; - if (SendDlgItemMessageW(hwndDlg, 14003, BM_GETCHECK, 0, 0) == BST_CHECKED) - pItem->dwNukeOnDelete = TRUE; - else - pItem->dwNukeOnDelete = FALSE; - } - return TRUE; - - } - break; - case WM_DESTROY: - FreeDriveItemContext(hwndDlg); - break; - } - return FALSE; -} - -BOOL SH_ShowRecycleBinProperties(WCHAR sDrive) -{ - HPROPSHEETPAGE hpsp[1]; - PROPSHEETHEADERW psh; - HPROPSHEETPAGE hprop; - - BOOL ret; - - - ZeroMemory(&psh, sizeof(PROPSHEETHEADERW)); - psh.dwSize = sizeof(PROPSHEETHEADERW); - psh.dwFlags = PSP_DEFAULT | PSH_PROPTITLE; - psh.pszCaption = MAKEINTRESOURCEW(IDS_RECYCLEBIN_FOLDER_NAME); - psh.hwndParent = NULL; - psh.u3.phpage = hpsp; - psh.hInstance = shell32_hInstance; - - hprop = SH_CreatePropertySheetPage("BITBUCKET_PROPERTIES_DLG", BitBucketDlg, (LPARAM)sDrive, NULL); - if (!hprop) - { - ERR("Failed to create property sheet\n"); - return FALSE; - } - hpsp[psh.nPages] = hprop; - psh.nPages++; - - - ret = PropertySheetW(&psh); - if (ret < 0) - return FALSE; - else - return TRUE; -} - -BOOL -TRASH_CanTrashFile(LPCWSTR wszPath) -{ - LONG ret; - DWORD dwNukeOnDelete, dwType, VolSerialNumber, MaxComponentLength; - DWORD FileSystemFlags, dwSize, dwDisposition; - HKEY hKey; - WCHAR szBuffer[10]; - WCHAR szKey[150] = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Bitbucket\\Volume\\"; - - if (wszPath[1] != L':') - { - /* path is UNC */ - return FALSE; - } - - if (GetDriveTypeW(wszPath) != DRIVE_FIXED) - { - /* no bitbucket on removable media */ - return FALSE; - } - - if (!GetVolumeInformationW(wszPath, NULL, 0, &VolSerialNumber, &MaxComponentLength, &FileSystemFlags, NULL, 0)) - { - ERR("GetVolumeInformationW failed with %u\n", GetLastError()); - return FALSE; - } - - swprintf(szBuffer, L"%04X-%04X", LOWORD(VolSerialNumber), HIWORD(VolSerialNumber)); - wcscat(szKey, szBuffer); - - if (RegCreateKeyExW(HKEY_CURRENT_USER, szKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, &dwDisposition) != ERROR_SUCCESS) - { - ERR("RegCreateKeyExW failed\n"); - return FALSE; - } - - if (dwDisposition & REG_CREATED_NEW_KEY) - { - /* per default move to bitbucket */ - dwNukeOnDelete = 0; - RegSetValueExW(hKey, L"NukeOnDelete", 0, REG_DWORD, (LPBYTE)&dwNukeOnDelete, sizeof(DWORD)); - /* per default unlimited size */ - dwSize = -1; - RegSetValueExW(hKey, L"MaxCapacity", 0, REG_DWORD, (LPBYTE)&dwSize, sizeof(DWORD)); - RegCloseKey(hKey); - return TRUE; - } - else - { - dwSize = sizeof(dwNukeOnDelete); - ret = RegQueryValueExW(hKey, L"NukeOnDelete", NULL, &dwType, (LPBYTE)&dwNukeOnDelete, &dwSize); - if (ret != ERROR_SUCCESS) - { - if (ret == ERROR_FILE_NOT_FOUND) - { - /* restore key and enable bitbucket */ - dwNukeOnDelete = 0; - RegSetValueExW(hKey, L"NukeOnDelete", 0, REG_DWORD, (LPBYTE)&dwNukeOnDelete, sizeof(DWORD)); - } - RegCloseKey(hKey); - return TRUE; - } - else if (dwNukeOnDelete) - { - /* do not delete to bitbucket */ - RegCloseKey(hKey); - return FALSE; - } - /* FIXME - * check if bitbucket is full - */ - RegCloseKey(hKey); - return TRUE; - } -} - -BOOL -TRASH_TrashFile(LPCWSTR wszPath) -{ - TRACE("(%s)\n", debugstr_w(wszPath)); - return DeleteFileToRecycleBinW(wszPath); -} - -/************************************************************************* - * SHUpdateRecycleBinIcon [SHELL32.@] - * - * Undocumented - */ -HRESULT WINAPI SHUpdateRecycleBinIcon(void) -{ - FIXME("stub\n"); - - - - return S_OK; -} diff --git a/reactos/dll/win32/shell32/shfldr_unixfs.c b/reactos/dll/win32/shell32/shfldr_unixfs.c deleted file mode 100644 index 95e4defc81e..00000000000 --- a/reactos/dll/win32/shell32/shfldr_unixfs.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * UNIXFS - Shell namespace extension for the unix filesystem - * - * Copyright (C) 2005 Michael Jung - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Placeholder in ReactOS, we don't need this */ diff --git a/reactos/dll/win32/shell32/shlexec.c b/reactos/dll/win32/shell32/shlexec.c deleted file mode 100644 index e1f183fc96e..00000000000 --- a/reactos/dll/win32/shell32/shlexec.c +++ /dev/null @@ -1,2018 +0,0 @@ -/* - * Shell Library Functions - * - * Copyright 1998 Marcus Meissner - * Copyright 2002 Eric Pouech - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(exec); - -static const WCHAR wszOpen[] = {'o','p','e','n',0}; -static const WCHAR wszExe[] = {'.','e','x','e',0}; -static const WCHAR wszILPtr[] = {':','%','p',0}; -static const WCHAR wszShell[] = {'\\','s','h','e','l','l','\\',0}; -static const WCHAR wszFolder[] = {'F','o','l','d','e','r',0}; -static const WCHAR wszEmpty[] = {0}; - -#define SEE_MASK_CLASSALL (SEE_MASK_CLASSNAME | SEE_MASK_CLASSKEY) - - -/*********************************************************************** - * SHELL_ArgifyW [Internal] - * - * this function is supposed to expand the escape sequences found in the registry - * some diving reported that the following were used: - * + %1, %2... seem to report to parameter of index N in ShellExecute pmts - * %1 file - * %2 printer - * %3 driver - * %4 port - * %I address of a global item ID (explorer switch /idlist) - * %L seems to be %1 as long filename followed by the 8+3 variation - * %S ??? - * %* all following parameters (see batfile) - * - */ -static BOOL SHELL_ArgifyW(WCHAR* out, int len, const WCHAR* fmt, const WCHAR* lpFile, LPITEMIDLIST pidl, LPCWSTR args, DWORD* out_len) -{ - WCHAR xlpFile[1024]; - BOOL done = FALSE; - BOOL found_p1 = FALSE; - PWSTR res = out; - PCWSTR cmd; - DWORD used = 0; - - TRACE("%p, %d, %s, %s, %p, %p\n", out, len, debugstr_w(fmt), - debugstr_w(lpFile), pidl, args); - - while (*fmt) - { - if (*fmt == '%') - { - switch (*++fmt) - { - case '\0': - case '%': - used++; - if (used < len) - *res++ = '%'; - break; - - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '0': - case '*': - if (args) - { - if (*fmt == '*') - { - used++; - if (used < len) - *res++ = '"'; - while(*args) - { - used++; - if (used < len) - *res++ = *args++; - else - args++; - } - used++; - if (used < len) - *res++ = '"'; - break; - } - else - { - while(*args && !isspace(*args)) - { - used++; - if (used < len) - *res++ = *args++; - else - args++; - } - - while(isspace(*args)) - ++args; - } - break; - } - else - { - break; - } - case '1': - if (!done || (*fmt == '1')) - { - /*FIXME Is the call to SearchPathW() really needed? We already have separated out the parameter string in args. */ - if (SearchPathW(NULL, lpFile, wszExe, sizeof(xlpFile)/sizeof(WCHAR), xlpFile, NULL)) - cmd = xlpFile; - else - cmd = lpFile; - - used += wcslen(cmd); - if (used < len) - { - wcscpy(res, cmd); - res += wcslen(cmd); - } - } - found_p1 = TRUE; - break; - - /* - * IE uses this a lot for activating things such as windows media - * player. This is not verified to be fully correct but it appears - * to work just fine. - */ - case 'l': - case 'L': - if (lpFile) { - used += wcslen(lpFile); - if (used < len) - { - wcscpy(res, lpFile); - res += wcslen(lpFile); - } - } - found_p1 = TRUE; - break; - - case 'i': - case 'I': - if (pidl) { - INT chars = 0; - /* %p should not exceed 8, maybe 16 when looking forward to 64bit. - * allowing a buffer of 100 should more than exceed all needs */ - WCHAR buf[100]; - LPVOID pv; - HGLOBAL hmem = SHAllocShared(pidl, ILGetSize(pidl), 0); - pv = SHLockShared(hmem, 0); - chars = swprintf(buf, wszILPtr, pv); - if (chars >= sizeof(buf)/sizeof(WCHAR)) - ERR("pidl format buffer too small!\n"); - used += chars; - if (used < len) - { - wcscpy(res,buf); - res += chars; - } - SHUnlockShared(pv); - } - found_p1 = TRUE; - break; - - default: - /* - * Check if this is an env-variable here... - */ - - /* Make sure that we have at least one more %.*/ - if (strchrW(fmt, '%')) - { - WCHAR tmpBuffer[1024]; - PWSTR tmpB = tmpBuffer; - WCHAR tmpEnvBuff[MAX_PATH]; - DWORD envRet; - - while (*fmt != '%') - *tmpB++ = *fmt++; - *tmpB++ = 0; - - TRACE("Checking %s to be an env-var\n", debugstr_w(tmpBuffer)); - - envRet = GetEnvironmentVariableW(tmpBuffer, tmpEnvBuff, MAX_PATH); - if (envRet == 0 || envRet > MAX_PATH) - { - used += wcslen(tmpBuffer); - if (used < len) - { - wcscpy( res, tmpBuffer ); - res += wcslen(tmpBuffer); - } - } - else - { - used += wcslen(tmpEnvBuff); - if (used < len) - { - wcscpy( res, tmpEnvBuff ); - res += wcslen(tmpEnvBuff); - } - } - } - done = TRUE; - break; - } - /* Don't skip past terminator (catch a single '%' at the end) */ - if (*fmt != '\0') - { - fmt++; - } - } - else - { - used ++; - if (used < len) - *res++ = *fmt++; - else - fmt++; - } - } - - *res = '\0'; - TRACE("used %i of %i space\n",used,len); - if (out_len) - *out_len = used; - - return found_p1; -} - -static HRESULT SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSize) -{ - STRRET strret; - IShellFolder* desktop; - - HRESULT hr = SHGetDesktopFolder(&desktop); - - if (SUCCEEDED(hr)) { - hr = IShellFolder_GetDisplayNameOf(desktop, pidl, SHGDN_FORPARSING, &strret); - - if (SUCCEEDED(hr)) - StrRetToStrNW(pszPath, uOutSize, &strret, pidl); - - IShellFolder_Release(desktop); - } - - return hr; -} - -/************************************************************************* - * SHELL_ExecuteW [Internal] - * - */ -static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait, - const SHELLEXECUTEINFOW *psei, LPSHELLEXECUTEINFOW psei_out) -{ - STARTUPINFOW startup; - PROCESS_INFORMATION info; - UINT_PTR retval = SE_ERR_NOASSOC; - UINT gcdret = 0; - WCHAR curdir[MAX_PATH]; - DWORD dwCreationFlags; - const WCHAR *lpDirectory = NULL; - - TRACE("Execute %s from directory %s\n", debugstr_w(lpCmd), debugstr_w(psei->lpDirectory)); - - /* make sure we don't fail the CreateProcess if the calling app passes in - * a bad working directory */ - if (psei->lpDirectory && psei->lpDirectory[0]) - { - DWORD attr = GetFileAttributesW(psei->lpDirectory); - if (attr != INVALID_FILE_ATTRIBUTES && attr & FILE_ATTRIBUTE_DIRECTORY) - lpDirectory = psei->lpDirectory; - } - - /* ShellExecute specifies the command from psei->lpDirectory - * if present. Not from the current dir as CreateProcess does */ - if( lpDirectory ) - if( ( gcdret = GetCurrentDirectoryW( MAX_PATH, curdir))) - if( !SetCurrentDirectoryW( lpDirectory)) - ERR("cannot set directory %s\n", debugstr_w(lpDirectory)); - ZeroMemory(&startup,sizeof(STARTUPINFOW)); - startup.cb = sizeof(STARTUPINFOW); - startup.dwFlags = STARTF_USESHOWWINDOW; - startup.wShowWindow = psei->nShow; - dwCreationFlags = CREATE_UNICODE_ENVIRONMENT; - if (psei->fMask & SEE_MASK_NO_CONSOLE) - dwCreationFlags |= CREATE_NEW_CONSOLE; - if (CreateProcessW(NULL, (LPWSTR)lpCmd, NULL, NULL, FALSE, dwCreationFlags, env, - lpDirectory, &startup, &info)) - { - /* Give 30 seconds to the app to come up, if desired. Probably only needed - when starting app immediately before making a DDE connection. */ - if (shWait) - if (WaitForInputIdle( info.hProcess, 30000 ) == WAIT_FAILED) - WARN("WaitForInputIdle failed: Error %d\n", GetLastError() ); - retval = 33; - if (psei->fMask & SEE_MASK_NOCLOSEPROCESS) - psei_out->hProcess = info.hProcess; - else - CloseHandle( info.hProcess ); - CloseHandle( info.hThread ); - } - else if ((retval = GetLastError()) >= 32) - { - TRACE("CreateProcess returned error %ld\n", retval); - retval = ERROR_BAD_FORMAT; - } - - TRACE("returning %lu\n", retval); - - psei_out->hInstApp = (HINSTANCE)retval; - if( gcdret ) - if( !SetCurrentDirectoryW( curdir)) - ERR("cannot return to directory %s\n", debugstr_w(curdir)); - - return retval; -} - - -/*********************************************************************** - * SHELL_BuildEnvW [Internal] - * - * Build the environment for the new process, adding the specified - * path to the PATH variable. Returned pointer must be freed by caller. - */ -static void *SHELL_BuildEnvW( const WCHAR *path ) -{ - static const WCHAR wPath[] = {'P','A','T','H','=',0}; - WCHAR *strings, *new_env; - WCHAR *p, *p2; - int total = wcslen(path) + 1; - BOOL got_path = FALSE; - - if (!(strings = GetEnvironmentStringsW())) return NULL; - p = strings; - while (*p) - { - int len = wcslen(p) + 1; - if (!_wcsnicmp( p, wPath, 5 )) got_path = TRUE; - total += len; - p += len; - } - if (!got_path) total += 5; /* we need to create PATH */ - total++; /* terminating null */ - - if (!(new_env = HeapAlloc( GetProcessHeap(), 0, total * sizeof(WCHAR) ))) - { - FreeEnvironmentStringsW( strings ); - return NULL; - } - p = strings; - p2 = new_env; - while (*p) - { - int len = wcslen(p) + 1; - memcpy( p2, p, len * sizeof(WCHAR) ); - if (!_wcsnicmp( p, wPath, 5 )) - { - p2[len - 1] = ';'; - wcscpy( p2 + len, path ); - p2 += wcslen(path) + 1; - } - p += len; - p2 += len; - } - if (!got_path) - { - wcscpy( p2, wPath ); - wcscat( p2, path ); - p2 += wcslen(p2) + 1; - } - *p2 = 0; - FreeEnvironmentStringsW( strings ); - return new_env; -} - - -/*********************************************************************** - * SHELL_TryAppPathW [Internal] - * - * Helper function for SHELL_FindExecutable - * @param lpResult - pointer to a buffer of size MAX_PATH - * On entry: szName is a filename (probably without path separators). - * On exit: if szName found in "App Path", place full path in lpResult, and return true - */ -static BOOL SHELL_TryAppPathW( LPCWSTR szName, LPWSTR lpResult, WCHAR **env) -{ - static const WCHAR wszKeyAppPaths[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s', - '\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','A','p','p',' ','P','a','t','h','s','\\',0}; - static const WCHAR wPath[] = {'P','a','t','h',0}; - HKEY hkApp = 0; - WCHAR buffer[1024]; - LONG len; - LONG res; - BOOL found = FALSE; - - if (env) *env = NULL; - wcscpy(buffer, wszKeyAppPaths); - wcscat(buffer, szName); - res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, buffer, 0, KEY_READ, &hkApp); - if (res) goto end; - - len = MAX_PATH*sizeof(WCHAR); - res = RegQueryValueW(hkApp, NULL, lpResult, &len); - if (res) goto end; - found = TRUE; - - if (env) - { - DWORD count = sizeof(buffer); - if (!RegQueryValueExW(hkApp, wPath, NULL, NULL, (LPBYTE)buffer, &count) && buffer[0]) - *env = SHELL_BuildEnvW( buffer ); - } - -end: - if (hkApp) RegCloseKey(hkApp); - return found; -} - -static UINT SHELL_FindExecutableByOperation(LPCWSTR lpOperation, LPWSTR key, LPWSTR filetype, LPWSTR command, LONG commandlen) -{ - static const WCHAR wCommand[] = {'\\','c','o','m','m','a','n','d',0}; - HKEY hkeyClass; - WCHAR verb[MAX_PATH]; - - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, filetype, 0, 0x02000000, &hkeyClass)) - return SE_ERR_NOASSOC; - if (!HCR_GetDefaultVerbW(hkeyClass, lpOperation, verb, sizeof(verb)/sizeof(verb[0]))) - return SE_ERR_NOASSOC; - RegCloseKey(hkeyClass); - - /* Looking for ...buffer\shell\\command */ - wcscat(filetype, wszShell); - wcscat(filetype, verb); - wcscat(filetype, wCommand); - - if (RegQueryValueW(HKEY_CLASSES_ROOT, filetype, command, - &commandlen) == ERROR_SUCCESS) - { - commandlen /= sizeof(WCHAR); - if (key) wcscpy(key, filetype); -#if 0 - LPWSTR tmp; - WCHAR param[256]; - LONG paramlen = sizeof(param); - static const WCHAR wSpace[] = {' ',0}; - - /* FIXME: it seems all Windows version don't behave the same here. - * the doc states that this ddeexec information can be found after - * the exec names. - * on Win98, it doesn't appear, but I think it does on Win2k - */ - /* Get the parameters needed by the application - from the associated ddeexec key */ - tmp = strstrW(filetype, wCommand); - tmp[0] = '\0'; - wcscat(filetype, wDdeexec); - if (RegQueryValueW(HKEY_CLASSES_ROOT, filetype, param, - ¶mlen) == ERROR_SUCCESS) - { - paramlen /= sizeof(WCHAR); - wcscat(command, wSpace); - wcscat(command, param); - commandlen += paramlen; - } -#endif - - command[commandlen] = '\0'; - - return 33; /* FIXME see SHELL_FindExecutable() */ - } - - return SE_ERR_NOASSOC; -} - -/************************************************************************* - * SHELL_FindExecutable [Internal] - * - * Utility for code sharing between FindExecutable and ShellExecute - * in: - * lpFile the name of a file - * lpOperation the operation on it (open) - * out: - * lpResult a buffer, big enough :-(, to store the command to do the - * operation on the file - * key a buffer, big enough, to get the key name to do actually the - * command (it'll be used afterwards for more information - * on the operation) - */ -static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation, - LPWSTR lpResult, int resultLen, LPWSTR key, WCHAR **env, LPITEMIDLIST pidl, LPCWSTR args) -{ - static const WCHAR wWindows[] = {'w','i','n','d','o','w','s',0}; - static const WCHAR wPrograms[] = {'p','r','o','g','r','a','m','s',0}; - static const WCHAR wExtensions[] = {'e','x','e',' ','p','i','f',' ','b','a','t',' ','c','m','d',' ','c','o','m',0}; - WCHAR *extension = NULL; /* pointer to file extension */ - WCHAR filetype[256]; /* registry name for this filetype */ - LONG filetypelen = sizeof(filetype); /* length of above */ - WCHAR command[1024]; /* command from registry */ - WCHAR wBuffer[256]; /* Used to GetProfileString */ - UINT retval = SE_ERR_NOASSOC; - WCHAR *tok; /* token pointer */ - WCHAR xlpFile[256]; /* result of SearchPath */ - DWORD attribs; /* file attributes */ - - TRACE("%s\n", debugstr_w(lpFile)); - - if (!lpResult) - return ERROR_INVALID_PARAMETER; - - xlpFile[0] = '\0'; - lpResult[0] = '\0'; /* Start off with an empty return string */ - if (key) *key = '\0'; - - /* trap NULL parameters on entry */ - if (!lpFile) - { - WARN("(lpFile=%s,lpResult=%s): NULL parameter\n", - debugstr_w(lpFile), debugstr_w(lpResult)); - return ERROR_FILE_NOT_FOUND; /* File not found. Close enough, I guess. */ - } - - if (SHELL_TryAppPathW( lpFile, lpResult, env )) - { - TRACE("found %s via App Paths\n", debugstr_w(lpResult)); - return 33; - } - - if (SearchPathW(lpPath, lpFile, wszExe, sizeof(xlpFile)/sizeof(WCHAR), xlpFile, NULL)) - { - TRACE("SearchPathW returned non-zero\n"); - lpFile = xlpFile; - /* Hey, isn't this value ignored? Why make this call? Shouldn't we return here? --dank*/ - } - - attribs = GetFileAttributesW(lpFile); - if (attribs!=INVALID_FILE_ATTRIBUTES && (attribs&FILE_ATTRIBUTE_DIRECTORY)) - { - wcscpy(filetype, wszFolder); - filetypelen = 6; /* strlen("Folder") */ - } - else - { - /* Did we get something? Anything? */ - if (xlpFile[0]==0) - { - TRACE("Returning SE_ERR_FNF\n"); - return SE_ERR_FNF; - } - /* First thing we need is the file's extension */ - extension = wcsrchr(xlpFile, '.'); /* Assume last "." is the one; */ - /* File->Run in progman uses */ - /* .\FILE.EXE :( */ - TRACE("xlpFile=%s,extension=%s\n", debugstr_w(xlpFile), debugstr_w(extension)); - - if (extension == NULL || extension[1]==0) - { - WARN("Returning SE_ERR_NOASSOC\n"); - return SE_ERR_NOASSOC; - } - - /* Three places to check: */ - /* 1. win.ini, [windows], programs (NB no leading '.') */ - /* 2. Registry, HKEY_CLASS_ROOT\\shell\open\command */ - /* 3. win.ini, [extensions], extension (NB no leading '.' */ - /* All I know of the order is that registry is checked before */ - /* extensions; however, it'd make sense to check the programs */ - /* section first, so that's what happens here. */ - - /* See if it's a program - if GetProfileString fails, we skip this - * section. Actually, if GetProfileString fails, we've probably - * got a lot more to worry about than running a program... */ - if (GetProfileStringW(wWindows, wPrograms, wExtensions, wBuffer, sizeof(wBuffer)/sizeof(WCHAR)) > 0) - { - CharLowerW(wBuffer); - tok = wBuffer; - while (*tok) - { - WCHAR *p = tok; - while (*p && *p != ' ' && *p != '\t') p++; - if (*p) - { - *p++ = 0; - while (*p == ' ' || *p == '\t') p++; - } - - if (wcsicmp(tok, &extension[1]) == 0) /* have to skip the leading "." */ - { - wcscpy(lpResult, xlpFile); - /* Need to perhaps check that the file has a path - * attached */ - TRACE("found %s\n", debugstr_w(lpResult)); - return 33; - /* Greater than 32 to indicate success */ - } - tok = p; - } - } - - /* Check registry */ - if (RegQueryValueW(HKEY_CLASSES_ROOT, extension, filetype, - &filetypelen) == ERROR_SUCCESS) - { - filetypelen /= sizeof(WCHAR); - if (filetypelen == sizeof(filetype)/sizeof(WCHAR)) - filetypelen--; - filetype[filetypelen] = '\0'; - TRACE("File type: %s\n", debugstr_w(filetype)); - } - else - { - *filetype = '\0'; - filetypelen = 0; - } - } - - if (*filetype) - { - /* pass the operation string to SHELL_FindExecutableByOperation() */ - filetype[filetypelen] = '\0'; - retval = SHELL_FindExecutableByOperation(lpOperation, key, filetype, command, sizeof(command)); - - if (retval > 32) - { - DWORD finishedLen; - SHELL_ArgifyW(lpResult, resultLen, command, xlpFile, pidl, args, &finishedLen); - if (finishedLen > resultLen) - ERR("Argify buffer not large enough.. truncated\n"); - - /* Remove double quotation marks and command line arguments */ - if (*lpResult == '"') - { - WCHAR *p = lpResult; - while (*(p + 1) != '"') - { - *p = *(p + 1); - p++; - } - *p = '\0'; - } - else - { - /* Truncate on first space */ - WCHAR *p = lpResult; - while (*p != ' ' && *p != '\0') - p++; - *p='\0'; - } - } - } - else /* Check win.ini */ - { - static const WCHAR wExtensions[] = {'e','x','t','e','n','s','i','o','n','s',0}; - - /* Toss the leading dot */ - extension++; - if (GetProfileStringW(wExtensions, extension, wszEmpty, command, sizeof(command)/sizeof(WCHAR)) > 0) - { - if (wcslen(command) != 0) - { - wcscpy(lpResult, command); - tok = wcschr(lpResult, '^'); /* should be ^.extension? */ - if (tok != NULL) - { - tok[0] = '\0'; - wcscat(lpResult, xlpFile); /* what if no dir in xlpFile? */ - tok = wcschr(command, '^'); /* see above */ - if ((tok != NULL) && (wcslen(tok)>5)) - { - wcscat(lpResult, &tok[5]); - } - } - retval = 33; /* FIXME - see above */ - } - } - } - - TRACE("returning %s\n", debugstr_w(lpResult)); - return retval; -} - -/****************************************************************** - * dde_cb - * - * callback for the DDE connection. not really useful - */ -static HDDEDATA CALLBACK dde_cb(UINT uType, UINT uFmt, HCONV hConv, - HSZ hsz1, HSZ hsz2, HDDEDATA hData, - ULONG_PTR dwData1, ULONG_PTR dwData2) -{ - TRACE("dde_cb: %04x, %04x, %p, %p, %p, %p, %08lx, %08lx\n", - uType, uFmt, hConv, hsz1, hsz2, hData, dwData1, dwData2); - return NULL; -} - -/****************************************************************** - * dde_connect - * - * ShellExecute helper. Used to do an operation with a DDE connection - * - * Handles both the direct connection (try #1), and if it fails, - * launching an application and trying (#2) to connect to it - * - */ -static unsigned dde_connect(const WCHAR* key, const WCHAR* start, WCHAR* ddeexec, - const WCHAR* lpFile, WCHAR *env, - LPCWSTR szCommandline, LPITEMIDLIST pidl, SHELL_ExecuteW32 execfunc, - const SHELLEXECUTEINFOW *psei, LPSHELLEXECUTEINFOW psei_out) -{ - static const WCHAR wApplication[] = {'\\','a','p','p','l','i','c','a','t','i','o','n',0}; - static const WCHAR wTopic[] = {'\\','t','o','p','i','c',0}; - WCHAR regkey[256]; - WCHAR * endkey = regkey + wcslen(key); - WCHAR app[256], topic[256], ifexec[256], res[256]; - LONG applen, topiclen, ifexeclen; - WCHAR * exec; - DWORD ddeInst = 0; - DWORD tid; - DWORD resultLen; - HSZ hszApp, hszTopic; - HCONV hConv; - HDDEDATA hDdeData; - unsigned ret = SE_ERR_NOASSOC; - BOOL unicode = !(GetVersion() & 0x80000000); - - wcscpy(regkey, key); - wcscpy(endkey, wApplication); - applen = sizeof(app); - if (RegQueryValueW(HKEY_CLASSES_ROOT, regkey, app, &applen) != ERROR_SUCCESS) - { - WCHAR command[1024], fullpath[MAX_PATH]; - static const WCHAR wSo[] = { '.','s','o',0 }; - int sizeSo = sizeof(wSo)/sizeof(WCHAR); - LPWSTR ptr = NULL; - DWORD ret = 0; - - /* Get application command from start string and find filename of application */ - if (*start == '"') - { - wcscpy(command, start+1); - if ((ptr = wcschr(command, '"'))) - *ptr = 0; - ret = SearchPathW(NULL, command, wszExe, sizeof(fullpath)/sizeof(WCHAR), fullpath, &ptr); - } - else - { - LPWSTR p,space; - for (p=(LPWSTR)start; (space=strchrW(p, ' ')); p=space+1) - { - int idx = space-start; - memcpy(command, start, idx*sizeof(WCHAR)); - command[idx] = '\0'; - if ((ret = SearchPathW(NULL, command, wszExe, sizeof(fullpath)/sizeof(WCHAR), fullpath, &ptr))) - break; - } - if (!ret) - ret = SearchPathW(NULL, start, wszExe, sizeof(fullpath)/sizeof(WCHAR), fullpath, &ptr); - } - - if (!ret) - { - ERR("Unable to find application path for command %s\n", debugstr_w(start)); - return ERROR_ACCESS_DENIED; - } - wcscpy(app, ptr); - - /* Remove extensions (including .so) */ - ptr = app + wcslen(app) - (sizeSo-1); - if (wcslen(app) >= sizeSo && - !wcscmp(ptr, wSo)) - *ptr = 0; - - ptr = strrchrW(app, '.'); - assert(ptr); - *ptr = 0; - } - - wcscpy(endkey, wTopic); - topiclen = sizeof(topic); - if (RegQueryValueW(HKEY_CLASSES_ROOT, regkey, topic, &topiclen) != ERROR_SUCCESS) - { - static const WCHAR wSystem[] = {'S','y','s','t','e','m',0}; - wcscpy(topic, wSystem); - } - - if (unicode) - { - if (DdeInitializeW(&ddeInst, dde_cb, APPCMD_CLIENTONLY, 0L) != DMLERR_NO_ERROR) - return 2; - } - else - { - if (DdeInitializeA(&ddeInst, dde_cb, APPCMD_CLIENTONLY, 0L) != DMLERR_NO_ERROR) - return 2; - } - - hszApp = DdeCreateStringHandleW(ddeInst, app, CP_WINUNICODE); - hszTopic = DdeCreateStringHandleW(ddeInst, topic, CP_WINUNICODE); - - hConv = DdeConnect(ddeInst, hszApp, hszTopic, NULL); - exec = ddeexec; - if (!hConv) - { - static const WCHAR wIfexec[] = {'\\','i','f','e','x','e','c',0}; - TRACE("Launching %s\n", debugstr_w(start)); - ret = execfunc(start, env, TRUE, psei, psei_out); - if (ret <= 32) - { - TRACE("Couldn't launch\n"); - goto error; - } - hConv = DdeConnect(ddeInst, hszApp, hszTopic, NULL); - if (!hConv) - { - TRACE("Couldn't connect. ret=%d\n", ret); - DdeUninitialize(ddeInst); - SetLastError(ERROR_DDE_FAIL); - return 30; /* whatever */ - } - strcpyW(endkey, wIfexec); - ifexeclen = sizeof(ifexec); - if (RegQueryValueW(HKEY_CLASSES_ROOT, regkey, ifexec, &ifexeclen) == ERROR_SUCCESS) - { - exec = ifexec; - } - } - - SHELL_ArgifyW(res, sizeof(res)/sizeof(WCHAR), exec, lpFile, pidl, szCommandline, &resultLen); - if (resultLen > sizeof(res)/sizeof(WCHAR)) - ERR("Argify buffer not large enough, truncated\n"); - TRACE("%s %s => %s\n", debugstr_w(exec), debugstr_w(lpFile), debugstr_w(res)); - - /* It's documented in the KB 330337 that IE has a bug and returns - * error DMLERR_NOTPROCESSED on XTYP_EXECUTE request. - */ - if (unicode) - hDdeData = DdeClientTransaction((LPBYTE)res, (strlenW(res) + 1) * sizeof(WCHAR), hConv, 0L, 0, - XTYP_EXECUTE, 30000, &tid); - else - { - DWORD lenA = WideCharToMultiByte(CP_ACP, 0, res, -1, NULL, 0, NULL, NULL); - char *resA = HeapAlloc(GetProcessHeap(), 0, lenA); - WideCharToMultiByte(CP_ACP, 0, res, -1, resA, lenA, NULL, NULL); - hDdeData = DdeClientTransaction( (LPBYTE)resA, lenA, hConv, 0L, 0, - XTYP_EXECUTE, 10000, &tid ); - HeapFree(GetProcessHeap(), 0, resA); - } - if (hDdeData) - DdeFreeDataHandle(hDdeData); - else - WARN("DdeClientTransaction failed with error %04x\n", DdeGetLastError(ddeInst)); - ret = 33; - - DdeDisconnect(hConv); - - error: - DdeUninitialize(ddeInst); - - return ret; -} - -/************************************************************************* - * execute_from_key [Internal] - */ -static UINT_PTR execute_from_key(LPCWSTR key, LPCWSTR lpFile, WCHAR *env, LPCWSTR szCommandline, - LPCWSTR executable_name, - SHELL_ExecuteW32 execfunc, - LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out) -{ - static const WCHAR wCommand[] = {'c','o','m','m','a','n','d',0}; - static const WCHAR wDdeexec[] = {'d','d','e','e','x','e','c',0}; - WCHAR cmd[256], param[1024], ddeexec[256]; - LONG cmdlen = sizeof(cmd), ddeexeclen = sizeof(ddeexec); - UINT_PTR retval = SE_ERR_NOASSOC; - DWORD resultLen; - LPWSTR tmp; - - TRACE("%s %s %s %s %s\n", debugstr_w(key), debugstr_w(lpFile), debugstr_w(env), - debugstr_w(szCommandline), debugstr_w(executable_name)); - - cmd[0] = '\0'; - param[0] = '\0'; - - /* Get the application from the registry */ - if (RegQueryValueW(HKEY_CLASSES_ROOT, key, cmd, &cmdlen) == ERROR_SUCCESS) - { - TRACE("got cmd: %s\n", debugstr_w(cmd)); - - /* Is there a replace() function anywhere? */ - cmdlen /= sizeof(WCHAR); - if (cmdlen >= sizeof(cmd)/sizeof(WCHAR)) - cmdlen = sizeof(cmd)/sizeof(WCHAR)-1; - cmd[cmdlen] = '\0'; - SHELL_ArgifyW(param, sizeof(param)/sizeof(WCHAR), cmd, lpFile, psei->lpIDList, szCommandline, &resultLen); - if (resultLen > sizeof(param)/sizeof(WCHAR)) - ERR("Argify buffer not large enough, truncating\n"); - } - - /* Get the parameters needed by the application - from the associated ddeexec key */ - tmp = strstrW(key, wCommand); - assert(tmp); - wcscpy(tmp, wDdeexec); - - if (RegQueryValueW(HKEY_CLASSES_ROOT, key, ddeexec, &ddeexeclen) == ERROR_SUCCESS) - { - TRACE("Got ddeexec %s => %s\n", debugstr_w(key), debugstr_w(ddeexec)); - if (!param[0]) strcpyW(param, executable_name); - retval = dde_connect(key, param, ddeexec, lpFile, env, szCommandline, psei->lpIDList, execfunc, psei, psei_out); - } - else if (param[0]) - { - TRACE("executing: %s\n", debugstr_w(param)); - retval = execfunc(param, env, FALSE, psei, psei_out); - } - else - WARN("Nothing appropriate found for %s\n", debugstr_w(key)); - - return retval; -} - -/************************************************************************* - * FindExecutableA [SHELL32.@] - */ -HINSTANCE WINAPI FindExecutableA(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult) -{ - HINSTANCE retval; - WCHAR *wFile = NULL, *wDirectory = NULL; - WCHAR wResult[MAX_PATH]; - - if (lpFile) __SHCloneStrAtoW(&wFile, lpFile); - if (lpDirectory) __SHCloneStrAtoW(&wDirectory, lpDirectory); - - retval = FindExecutableW(wFile, wDirectory, wResult); - WideCharToMultiByte(CP_ACP, 0, wResult, -1, lpResult, MAX_PATH, NULL, NULL); - SHFree( wFile ); - SHFree( wDirectory ); - - TRACE("returning %s\n", lpResult); - return retval; -} - -/************************************************************************* - * FindExecutableW [SHELL32.@] - * - * This function returns the executable associated with the specified file - * for the default verb. - * - * PARAMS - * lpFile [I] The file to find the association for. This must refer to - * an existing file otherwise FindExecutable fails and returns - * SE_ERR_FNF. - * lpResult [O] Points to a buffer into which the executable path is - * copied. This parameter must not be NULL otherwise - * FindExecutable() segfaults. The buffer must be of size at - * least MAX_PATH characters. - * - * RETURNS - * A value greater than 32 on success, less than or equal to 32 otherwise. - * See the SE_ERR_* constants. - * - * NOTES - * On Windows XP and 2003, FindExecutable() seems to first convert the - * filename into 8.3 format, thus taking into account only the first three - * characters of the extension, and expects to find an association for those. - * However other Windows versions behave sanely. - */ -HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory, LPWSTR lpResult) -{ - UINT_PTR retval = SE_ERR_NOASSOC; - WCHAR old_dir[1024]; - - TRACE("File %s, Dir %s\n", debugstr_w(lpFile), debugstr_w(lpDirectory)); - - lpResult[0] = '\0'; /* Start off with an empty return string */ - if (lpFile == NULL) - return (HINSTANCE)SE_ERR_FNF; - - if (lpDirectory) - { - GetCurrentDirectoryW(sizeof(old_dir)/sizeof(WCHAR), old_dir); - SetCurrentDirectoryW(lpDirectory); - } - - retval = SHELL_FindExecutable(lpDirectory, lpFile, wszOpen, lpResult, MAX_PATH, NULL, NULL, NULL, NULL); - - TRACE("returning %s\n", debugstr_w(lpResult)); - if (lpDirectory) - SetCurrentDirectoryW(old_dir); - return (HINSTANCE)retval; -} - -/* FIXME: is this already implemented somewhere else? */ -static HKEY ShellExecute_GetClassKey( const SHELLEXECUTEINFOW *sei ) -{ - LPCWSTR ext = NULL, lpClass = NULL; - LPWSTR cls = NULL; - DWORD type = 0, sz = 0; - HKEY hkey = 0; - LONG r; - - if (sei->fMask & SEE_MASK_CLASSALL) - return sei->hkeyClass; - - if (sei->fMask & SEE_MASK_CLASSNAME) - lpClass = sei->lpClass; - else - { - ext = PathFindExtensionW( sei->lpFile ); - TRACE("ext = %s\n", debugstr_w( ext ) ); - if (!ext) - return hkey; - - r = RegOpenKeyW( HKEY_CLASSES_ROOT, ext, &hkey ); - if (r != ERROR_SUCCESS ) - return hkey; - - r = RegQueryValueExW( hkey, NULL, 0, &type, NULL, &sz ); - if ( r == ERROR_SUCCESS && type == REG_SZ ) - { - sz += sizeof (WCHAR); - cls = HeapAlloc( GetProcessHeap(), 0, sz ); - cls[0] = 0; - RegQueryValueExW( hkey, NULL, 0, &type, (LPBYTE) cls, &sz ); - } - - RegCloseKey( hkey ); - lpClass = cls; - } - - TRACE("class = %s\n", debugstr_w(lpClass) ); - - hkey = 0; - if ( lpClass ) - RegOpenKeyW( HKEY_CLASSES_ROOT, lpClass, &hkey ); - - HeapFree( GetProcessHeap(), 0, cls ); - - return hkey; -} - -static IDataObject *shellex_get_dataobj( LPSHELLEXECUTEINFOW sei ) -{ - LPCITEMIDLIST pidllast = NULL; - IDataObject *dataobj = NULL; - IShellFolder *shf = NULL; - LPITEMIDLIST pidl = NULL; - HRESULT r; - - if (sei->fMask & SEE_MASK_CLASSALL) - pidl = sei->lpIDList; - else - { - WCHAR fullpath[MAX_PATH]; - BOOL ret; - - fullpath[0] = 0; - ret = GetFullPathNameW( sei->lpFile, MAX_PATH, fullpath, NULL ); - if (!ret) - goto end; - - pidl = ILCreateFromPathW( fullpath ); - } - - r = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&shf, &pidllast ); - if ( FAILED( r ) ) - goto end; - - IShellFolder_GetUIObjectOf( shf, NULL, 1, &pidllast, - &IID_IDataObject, NULL, (LPVOID*) &dataobj ); - -end: - if ( pidl != sei->lpIDList ) - ILFree( pidl ); - if ( shf ) - IShellFolder_Release( shf ); - return dataobj; -} - -static HRESULT shellex_run_context_menu_default( IShellExtInit *obj, - LPSHELLEXECUTEINFOW sei ) -{ - IContextMenu *cm = NULL; - CMINVOKECOMMANDINFOEX ici; - MENUITEMINFOW info; - WCHAR string[0x80]; - INT i, n, def = -1; - HMENU hmenu = 0; - HRESULT r; - - TRACE("%p %p\n", obj, sei ); - - r = IShellExtInit_QueryInterface( obj, &IID_IContextMenu, (LPVOID*) &cm ); - if ( FAILED( r ) ) - return r; - - hmenu = CreateMenu(); - if ( !hmenu ) - goto end; - - /* the number of the last menu added is returned in r */ - r = IContextMenu_QueryContextMenu( cm, hmenu, 0, 0x20, 0x7fff, CMF_DEFAULTONLY ); - if ( FAILED( r ) ) - goto end; - - n = GetMenuItemCount( hmenu ); - for ( i = 0; i < n; i++ ) - { - memset( &info, 0, sizeof info ); - info.cbSize = sizeof info; - info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_STATE | MIIM_DATA | MIIM_ID; - info.dwTypeData = string; - info.cch = sizeof string; - string[0] = 0; - GetMenuItemInfoW( hmenu, i, TRUE, &info ); - - TRACE("menu %d %s %08x %08lx %08x %08x\n", i, debugstr_w(string), - info.fState, info.dwItemData, info.fType, info.wID ); - if ( ( !sei->lpVerb && (info.fState & MFS_DEFAULT) ) || - ( sei->lpVerb && !lstrcmpiW( sei->lpVerb, string ) ) ) - { - def = i; - break; - } - } - - r = E_FAIL; - if ( def == -1 ) - goto end; - - memset( &ici, 0, sizeof ici ); - ici.cbSize = sizeof ici; - ici.fMask = CMIC_MASK_UNICODE | (sei->fMask & (SEE_MASK_NOASYNC|SEE_MASK_ASYNCOK|SEE_MASK_FLAG_NO_UI)); - ici.nShow = sei->nShow; - ici.lpVerb = MAKEINTRESOURCEA( def ); - ici.hwnd = sei->hwnd; - ici.lpParametersW = sei->lpParameters; - - r = IContextMenu_InvokeCommand( cm, (LPCMINVOKECOMMANDINFO) &ici ); - - TRACE("invoke command returned %08x\n", r ); - -end: - if ( hmenu ) - DestroyMenu( hmenu ); - if ( cm ) - IContextMenu_Release( cm ); - return r; -} - -static HRESULT shellex_load_object_and_run( HKEY hkey, LPCGUID guid, LPSHELLEXECUTEINFOW sei ) -{ - IDataObject *dataobj = NULL; - IObjectWithSite *ows = NULL; - IShellExtInit *obj = NULL; - HRESULT r; - - TRACE("%p %s %p\n", hkey, debugstr_guid( guid ), sei ); - - r = CoInitialize( NULL ); - if ( FAILED( r ) ) - goto end; - - r = CoCreateInstance( guid, NULL, CLSCTX_INPROC_SERVER, - &IID_IShellExtInit, (LPVOID*)&obj ); - if ( FAILED( r ) ) - { - ERR("failed %08x\n", r ); - goto end; - } - - dataobj = shellex_get_dataobj( sei ); - if ( !dataobj ) - { - ERR("failed to get data object\n"); - goto end; - } - - r = IShellExtInit_Initialize( obj, NULL, dataobj, hkey ); - if ( FAILED( r ) ) - goto end; - - r = IShellExtInit_QueryInterface( obj, &IID_IObjectWithSite, (LPVOID*) &ows ); - if ( FAILED( r ) ) - goto end; - - IObjectWithSite_SetSite( ows, NULL ); - - r = shellex_run_context_menu_default( obj, sei ); - -end: - if ( ows ) - IObjectWithSite_Release( ows ); - if ( dataobj ) - IDataObject_Release( dataobj ); - if ( obj ) - IShellExtInit_Release( obj ); - CoUninitialize(); - return r; -} - - -/************************************************************************* - * ShellExecute_FromContextMenu [Internal] - */ -static LONG ShellExecute_FromContextMenu( LPSHELLEXECUTEINFOW sei ) -{ - static const WCHAR szcm[] = { 's','h','e','l','l','e','x','\\', - 'C','o','n','t','e','x','t','M','e','n','u','H','a','n','d','l','e','r','s',0 }; - HKEY hkey, hkeycm = 0; - WCHAR szguid[39]; - HRESULT hr; - GUID guid; - DWORD i; - LONG r; - - TRACE("%s\n", debugstr_w(sei->lpFile) ); - - hkey = ShellExecute_GetClassKey( sei ); - if ( !hkey ) - return ERROR_FUNCTION_FAILED; - - r = RegOpenKeyW( hkey, szcm, &hkeycm ); - if ( r == ERROR_SUCCESS ) - { - i = 0; - while ( 1 ) - { - r = RegEnumKeyW( hkeycm, i++, szguid, sizeof(szguid)/sizeof(szguid[0]) ); - if ( r != ERROR_SUCCESS ) - break; - - hr = CLSIDFromString( szguid, &guid ); - if (SUCCEEDED(hr)) - { - /* stop at the first one that succeeds in running */ - hr = shellex_load_object_and_run( hkey, &guid, sei ); - if ( SUCCEEDED( hr ) ) - break; - } - } - RegCloseKey( hkeycm ); - } - - if ( hkey != sei->hkeyClass ) - RegCloseKey( hkey ); - return r; -} - -static UINT_PTR SHELL_execute_class( LPCWSTR wszApplicationName, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc ) -{ - static const WCHAR wSpace[] = {' ',0}; - WCHAR execCmd[1024], wcmd[1024]; - /* launch a document by fileclass like 'WordPad.Document.1' */ - /* the Commandline contains 'c:\Path\wordpad.exe "%1"' */ - /* FIXME: wcmd should not be of a fixed size. Fixed to 1024, MAX_PATH is way too short! */ - ULONG cmask=(psei->fMask & SEE_MASK_CLASSALL); - DWORD resultLen; - BOOL done; - - HCR_GetExecuteCommandW((cmask == SEE_MASK_CLASSKEY) ? psei->hkeyClass : NULL, - (cmask == SEE_MASK_CLASSNAME) ? psei->lpClass: NULL, - psei->lpVerb, - execCmd, sizeof(execCmd)); - - /* FIXME: get the extension of lpFile, check if it fits to the lpClass */ - TRACE("SEE_MASK_CLASSNAME->%s, doc->%s\n", debugstr_w(execCmd), debugstr_w(wszApplicationName)); - - wcmd[0] = '\0'; - done = SHELL_ArgifyW(wcmd, sizeof(wcmd)/sizeof(WCHAR), execCmd, wszApplicationName, psei->lpIDList, NULL, &resultLen); - if (!done && wszApplicationName[0]) - { - strcatW(wcmd, wSpace); - strcatW(wcmd, wszApplicationName); - } - if (resultLen > sizeof(wcmd)/sizeof(WCHAR)) - ERR("Argify buffer not large enough... truncating\n"); - return execfunc(wcmd, NULL, FALSE, psei, psei_out); -} - -static BOOL SHELL_translate_idlist( LPSHELLEXECUTEINFOW sei, LPWSTR wszParameters, DWORD parametersLen, LPWSTR wszApplicationName, DWORD dwApplicationNameLen ) -{ - static const WCHAR wExplorer[] = {'e','x','p','l','o','r','e','r','.','e','x','e',0}; - WCHAR buffer[MAX_PATH]; - BOOL appKnownSingular = FALSE; - - /* last chance to translate IDList: now also allow CLSID paths */ - if (SUCCEEDED(SHELL_GetPathFromIDListForExecuteW(sei->lpIDList, buffer, sizeof(buffer)))) { - if (buffer[0]==':' && buffer[1]==':') { - /* open shell folder for the specified class GUID */ - if (strlenW(buffer) + 1 > parametersLen) - ERR("parameters len exceeds buffer size (%i > %i), truncating\n", - lstrlenW(buffer) + 1, parametersLen); - lstrcpynW(wszParameters, buffer, parametersLen); - if (strlenW(wExplorer) > dwApplicationNameLen) - ERR("application len exceeds buffer size (%i > %i), truncating\n", - lstrlenW(wExplorer) + 1, dwApplicationNameLen); - lstrcpynW(wszApplicationName, wExplorer, dwApplicationNameLen); - appKnownSingular = TRUE; - - sei->fMask &= ~SEE_MASK_INVOKEIDLIST; - } else { - WCHAR target[MAX_PATH]; - DWORD attribs; - DWORD resultLen; - /* Check if we're executing a directory and if so use the - handler for the Folder class */ - strcpyW(target, buffer); - attribs = GetFileAttributesW(buffer); - if (attribs != INVALID_FILE_ATTRIBUTES && - (attribs & FILE_ATTRIBUTE_DIRECTORY) && - HCR_GetExecuteCommandW(0, wszFolder, - sei->lpVerb, - buffer, sizeof(buffer))) { - SHELL_ArgifyW(wszApplicationName, dwApplicationNameLen, - buffer, target, sei->lpIDList, NULL, &resultLen); - if (resultLen > dwApplicationNameLen) - ERR("Argify buffer not large enough... truncating\n"); - appKnownSingular = FALSE; - } - sei->fMask &= ~SEE_MASK_INVOKEIDLIST; - } - } - return appKnownSingular; -} - -static UINT_PTR SHELL_quote_and_execute( LPCWSTR wcmd, LPCWSTR wszParameters, LPCWSTR lpstrProtocol, LPCWSTR wszApplicationName, LPWSTR env, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc ) -{ - static const WCHAR wQuote[] = {'"',0}; - static const WCHAR wSpace[] = {' ',0}; - UINT_PTR retval; - DWORD len; - WCHAR *wszQuotedCmd; - - /* Length of quotes plus length of command plus NULL terminator */ - len = 2 + lstrlenW(wcmd) + 1; - if (wszParameters[0]) - { - /* Length of space plus length of parameters */ - len += 1 + lstrlenW(wszParameters); - } - wszQuotedCmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - /* Must quote to handle case where cmd contains spaces, - * else security hole if malicious user creates executable file "C:\\Program" - */ - strcpyW(wszQuotedCmd, wQuote); - strcatW(wszQuotedCmd, wcmd); - strcatW(wszQuotedCmd, wQuote); - if (wszParameters[0]) { - strcatW(wszQuotedCmd, wSpace); - strcatW(wszQuotedCmd, wszParameters); - } - TRACE("%s/%s => %s/%s\n", debugstr_w(wszApplicationName), debugstr_w(psei->lpVerb), debugstr_w(wszQuotedCmd), debugstr_w(lpstrProtocol)); - if (*lpstrProtocol) - retval = execute_from_key(lpstrProtocol, wszApplicationName, env, psei->lpParameters, wcmd, execfunc, psei, psei_out); - else - retval = execfunc(wszQuotedCmd, env, FALSE, psei, psei_out); - HeapFree(GetProcessHeap(), 0, wszQuotedCmd); - return retval; -} - -static UINT_PTR SHELL_execute_url( LPCWSTR lpFile, LPCWSTR wFile, LPCWSTR wcmd, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc ) -{ - static const WCHAR wShell[] = {'\\','s','h','e','l','l','\\',0}; - static const WCHAR wCommand[] = {'\\','c','o','m','m','a','n','d',0}; - UINT_PTR retval; - WCHAR *lpstrProtocol; - LPCWSTR lpstrRes; - INT iSize; - DWORD len; - - lpstrRes = strchrW(lpFile, ':'); - if (lpstrRes) - iSize = lpstrRes - lpFile; - else - iSize = strlenW(lpFile); - - TRACE("Got URL: %s\n", debugstr_w(lpFile)); - /* Looking for ...protocol\shell\lpOperation\command */ - len = iSize + lstrlenW(wShell) + lstrlenW(wCommand) + 1; - if (psei->lpVerb) - len += lstrlenW(psei->lpVerb); - else - len += lstrlenW(wszOpen); - lpstrProtocol = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - memcpy(lpstrProtocol, lpFile, iSize*sizeof(WCHAR)); - lpstrProtocol[iSize] = '\0'; - strcatW(lpstrProtocol, wShell); - strcatW(lpstrProtocol, psei->lpVerb? psei->lpVerb: wszOpen); - strcatW(lpstrProtocol, wCommand); - - /* Remove File Protocol from lpFile */ - /* In the case file://path/file */ - if (!strncmpiW(lpFile, wFile, iSize)) - { - lpFile += iSize; - while (*lpFile == ':') lpFile++; - } - retval = execute_from_key(lpstrProtocol, lpFile, NULL, psei->lpParameters, - wcmd, execfunc, psei, psei_out); - HeapFree(GetProcessHeap(), 0, lpstrProtocol); - return retval; -} - -void do_error_dialog( UINT_PTR retval, HWND hwnd, WCHAR* filename) -{ - WCHAR msg[2048]; - DWORD_PTR msgArguments[3] = { (DWORD_PTR)filename, 0, 0 }; - DWORD error_code; - - error_code = GetLastError(); - - if (retval == SE_ERR_NOASSOC) - LoadStringW(shell32_hInstance, IDS_SHLEXEC_NOASSOC, msg, sizeof(msg)/sizeof(WCHAR)); - else - FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, - NULL, - error_code, - LANG_USER_DEFAULT, - msg, - sizeof(msg)/sizeof(WCHAR), - (va_list*)msgArguments); - - MessageBoxW(hwnd, msg, NULL, MB_ICONERROR); -} - -/************************************************************************* - * SHELL_execute [Internal] - */ -BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc ) -{ - static const WCHAR wSpace[] = {' ',0}; - static const WCHAR wWww[] = {'w','w','w',0}; - static const WCHAR wFile[] = {'f','i','l','e',0}; - static const WCHAR wHttp[] = {'h','t','t','p',':','/','/',0}; - static const DWORD unsupportedFlags = - SEE_MASK_INVOKEIDLIST | SEE_MASK_ICON | SEE_MASK_HOTKEY | - SEE_MASK_CONNECTNETDRV | SEE_MASK_FLAG_DDEWAIT | - SEE_MASK_UNICODE | SEE_MASK_ASYNCOK | SEE_MASK_HMONITOR; - - WCHAR parametersBuffer[1024], dirBuffer[MAX_PATH], wcmdBuffer[1024]; - WCHAR *wszApplicationName, *wszParameters, *wszDir, *wcmd; - DWORD dwApplicationNameLen = MAX_PATH+2; - DWORD parametersLen = sizeof(parametersBuffer) / sizeof(WCHAR); - DWORD dirLen = sizeof(dirBuffer) / sizeof(WCHAR); - DWORD wcmdLen = sizeof(wcmdBuffer) / sizeof(WCHAR); - DWORD len; - SHELLEXECUTEINFOW sei_tmp; /* modifiable copy of SHELLEXECUTEINFO struct */ - WCHAR wfileName[MAX_PATH]; - WCHAR *env; - WCHAR lpstrProtocol[256]; - LPCWSTR lpFile; - UINT_PTR retval = SE_ERR_NOASSOC; - BOOL appKnownSingular = FALSE; - - /* make a local copy of the LPSHELLEXECUTEINFO structure and work with this from now on */ - sei_tmp = *sei; - - TRACE("mask=0x%08x hwnd=%p verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s\n", - sei_tmp.fMask, sei_tmp.hwnd, debugstr_w(sei_tmp.lpVerb), - debugstr_w(sei_tmp.lpFile), debugstr_w(sei_tmp.lpParameters), - debugstr_w(sei_tmp.lpDirectory), sei_tmp.nShow, - ((sei_tmp.fMask & SEE_MASK_CLASSALL) == SEE_MASK_CLASSNAME) ? - debugstr_w(sei_tmp.lpClass) : "not used"); - - sei->hProcess = NULL; - - /* make copies of all path/command strings */ - if (!sei_tmp.lpFile) - { - wszApplicationName = HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen*sizeof(WCHAR)); - *wszApplicationName = '\0'; - } - else if (*sei_tmp.lpFile == '\"') - { - DWORD l = strlenW(sei_tmp.lpFile+1); - if(l >= dwApplicationNameLen) dwApplicationNameLen = l+1; - wszApplicationName = HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen*sizeof(WCHAR)); - memcpy(wszApplicationName, sei_tmp.lpFile+1, (l+1)*sizeof(WCHAR)); - if (wszApplicationName[l-1] == '\"') - wszApplicationName[l-1] = '\0'; - appKnownSingular = TRUE; - TRACE("wszApplicationName=%s\n",debugstr_w(wszApplicationName)); - } else { - DWORD l = strlenW(sei_tmp.lpFile)+1; - if(l > dwApplicationNameLen) dwApplicationNameLen = l+1; - wszApplicationName = HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen*sizeof(WCHAR)); - memcpy(wszApplicationName, sei_tmp.lpFile, l*sizeof(WCHAR)); - } - - wszParameters = parametersBuffer; - if (sei_tmp.lpParameters) - { - len = lstrlenW(sei_tmp.lpParameters) + 1; - if (len > parametersLen) - { - wszParameters = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - parametersLen = len; - } - strcpyW(wszParameters, sei_tmp.lpParameters); - } - else - *wszParameters = '\0'; - - wszDir = dirBuffer; - if (sei_tmp.lpDirectory) - { - len = lstrlenW(sei_tmp.lpDirectory) + 1; - if (len > dirLen) - { - wszDir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - dirLen = len; - } - strcpyW(wszDir, sei_tmp.lpDirectory); - } - else - *wszDir = '\0'; - - /* adjust string pointers to point to the new buffers */ - sei_tmp.lpFile = wszApplicationName; - sei_tmp.lpParameters = wszParameters; - sei_tmp.lpDirectory = wszDir; - - if (sei_tmp.fMask & unsupportedFlags) - { - FIXME("flags ignored: 0x%08x\n", sei_tmp.fMask & unsupportedFlags); - } - - /* process the IDList */ - if (sei_tmp.fMask & SEE_MASK_IDLIST) - { - IShellExecuteHookW* pSEH; - - HRESULT hr = SHBindToParent(sei_tmp.lpIDList, &IID_IShellExecuteHookW, (LPVOID*)&pSEH, NULL); - - if (SUCCEEDED(hr)) - { - hr = IShellExecuteHookW_Execute(pSEH, &sei_tmp); - - IShellExecuteHookW_Release(pSEH); - - if (hr == S_OK) { - HeapFree(GetProcessHeap(), 0, wszApplicationName); - if (wszParameters != parametersBuffer) - HeapFree(GetProcessHeap(), 0, wszParameters); - if (wszDir != dirBuffer) - HeapFree(GetProcessHeap(), 0, wszDir); - return TRUE; - } - } - - SHGetPathFromIDListW(sei_tmp.lpIDList, wszApplicationName); - appKnownSingular = TRUE; - TRACE("-- idlist=%p (%s)\n", sei_tmp.lpIDList, debugstr_w(wszApplicationName)); - } - - if ( ERROR_SUCCESS == ShellExecute_FromContextMenu( &sei_tmp ) ) - { - sei->hInstApp = (HINSTANCE) 33; - HeapFree(GetProcessHeap(), 0, wszApplicationName); - if (wszParameters != parametersBuffer) - HeapFree(GetProcessHeap(), 0, wszParameters); - if (wszDir != dirBuffer) - HeapFree(GetProcessHeap(), 0, wszDir); - return TRUE; - } - - if (sei_tmp.fMask & SEE_MASK_CLASSALL) - { - retval = SHELL_execute_class( wszApplicationName, &sei_tmp, sei, - execfunc ); - if (retval <= 32 && !(sei_tmp.fMask & SEE_MASK_FLAG_NO_UI)) - { - OPENASINFO Info; - - //FIXME - // need full path - - Info.pcszFile = wszApplicationName; - Info.pcszClass = NULL; - Info.oaifInFlags = OAIF_ALLOW_REGISTRATION | OAIF_EXEC; - - //if (SHOpenWithDialog(sei_tmp.hwnd, &Info) != S_OK) - do_error_dialog(retval, sei_tmp.hwnd, wszApplicationName); - } - HeapFree(GetProcessHeap(), 0, wszApplicationName); - if (wszParameters != parametersBuffer) - HeapFree(GetProcessHeap(), 0, wszParameters); - if (wszDir != dirBuffer) - HeapFree(GetProcessHeap(), 0, wszDir); - return retval > 32; - } - - /* Has the IDList not yet been translated? */ - if (sei_tmp.fMask & SEE_MASK_IDLIST) - { - appKnownSingular = SHELL_translate_idlist( &sei_tmp, wszParameters, - parametersLen, - wszApplicationName, - dwApplicationNameLen ); - } - - /* expand environment strings */ - len = ExpandEnvironmentStringsW(sei_tmp.lpFile, NULL, 0); - if (len>0) - { - LPWSTR buf; - buf = HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR)); - - ExpandEnvironmentStringsW(sei_tmp.lpFile, buf, len+1); - HeapFree(GetProcessHeap(), 0, wszApplicationName); - dwApplicationNameLen = len+1; - wszApplicationName = buf; - /* appKnownSingular unmodified */ - - sei_tmp.lpFile = wszApplicationName; - } - - if (*sei_tmp.lpParameters) - { - len = ExpandEnvironmentStringsW(sei_tmp.lpParameters, NULL, 0); - if (len > 0) - { - LPWSTR buf; - len++; - buf = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR)); - ExpandEnvironmentStringsW(sei_tmp.lpParameters, buf, len); - if (wszParameters != parametersBuffer) - HeapFree(GetProcessHeap(), 0, wszParameters); - wszParameters = buf; - parametersLen = len; - sei_tmp.lpParameters = wszParameters; - } - } - - if (*sei_tmp.lpDirectory) - { - len = ExpandEnvironmentStringsW(sei_tmp.lpDirectory, NULL, 0); - if (len > 0) - { - LPWSTR buf; - len++; - buf = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR)); - ExpandEnvironmentStringsW(sei_tmp.lpDirectory, buf, len); - if (wszDir != dirBuffer) - HeapFree(GetProcessHeap(), 0, wszDir); - wszDir = buf; - sei_tmp.lpDirectory = wszDir; - } - } - - /* Else, try to execute the filename */ - TRACE("execute:%s,%s,%s\n", debugstr_w(wszApplicationName), debugstr_w(wszParameters), debugstr_w(wszDir)); - - /* separate out command line arguments from executable file name */ - if (!*sei_tmp.lpParameters && !appKnownSingular) { - /* If the executable path is quoted, handle the rest of the command line as parameters. */ - if (sei_tmp.lpFile[0] == '"') { - LPWSTR src = wszApplicationName/*sei_tmp.lpFile*/ + 1; - LPWSTR dst = wfileName; - LPWSTR end; - - /* copy the unquoted executable path to 'wfileName' */ - while(*src && *src!='"') - *dst++ = *src++; - - *dst = '\0'; - - if (*src == '"') { - end = ++src; - - while(isspace(*src)) - ++src; - } else - end = src; - - /* copy the parameter string to 'wszParameters' */ - strcpyW(wszParameters, src); - - /* terminate previous command string after the quote character */ - *end = '\0'; - } - else - { - /* If the executable name is not quoted, we have to use this search loop here, - that in CreateProcess() is not sufficient because it does not handle shell links. */ - WCHAR buffer[MAX_PATH], xlpFile[MAX_PATH]; - LPWSTR space, s; - - LPWSTR beg = wszApplicationName/*sei_tmp.lpFile*/; - for(s=beg; (space=strchrW(s, ' ')); s=space+1) { - int idx = space-sei_tmp.lpFile; - memcpy(buffer, sei_tmp.lpFile, idx * sizeof(WCHAR)); - buffer[idx] = '\0'; - - /*FIXME This finds directory paths if the targeted file name contains spaces. */ - if (SearchPathW(*sei_tmp.lpDirectory? sei_tmp.lpDirectory: NULL, buffer, wszExe, sizeof(xlpFile)/sizeof(xlpFile[0]), xlpFile, NULL)) - { - /* separate out command from parameter string */ - LPCWSTR p = space + 1; - - while(isspaceW(*p)) - ++p; - - strcpyW(wszParameters, p); - *space = '\0'; - - break; - } - } - - lstrcpynW(wfileName, sei_tmp.lpFile,sizeof(wfileName)/sizeof(WCHAR)); - } - } else - lstrcpynW(wfileName, sei_tmp.lpFile,sizeof(wfileName)/sizeof(WCHAR)); - - lpFile = wfileName; - - wcmd = wcmdBuffer; - len = lstrlenW(wszApplicationName) + 1; - if (sei_tmp.lpParameters[0]) - len += 1 + lstrlenW(wszParameters); - if (len > wcmdLen) - { - wcmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - wcmdLen = len; - } - strcpyW(wcmd, wszApplicationName); - if (sei_tmp.lpParameters[0]) { - strcatW(wcmd, wSpace); - strcatW(wcmd, wszParameters); - } - - retval = execfunc(wcmd, NULL, FALSE, &sei_tmp, sei); - if (retval > 32) { - HeapFree(GetProcessHeap(), 0, wszApplicationName); - if (wszParameters != parametersBuffer) - HeapFree(GetProcessHeap(), 0, wszParameters); - if (wszDir != dirBuffer) - HeapFree(GetProcessHeap(), 0, wszDir); - if (wcmd != wcmdBuffer) - HeapFree(GetProcessHeap(), 0, wcmd); - return TRUE; - } - - /* Else, try to find the executable */ - wcmd[0] = '\0'; - retval = SHELL_FindExecutable(sei_tmp.lpDirectory, lpFile, sei_tmp.lpVerb, wcmd, wcmdLen, lpstrProtocol, &env, sei_tmp.lpIDList, sei_tmp.lpParameters); - if (retval > 32) /* Found */ - { - retval = SHELL_quote_and_execute( wcmd, wszParameters, lpstrProtocol, - wszApplicationName, env, &sei_tmp, - sei, execfunc ); - HeapFree( GetProcessHeap(), 0, env ); - } - else if (PathIsDirectoryW(lpFile)) - { - static const WCHAR wExplorer[] = {'e','x','p','l','o','r','e','r',0}; - static const WCHAR wQuote[] = {'"',0}; - WCHAR wExec[MAX_PATH]; - WCHAR * lpQuotedFile = HeapAlloc( GetProcessHeap(), 0, sizeof(WCHAR) * (strlenW(lpFile) + 3) ); - - if (lpQuotedFile) - { - retval = SHELL_FindExecutable( sei_tmp.lpDirectory, wExplorer, - wszOpen, wExec, MAX_PATH, - NULL, &env, NULL, NULL ); - if (retval > 32) - { - strcpyW(lpQuotedFile, wQuote); - strcatW(lpQuotedFile, lpFile); - strcatW(lpQuotedFile, wQuote); - retval = SHELL_quote_and_execute( wExec, lpQuotedFile, - lpstrProtocol, - wszApplicationName, env, - &sei_tmp, sei, execfunc ); - HeapFree( GetProcessHeap(), 0, env ); - } - HeapFree( GetProcessHeap(), 0, lpQuotedFile ); - } - else - retval = 0; /* Out of memory */ - } - else if (PathIsURLW(lpFile)) /* File not found, check for URL */ - { - retval = SHELL_execute_url( lpFile, wFile, wcmd, &sei_tmp, sei, execfunc ); - } - /* Check if file specified is in the form www.??????.*** */ - else if (!strncmpiW(lpFile, wWww, 3)) - { - /* if so, append lpFile http:// and call ShellExecute */ - WCHAR lpstrTmpFile[256]; - strcpyW(lpstrTmpFile, wHttp); - strcatW(lpstrTmpFile, lpFile); - retval = (UINT_PTR)ShellExecuteW(sei_tmp.hwnd, sei_tmp.lpVerb, lpstrTmpFile, NULL, NULL, 0); - } - - TRACE("retval %lu\n", retval); - - if (retval <= 32 && !(sei_tmp.fMask & SEE_MASK_FLAG_NO_UI)) - { - OPENASINFO Info; - - //FIXME - // need full path - - Info.pcszFile = wszApplicationName; - Info.pcszClass = NULL; - Info.oaifInFlags = OAIF_ALLOW_REGISTRATION | OAIF_EXEC; - - //if (SHOpenWithDialog(sei_tmp.hwnd, &Info) != S_OK) - do_error_dialog(retval, sei_tmp.hwnd, wszApplicationName); - } - - HeapFree(GetProcessHeap(), 0, wszApplicationName); - if (wszParameters != parametersBuffer) - HeapFree(GetProcessHeap(), 0, wszParameters); - if (wszDir != dirBuffer) - HeapFree(GetProcessHeap(), 0, wszDir); - if (wcmd != wcmdBuffer) - HeapFree(GetProcessHeap(), 0, wcmd); - - sei->hInstApp = (HINSTANCE)(retval > 32 ? 33 : retval); - - return retval > 32; -} - -/************************************************************************* - * ShellExecuteA [SHELL32.290] - */ -HINSTANCE WINAPI ShellExecuteA(HWND hWnd, LPCSTR lpOperation,LPCSTR lpFile, - LPCSTR lpParameters,LPCSTR lpDirectory, INT iShowCmd) -{ - SHELLEXECUTEINFOA sei; - - TRACE("%p,%s,%s,%s,%s,%d\n", - hWnd, debugstr_a(lpOperation), debugstr_a(lpFile), - debugstr_a(lpParameters), debugstr_a(lpDirectory), iShowCmd); - - sei.cbSize = sizeof(sei); - sei.fMask = SEE_MASK_FLAG_NO_UI; - sei.hwnd = hWnd; - sei.lpVerb = lpOperation; - sei.lpFile = lpFile; - sei.lpParameters = lpParameters; - sei.lpDirectory = lpDirectory; - sei.nShow = iShowCmd; - sei.lpIDList = 0; - sei.lpClass = 0; - sei.hkeyClass = 0; - sei.dwHotKey = 0; - sei.hProcess = 0; - - ShellExecuteExA (&sei); - return sei.hInstApp; -} - -/************************************************************************* - * ShellExecuteExA [SHELL32.292] - * - */ -BOOL WINAPI ShellExecuteExA (LPSHELLEXECUTEINFOA sei) -{ - SHELLEXECUTEINFOW seiW; - BOOL ret; - WCHAR *wVerb = NULL, *wFile = NULL, *wParameters = NULL, *wDirectory = NULL, *wClass = NULL; - - TRACE("%p\n", sei); - - memcpy(&seiW, sei, sizeof(SHELLEXECUTEINFOW)); - - if (sei->lpVerb) - seiW.lpVerb = __SHCloneStrAtoW(&wVerb, sei->lpVerb); - - if (sei->lpFile) - seiW.lpFile = __SHCloneStrAtoW(&wFile, sei->lpFile); - - if (sei->lpParameters) - seiW.lpParameters = __SHCloneStrAtoW(&wParameters, sei->lpParameters); - - if (sei->lpDirectory) - seiW.lpDirectory = __SHCloneStrAtoW(&wDirectory, sei->lpDirectory); - - if ((sei->fMask & SEE_MASK_CLASSALL) == SEE_MASK_CLASSNAME && sei->lpClass) - seiW.lpClass = __SHCloneStrAtoW(&wClass, sei->lpClass); - else - seiW.lpClass = NULL; - - ret = SHELL_execute( &seiW, SHELL_ExecuteW ); - - sei->hInstApp = seiW.hInstApp; - - if (sei->fMask & SEE_MASK_NOCLOSEPROCESS) - sei->hProcess = seiW.hProcess; - - SHFree(wVerb); - SHFree(wFile); - SHFree(wParameters); - SHFree(wDirectory); - SHFree(wClass); - - return ret; -} - -/************************************************************************* - * ShellExecuteExW [SHELL32.293] - * - */ -BOOL WINAPI ShellExecuteExW (LPSHELLEXECUTEINFOW sei) -{ - return SHELL_execute( sei, SHELL_ExecuteW ); -} - -/************************************************************************* - * ShellExecuteW [SHELL32.294] - * from shellapi.h - * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation, - * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd); - */ -HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpOperation, LPCWSTR lpFile, - LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd) -{ - SHELLEXECUTEINFOW sei; - - TRACE("\n"); - sei.cbSize = sizeof(sei); - sei.fMask = SEE_MASK_FLAG_NO_UI; - sei.hwnd = hwnd; - sei.lpVerb = lpOperation; - sei.lpFile = lpFile; - sei.lpParameters = lpParameters; - sei.lpDirectory = lpDirectory; - sei.nShow = nShowCmd; - sei.lpIDList = 0; - sei.lpClass = 0; - sei.hkeyClass = 0; - sei.dwHotKey = 0; - sei.hProcess = 0; - - SHELL_execute( &sei, SHELL_ExecuteW ); - return sei.hInstApp; -} - -/************************************************************************* - * WOWShellExecute [SHELL32.@] - * - * FIXME: the callback function most likely doesn't work the same way on Windows. - */ -HINSTANCE WINAPI WOWShellExecute(HWND hWnd, LPCSTR lpOperation,LPCSTR lpFile, - LPCSTR lpParameters,LPCSTR lpDirectory, INT iShowCmd, void *callback) -{ - SHELLEXECUTEINFOW seiW; - WCHAR *wVerb = NULL, *wFile = NULL, *wParameters = NULL, *wDirectory = NULL; - HANDLE hProcess = 0; - - seiW.lpVerb = lpOperation ? __SHCloneStrAtoW(&wVerb, lpOperation) : NULL; - seiW.lpFile = lpFile ? __SHCloneStrAtoW(&wFile, lpFile) : NULL; - seiW.lpParameters = lpParameters ? __SHCloneStrAtoW(&wParameters, lpParameters) : NULL; - seiW.lpDirectory = lpDirectory ? __SHCloneStrAtoW(&wDirectory, lpDirectory) : NULL; - - seiW.cbSize = sizeof(seiW); - seiW.fMask = 0; - seiW.hwnd = hWnd; - seiW.nShow = iShowCmd; - seiW.lpIDList = 0; - seiW.lpClass = 0; - seiW.hkeyClass = 0; - seiW.dwHotKey = 0; - seiW.hProcess = hProcess; - - SHELL_execute( &seiW, callback ); - - SHFree(wVerb); - SHFree(wFile); - SHFree(wParameters); - SHFree(wDirectory); - return seiW.hInstApp; -} - -/************************************************************************* - * OpenAs_RunDLLA [SHELL32.@] - */ -void WINAPI OpenAs_RunDLLA(HWND hwnd, HINSTANCE hinst, LPCSTR cmdline, int cmdshow) -{ - FIXME("%p, %p, %s, %d\n", hwnd, hinst, debugstr_a(cmdline), cmdshow); -} - -/************************************************************************* - * OpenAs_RunDLLW [SHELL32.@] - */ -void WINAPI OpenAs_RunDLLW(HWND hwnd, HINSTANCE hinst, LPCWSTR cmdline, int cmdshow) -{ - FIXME("%p, %p, %s, %d\n", hwnd, hinst, debugstr_w(cmdline), cmdshow); -} diff --git a/reactos/dll/win32/shell32/shlfileop.c b/reactos/dll/win32/shell32/shlfileop.c deleted file mode 100644 index f22b7225a00..00000000000 --- a/reactos/dll/win32/shell32/shlfileop.c +++ /dev/null @@ -1,1881 +0,0 @@ -/* - * SHFileOperation - * - * Copyright 2000 Juergen Schmied - * Copyright 2002 Andriy Palamarchuk - * Copyright 2004 Dietrich Teickner (from Odin) - * Copyright 2004 Rolf Kalbermatter - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -//#define NO_SHLWAPI_STREAM -#include - - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -#define IsAttrib(x, y) ((INVALID_FILE_ATTRIBUTES != (x)) && ((x) & (y))) -#define IsAttribFile(x) (!((x) & FILE_ATTRIBUTE_DIRECTORY)) -#define IsAttribDir(x) IsAttrib(x, FILE_ATTRIBUTE_DIRECTORY) -#define IsDotDir(x) ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0)))) - -#define FO_MASK 0xF -#define WM_FILE (WM_USER + 1) -#define TIMER_ID (100) - -static const WCHAR wWildcardFile[] = {'*',0}; -static const WCHAR wWildcardChars[] = {'*','?',0}; - -static DWORD SHNotifyCreateDirectoryW(LPCWSTR path, LPSECURITY_ATTRIBUTES sec); -static DWORD SHNotifyRemoveDirectoryW(LPCWSTR path); -static DWORD SHNotifyDeleteFileW(LPCWSTR path); -static DWORD SHNotifyMoveFileW(LPCWSTR src, LPCWSTR dest); -static DWORD SHNotifyCopyFileW(LPCWSTR src, LPCWSTR dest, BOOL bFailIfExists); -static DWORD SHFindAttrW(LPCWSTR pName, BOOL fileOnly); - -typedef struct -{ - SHFILEOPSTRUCTW *req; - DWORD dwYesToAllMask; - BOOL bManyItems; - BOOL bCancelled; -} FILE_OPERATION; - -#define ERROR_SHELL_INTERNAL_FILE_NOT_FOUND 1026 - -typedef struct -{ - DWORD attributes; - LPWSTR szDirectory; - LPWSTR szFilename; - LPWSTR szFullPath; - BOOL bFromWildcard; - BOOL bFromRelative; - BOOL bExists; -} FILE_ENTRY; - -typedef struct -{ - FILE_ENTRY *feFiles; - DWORD num_alloc; - DWORD dwNumFiles; - BOOL bAnyFromWildcard; - BOOL bAnyDirectories; - BOOL bAnyDontExist; -} FILE_LIST; - -typedef struct -{ - FILE_LIST * from; - FILE_LIST * to; - FILE_OPERATION * op; - DWORD Index; - HWND hDlgCtrl; - HWND hwndDlg; -}FILE_OPERATION_CONTEXT; - - -/* Confirm dialogs with an optional "Yes To All" as used in file operations confirmations - */ -static const WCHAR CONFIRM_MSG_PROP[] = {'W','I','N','E','_','C','O','N','F','I','R','M',0}; - -struct confirm_msg_info -{ - LPWSTR lpszText; - LPWSTR lpszCaption; - HICON hIcon; - BOOL bYesToAll; -}; - -/* as some buttons may be hidden and the dialog height may change we may need - * to move the controls */ -static void confirm_msg_move_button(HWND hDlg, INT iId, INT *xPos, INT yOffset, BOOL bShow) -{ - HWND hButton = GetDlgItem(hDlg, iId); - RECT r; - - if (bShow) { - POINT pt; - int width; - - GetWindowRect(hButton, &r); - width = r.right - r.left; - pt.x = r.left; - pt.y = r.top; - ScreenToClient(hDlg, &pt); - MoveWindow(hButton, *xPos - width, pt.y - yOffset, width, r.bottom - r.top, FALSE); - *xPos -= width + 5; - } - else - ShowWindow(hButton, SW_HIDE); -} - -/* Note: we paint the text manually and don't use the static control to make - * sure the text has the same height as the one computed in WM_INITDIALOG - */ -static INT_PTR ConfirmMsgBox_Paint(HWND hDlg) -{ - PAINTSTRUCT ps; - HFONT hOldFont; - RECT r; - HDC hdc; - - BeginPaint(hDlg, &ps); - hdc = ps.hdc; - - GetClientRect(GetDlgItem(hDlg, IDD_MESSAGE), &r); - /* this will remap the rect to dialog coords */ - MapWindowPoints(GetDlgItem(hDlg, IDD_MESSAGE), hDlg, (LPPOINT)&r, 2); - hOldFont = SelectObject(hdc, (HFONT)SendDlgItemMessageW(hDlg, IDD_MESSAGE, WM_GETFONT, 0, 0)); - DrawTextW(hdc, GetPropW(hDlg, CONFIRM_MSG_PROP), -1, &r, DT_NOPREFIX | DT_PATH_ELLIPSIS | DT_WORDBREAK); - SelectObject(hdc, hOldFont); - EndPaint(hDlg, &ps); - return TRUE; -} - -static INT_PTR ConfirmMsgBox_Init(HWND hDlg, LPARAM lParam) -{ - struct confirm_msg_info *info = (struct confirm_msg_info *)lParam; - INT xPos, yOffset; - int width, height; - HFONT hOldFont; - HDC hdc; - RECT r; - - SetWindowTextW(hDlg, info->lpszCaption); - ShowWindow(GetDlgItem(hDlg, IDD_MESSAGE), SW_HIDE); - SetPropW(hDlg, CONFIRM_MSG_PROP, info->lpszText); - SendDlgItemMessageW(hDlg, IDD_ICON, STM_SETICON, (WPARAM)info->hIcon, 0); - - /* compute the text height and resize the dialog */ - GetClientRect(GetDlgItem(hDlg, IDD_MESSAGE), &r); - hdc = GetDC(hDlg); - yOffset = r.bottom; - hOldFont = SelectObject(hdc, (HFONT)SendDlgItemMessageW(hDlg, IDD_MESSAGE, WM_GETFONT, 0, 0)); - DrawTextW(hdc, info->lpszText, -1, &r, DT_NOPREFIX | DT_PATH_ELLIPSIS | DT_WORDBREAK | DT_CALCRECT); - SelectObject(hdc, hOldFont); - yOffset -= r.bottom; - yOffset = min(yOffset, 35); /* don't make the dialog too small */ - ReleaseDC(hDlg, hdc); - - GetClientRect(hDlg, &r); - xPos = r.right - 7; - GetWindowRect(hDlg, &r); - width = r.right - r.left; - height = r.bottom - r.top - yOffset; - MoveWindow(hDlg, (GetSystemMetrics(SM_CXSCREEN) - width)/2, - (GetSystemMetrics(SM_CYSCREEN) - height)/2, width, height, FALSE); - - confirm_msg_move_button(hDlg, IDCANCEL, &xPos, yOffset, info->bYesToAll); - confirm_msg_move_button(hDlg, IDNO, &xPos, yOffset, TRUE); - confirm_msg_move_button(hDlg, IDD_YESTOALL, &xPos, yOffset, info->bYesToAll); - confirm_msg_move_button(hDlg, IDYES, &xPos, yOffset, TRUE); - return TRUE; -} - -static INT_PTR CALLBACK ConfirmMsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch (uMsg) - { - case WM_INITDIALOG: - return ConfirmMsgBox_Init(hDlg, lParam); - case WM_PAINT: - return ConfirmMsgBox_Paint(hDlg); - case WM_COMMAND: - EndDialog(hDlg, wParam); - break; - case WM_CLOSE: - EndDialog(hDlg, IDCANCEL); - break; - } - return FALSE; -} - -int SHELL_ConfirmMsgBox(HWND hWnd, LPWSTR lpszText, LPWSTR lpszCaption, HICON hIcon, BOOL bYesToAll) -{ - static const WCHAR wszTemplate[] = {'S','H','E','L','L','_','Y','E','S','T','O','A','L','L','_','M','S','G','B','O','X',0}; - struct confirm_msg_info info; - - info.lpszText = lpszText; - info.lpszCaption = lpszCaption; - info.hIcon = hIcon; - info.bYesToAll = bYesToAll; - return DialogBoxParamW(shell32_hInstance, wszTemplate, hWnd, ConfirmMsgBoxProc, (LPARAM)&info); -} - -/* confirmation dialogs content */ -typedef struct -{ - HINSTANCE hIconInstance; - UINT icon_resource_id; - UINT caption_resource_id, text_resource_id; -} SHELL_ConfirmIDstruc; - -static BOOL SHELL_ConfirmIDs(int nKindOfDialog, SHELL_ConfirmIDstruc *ids) -{ - ids->hIconInstance = shell32_hInstance; - switch (nKindOfDialog) { - case ASK_DELETE_FILE: - ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE; - ids->caption_resource_id = IDS_DELETEITEM_CAPTION; - ids->text_resource_id = IDS_DELETEITEM_TEXT; - return TRUE; - case ASK_DELETE_FOLDER: - ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE; - ids->caption_resource_id = IDS_DELETEFOLDER_CAPTION; - ids->text_resource_id = IDS_DELETEITEM_TEXT; - return TRUE; - case ASK_DELETE_MULTIPLE_ITEM: - ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE; - ids->caption_resource_id = IDS_DELETEITEM_CAPTION; - ids->text_resource_id = IDS_DELETEMULTIPLE_TEXT; - return TRUE; - case ASK_TRASH_FILE: - ids->icon_resource_id = IDI_SHELL_TRASH_FILE; - ids->caption_resource_id = IDS_DELETEITEM_CAPTION; - ids->text_resource_id = IDS_TRASHITEM_TEXT; - return TRUE; - case ASK_TRASH_FOLDER: - ids->icon_resource_id = IDI_SHELL_TRASH_FILE; - ids->caption_resource_id = IDS_DELETEFOLDER_CAPTION; - ids->text_resource_id = IDS_TRASHFOLDER_TEXT; - return TRUE; - case ASK_TRASH_MULTIPLE_ITEM: - ids->icon_resource_id = IDI_SHELL_TRASH_FILE; - ids->caption_resource_id = IDS_DELETEITEM_CAPTION; - ids->text_resource_id = IDS_TRASHMULTIPLE_TEXT; - return TRUE; - case ASK_CANT_TRASH_ITEM: - ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE; - ids->caption_resource_id = IDS_DELETEITEM_CAPTION; - ids->text_resource_id = IDS_CANTTRASH_TEXT; - return TRUE; - case ASK_DELETE_SELECTED: - ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE; - ids->caption_resource_id = IDS_DELETEITEM_CAPTION; - ids->text_resource_id = IDS_DELETESELECTED_TEXT; - return TRUE; - case ASK_OVERWRITE_FILE: - ids->hIconInstance = NULL; - ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE; - ids->caption_resource_id = IDS_OVERWRITEFILE_CAPTION; - ids->text_resource_id = IDS_OVERWRITEFILE_TEXT; - return TRUE; - case ASK_OVERWRITE_FOLDER: - ids->hIconInstance = NULL; - ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE; - ids->caption_resource_id = IDS_OVERWRITEFILE_CAPTION; - ids->text_resource_id = IDS_OVERWRITEFOLDER_TEXT; - return TRUE; - default: - FIXME(" Unhandled nKindOfDialog %d stub\n", nKindOfDialog); - } - return FALSE; -} - -static BOOL SHELL_ConfirmDialogW(HWND hWnd, int nKindOfDialog, LPCWSTR szDir, FILE_OPERATION *op) -{ - WCHAR szCaption[255], szText[255], szBuffer[MAX_PATH + 256]; - SHELL_ConfirmIDstruc ids; - DWORD_PTR args[1]; - HICON hIcon; - int ret; - - assert(nKindOfDialog >= 0 && nKindOfDialog < 32); - if (op && (op->dwYesToAllMask & (1 << nKindOfDialog))) - return TRUE; - - if (!SHELL_ConfirmIDs(nKindOfDialog, &ids)) return FALSE; - - LoadStringW(shell32_hInstance, ids.caption_resource_id, szCaption, sizeof(szCaption)/sizeof(WCHAR)); - LoadStringW(shell32_hInstance, ids.text_resource_id, szText, sizeof(szText)/sizeof(WCHAR)); - - args[0] = (DWORD_PTR)szDir; - FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY, - szText, 0, 0, szBuffer, sizeof(szBuffer), (va_list*)args); - hIcon = LoadIconW(ids.hIconInstance, (LPWSTR)MAKEINTRESOURCE(ids.icon_resource_id)); - - ret = SHELL_ConfirmMsgBox(hWnd, szBuffer, szCaption, hIcon, op && op->bManyItems); - if (op) { - if (ret == IDD_YESTOALL) { - op->dwYesToAllMask |= (1 << nKindOfDialog); - ret = IDYES; - } - if (ret == IDCANCEL) - op->bCancelled = TRUE; - if (ret != IDYES) - op->req->fAnyOperationsAborted = TRUE; - } - return ret == IDYES; -} - -BOOL SHELL_ConfirmYesNoW(HWND hWnd, int nKindOfDialog, LPCWSTR szDir) -{ - return SHELL_ConfirmDialogW(hWnd, nKindOfDialog, szDir, NULL); -} - -static DWORD SHELL32_AnsiToUnicodeBuf(LPCSTR aPath, LPWSTR *wPath, DWORD minChars) -{ - DWORD len = MultiByteToWideChar(CP_ACP, 0, aPath, -1, NULL, 0); - - if (len < minChars) - len = minChars; - - *wPath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - if (*wPath) - { - MultiByteToWideChar(CP_ACP, 0, aPath, -1, *wPath, len); - return NO_ERROR; - } - return E_OUTOFMEMORY; -} - -static void SHELL32_FreeUnicodeBuf(LPWSTR wPath) -{ - HeapFree(GetProcessHeap(), 0, wPath); -} - -HRESULT WINAPI SHIsFileAvailableOffline(LPCWSTR path, LPDWORD status) -{ - FIXME("(%s, %p) stub\n", debugstr_w(path), status); - return E_FAIL; -} - -/************************************************************************** - * SHELL_DeleteDirectory() [internal] - * - * Asks for confirmation when bShowUI is true and deletes the directory and - * all its subdirectories and files if necessary. - */ -BOOL SHELL_DeleteDirectoryW(HWND hwnd, LPCWSTR pszDir, BOOL bShowUI) -{ - BOOL ret = TRUE; - HANDLE hFind; - WIN32_FIND_DATAW wfd; - WCHAR szTemp[MAX_PATH]; - - /* Make sure the directory exists before eventually prompting the user */ - PathCombineW(szTemp, pszDir, wWildcardFile); - hFind = FindFirstFileW(szTemp, &wfd); - if (hFind == INVALID_HANDLE_VALUE) - return FALSE; - - if (!bShowUI || (ret = SHELL_ConfirmDialogW(hwnd, ASK_DELETE_FOLDER, pszDir, NULL))) - { - do - { - if (IsDotDir(wfd.cFileName)) - continue; - PathCombineW(szTemp, pszDir, wfd.cFileName); - if (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes) - ret = SHELL_DeleteDirectoryW(hwnd, szTemp, FALSE); - else - ret = (SHNotifyDeleteFileW(szTemp) == ERROR_SUCCESS); - } while (ret && FindNextFileW(hFind, &wfd)); - } - FindClose(hFind); - if (ret) - ret = (SHNotifyRemoveDirectoryW(pszDir) == ERROR_SUCCESS); - return ret; -} - -/************************************************************************** - * Win32CreateDirectory [SHELL32.93] - * - * Creates a directory. Also triggers a change notify if one exists. - * - * PARAMS - * path [I] path to directory to create - * - * RETURNS - * TRUE if successful, FALSE otherwise - */ - -static DWORD SHNotifyCreateDirectoryW(LPCWSTR path, LPSECURITY_ATTRIBUTES sec) -{ - TRACE("(%s, %p)\n", debugstr_w(path), sec); - - if (CreateDirectoryW(path, sec)) - { - SHChangeNotify(SHCNE_MKDIR, SHCNF_PATHW, path, NULL); - return ERROR_SUCCESS; - } - return GetLastError(); -} - -/**********************************************************************/ - -BOOL WINAPI Win32CreateDirectoryW(LPCWSTR path, LPSECURITY_ATTRIBUTES sec) -{ - return (SHNotifyCreateDirectoryW(path, sec) == ERROR_SUCCESS); -} - -/************************************************************************ - * Win32RemoveDirectory [SHELL32.94] - * - * Deletes a directory. Also triggers a change notify if one exists. - * - * PARAMS - * path [I] path to directory to delete - * - * RETURNS - * TRUE if successful, FALSE otherwise - */ -static DWORD SHNotifyRemoveDirectoryW(LPCWSTR path) -{ - BOOL ret; - TRACE("(%s)\n", debugstr_w(path)); - - ret = RemoveDirectoryW(path); - if (!ret) - { - /* Directory may be write protected */ - DWORD dwAttr = GetFileAttributesW(path); - if (IsAttrib(dwAttr, FILE_ATTRIBUTE_READONLY)) - if (SetFileAttributesW(path, dwAttr & ~FILE_ATTRIBUTE_READONLY)) - ret = RemoveDirectoryW(path); - } - if (ret) - { - SHChangeNotify(SHCNE_RMDIR, SHCNF_PATHW, path, NULL); - return ERROR_SUCCESS; - } - return GetLastError(); -} - -/***********************************************************************/ - -BOOL WINAPI Win32RemoveDirectoryW(LPCWSTR path) -{ - return (SHNotifyRemoveDirectoryW(path) == ERROR_SUCCESS); -} - -/************************************************************************ - * Win32DeleteFile [SHELL32.164] - * - * Deletes a file. Also triggers a change notify if one exists. - * - * PARAMS - * path [I] path to file to delete - * - * RETURNS - * TRUE if successful, FALSE otherwise - */ -static DWORD SHNotifyDeleteFileW(LPCWSTR path) -{ - BOOL ret; - - TRACE("(%s)\n", debugstr_w(path)); - - ret = DeleteFileW(path); - if (!ret) - { - /* File may be write protected or a system file */ - DWORD dwAttr = GetFileAttributesW(path); - if (IsAttrib(dwAttr, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)) - if (SetFileAttributesW(path, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM))) - ret = DeleteFileW(path); - } - if (ret) - { - SHChangeNotify(SHCNE_DELETE, SHCNF_PATHW, path, NULL); - return ERROR_SUCCESS; - } - return GetLastError(); -} - -/***********************************************************************/ - -DWORD WINAPI Win32DeleteFileW(LPCWSTR path) -{ - return (SHNotifyDeleteFileW(path) == ERROR_SUCCESS); -} - -/************************************************************************ - * SHNotifyMoveFile [internal] - * - * Moves a file. Also triggers a change notify if one exists. - * - * PARAMS - * src [I] path to source file to move - * dest [I] path to target file to move to - * - * RETURNS - * ERORR_SUCCESS if successful - */ -static DWORD SHNotifyMoveFileW(LPCWSTR src, LPCWSTR dest) -{ - BOOL ret; - - TRACE("(%s %s)\n", debugstr_w(src), debugstr_w(dest)); - - ret = MoveFileExW(src, dest, MOVEFILE_REPLACE_EXISTING); - - /* MOVEFILE_REPLACE_EXISTING fails with dirs, so try MoveFile */ - if (!ret) - ret = MoveFileW(src, dest); - - if (!ret) - { - DWORD dwAttr; - - dwAttr = SHFindAttrW(dest, FALSE); - if (INVALID_FILE_ATTRIBUTES == dwAttr) - { - /* Source file may be write protected or a system file */ - dwAttr = GetFileAttributesW(src); - if (IsAttrib(dwAttr, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)) - if (SetFileAttributesW(src, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM))) - ret = MoveFileW(src, dest); - } - } - if (ret) - { - SHChangeNotify(SHCNE_RENAMEITEM, SHCNF_PATHW, src, dest); - return ERROR_SUCCESS; - } - return GetLastError(); -} - -static DWORD WINAPI SHOperationProgressRoutine(LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER StreamSize, LARGE_INTEGER StreamBytesTransferred, DWORD dwStreamNumber, DWORD dwCallbackReason, HANDLE hSourceFile, HANDLE hDestinationFile, LPVOID lpData) -{ - FILE_OPERATION_CONTEXT * Context; - LARGE_INTEGER Progress; - - /* get context */ - Context = (FILE_OPERATION_CONTEXT*)lpData; - - if (TotalBytesTransferred.QuadPart) - { - Progress.QuadPart = (TotalBytesTransferred.QuadPart * 100) / TotalFileSize.QuadPart; - } - else - { - Progress.QuadPart = 1; - } - - /* update progress bar */ - SendMessageW(Context->hDlgCtrl, PBM_SETPOS, (WPARAM)Progress.u.LowPart, 0); - - if (TotalBytesTransferred.QuadPart == TotalFileSize.QuadPart) - { - /* file was copied */ - Context->Index++; - PostMessageW(Context->hwndDlg, WM_FILE, 0, 0); - } - - return PROGRESS_CONTINUE; -} - -BOOL -QueueFile( - FILE_OPERATION_CONTEXT * Context) -{ - FILE_ENTRY * from, *to = NULL; - BOOL bRet = FALSE; - - if (Context->Index >= Context->from->dwNumFiles) - return FALSE; - - /* get current file */ - from = &Context->from->feFiles[Context->Index]; - - if (Context->op->req->wFunc != FO_DELETE) - to = &Context->to->feFiles[Context->Index]; - - /* update status */ - SendDlgItemMessageW(Context->hwndDlg, 14001, WM_SETTEXT, 0, (LPARAM)from->szFullPath); - - if (Context->op->req->wFunc == FO_COPY) - { - bRet = CopyFileExW(from->szFullPath, to->szFullPath, SHOperationProgressRoutine, (LPVOID)Context, &Context->op->bCancelled, 0); - } - else if (Context->op->req->wFunc == FO_MOVE) - { - //bRet = MoveFileWithProgressW(from->szFullPath, to->szFullPath, SHOperationProgressRoutine, (LPVOID)Context, MOVEFILE_COPY_ALLOWED); - } - else if (Context->op->req->wFunc == FO_DELETE) - { - bRet = DeleteFile(from->szFullPath); - } - - return bRet; -} - -static INT_PTR CALLBACK SHOperationDialog(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - FILE_OPERATION_CONTEXT * Context; - - Context = (FILE_OPERATION_CONTEXT*) GetWindowLongPtr(hwndDlg, DWLP_USER); - - switch(uMsg) - { - case WM_INITDIALOG: - SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG)lParam); - - /* get context */ - Context = (FILE_OPERATION_CONTEXT*)lParam; - - /* store progress bar handle */ - Context->hDlgCtrl = GetDlgItem(hwndDlg, 14000); - - /* store window handle */ - Context->hwndDlg = hwndDlg; - - /* set progress bar range */ - (void)SendMessageW(Context->hDlgCtrl, (UINT) PBM_SETRANGE, 0, MAKELPARAM(0, 100)); - - /* start file queueing */ - SetTimer(hwndDlg, TIMER_ID, 1000, NULL); - //QueueFile(Context); - - return TRUE; - - case WM_CLOSE: - Context->op->bCancelled = TRUE; - EndDialog(hwndDlg, Context->op->bCancelled); - return TRUE; - case WM_COMMAND: - if (LOWORD(wParam) == 14002) - { - Context->op->bCancelled = TRUE; - EndDialog(hwndDlg, Context->op->bCancelled); - return TRUE; - } - break; - case WM_TIMER: - if (wParam == TIMER_ID) - { - QueueFile(Context); - KillTimer(hwndDlg, TIMER_ID); - } - break; - case WM_FILE: - if (!QueueFile(Context)) - EndDialog(hwndDlg, Context->op->bCancelled); - default: - break; - } - return FALSE; -} - -HRESULT -SHShowFileOperationDialog(FILE_OPERATION *op, FILE_LIST *flFrom, FILE_LIST *flTo) -{ - HWND hwnd; - BOOL bRet; - MSG msg; - FILE_OPERATION_CONTEXT Context; - - Context.from = flFrom; - Context.to = flTo; - Context.op = op; - Context.Index = 0; - Context.op->bCancelled = FALSE; - - hwnd = CreateDialogParam(shell32_hInstance, MAKEINTRESOURCE(IDD_SH_FILE_COPY), NULL, SHOperationDialog, (LPARAM)&Context); - if (hwnd == NULL) - { - ERR("Failed to create dialog\n"); - return E_FAIL; - } - ShowWindow(hwnd, SW_SHOWNORMAL); - - while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0) - { - if (!IsWindow(hwnd) || !IsDialogMessage(hwnd, &msg)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - return NOERROR; -} - - -/************************************************************************ - * SHNotifyCopyFile [internal] - * - * Copies a file. Also triggers a change notify if one exists. - * - * PARAMS - * src [I] path to source file to move - * dest [I] path to target file to move to - * bFailIfExists [I] if TRUE, the target file will not be overwritten if - * a file with this name already exists - * - * RETURNS - * ERROR_SUCCESS if successful - */ -static DWORD SHNotifyCopyFileW(LPCWSTR src, LPCWSTR dest, BOOL bFailIfExists) -{ - BOOL ret; - DWORD attribs; - - TRACE("(%s %s %s)\n", debugstr_w(src), debugstr_w(dest), bFailIfExists ? "failIfExists" : ""); - - /* Destination file may already exist with read only attribute */ - attribs = GetFileAttributesW(dest); - if (IsAttrib(attribs, FILE_ATTRIBUTE_READONLY)) - SetFileAttributesW(dest, attribs & ~FILE_ATTRIBUTE_READONLY); - - ret = CopyFileW(src, dest, bFailIfExists); - if (ret) - { - SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, dest, NULL); - return ERROR_SUCCESS; - } - - return GetLastError(); -} - -/************************************************************************* - * SHCreateDirectory [SHELL32.165] - * - * This function creates a file system folder whose fully qualified path is - * given by path. If one or more of the intermediate folders do not exist, - * they will be created as well. - * - * PARAMS - * hWnd [I] - * path [I] path of directory to create - * - * RETURNS - * ERROR_SUCCESS or one of the following values: - * ERROR_BAD_PATHNAME if the path is relative - * ERROR_FILE_EXISTS when a file with that name exists - * ERROR_PATH_NOT_FOUND can't find the path, probably invalid - * ERROR_INVALID_NAME if the path contains invalid chars - * ERROR_ALREADY_EXISTS when the directory already exists - * ERROR_FILENAME_EXCED_RANGE if the filename was to long to process - * - * NOTES - * exported by ordinal - * Win9x exports ANSI - * WinNT/2000 exports Unicode - */ -DWORD WINAPI SHCreateDirectory(HWND hWnd, LPCWSTR path) -{ - return SHCreateDirectoryExW(hWnd, path, NULL); -} - -/************************************************************************* - * SHCreateDirectoryExA [SHELL32.@] - * - * This function creates a file system folder whose fully qualified path is - * given by path. If one or more of the intermediate folders do not exist, - * they will be created as well. - * - * PARAMS - * hWnd [I] - * path [I] path of directory to create - * sec [I] security attributes to use or NULL - * - * RETURNS - * ERROR_SUCCESS or one of the following values: - * ERROR_BAD_PATHNAME or ERROR_PATH_NOT_FOUND if the path is relative - * ERROR_INVALID_NAME if the path contains invalid chars - * ERROR_FILE_EXISTS when a file with that name exists - * ERROR_ALREADY_EXISTS when the directory already exists - * ERROR_FILENAME_EXCED_RANGE if the filename was to long to process - * - * FIXME: Not implemented yet; - * SHCreateDirectoryEx also verifies that the files in the directory will be visible - * if the path is a network path to deal with network drivers which might have a limited - * but unknown maximum path length. If not: - * - * If hWnd is set to a valid window handle, a message box is displayed warning - * the user that the files may not be accessible. If the user chooses not to - * proceed, the function returns ERROR_CANCELLED. - * - * If hWnd is set to NULL, no user interface is displayed and the function - * returns ERROR_CANCELLED. - */ -int WINAPI SHCreateDirectoryExA(HWND hWnd, LPCSTR path, LPSECURITY_ATTRIBUTES sec) -{ - LPWSTR wPath; - DWORD retCode; - - TRACE("(%s, %p)\n", debugstr_a(path), sec); - - retCode = SHELL32_AnsiToUnicodeBuf(path, &wPath, 0); - if (!retCode) - { - retCode = SHCreateDirectoryExW(hWnd, wPath, sec); - SHELL32_FreeUnicodeBuf(wPath); - } - return retCode; -} - -/************************************************************************* - * SHCreateDirectoryExW [SHELL32.@] - * - * See SHCreateDirectoryExA. - */ -int WINAPI SHCreateDirectoryExW(HWND hWnd, LPCWSTR path, LPSECURITY_ATTRIBUTES sec) -{ - int ret = ERROR_BAD_PATHNAME; - TRACE("(%p, %s, %p)\n", hWnd, debugstr_w(path), sec); - - if (PathIsRelativeW(path)) - { - SetLastError(ret); - } - else - { - ret = SHNotifyCreateDirectoryW(path, sec); - /* Refuse to work on certain error codes before trying to create directories recursively */ - if (ret != ERROR_SUCCESS && - ret != ERROR_FILE_EXISTS && - ret != ERROR_ALREADY_EXISTS && - ret != ERROR_FILENAME_EXCED_RANGE) - { - WCHAR *pEnd, *pSlash, szTemp[MAX_PATH + 1]; /* extra for PathAddBackslash() */ - - lstrcpynW(szTemp, path, MAX_PATH); - pEnd = PathAddBackslashW(szTemp); - pSlash = szTemp + 3; - - while (*pSlash) - { - while (*pSlash && *pSlash != '\\') pSlash++; - if (*pSlash) - { - *pSlash = 0; /* terminate path at separator */ - - ret = SHNotifyCreateDirectoryW(szTemp, pSlash + 1 == pEnd ? sec : NULL); - } - *pSlash++ = '\\'; /* put the separator back */ - } - } - - if (ret && hWnd && (ERROR_CANCELLED != ret)) - { - /* We failed and should show a dialog box */ - FIXME("Show system error message, creating path %s, failed with error %d\n", debugstr_w(path), ret); - ret = ERROR_CANCELLED; /* Error has been already presented to user (not really yet!) */ - } - } - return ret; -} - -/************************************************************************* - * SHFindAttrW [internal] - * - * Get the Attributes for a file or directory. The difference to GetAttributes() - * is that this function will also work for paths containing wildcard characters - * in its filename. - - * PARAMS - * path [I] path of directory or file to check - * fileOnly [I] TRUE if only files should be found - * - * RETURNS - * INVALID_FILE_ATTRIBUTES if the path does not exist, the actual attributes of - * the first file or directory found otherwise - */ -static DWORD SHFindAttrW(LPCWSTR pName, BOOL fileOnly) -{ - WIN32_FIND_DATAW wfd; - BOOL b_FileMask = fileOnly && (NULL != StrPBrkW(pName, wWildcardChars)); - DWORD dwAttr = INVALID_FILE_ATTRIBUTES; - HANDLE hFind = FindFirstFileW(pName, &wfd); - - TRACE("%s %d\n", debugstr_w(pName), fileOnly); - if (INVALID_HANDLE_VALUE != hFind) - { - do - { - if (b_FileMask && IsAttribDir(wfd.dwFileAttributes)) - continue; - dwAttr = wfd.dwFileAttributes; - break; - } - while (FindNextFileW(hFind, &wfd)); - FindClose(hFind); - } - return dwAttr; -} - -/************************************************************************* - * - * SHNameTranslate HelperFunction for SHFileOperationA - * - * Translates a list of 0 terminated ASCII strings into Unicode. If *wString - * is NULL, only the necessary size of the string is determined and returned, - * otherwise the ASCII strings are copied into it and the buffer is increased - * to point to the location after the final 0 termination char. - */ -static DWORD SHNameTranslate(LPWSTR* wString, LPCWSTR* pWToFrom, BOOL more) -{ - DWORD size = 0, aSize = 0; - LPCSTR aString = (LPCSTR)*pWToFrom; - - if (aString) - { - do - { - size = lstrlenA(aString) + 1; - aSize += size; - aString += size; - } while ((size != 1) && more); - /* The two sizes might be different in the case of multibyte chars */ - size = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*pWToFrom, aSize, *wString, 0); - if (*wString) /* only in the second loop */ - { - MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*pWToFrom, aSize, *wString, size); - *pWToFrom = *wString; - *wString += size; - } - } - return size; -} -/************************************************************************* - * SHFileOperationA [SHELL32.@] - * - * Function to copy, move, delete and create one or more files with optional - * user prompts. - * - * PARAMS - * lpFileOp [I/O] pointer to a structure containing all the necessary information - * - * RETURNS - * Success: ERROR_SUCCESS. - * Failure: ERROR_CANCELLED. - * - * NOTES - * exported by name - */ -int WINAPI SHFileOperationA(LPSHFILEOPSTRUCTA lpFileOp) -{ - SHFILEOPSTRUCTW nFileOp = *((LPSHFILEOPSTRUCTW)lpFileOp); - int retCode = 0; - DWORD size; - LPWSTR ForFree = NULL, /* we change wString in SHNameTranslate and can't use it for freeing */ - wString = NULL; /* we change this in SHNameTranslate */ - - TRACE("\n"); - if (FO_DELETE == (nFileOp.wFunc & FO_MASK)) - nFileOp.pTo = NULL; /* we need a NULL or a valid pointer for translation */ - if (!(nFileOp.fFlags & FOF_SIMPLEPROGRESS)) - nFileOp.lpszProgressTitle = NULL; /* we need a NULL or a valid pointer for translation */ - while (1) /* every loop calculate size, second translate also, if we have storage for this */ - { - size = SHNameTranslate(&wString, &nFileOp.lpszProgressTitle, FALSE); /* no loop */ - size += SHNameTranslate(&wString, &nFileOp.pFrom, TRUE); /* internal loop */ - size += SHNameTranslate(&wString, &nFileOp.pTo, TRUE); /* internal loop */ - - if (ForFree) - { - retCode = SHFileOperationW(&nFileOp); - HeapFree(GetProcessHeap(), 0, ForFree); /* we cannot use wString, it was changed */ - break; - } - else - { - wString = ForFree = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); - if (ForFree) continue; - retCode = ERROR_OUTOFMEMORY; - nFileOp.fAnyOperationsAborted = TRUE; - SetLastError(retCode); - return retCode; - } - } - - lpFileOp->hNameMappings = nFileOp.hNameMappings; - lpFileOp->fAnyOperationsAborted = nFileOp.fAnyOperationsAborted; - return retCode; -} - - - - -static void __inline grow_list(FILE_LIST *list) -{ - FILE_ENTRY *new = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, list->feFiles, - list->num_alloc * 2 * sizeof(*new) ); - list->feFiles = new; - list->num_alloc *= 2; -} - -/* adds a file to the FILE_ENTRY struct - */ -static void add_file_to_entry(FILE_ENTRY *feFile, LPCWSTR szFile) -{ - DWORD dwLen = lstrlenW(szFile) + 1; - LPCWSTR ptr; - - feFile->szFullPath = HeapAlloc(GetProcessHeap(), 0, dwLen * sizeof(WCHAR)); - lstrcpyW(feFile->szFullPath, szFile); - - ptr = StrRChrW(szFile, NULL, '\\'); - if (ptr) - { - dwLen = ptr - szFile + 1; - feFile->szDirectory = HeapAlloc(GetProcessHeap(), 0, dwLen * sizeof(WCHAR)); - lstrcpynW(feFile->szDirectory, szFile, dwLen); - - dwLen = lstrlenW(feFile->szFullPath) - dwLen + 1; - feFile->szFilename = HeapAlloc(GetProcessHeap(), 0, dwLen * sizeof(WCHAR)); - lstrcpyW(feFile->szFilename, ptr + 1); /* skip over backslash */ - } - feFile->bFromWildcard = FALSE; -} - -static LPWSTR wildcard_to_file(LPCWSTR szWildCard, LPCWSTR szFileName) -{ - LPCWSTR ptr; - LPWSTR szFullPath; - DWORD dwDirLen, dwFullLen; - - ptr = StrRChrW(szWildCard, NULL, '\\'); - dwDirLen = ptr - szWildCard + 1; - - dwFullLen = dwDirLen + lstrlenW(szFileName) + 1; - szFullPath = HeapAlloc(GetProcessHeap(), 0, dwFullLen * sizeof(WCHAR)); - - lstrcpynW(szFullPath, szWildCard, dwDirLen + 1); - lstrcatW(szFullPath, szFileName); - - return szFullPath; -} - -static void parse_wildcard_files(FILE_LIST *flList, LPCWSTR szFile, LPDWORD pdwListIndex) -{ - WIN32_FIND_DATAW wfd; - HANDLE hFile = FindFirstFileW(szFile, &wfd); - FILE_ENTRY *file; - LPWSTR szFullPath; - BOOL res; - - if (hFile == INVALID_HANDLE_VALUE) return; - - for (res = TRUE; res; res = FindNextFileW(hFile, &wfd)) - { - if (IsDotDir(wfd.cFileName)) continue; - if (*pdwListIndex >= flList->num_alloc) grow_list( flList ); - szFullPath = wildcard_to_file(szFile, wfd.cFileName); - file = &flList->feFiles[(*pdwListIndex)++]; - add_file_to_entry(file, szFullPath); - file->bFromWildcard = TRUE; - file->attributes = wfd.dwFileAttributes; - if (IsAttribDir(file->attributes)) flList->bAnyDirectories = TRUE; - HeapFree(GetProcessHeap(), 0, szFullPath); - } - - FindClose(hFile); -} - -/* takes the null-separated file list and fills out the FILE_LIST */ -static HRESULT parse_file_list(FILE_LIST *flList, LPCWSTR szFiles) -{ - LPCWSTR ptr = szFiles; - WCHAR szCurFile[MAX_PATH]; - DWORD i = 0; - - if (!szFiles) - return ERROR_INVALID_PARAMETER; - - flList->bAnyFromWildcard = FALSE; - flList->bAnyDirectories = FALSE; - flList->bAnyDontExist = FALSE; - flList->num_alloc = 32; - flList->dwNumFiles = 0; - - /* empty list */ - if (!szFiles[0]) - return ERROR_ACCESS_DENIED; - - flList->feFiles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - flList->num_alloc * sizeof(FILE_ENTRY)); - - while (*ptr) - { - if (i >= flList->num_alloc) grow_list( flList ); - - /* change relative to absolute path */ - if (PathIsRelativeW(ptr)) - { - GetCurrentDirectoryW(MAX_PATH, szCurFile); - PathCombineW(szCurFile, szCurFile, ptr); - flList->feFiles[i].bFromRelative = TRUE; - } - else - { - lstrcpyW(szCurFile, ptr); - flList->feFiles[i].bFromRelative = FALSE; - } - - /* parse wildcard files if they are in the filename */ - if (StrPBrkW(szCurFile, wWildcardChars)) - { - parse_wildcard_files(flList, szCurFile, &i); - flList->bAnyFromWildcard = TRUE; - i--; - } - else - { - FILE_ENTRY *file = &flList->feFiles[i]; - add_file_to_entry(file, szCurFile); - file->attributes = GetFileAttributesW( file->szFullPath ); - file->bExists = (file->attributes != INVALID_FILE_ATTRIBUTES); - if (!file->bExists) flList->bAnyDontExist = TRUE; - if (IsAttribDir(file->attributes)) flList->bAnyDirectories = TRUE; - } - - /* advance to the next string */ - ptr += lstrlenW(ptr) + 1; - i++; - } - flList->dwNumFiles = i; - - return S_OK; -} - -/* free the FILE_LIST */ -static void destroy_file_list(FILE_LIST *flList) -{ - DWORD i; - - if (!flList || !flList->feFiles) - return; - - for (i = 0; i < flList->dwNumFiles; i++) - { - HeapFree(GetProcessHeap(), 0, flList->feFiles[i].szDirectory); - HeapFree(GetProcessHeap(), 0, flList->feFiles[i].szFilename); - HeapFree(GetProcessHeap(), 0, flList->feFiles[i].szFullPath); - } - - HeapFree(GetProcessHeap(), 0, flList->feFiles); -} - -static void copy_dir_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, LPCWSTR szDestPath) -{ - WCHAR szFrom[MAX_PATH], szTo[MAX_PATH]; - SHFILEOPSTRUCTW fileOp; - - static const WCHAR wildCardFiles[] = {'*','.','*',0}; - - if (IsDotDir(feFrom->szFilename)) - return; - - if (PathFileExistsW(szDestPath)) - PathCombineW(szTo, szDestPath, feFrom->szFilename); - else - lstrcpyW(szTo, szDestPath); - - if (!(op->req->fFlags & FOF_NOCONFIRMATION) && PathFileExistsW(szTo)) { - if (!SHELL_ConfirmDialogW(op->req->hwnd, ASK_OVERWRITE_FOLDER, feFrom->szFilename, op)) - { - /* Vista returns an ERROR_CANCELLED even if user pressed "No" */ - if (!op->bManyItems) - op->bCancelled = TRUE; - return; - } - } - - szTo[lstrlenW(szTo) + 1] = '\0'; - SHNotifyCreateDirectoryW(szTo, NULL); - - PathCombineW(szFrom, feFrom->szFullPath, wildCardFiles); - szFrom[lstrlenW(szFrom) + 1] = '\0'; - - fileOp = *op->req; - fileOp.pFrom = szFrom; - fileOp.pTo = szTo; - fileOp.fFlags &= ~FOF_MULTIDESTFILES; /* we know we're copying to one dir */ - - /* Don't ask the user about overwriting files when he accepted to overwrite the - folder. FIXME: this is not exactly what Windows does - e.g. there would be - an additional confirmation for a nested folder */ - fileOp.fFlags |= FOF_NOCONFIRMATION; - - SHFileOperationW(&fileOp); -} - -static BOOL copy_file_to_file(FILE_OPERATION *op, const WCHAR *szFrom, const WCHAR *szTo) -{ - if (!(op->req->fFlags & FOF_NOCONFIRMATION) && PathFileExistsW(szTo)) - { - if (!SHELL_ConfirmDialogW(op->req->hwnd, ASK_OVERWRITE_FILE, PathFindFileNameW(szTo), op)) - return 0; - } - - return SHNotifyCopyFileW(szFrom, szTo, FALSE) == 0; -} - -/* copy a file or directory to another directory */ -static void copy_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, const FILE_ENTRY *feTo) -{ - if (!PathFileExistsW(feTo->szFullPath)) - SHNotifyCreateDirectoryW(feTo->szFullPath, NULL); - - if (IsAttribFile(feFrom->attributes)) - { - WCHAR szDestPath[MAX_PATH]; - - PathCombineW(szDestPath, feTo->szFullPath, feFrom->szFilename); - copy_file_to_file(op, feFrom->szFullPath, szDestPath); - } - else if (!(op->req->fFlags & FOF_FILESONLY && feFrom->bFromWildcard)) - copy_dir_to_dir(op, feFrom, feTo->szFullPath); -} - -static void create_dest_dirs(LPCWSTR szDestDir) -{ - WCHAR dir[MAX_PATH]; - LPCWSTR ptr = StrChrW(szDestDir, '\\'); - - /* make sure all directories up to last one are created */ - while (ptr && (ptr = StrChrW(ptr + 1, '\\'))) - { - lstrcpynW(dir, szDestDir, ptr - szDestDir + 1); - - if (!PathFileExistsW(dir)) - SHNotifyCreateDirectoryW(dir, NULL); - } - - /* create last directory */ - if (!PathFileExistsW(szDestDir)) - SHNotifyCreateDirectoryW(szDestDir, NULL); -} - -/* the FO_COPY operation */ -static HRESULT copy_files(FILE_OPERATION *op, const FILE_LIST *flFrom, FILE_LIST *flTo) -{ - DWORD i; - const FILE_ENTRY *entryToCopy; - const FILE_ENTRY *fileDest = &flTo->feFiles[0]; - - if (flFrom->bAnyDontExist) - return ERROR_SHELL_INTERNAL_FILE_NOT_FOUND; - - if (flTo->dwNumFiles == 0) - { - /* If the destination is empty, SHFileOperation should use the current directory */ - WCHAR curdir[MAX_PATH+1]; - - GetCurrentDirectoryW(MAX_PATH, curdir); - curdir[lstrlenW(curdir)+1] = 0; - - destroy_file_list(flTo); - ZeroMemory(flTo, sizeof(FILE_LIST)); - parse_file_list(flTo, curdir); - fileDest = &flTo->feFiles[0]; - } - - if (op->req->fFlags & FOF_MULTIDESTFILES) - { - if (flFrom->bAnyFromWildcard) - return ERROR_CANCELLED; - - if (flFrom->dwNumFiles != flTo->dwNumFiles) - { - if (flFrom->dwNumFiles != 1 && !IsAttribDir(fileDest->attributes)) - return ERROR_CANCELLED; - - /* Free all but the first entry. */ - for (i = 1; i < flTo->dwNumFiles; i++) - { - HeapFree(GetProcessHeap(), 0, flTo->feFiles[i].szDirectory); - HeapFree(GetProcessHeap(), 0, flTo->feFiles[i].szFilename); - HeapFree(GetProcessHeap(), 0, flTo->feFiles[i].szFullPath); - } - - flTo->dwNumFiles = 1; - } - else if (IsAttribDir(fileDest->attributes)) - { - for (i = 1; i < flTo->dwNumFiles; i++) - if (!IsAttribDir(flTo->feFiles[i].attributes) || - !IsAttribDir(flFrom->feFiles[i].attributes)) - { - return ERROR_CANCELLED; - } - } - } - else if (flFrom->dwNumFiles != 1) - { - if (flTo->dwNumFiles != 1 && !IsAttribDir(fileDest->attributes)) - return ERROR_CANCELLED; - - if (PathFileExistsW(fileDest->szFullPath) && - IsAttribFile(fileDest->attributes)) - { - return ERROR_CANCELLED; - } - - if (flTo->dwNumFiles == 1 && fileDest->bFromRelative && - !PathFileExistsW(fileDest->szFullPath)) - { - return ERROR_CANCELLED; - } - } - - for (i = 0; i < flFrom->dwNumFiles; i++) - { - entryToCopy = &flFrom->feFiles[i]; - - if ((op->req->fFlags & FOF_MULTIDESTFILES) && - flTo->dwNumFiles > 1) - { - fileDest = &flTo->feFiles[i]; - } - - if (IsAttribDir(entryToCopy->attributes) && - !lstrcmpiW(entryToCopy->szFullPath, fileDest->szDirectory)) - { - return ERROR_SUCCESS; - } - - create_dest_dirs(fileDest->szDirectory); - - if (!lstrcmpiW(entryToCopy->szFullPath, fileDest->szFullPath)) - { - if (IsAttribFile(entryToCopy->attributes)) - return ERROR_NO_MORE_SEARCH_HANDLES; - else - return ERROR_SUCCESS; - } - - if ((flFrom->dwNumFiles > 1 && flTo->dwNumFiles == 1) || - IsAttribDir(fileDest->attributes)) - { - copy_to_dir(op, entryToCopy, fileDest); - } - else if (IsAttribDir(entryToCopy->attributes)) - { - copy_dir_to_dir(op, entryToCopy, fileDest->szFullPath); - } - else - { - if (!copy_file_to_file(op, entryToCopy->szFullPath, fileDest->szFullPath)) - { - op->req->fAnyOperationsAborted = TRUE; - return ERROR_CANCELLED; - } - } - - /* Vista return code. XP would return e.g. ERROR_FILE_NOT_FOUND, ERROR_ALREADY_EXISTS */ - if (op->bCancelled) - return ERROR_CANCELLED; - } - - /* Vista return code. On XP if the used pressed "No" for the last item, - * ERROR_ARENA_TRASHED would be returned */ - return ERROR_SUCCESS; -} - -static BOOL confirm_delete_list(HWND hWnd, DWORD fFlags, BOOL fTrash, const FILE_LIST *flFrom) -{ - if (flFrom->dwNumFiles > 1) - { - WCHAR tmp[8]; - const WCHAR format[] = {'%','d',0}; - - wnsprintfW(tmp, sizeof(tmp)/sizeof(tmp[0]), format, flFrom->dwNumFiles); - return SHELL_ConfirmDialogW(hWnd, (fTrash?ASK_TRASH_MULTIPLE_ITEM:ASK_DELETE_MULTIPLE_ITEM), tmp, NULL); - } - else - { - const FILE_ENTRY *fileEntry = &flFrom->feFiles[0]; - - if (IsAttribFile(fileEntry->attributes)) - return SHELL_ConfirmDialogW(hWnd, (fTrash?ASK_TRASH_FILE:ASK_DELETE_FILE), fileEntry->szFullPath, NULL); - else if (!(fFlags & FOF_FILESONLY && fileEntry->bFromWildcard)) - return SHELL_ConfirmDialogW(hWnd, (fTrash?ASK_TRASH_FOLDER:ASK_DELETE_FOLDER), fileEntry->szFullPath, NULL); - } - return TRUE; -} - -/* the FO_DELETE operation */ -static HRESULT delete_files(LPSHFILEOPSTRUCTW lpFileOp, const FILE_LIST *flFrom) -{ - const FILE_ENTRY *fileEntry; - DWORD i; - BOOL bPathExists; - BOOL bTrash; - - if (!flFrom->dwNumFiles) - return ERROR_SUCCESS; - - /* Windows also checks only the first item */ - bTrash = (lpFileOp->fFlags & FOF_ALLOWUNDO) - && TRASH_CanTrashFile(flFrom->feFiles[0].szFullPath); - - if (!(lpFileOp->fFlags & FOF_NOCONFIRMATION) || (!bTrash && lpFileOp->fFlags & FOF_WANTNUKEWARNING)) - if (!confirm_delete_list(lpFileOp->hwnd, lpFileOp->fFlags, bTrash, flFrom)) - { - lpFileOp->fAnyOperationsAborted = TRUE; - return 0; - } - - for (i = 0; i < flFrom->dwNumFiles; i++) - { - bPathExists = TRUE; - fileEntry = &flFrom->feFiles[i]; - - if (!IsAttribFile(fileEntry->attributes) && - (lpFileOp->fFlags & FOF_FILESONLY && fileEntry->bFromWildcard)) - continue; - - if (bTrash) - { - BOOL bDelete; - if (TRASH_TrashFile(fileEntry->szFullPath)) - continue; - - /* Note: Windows silently deletes the file in such a situation, we show a dialog */ - if (!(lpFileOp->fFlags & FOF_NOCONFIRMATION) || (lpFileOp->fFlags & FOF_WANTNUKEWARNING)) - bDelete = SHELL_ConfirmDialogW(lpFileOp->hwnd, ASK_CANT_TRASH_ITEM, fileEntry->szFullPath, NULL); - else - bDelete = TRUE; - - if (!bDelete) - { - lpFileOp->fAnyOperationsAborted = TRUE; - break; - } - } - - /* delete the file or directory */ - if (IsAttribFile(fileEntry->attributes)) - bPathExists = DeleteFileW(fileEntry->szFullPath); - else - bPathExists = SHELL_DeleteDirectoryW(lpFileOp->hwnd, fileEntry->szFullPath, FALSE); - - if (!bPathExists) - return ERROR_PATH_NOT_FOUND; - } - - return ERROR_SUCCESS; -} - -static void move_dir_to_dir(LPSHFILEOPSTRUCTW lpFileOp, const FILE_ENTRY *feFrom, LPCWSTR szDestPath) -{ - WCHAR szFrom[MAX_PATH], szTo[MAX_PATH]; - SHFILEOPSTRUCTW fileOp; - - static const WCHAR wildCardFiles[] = {'*','.','*',0}; - - if (IsDotDir(feFrom->szFilename)) - return; - - SHNotifyCreateDirectoryW(szDestPath, NULL); - - PathCombineW(szFrom, feFrom->szFullPath, wildCardFiles); - szFrom[lstrlenW(szFrom) + 1] = '\0'; - - lstrcpyW(szTo, szDestPath); - szTo[lstrlenW(szDestPath) + 1] = '\0'; - - fileOp = *lpFileOp; - fileOp.pFrom = szFrom; - fileOp.pTo = szTo; - - SHFileOperationW(&fileOp); -} - -/* moves a file or directory to another directory */ -static void move_to_dir(LPSHFILEOPSTRUCTW lpFileOp, const FILE_ENTRY *feFrom, const FILE_ENTRY *feTo) -{ - WCHAR szDestPath[MAX_PATH]; - - PathCombineW(szDestPath, feTo->szFullPath, feFrom->szFilename); - - if (IsAttribFile(feFrom->attributes)) - SHNotifyMoveFileW(feFrom->szFullPath, szDestPath); - else if (!(lpFileOp->fFlags & FOF_FILESONLY && feFrom->bFromWildcard)) - move_dir_to_dir(lpFileOp, feFrom, szDestPath); -} - -/* the FO_MOVE operation */ -static HRESULT move_files(LPSHFILEOPSTRUCTW lpFileOp, const FILE_LIST *flFrom, const FILE_LIST *flTo) -{ - DWORD i; - const FILE_ENTRY *entryToMove; - const FILE_ENTRY *fileDest; - - if (!flFrom->dwNumFiles || !flTo->dwNumFiles) - return ERROR_CANCELLED; - - if (!(lpFileOp->fFlags & FOF_MULTIDESTFILES) && - flTo->dwNumFiles > 1 && flFrom->dwNumFiles > 1) - { - return ERROR_CANCELLED; - } - - if (!(lpFileOp->fFlags & FOF_MULTIDESTFILES) && - !flFrom->bAnyDirectories && - flFrom->dwNumFiles > flTo->dwNumFiles) - { - return ERROR_CANCELLED; - } - - if (!PathFileExistsW(flTo->feFiles[0].szDirectory)) - return ERROR_CANCELLED; - - if ((lpFileOp->fFlags & FOF_MULTIDESTFILES) && - flFrom->dwNumFiles != flTo->dwNumFiles) - { - return ERROR_CANCELLED; - } - - fileDest = &flTo->feFiles[0]; - for (i = 0; i < flFrom->dwNumFiles; i++) - { - entryToMove = &flFrom->feFiles[i]; - - if (lpFileOp->fFlags & FOF_MULTIDESTFILES) - fileDest = &flTo->feFiles[i]; - - if (!PathFileExistsW(fileDest->szDirectory)) - return ERROR_CANCELLED; - - if (fileDest->bExists && IsAttribDir(fileDest->attributes)) - move_to_dir(lpFileOp, entryToMove, fileDest); - else - SHNotifyMoveFileW(entryToMove->szFullPath, fileDest->szFullPath); - } - - return ERROR_SUCCESS; -} - -/* the FO_RENAME files */ -static HRESULT rename_files(LPSHFILEOPSTRUCTW lpFileOp, const FILE_LIST *flFrom, const FILE_LIST *flTo) -{ - const FILE_ENTRY *feFrom; - const FILE_ENTRY *feTo; - - if (flFrom->dwNumFiles != 1) - return ERROR_GEN_FAILURE; - - if (flTo->dwNumFiles != 1) - return ERROR_CANCELLED; - - feFrom = &flFrom->feFiles[0]; - feTo= &flTo->feFiles[0]; - - /* fail if destination doesn't exist */ - if (!feFrom->bExists) - return ERROR_SHELL_INTERNAL_FILE_NOT_FOUND; - - /* fail if destination already exists */ - if (feTo->bExists) - return ERROR_ALREADY_EXISTS; - - return SHNotifyMoveFileW(feFrom->szFullPath, feTo->szFullPath); -} - -/* alert the user if an unsupported flag is used */ -static void check_flags(FILEOP_FLAGS fFlags) -{ - WORD wUnsupportedFlags = FOF_NO_CONNECTED_ELEMENTS | - FOF_NOCOPYSECURITYATTRIBS | FOF_NORECURSEREPARSE | - FOF_RENAMEONCOLLISION | FOF_WANTMAPPINGHANDLE; - - if (fFlags & wUnsupportedFlags) - FIXME("Unsupported flags: %04x\n", fFlags); -} - -/************************************************************************* - * SHFileOperationW [SHELL32.@] - * - * See SHFileOperationA - */ -int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) -{ - FILE_OPERATION op; - FILE_LIST flFrom, flTo; - int ret = 0; - - if (!lpFileOp) - return ERROR_INVALID_PARAMETER; - - check_flags(lpFileOp->fFlags); - - ZeroMemory(&flFrom, sizeof(FILE_LIST)); - ZeroMemory(&flTo, sizeof(FILE_LIST)); - - if ((ret = parse_file_list(&flFrom, lpFileOp->pFrom))) - return ret; - - if (lpFileOp->wFunc != FO_DELETE) - parse_file_list(&flTo, lpFileOp->pTo); - - ZeroMemory(&op, sizeof(op)); - op.req = lpFileOp; - op.bManyItems = (flFrom.dwNumFiles > 1); - - switch (lpFileOp->wFunc) - { - case FO_COPY: - ret = copy_files(&op, &flFrom, &flTo); - break; - case FO_DELETE: - ret = delete_files(lpFileOp, &flFrom); - break; - case FO_MOVE: - ret = move_files(lpFileOp, &flFrom, &flTo); - break; - case FO_RENAME: - ret = rename_files(lpFileOp, &flFrom, &flTo); - break; - default: - ret = ERROR_INVALID_PARAMETER; - break; - } - - destroy_file_list(&flFrom); - - if (lpFileOp->wFunc != FO_DELETE) - destroy_file_list(&flTo); - - if (ret == ERROR_CANCELLED) - lpFileOp->fAnyOperationsAborted = TRUE; - - return ret; -} - -#define SHDSA_GetItemCount(hdsa) (*(int*)(hdsa)) - -/************************************************************************* - * SHFreeNameMappings [shell32.246] - * - * Free the mapping handle returned by SHFileOperation if FOF_WANTSMAPPINGHANDLE - * was specified. - * - * PARAMS - * hNameMapping [I] handle to the name mappings used during renaming of files - * - * RETURNS - * Nothing - */ -void WINAPI SHFreeNameMappings(HANDLE hNameMapping) -{ - if (hNameMapping) - { - int i = SHDSA_GetItemCount((HDSA)hNameMapping) - 1; - - for (; i>= 0; i--) - { - LPSHNAMEMAPPINGW lp = DSA_GetItemPtr(hNameMapping, i); - - SHFree(lp->pszOldPath); - SHFree(lp->pszNewPath); - } - DSA_Destroy(hNameMapping); - } -} - -/************************************************************************* - * SheGetDirA [SHELL32.@] - * - * drive = 0: returns the current directory path - * drive > 0: returns the current directory path of the specified drive - * drive=1 -> A: drive=2 -> B: ... - * returns 0 if successful -*/ -DWORD WINAPI SheGetDirA(DWORD drive, LPSTR buffer) -{ - WCHAR org_path[MAX_PATH]; - DWORD ret; - char drv_path[3]; - - /* change current directory to the specified drive */ - if (drive) { - strcpy(drv_path, "A:"); - drv_path[0] += (char)drive-1; - - GetCurrentDirectoryW(MAX_PATH, org_path); - - SetCurrentDirectoryA(drv_path); - } - - /* query current directory path of the specified drive */ - ret = GetCurrentDirectoryA(MAX_PATH, buffer); - - /* back to the original drive */ - if (drive) - SetCurrentDirectoryW(org_path); - - if (!ret) - return GetLastError(); - - return 0; -} - -/************************************************************************* - * SheGetDirW [SHELL32.@] - * - * drive = 0: returns the current directory path - * drive > 0: returns the current directory path of the specified drive - * drive=1 -> A: drive=2 -> B: ... - * returns 0 if successful - */ -DWORD WINAPI SheGetDirW(DWORD drive, LPWSTR buffer) -{ - WCHAR org_path[MAX_PATH]; - DWORD ret; - char drv_path[3]; - - /* change current directory to the specified drive */ - if (drive) { - strcpy(drv_path, "A:"); - drv_path[0] += (char)drive-1; - - GetCurrentDirectoryW(MAX_PATH, org_path); - - SetCurrentDirectoryA(drv_path); - } - - /* query current directory path of the specified drive */ - ret = GetCurrentDirectoryW(MAX_PATH, buffer); - - /* back to the original drive */ - if (drive) - SetCurrentDirectoryW(org_path); - - if (!ret) - return GetLastError(); - - return 0; -} - -/************************************************************************* - * SheChangeDirA [SHELL32.@] - * - * changes the current directory to the specified path - * and returns 0 if successful - */ -DWORD WINAPI SheChangeDirA(LPSTR path) -{ - if (SetCurrentDirectoryA(path)) - return 0; - else - return GetLastError(); -} - -/************************************************************************* - * SheChangeDirW [SHELL32.@] - * - * changes the current directory to the specified path - * and returns 0 if successful - */ -DWORD WINAPI SheChangeDirW(LPWSTR path) -{ - if (SetCurrentDirectoryW(path)) - return 0; - else - return GetLastError(); -} - -/************************************************************************* - * IsNetDrive [SHELL32.66] - */ -BOOL WINAPI IsNetDrive(DWORD drive) -{ - char root[4]; - strcpy(root, "A:\\"); - root[0] += (char)drive; - return (GetDriveTypeA(root) == DRIVE_REMOTE); -} - - -/************************************************************************* - * RealDriveType [SHELL32.524] - */ -INT WINAPI RealDriveType(INT drive, BOOL bQueryNet) -{ - char root[] = "A:\\"; - root[0] += (char)drive; - return GetDriveTypeA(root); -} - -/*********************************************************************** - * SHPathPrepareForWriteW (SHELL32.@) - */ -HRESULT WINAPI SHPathPrepareForWriteW(HWND hwnd, IUnknown *modless, LPCWSTR path, DWORD flags) -{ - HRESULT res; - DWORD err; - LPCWSTR realpath; - int len; - WCHAR* last_slash; - WCHAR* temppath=NULL; - - TRACE("%p %p %s 0x%80x\n", hwnd, modless, debugstr_w(path), flags); - - if (flags & ~(SHPPFW_DIRCREATE|SHPPFW_ASKDIRCREATE|SHPPFW_IGNOREFILENAME)) - FIXME("unimplemented flags 0x%08x\n", flags); - - /* cut off filename if necessary */ - if (flags & SHPPFW_IGNOREFILENAME) - { - last_slash = StrRChrW(path, NULL, '\\'); - if (last_slash == NULL) - len = 1; - else - len = last_slash - path + 1; - temppath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - if (!temppath) - return E_OUTOFMEMORY; - StrCpyNW(temppath, path, len); - realpath = temppath; - } - else - { - realpath = path; - } - - /* try to create the directory if asked to */ - if (flags & (SHPPFW_DIRCREATE|SHPPFW_ASKDIRCREATE)) - { - if (flags & SHPPFW_ASKDIRCREATE) - FIXME("treating SHPPFW_ASKDIRCREATE as SHPPFW_DIRCREATE\n"); - - SHCreateDirectoryExW(0, realpath, NULL); - } - - /* check if we can access the directory */ - res = GetFileAttributesW(realpath); - - HeapFree(GetProcessHeap(), 0, temppath); - - if (res == INVALID_FILE_ATTRIBUTES) - { - err = GetLastError(); - if (err == ERROR_FILE_NOT_FOUND) - return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND); - return HRESULT_FROM_WIN32(err); - } - else if (res & FILE_ATTRIBUTE_DIRECTORY) - return S_OK; - else - return HRESULT_FROM_WIN32(ERROR_DIRECTORY); -} - -/*********************************************************************** - * SHPathPrepareForWriteA (SHELL32.@) - */ -HRESULT WINAPI SHPathPrepareForWriteA(HWND hwnd, IUnknown *modless, LPCSTR path, DWORD flags) -{ - WCHAR wpath[MAX_PATH]; - MultiByteToWideChar( CP_ACP, 0, path, -1, wpath, MAX_PATH); - return SHPathPrepareForWriteW(hwnd, modless, wpath, flags); -} diff --git a/reactos/dll/win32/shell32/shlfolder.c b/reactos/dll/win32/shell32/shlfolder.c deleted file mode 100644 index f9d5c1eea5e..00000000000 --- a/reactos/dll/win32/shell32/shlfolder.c +++ /dev/null @@ -1,564 +0,0 @@ -/* - * Shell Folder stuff - * - * Copyright 1997 Marcus Meissner - * Copyright 1998, 1999, 2002 Juergen Schmied - * - * IShellFolder2 and related interfaces - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL (shell); - -static const WCHAR wszDotShellClassInfo[] = { - '.','S','h','e','l','l','C','l','a','s','s','I','n','f','o',0}; - -/*************************************************************************** - * SHELL32_GetCustomFolderAttribute (internal function) - * - * Gets a value from the folder's desktop.ini file, if one exists. - * - * PARAMETERS - * pidl [I] Folder containing the desktop.ini file. - * pwszHeading [I] Heading in .ini file. - * pwszAttribute [I] Attribute in .ini file. - * pwszValue [O] Buffer to store value into. - * cchValue [I] Size in characters including NULL of buffer pointed to - * by pwszValue. - * - * RETURNS - * TRUE if returned non-NULL value. - * FALSE otherwise. - */ -static BOOL __inline SHELL32_GetCustomFolderAttributeFromPath( - LPWSTR pwszFolderPath, LPCWSTR pwszHeading, LPCWSTR pwszAttribute, - LPWSTR pwszValue, DWORD cchValue) -{ - static const WCHAR wszDesktopIni[] = - {'d','e','s','k','t','o','p','.','i','n','i',0}; - static const WCHAR wszDefault[] = {0}; - - PathAddBackslashW(pwszFolderPath); - PathAppendW(pwszFolderPath, wszDesktopIni); - return GetPrivateProfileStringW(pwszHeading, pwszAttribute, wszDefault, - pwszValue, cchValue, pwszFolderPath); -} - -BOOL SHELL32_GetCustomFolderAttribute( - LPCITEMIDLIST pidl, LPCWSTR pwszHeading, LPCWSTR pwszAttribute, - LPWSTR pwszValue, DWORD cchValue) -{ - DWORD dwAttrib = FILE_ATTRIBUTE_SYSTEM; - WCHAR wszFolderPath[MAX_PATH]; - - /* Hack around not having system attribute on non-Windows file systems */ - if (0) - dwAttrib = _ILGetFileAttributes(pidl, NULL, 0); - - if (dwAttrib & FILE_ATTRIBUTE_SYSTEM) - { - if (!SHGetPathFromIDListW(pidl, wszFolderPath)) - return FALSE; - - return SHELL32_GetCustomFolderAttributeFromPath(wszFolderPath, pwszHeading, - pwszAttribute, pwszValue, cchValue); - } - return FALSE; -} - -/*************************************************************************** - * GetNextElement (internal function) - * - * Gets a part of a string till the first backslash. - * - * PARAMETERS - * pszNext [IN] string to get the element from - * pszOut [IN] pointer to buffer which receives string - * dwOut [IN] length of pszOut - * - * RETURNS - * LPSTR pointer to first, not yet parsed char - */ - -LPCWSTR GetNextElementW (LPCWSTR pszNext, LPWSTR pszOut, DWORD dwOut) -{ - LPCWSTR pszTail = pszNext; - DWORD dwCopy; - - TRACE ("(%s %p 0x%08x)\n", debugstr_w (pszNext), pszOut, dwOut); - - *pszOut = 0x0000; - - if (!pszNext || !*pszNext) - return NULL; - - while (*pszTail && (*pszTail != (WCHAR) '\\')) - pszTail++; - - dwCopy = pszTail - pszNext + 1; - lstrcpynW (pszOut, pszNext, (dwOut < dwCopy) ? dwOut : dwCopy); - - if (*pszTail) - pszTail++; - else - pszTail = NULL; - - TRACE ("--(%s %s 0x%08x %p)\n", debugstr_w (pszNext), debugstr_w (pszOut), dwOut, pszTail); - return pszTail; -} - -HRESULT SHELL32_ParseNextElement (IShellFolder2 * psf, HWND hwndOwner, LPBC pbc, - LPITEMIDLIST * pidlInOut, LPOLESTR szNext, DWORD * pEaten, DWORD * pdwAttributes) -{ - HRESULT hr = E_INVALIDARG; - LPITEMIDLIST pidlOut = NULL, - pidlTemp = NULL; - IShellFolder *psfChild; - - TRACE ("(%p, %p, %p, %s)\n", psf, pbc, pidlInOut ? *pidlInOut : NULL, debugstr_w (szNext)); - - /* get the shellfolder for the child pidl and let it analyse further */ - hr = IShellFolder_BindToObject (psf, *pidlInOut, pbc, &IID_IShellFolder, (LPVOID *) & psfChild); - - if (SUCCEEDED(hr)) { - hr = IShellFolder_ParseDisplayName (psfChild, hwndOwner, pbc, szNext, pEaten, &pidlOut, pdwAttributes); - IShellFolder_Release (psfChild); - - if (SUCCEEDED(hr)) { - pidlTemp = ILCombine (*pidlInOut, pidlOut); - - if (!pidlTemp) - hr = E_OUTOFMEMORY; - } - - if (pidlOut) - ILFree (pidlOut); - } - - ILFree (*pidlInOut); - *pidlInOut = pidlTemp; - - TRACE ("-- pidl=%p ret=0x%08x\n", pidlInOut ? *pidlInOut : NULL, hr); - return hr; -} - -/*********************************************************************** - * SHELL32_CoCreateInitSF - * - * Creates a shell folder and initializes it with a pidl and a root folder - * via IPersistFolder3 or IPersistFolder. - * - * NOTES - * pathRoot can be NULL for Folders being a drive. - * In this case the absolute path is built from pidlChild (eg. C:) - */ -static HRESULT SHELL32_CoCreateInitSF (LPCITEMIDLIST pidlRoot, LPCWSTR pathRoot, - LPCITEMIDLIST pidlChild, REFCLSID clsid, LPVOID * ppvOut) -{ - HRESULT hr; - - TRACE ("%p %s %p\n", pidlRoot, debugstr_w(pathRoot), pidlChild); - - hr = SHCoCreateInstance(NULL, clsid, NULL, &IID_IShellFolder, ppvOut); - if (SUCCEEDED (hr)) - { - LPITEMIDLIST pidlAbsolute = ILCombine (pidlRoot, pidlChild); - IPersistFolder *pPF; - IPersistFolder3 *ppf; - - if (_ILIsFolder(pidlChild) && - SUCCEEDED (IUnknown_QueryInterface ((IUnknown *) * ppvOut, &IID_IPersistFolder3, (LPVOID *) & ppf))) - { - PERSIST_FOLDER_TARGET_INFO ppfti; - - ZeroMemory (&ppfti, sizeof (ppfti)); - - /* fill the PERSIST_FOLDER_TARGET_INFO */ - ppfti.dwAttributes = -1; - ppfti.csidl = -1; - - /* build path */ - if (pathRoot) { - lstrcpynW (ppfti.szTargetParsingName, pathRoot, MAX_PATH - 1); - PathAddBackslashW(ppfti.szTargetParsingName); /* FIXME: why have drives a backslash here ? */ - } - - if (pidlChild) { - int len = wcslen(ppfti.szTargetParsingName); - - if (!_ILSimpleGetTextW(pidlChild, ppfti.szTargetParsingName + len, MAX_PATH - len)) - hr = E_INVALIDARG; - } - - IPersistFolder3_InitializeEx (ppf, NULL, pidlAbsolute, &ppfti); - IPersistFolder3_Release (ppf); - } - else if (SUCCEEDED ((hr = IUnknown_QueryInterface ((IUnknown *) * ppvOut, &IID_IPersistFolder, (LPVOID *) & pPF)))) { - IPersistFolder_Initialize (pPF, pidlAbsolute); - IPersistFolder_Release (pPF); - } - ILFree (pidlAbsolute); - } - TRACE ("-- (%p) ret=0x%08x\n", *ppvOut, hr); - return hr; -} - -/*********************************************************************** - * SHELL32_BindToChild [Internal] - * - * Common code for IShellFolder_BindToObject. - * - * PARAMS - * pidlRoot [I] The parent shell folder's absolute pidl. - * pathRoot [I] Absolute dos path of the parent shell folder. - * pidlComplete [I] PIDL of the child. Relative to pidlRoot. - * riid [I] GUID of the interface, which ppvOut shall be bound to. - * ppvOut [O] A reference to the child's interface (riid). - * - * NOTES - * pidlComplete has to contain at least one non empty SHITEMID. - * This function makes special assumptions on the shell namespace, which - * means you probably can't use it for your IShellFolder implementation. - */ -HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot, - LPCWSTR pathRoot, LPCITEMIDLIST pidlComplete, REFIID riid, LPVOID * ppvOut) -{ - GUID const *clsid; - IShellFolder *pSF; - HRESULT hr; - LPITEMIDLIST pidlChild; - - if (!pidlRoot || !ppvOut || !pidlComplete || !pidlComplete->mkid.cb) - return E_INVALIDARG; - - *ppvOut = NULL; - - pidlChild = ILCloneFirst (pidlComplete); - - if ((clsid = _ILGetGUIDPointer (pidlChild))) { - /* virtual folder */ - hr = SHELL32_CoCreateInitSF (pidlRoot, pathRoot, pidlChild, clsid, (LPVOID *)&pSF); - } else { - /* file system folder */ - CLSID clsidFolder = CLSID_ShellFSFolder; - static const WCHAR wszCLSID[] = {'C','L','S','I','D',0}; - WCHAR wszCLSIDValue[CHARS_IN_GUID], wszFolderPath[MAX_PATH], *pwszPathTail = wszFolderPath; - - /* see if folder CLSID should be overridden by desktop.ini file */ - if (pathRoot) { - lstrcpynW(wszFolderPath, pathRoot, MAX_PATH); - pwszPathTail = PathAddBackslashW(wszFolderPath); - } - - _ILSimpleGetTextW(pidlChild,pwszPathTail,MAX_PATH - (int)(pwszPathTail - wszFolderPath)); - - if (SHELL32_GetCustomFolderAttributeFromPath (wszFolderPath, - wszDotShellClassInfo, wszCLSID, wszCLSIDValue, CHARS_IN_GUID)) - CLSIDFromString (wszCLSIDValue, &clsidFolder); - - hr = SHELL32_CoCreateInitSF (pidlRoot, pathRoot, pidlChild, - &clsidFolder, (LPVOID *)&pSF); - } - ILFree (pidlChild); - - if (SUCCEEDED (hr)) { - if (_ILIsPidlSimple (pidlComplete)) { - /* no sub folders */ - hr = IShellFolder_QueryInterface (pSF, riid, ppvOut); - } else { - /* go deeper */ - hr = IShellFolder_BindToObject (pSF, ILGetNext (pidlComplete), NULL, riid, ppvOut); - } - IShellFolder_Release (pSF); - } - - TRACE ("-- returning (%p) %08x\n", *ppvOut, hr); - - return hr; -} - -/*********************************************************************** - * SHELL32_GetDisplayNameOfChild - * - * Retrieves the display name of a child object of a shellfolder. - * - * For a pidl eg. [subpidl1][subpidl2][subpidl3]: - * - it binds to the child shellfolder [subpidl1] - * - asks it for the displayname of [subpidl2][subpidl3] - * - * Is possible the pidl is a simple pidl. In this case it asks the - * subfolder for the displayname of an empty pidl. The subfolder - * returns the own displayname eg. "::{guid}". This is used for - * virtual folders with the registry key WantsFORPARSING set. - */ -HRESULT SHELL32_GetDisplayNameOfChild (IShellFolder2 * psf, - LPCITEMIDLIST pidl, DWORD dwFlags, LPWSTR szOut, DWORD dwOutLen) -{ - LPITEMIDLIST pidlFirst; - HRESULT hr = E_INVALIDARG; - - TRACE ("(%p)->(pidl=%p 0x%08x %p 0x%08x)\n", psf, pidl, dwFlags, szOut, dwOutLen); - pdump (pidl); - - pidlFirst = ILCloneFirst (pidl); - if (pidlFirst) { - IShellFolder2 *psfChild; - - hr = IShellFolder_BindToObject (psf, pidlFirst, NULL, &IID_IShellFolder, (LPVOID *) & psfChild); - if (SUCCEEDED (hr)) { - STRRET strTemp; - LPITEMIDLIST pidlNext = ILGetNext (pidl); - - hr = IShellFolder_GetDisplayNameOf (psfChild, pidlNext, dwFlags, &strTemp); - if (SUCCEEDED (hr)) { - if(!StrRetToStrNW (szOut, dwOutLen, &strTemp, pidlNext)) - hr = E_FAIL; - } - IShellFolder_Release (psfChild); - } - ILFree (pidlFirst); - } else - hr = E_OUTOFMEMORY; - - TRACE ("-- ret=0x%08x %s\n", hr, debugstr_w(szOut)); - - return hr; -} - -/*********************************************************************** - * SHELL32_GetItemAttributes - * - * NOTES - * Observed values: - * folder: 0xE0000177 FILESYSTEM | HASSUBFOLDER | FOLDER - * file: 0x40000177 FILESYSTEM - * drive: 0xf0000144 FILESYSTEM | HASSUBFOLDER | FOLDER | FILESYSANCESTOR - * mycomputer: 0xb0000154 HASSUBFOLDER | FOLDER | FILESYSANCESTOR - * (seems to be default for shell extensions if no registry entry exists) - * - * win2k: - * folder: 0xF0400177 FILESYSTEM | HASSUBFOLDER | FOLDER | FILESYSANCESTOR | CANMONIKER - * file: 0x40400177 FILESYSTEM | CANMONIKER - * drive 0xF0400154 FILESYSTEM | HASSUBFOLDER | FOLDER | FILESYSANCESTOR | CANMONIKER | CANRENAME (LABEL) - * - * According to the MSDN documentation this function should not set flags. It claims only to reset flags when necessary. - * However it turns out the native shell32.dll _sets_ flags in several cases - so do we. - */ -HRESULT SHELL32_GetItemAttributes (IShellFolder * psf, LPCITEMIDLIST pidl, LPDWORD pdwAttributes) -{ - DWORD dwAttributes; - BOOL has_guid; - static const DWORD dwSupportedAttr= - SFGAO_CANCOPY | /*0x00000001 */ - SFGAO_CANMOVE | /*0x00000002 */ - SFGAO_CANLINK | /*0x00000004 */ - SFGAO_CANRENAME | /*0x00000010 */ - SFGAO_CANDELETE | /*0x00000020 */ - SFGAO_HASPROPSHEET | /*0x00000040 */ - SFGAO_DROPTARGET | /*0x00000100 */ - SFGAO_LINK | /*0x00010000 */ - SFGAO_READONLY | /*0x00040000 */ - SFGAO_HIDDEN | /*0x00080000 */ - SFGAO_FILESYSANCESTOR | /*0x10000000 */ - SFGAO_FOLDER | /*0x20000000 */ - SFGAO_FILESYSTEM | /*0x40000000 */ - SFGAO_HASSUBFOLDER; /*0x80000000 */ - - TRACE ("0x%08x\n", *pdwAttributes); - - if (*pdwAttributes & ~dwSupportedAttr) - { - WARN ("attributes 0x%08x not implemented\n", (*pdwAttributes & ~dwSupportedAttr)); - *pdwAttributes &= dwSupportedAttr; - } - - has_guid = _ILGetGUIDPointer(pidl) != NULL; - - dwAttributes = *pdwAttributes; - - if (_ILIsDrive (pidl)) { - *pdwAttributes &= SFGAO_HASSUBFOLDER|SFGAO_FILESYSTEM|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR| - SFGAO_DROPTARGET|SFGAO_HASPROPSHEET|SFGAO_CANRENAME; - } else if (has_guid && HCR_GetFolderAttributes(pidl, &dwAttributes)) { - *pdwAttributes = dwAttributes; - } else if (_ILGetDataPointer (pidl)) { - dwAttributes = _ILGetFileAttributes (pidl, NULL, 0); - - if (!dwAttributes && has_guid) { - WCHAR path[MAX_PATH]; - STRRET strret; - - /* File attributes are not present in the internal PIDL structure, so get them from the file system. */ - - HRESULT hr = IShellFolder_GetDisplayNameOf(psf, pidl, SHGDN_FORPARSING, &strret); - - if (SUCCEEDED(hr)) { - hr = StrRetToBufW(&strret, pidl, path, MAX_PATH); - - /* call GetFileAttributes() only for file system paths, not for parsing names like "::{...}" */ - if (SUCCEEDED(hr) && path[0]!=':') - dwAttributes = GetFileAttributesW(path); - } - } - - /* Set common attributes */ - *pdwAttributes |= SFGAO_FILESYSTEM | SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANDELETE | - SFGAO_CANRENAME | SFGAO_CANLINK | SFGAO_CANMOVE | SFGAO_CANCOPY; - - if (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) - { - *pdwAttributes |= (SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR); - *pdwAttributes &= ~SFGAO_CANLINK; - } - else - *pdwAttributes &= ~(SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR); - - if (dwAttributes & FILE_ATTRIBUTE_HIDDEN) - *pdwAttributes |= SFGAO_HIDDEN; - else - *pdwAttributes &= ~SFGAO_HIDDEN; - - if (dwAttributes & FILE_ATTRIBUTE_READONLY) - *pdwAttributes |= SFGAO_READONLY; - else - *pdwAttributes &= ~SFGAO_READONLY; - - if (SFGAO_LINK & *pdwAttributes) { - char ext[MAX_PATH]; - - if (!_ILGetExtension(pidl, ext, MAX_PATH) || lstrcmpiA(ext, "lnk")) - *pdwAttributes &= ~SFGAO_LINK; - } - - if (SFGAO_HASSUBFOLDER & *pdwAttributes) - { - IShellFolder *psf2; - if (SUCCEEDED(IShellFolder_BindToObject(psf, pidl, 0, (REFIID)&IID_IShellFolder, (LPVOID *)&psf2))) - { - IEnumIDList *pEnumIL = NULL; - if (SUCCEEDED(IShellFolder_EnumObjects(psf2, 0, SHCONTF_FOLDERS, &pEnumIL))) - { - if (IEnumIDList_Skip(pEnumIL, 1) != S_OK) - *pdwAttributes &= ~SFGAO_HASSUBFOLDER; - IEnumIDList_Release(pEnumIL); - } - IShellFolder_Release(psf2); - } - } - } else { - *pdwAttributes &= SFGAO_HASSUBFOLDER|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR|SFGAO_DROPTARGET|SFGAO_HASPROPSHEET|SFGAO_CANRENAME|SFGAO_CANLINK; - } - TRACE ("-- 0x%08x\n", *pdwAttributes); - return S_OK; -} - -/*********************************************************************** - * SHELL32_CompareIDs - */ -HRESULT SHELL32_CompareIDs (IShellFolder * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - int type1, - type2; - char szTemp1[MAX_PATH]; - char szTemp2[MAX_PATH]; - HRESULT nReturn; - LPITEMIDLIST firstpidl, - nextpidl1, - nextpidl2; - IShellFolder *psf; - - /* test for empty pidls */ - BOOL isEmpty1 = _ILIsDesktop (pidl1); - BOOL isEmpty2 = _ILIsDesktop (pidl2); - - if (isEmpty1 && isEmpty2) - return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 0 ); - if (isEmpty1) - return MAKE_HRESULT( SEVERITY_SUCCESS, 0, (WORD)-1 ); - if (isEmpty2) - return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 1 ); - - /* test for different types. Sort order is the PT_* constant */ - type1 = _ILGetDataPointer (pidl1)->type; - type2 = _ILGetDataPointer (pidl2)->type; - if (type1 < type2) - return MAKE_HRESULT( SEVERITY_SUCCESS, 0, (WORD)-1 ); - else if (type1 > type2) - return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 1 ); - - /* test for name of pidl */ - _ILSimpleGetText (pidl1, szTemp1, MAX_PATH); - _ILSimpleGetText (pidl2, szTemp2, MAX_PATH); - nReturn = lstrcmpiA (szTemp1, szTemp2); - if (nReturn < 0) - return MAKE_HRESULT( SEVERITY_SUCCESS, 0, (WORD)-1 ); - else if (nReturn > 0) - return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 1 ); - - /* test of complex pidls */ - firstpidl = ILCloneFirst (pidl1); - nextpidl1 = ILGetNext (pidl1); - nextpidl2 = ILGetNext (pidl2); - - /* optimizing: test special cases and bind not deeper */ - /* the deeper shellfolder would do the same */ - isEmpty1 = _ILIsDesktop (nextpidl1); - isEmpty2 = _ILIsDesktop (nextpidl2); - - if (isEmpty1 && isEmpty2) { - return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 0 ); - } else if (isEmpty1) { - return MAKE_HRESULT( SEVERITY_SUCCESS, 0, (WORD)-1 ); - } else if (isEmpty2) { - return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 1 ); - /* optimizing end */ - } else if (SUCCEEDED (IShellFolder_BindToObject (iface, firstpidl, NULL, &IID_IShellFolder, (LPVOID *) & psf))) { - nReturn = IShellFolder_CompareIDs (psf, lParam, nextpidl1, nextpidl2); - IShellFolder_Release (psf); - } - ILFree (firstpidl); - return nReturn; -} - -/*********************************************************************** - * SHCreateLinks - * - * Undocumented. - */ -HRESULT WINAPI SHCreateLinks( HWND hWnd, LPCSTR lpszDir, LPDATAOBJECT lpDataObject, - UINT uFlags, LPITEMIDLIST *lppidlLinks) -{ - FIXME("%p %s %p %08x %p\n",hWnd,lpszDir,lpDataObject,uFlags,lppidlLinks); - return E_NOTIMPL; -} - -/*********************************************************************** - * SHOpenFolderAndSelectItems - * - * Unimplemented. - */ -HRESULT -WINAPI -SHOpenFolderAndSelectItems(LPITEMIDLIST pidlFolder, - UINT cidl, - PCUITEMID_CHILD_ARRAY *apidl, - DWORD dwFlags) -{ - FIXME("SHOpenFolderAndSelectItems() stub\n"); - return E_NOTIMPL; -} diff --git a/reactos/dll/win32/shell32/shlfsbind.c b/reactos/dll/win32/shell32/shlfsbind.c deleted file mode 100644 index a9bf8f0af6c..00000000000 --- a/reactos/dll/win32/shell32/shlfsbind.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - * File System Bind Data object to use as parameter for the bind context to - * IShellFolder_ParseDisplayName - * - * Copyright 2003 Rolf Kalbermatter - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - * - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(pidl); - -/*********************************************************************** - * IFileSystemBindData implementation - */ -typedef struct -{ - const IFileSystemBindDataVtbl *lpVtbl; - LONG ref; - WIN32_FIND_DATAW findFile; -} IFileSystemBindDataImpl; - -static HRESULT WINAPI IFileSystemBindData_fnQueryInterface(IFileSystemBindData *, REFIID, LPVOID*); -static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *); -static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *); -static HRESULT WINAPI IFileSystemBindData_fnGetFindData(IFileSystemBindData *, WIN32_FIND_DATAW *); -static HRESULT WINAPI IFileSystemBindData_fnSetFindData(IFileSystemBindData *, const WIN32_FIND_DATAW *); - -static const IFileSystemBindDataVtbl sbvt = -{ - IFileSystemBindData_fnQueryInterface, - IFileSystemBindData_fnAddRef, - IFileSystemBindData_fnRelease, - IFileSystemBindData_fnSetFindData, - IFileSystemBindData_fnGetFindData, -}; - -static const WCHAR wFileSystemBindData[] = { - 'F','i','l','e',' ','S','y','s','t','e','m',' ','B','i','n','d','D','a','t','a',0}; - -HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV) -{ - IFileSystemBindDataImpl *sb; - HRESULT ret = E_OUTOFMEMORY; - - TRACE("%p, %p\n", pfd, ppV); - - if (!ppV) - return E_INVALIDARG; - - *ppV = NULL; - - sb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IFileSystemBindDataImpl)); - if (!sb) - return ret; - - sb->lpVtbl = &sbvt; - sb->ref = 1; - IFileSystemBindData_fnSetFindData((IFileSystemBindData*)sb, pfd); - - ret = CreateBindCtx(0, ppV); - if (SUCCEEDED(ret)) - { - BIND_OPTS bindOpts; - - bindOpts.cbStruct = sizeof(BIND_OPTS); - bindOpts.grfFlags = 0; - bindOpts.grfMode = STGM_CREATE; - bindOpts.dwTickCountDeadline = 0; - IBindCtx_SetBindOptions(*ppV, &bindOpts); - IBindCtx_RegisterObjectParam(*ppV, (LPOLESTR)wFileSystemBindData, (LPUNKNOWN)sb); - - IFileSystemBindData_Release((IFileSystemBindData*)sb); - } - else - HeapFree(GetProcessHeap(), 0, sb); - return ret; -} - -HRESULT WINAPI FileSystemBindData_GetFindData(LPBC pbc, WIN32_FIND_DATAW *pfd) -{ - LPUNKNOWN pUnk; - IFileSystemBindData *pfsbd = NULL; - HRESULT ret; - - TRACE("%p, %p\n", pbc, pfd); - - if (!pfd) - return E_INVALIDARG; - - ret = IBindCtx_GetObjectParam(pbc, (LPOLESTR)wFileSystemBindData, &pUnk); - if (SUCCEEDED(ret)) - { - ret = IUnknown_QueryInterface(pUnk, &IID_IFileSystemBindData, (LPVOID *)&pfsbd); - if (SUCCEEDED(ret)) - { - ret = IFileSystemBindData_GetFindData(pfsbd, pfd); - IFileSystemBindData_Release(pfsbd); - } - IUnknown_Release(pUnk); - } - return ret; -} - -HRESULT WINAPI FileSystemBindData_SetFindData(LPBC pbc, const WIN32_FIND_DATAW *pfd) -{ - LPUNKNOWN pUnk; - IFileSystemBindData *pfsbd = NULL; - HRESULT ret; - - TRACE("%p, %p\n", pbc, pfd); - - ret = IBindCtx_GetObjectParam(pbc, (LPOLESTR)wFileSystemBindData, &pUnk); - if (SUCCEEDED(ret)) - { - ret = IUnknown_QueryInterface(pUnk, &IID_IFileSystemBindData, (LPVOID *)&pfsbd); - if (SUCCEEDED(ret)) - { - ret = IFileSystemBindData_SetFindData(pfsbd, pfd); - IFileSystemBindData_Release(pfsbd); - } - IUnknown_Release(pUnk); - } - return ret; -} - -static HRESULT WINAPI IFileSystemBindData_fnQueryInterface( - IFileSystemBindData *iface, REFIID riid, LPVOID *ppV) -{ - IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; - TRACE("(%p)->(\n\tIID:\t%s, %p)\n", This, debugstr_guid(riid), ppV); - - *ppV = NULL; - - if (IsEqualIID(riid, &IID_IUnknown)) - *ppV = This; - else if (IsEqualIID(riid, &IID_IFileSystemBindData)) - *ppV = (IFileSystemBindData*)This; - - if (*ppV) - { - IUnknown_AddRef((IUnknown*)(*ppV)); - TRACE("-- Interface: (%p)->(%p)\n", ppV, *ppV); - return S_OK; - } - TRACE("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *iface) -{ - IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE("(%p)->(count=%i)\n", This, refCount - 1); - - return refCount; -} - -static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *iface) -{ - IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(count=%i)\n", This, refCount + 1); - - if (!refCount) - { - TRACE(" destroying ISFBindPidl(%p)\n",This); - HeapFree(GetProcessHeap(), 0, This); - } - return refCount; -} - -static HRESULT WINAPI IFileSystemBindData_fnGetFindData( - IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd) -{ - IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; - TRACE("(%p), %p\n", This, pfd); - - if (!pfd) - return E_INVALIDARG; - - memcpy(pfd, &This->findFile, sizeof(WIN32_FIND_DATAW)); - return NOERROR; -} - -static HRESULT WINAPI IFileSystemBindData_fnSetFindData( - IFileSystemBindData *iface, const WIN32_FIND_DATAW *pfd) -{ - IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; - TRACE("(%p), %p\n", This, pfd); - - if (pfd) - memcpy(&This->findFile, pfd, sizeof(WIN32_FIND_DATAW)); - else - memset(&This->findFile, 0, sizeof(WIN32_FIND_DATAW)); - return NOERROR; -} diff --git a/reactos/dll/win32/shell32/shlmenu.c b/reactos/dll/win32/shell32/shlmenu.c deleted file mode 100644 index 821bf50687a..00000000000 --- a/reactos/dll/win32/shell32/shlmenu.c +++ /dev/null @@ -1,985 +0,0 @@ -/* - * see www.geocities.com/SiliconValley/4942/filemenu.html - * - * Copyright 1999, 2000 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#ifdef FM_SEPARATOR -#undef FM_SEPARATOR -#endif -#define FM_SEPARATOR (LPCWSTR)1 - -static BOOL FileMenu_AppendItemW(HMENU hMenu, LPCWSTR lpText, UINT uID, int icon, - HMENU hMenuPopup, int nItemHeight); - -typedef struct -{ - BOOL bInitialized; - BOOL bFixedItems; - /* create */ - COLORREF crBorderColor; - int nBorderWidth; - HBITMAP hBorderBmp; - - /* insert using pidl */ - LPITEMIDLIST pidl; - UINT uID; - UINT uFlags; - UINT uEnumFlags; - LPFNFMCALLBACK lpfnCallback; -} FMINFO, *LPFMINFO; - -typedef struct -{ int cchItemText; - int iIconIndex; - HMENU hMenu; - WCHAR szItemText[1]; -} FMITEM, * LPFMITEM; - -static BOOL bAbortInit; - -#define CCH_MAXITEMTEXT 256 - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -static LPFMINFO FM_GetMenuInfo(HMENU hmenu) -{ - MENUINFO MenuInfo; - LPFMINFO menudata; - - MenuInfo.cbSize = sizeof(MENUINFO); - MenuInfo.fMask = MIM_MENUDATA; - - if (! GetMenuInfo(hmenu, &MenuInfo)) - return NULL; - - menudata = (LPFMINFO)MenuInfo.dwMenuData; - - if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO))) - { - ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize); - return 0; - } - - return menudata; - -} -/************************************************************************* - * FM_SetMenuParameter [internal] - * - */ -static LPFMINFO FM_SetMenuParameter( - HMENU hmenu, - UINT uID, - LPCITEMIDLIST pidl, - UINT uFlags, - UINT uEnumFlags, - LPFNFMCALLBACK lpfnCallback) -{ - LPFMINFO menudata; - - TRACE("\n"); - - menudata = FM_GetMenuInfo(hmenu); - - SHFree(menudata->pidl); - - menudata->uID = uID; - menudata->pidl = ILClone(pidl); - menudata->uFlags = uFlags; - menudata->uEnumFlags = uEnumFlags; - menudata->lpfnCallback = lpfnCallback; - - return menudata; -} - -/************************************************************************* - * FM_InitMenuPopup [internal] - * - */ -static int FM_InitMenuPopup(HMENU hmenu, LPCITEMIDLIST pAlternatePidl) -{ IShellFolder *lpsf, *lpsf2; - ULONG ulItemAttr = SFGAO_FOLDER; - UINT uID, uEnumFlags; - LPFNFMCALLBACK lpfnCallback; - LPCITEMIDLIST pidl; - WCHAR sTemp[MAX_PATH]; - int NumberOfItems = 0, iIcon; - MENUINFO MenuInfo; - LPFMINFO menudata; - - TRACE("%p %p\n", hmenu, pAlternatePidl); - - MenuInfo.cbSize = sizeof(MENUINFO); - MenuInfo.fMask = MIM_MENUDATA; - - if (! GetMenuInfo(hmenu, &MenuInfo)) - return FALSE; - - menudata = (LPFMINFO)MenuInfo.dwMenuData; - - if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO))) - { - ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize); - return 0; - } - - if (menudata->bInitialized) - return 0; - - pidl = (pAlternatePidl? pAlternatePidl: menudata->pidl); - if (!pidl) - return 0; - - uID = menudata->uID; - uEnumFlags = menudata->uEnumFlags; - lpfnCallback = menudata->lpfnCallback; - menudata->bInitialized = FALSE; - - SetMenuInfo(hmenu, &MenuInfo); - - if (SUCCEEDED (SHGetDesktopFolder(&lpsf))) - { - if (SUCCEEDED(IShellFolder_BindToObject(lpsf, pidl,0,&IID_IShellFolder,(LPVOID *)&lpsf2))) - { - IEnumIDList *lpe = NULL; - - if (SUCCEEDED (IShellFolder_EnumObjects(lpsf2, 0, uEnumFlags, &lpe ))) - { - - LPITEMIDLIST pidlTemp = NULL; - ULONG ulFetched; - - while ((!bAbortInit) && (NOERROR == IEnumIDList_Next(lpe,1,&pidlTemp,&ulFetched))) - { - if (SUCCEEDED (IShellFolder_GetAttributesOf(lpsf, 1, (LPCITEMIDLIST*)&pidlTemp, &ulItemAttr))) - { - ILGetDisplayNameExW(NULL, pidlTemp, sTemp, ILGDN_FORPARSING); - if (! (PidlToSicIndex(lpsf, pidlTemp, FALSE, 0, &iIcon))) - iIcon = FM_BLANK_ICON; - if ( SFGAO_FOLDER & ulItemAttr) - { - LPFMINFO lpFmMi; - MENUINFO MenuInfo; - HMENU hMenuPopup = CreatePopupMenu(); - - lpFmMi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO)); - - lpFmMi->pidl = ILCombine(pidl, pidlTemp); - lpFmMi->uEnumFlags = SHCONTF_FOLDERS | SHCONTF_NONFOLDERS; - - MenuInfo.cbSize = sizeof(MENUINFO); - MenuInfo.fMask = MIM_MENUDATA; - MenuInfo.dwMenuData = (ULONG_PTR) lpFmMi; - SetMenuInfo (hMenuPopup, &MenuInfo); - - FileMenu_AppendItemW (hmenu, sTemp, uID, iIcon, hMenuPopup, FM_DEFAULT_HEIGHT); - } - else - { - LPWSTR pExt = PathFindExtensionW(sTemp); - if (pExt) - *pExt = 0; - FileMenu_AppendItemW (hmenu, sTemp, uID, iIcon, 0, FM_DEFAULT_HEIGHT); - } - } - - if (lpfnCallback) - { - TRACE("enter callback\n"); - lpfnCallback ( pidl, pidlTemp); - TRACE("leave callback\n"); - } - - NumberOfItems++; - } - IEnumIDList_Release (lpe); - } - IShellFolder_Release(lpsf2); - } - IShellFolder_Release(lpsf); - } - - if ( GetMenuItemCount (hmenu) == 0 ) - { - static const WCHAR szEmpty[] = { '(','e','m','p','t','y',')',0 }; - FileMenu_AppendItemW (hmenu, szEmpty, uID, FM_BLANK_ICON, 0, FM_DEFAULT_HEIGHT); - NumberOfItems++; - } - - menudata->bInitialized = TRUE; - SetMenuInfo(hmenu, &MenuInfo); - - return NumberOfItems; -} -/************************************************************************* - * FileMenu_Create [SHELL32.114] - * - * NOTES - * for non-root menus values are - * (ffffffff,00000000,00000000,00000000,00000000) - */ -HMENU WINAPI FileMenu_Create ( - COLORREF crBorderColor, - int nBorderWidth, - HBITMAP hBorderBmp, - int nSelHeight, - UINT uFlags) -{ - MENUINFO MenuInfo; - LPFMINFO menudata; - - HMENU hMenu = CreatePopupMenu(); - - TRACE("0x%08x 0x%08x %p 0x%08x 0x%08x hMenu=%p\n", - crBorderColor, nBorderWidth, hBorderBmp, nSelHeight, uFlags, hMenu); - - menudata = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO)); - menudata->crBorderColor = crBorderColor; - menudata->nBorderWidth = nBorderWidth; - menudata->hBorderBmp = hBorderBmp; - - MenuInfo.cbSize = sizeof(MENUINFO); - MenuInfo.fMask = MIM_MENUDATA; - MenuInfo.dwMenuData = (ULONG_PTR) menudata; - SetMenuInfo (hMenu, &MenuInfo); - - return hMenu; -} - -/************************************************************************* - * FileMenu_Destroy [SHELL32.118] - * - * NOTES - * exported by name - */ -void WINAPI FileMenu_Destroy (HMENU hmenu) -{ - LPFMINFO menudata; - - TRACE("%p\n", hmenu); - - FileMenu_DeleteAllItems (hmenu); - - menudata = FM_GetMenuInfo(hmenu); - - SHFree( menudata->pidl); - HeapFree(GetProcessHeap(), 0, menudata); - - DestroyMenu (hmenu); -} - -/************************************************************************* - * FileMenu_AppendItem [SHELL32.115] - * - */ -static BOOL FileMenu_AppendItemW( - HMENU hMenu, - LPCWSTR lpText, - UINT uID, - int icon, - HMENU hMenuPopup, - int nItemHeight) -{ - MENUITEMINFOW mii; - LPFMITEM myItem; - LPFMINFO menudata; - MENUINFO MenuInfo; - - - TRACE("%p %s 0x%08x 0x%08x %p 0x%08x\n", - hMenu, (lpText!=FM_SEPARATOR) ? debugstr_w(lpText) : NULL, - uID, icon, hMenuPopup, nItemHeight); - - ZeroMemory (&mii, sizeof(MENUITEMINFOW)); - - mii.cbSize = sizeof(MENUITEMINFOW); - - if (lpText != FM_SEPARATOR) - { - int len = strlenW (lpText); - myItem = SHAlloc(sizeof(FMITEM) + len*sizeof(WCHAR)); - strcpyW (myItem->szItemText, lpText); - myItem->cchItemText = len; - myItem->iIconIndex = icon; - myItem->hMenu = hMenu; - mii.fMask = MIIM_DATA; - mii.dwItemData = (ULONG_PTR) myItem; - } - - if ( hMenuPopup ) - { /* sub menu */ - mii.fMask |= MIIM_TYPE | MIIM_SUBMENU; - mii.fType = MFT_OWNERDRAW; - mii.hSubMenu = hMenuPopup; - } - else if (lpText == FM_SEPARATOR ) - { mii.fMask |= MIIM_ID | MIIM_TYPE; - mii.fType = MFT_SEPARATOR; - } - else - { /* normal item */ - mii.fMask |= MIIM_ID | MIIM_TYPE | MIIM_STATE; - mii.fState = MFS_ENABLED | MFS_DEFAULT; - mii.fType = MFT_OWNERDRAW; - } - mii.wID = uID; - - InsertMenuItemW (hMenu, (UINT)-1, TRUE, &mii); - - /* set bFixedItems to true */ - MenuInfo.cbSize = sizeof(MENUINFO); - MenuInfo.fMask = MIM_MENUDATA; - - if (! GetMenuInfo(hMenu, &MenuInfo)) - return FALSE; - - menudata = (LPFMINFO)MenuInfo.dwMenuData; - if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO))) - { - ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize); - return 0; - } - - menudata->bFixedItems = TRUE; - SetMenuInfo(hMenu, &MenuInfo); - - return TRUE; - -} - -/**********************************************************************/ - -BOOL WINAPI FileMenu_AppendItemAW( - HMENU hMenu, - LPCVOID lpText, - UINT uID, - int icon, - HMENU hMenuPopup, - int nItemHeight) -{ - BOOL ret; - - if (!lpText) return FALSE; - - if (SHELL_OsIsUnicode() || lpText == FM_SEPARATOR) - ret = FileMenu_AppendItemW(hMenu, lpText, uID, icon, hMenuPopup, nItemHeight); - else - { - DWORD len = MultiByteToWideChar( CP_ACP, 0, lpText, -1, NULL, 0 ); - LPWSTR lpszText = HeapAlloc ( GetProcessHeap(), 0, len*sizeof(WCHAR) ); - if (!lpszText) return FALSE; - MultiByteToWideChar( CP_ACP, 0, lpText, -1, lpszText, len ); - ret = FileMenu_AppendItemW(hMenu, lpszText, uID, icon, hMenuPopup, nItemHeight); - HeapFree( GetProcessHeap(), 0, lpszText ); - } - - return ret; -} - -/************************************************************************* - * FileMenu_InsertUsingPidl [SHELL32.110] - * - * NOTES - * uEnumFlags any SHCONTF flag - */ -int WINAPI FileMenu_InsertUsingPidl ( - HMENU hmenu, - UINT uID, - LPCITEMIDLIST pidl, - UINT uFlags, - UINT uEnumFlags, - LPFNFMCALLBACK lpfnCallback) -{ - TRACE("%p 0x%08x %p 0x%08x 0x%08x %p\n", - hmenu, uID, pidl, uFlags, uEnumFlags, lpfnCallback); - - pdump (pidl); - - bAbortInit = FALSE; - - FM_SetMenuParameter(hmenu, uID, pidl, uFlags, uEnumFlags, lpfnCallback); - - return FM_InitMenuPopup(hmenu, NULL); -} - -/************************************************************************* - * FileMenu_ReplaceUsingPidl [SHELL32.113] - * - * FIXME: the static items are deleted but won't be refreshed - */ -int WINAPI FileMenu_ReplaceUsingPidl( - HMENU hmenu, - UINT uID, - LPCITEMIDLIST pidl, - UINT uEnumFlags, - LPFNFMCALLBACK lpfnCallback) -{ - TRACE("%p 0x%08x %p 0x%08x %p\n", - hmenu, uID, pidl, uEnumFlags, lpfnCallback); - - FileMenu_DeleteAllItems (hmenu); - - FM_SetMenuParameter(hmenu, uID, pidl, 0, uEnumFlags, lpfnCallback); - - return FM_InitMenuPopup(hmenu, NULL); -} - -/************************************************************************* - * FileMenu_Invalidate [SHELL32.111] - */ -void WINAPI FileMenu_Invalidate (HMENU hMenu) -{ - FIXME("%p\n",hMenu); -} - -/************************************************************************* - * FileMenu_FindSubMenuByPidl [SHELL32.106] - */ -HMENU WINAPI FileMenu_FindSubMenuByPidl( - HMENU hMenu, - LPCITEMIDLIST pidl) -{ - FIXME("%p %p\n",hMenu, pidl); - return 0; -} - -/************************************************************************* - * FileMenu_AppendFilesForPidl [SHELL32.124] - */ -int WINAPI FileMenu_AppendFilesForPidl( - HMENU hmenu, - LPCITEMIDLIST pidl, - BOOL bAddSeparator) -{ - LPFMINFO menudata; - - menudata = FM_GetMenuInfo(hmenu); - - menudata->bInitialized = FALSE; - - FM_InitMenuPopup(hmenu, pidl); - - if (bAddSeparator) - FileMenu_AppendItemW (hmenu, FM_SEPARATOR, 0, 0, 0, FM_DEFAULT_HEIGHT); - - TRACE("%p %p 0x%08x\n",hmenu, pidl,bAddSeparator); - - return 0; -} -/************************************************************************* - * FileMenu_AddFilesForPidl [SHELL32.125] - * - * NOTES - * uEnumFlags any SHCONTF flag - */ -int WINAPI FileMenu_AddFilesForPidl ( - HMENU hmenu, - UINT uReserved, - UINT uID, - LPCITEMIDLIST pidl, - UINT uFlags, - UINT uEnumFlags, - LPFNFMCALLBACK lpfnCallback) -{ - TRACE("%p 0x%08x 0x%08x %p 0x%08x 0x%08x %p\n", - hmenu, uReserved, uID, pidl, uFlags, uEnumFlags, lpfnCallback); - - return FileMenu_InsertUsingPidl ( hmenu, uID, pidl, uFlags, uEnumFlags, lpfnCallback); - -} - - -/************************************************************************* - * FileMenu_TrackPopupMenuEx [SHELL32.116] - */ -BOOL WINAPI FileMenu_TrackPopupMenuEx ( - HMENU hMenu, - UINT uFlags, - int x, - int y, - HWND hWnd, - LPTPMPARAMS lptpm) -{ - TRACE("%p 0x%08x 0x%x 0x%x %p %p\n", - hMenu, uFlags, x, y, hWnd, lptpm); - return TrackPopupMenuEx(hMenu, uFlags, x, y, hWnd, lptpm); -} - -/************************************************************************* - * FileMenu_GetLastSelectedItemPidls [SHELL32.107] - */ -BOOL WINAPI FileMenu_GetLastSelectedItemPidls( - UINT uReserved, - LPCITEMIDLIST *ppidlFolder, - LPCITEMIDLIST *ppidlItem) -{ - FIXME("0x%08x %p %p\n",uReserved, ppidlFolder, ppidlItem); - return 0; -} - -#define FM_ICON_SIZE 16 -#define FM_Y_SPACE 4 -#define FM_SPACE1 4 -#define FM_SPACE2 2 -#define FM_LEFTBORDER 2 -#define FM_RIGHTBORDER 8 -/************************************************************************* - * FileMenu_MeasureItem [SHELL32.112] - */ -LRESULT WINAPI FileMenu_MeasureItem( - HWND hWnd, - LPMEASUREITEMSTRUCT lpmis) -{ - LPFMITEM pMyItem = (LPFMITEM)(lpmis->itemData); - HDC hdc = GetDC(hWnd); - SIZE size; - LPFMINFO menuinfo; - - TRACE("%p %p %s\n", hWnd, lpmis, debugstr_w(pMyItem->szItemText)); - - GetTextExtentPoint32W(hdc, pMyItem->szItemText, pMyItem->cchItemText, &size); - - lpmis->itemWidth = size.cx + FM_LEFTBORDER + FM_ICON_SIZE + FM_SPACE1 + FM_SPACE2 + FM_RIGHTBORDER; - lpmis->itemHeight = (size.cy > (FM_ICON_SIZE + FM_Y_SPACE)) ? size.cy : (FM_ICON_SIZE + FM_Y_SPACE); - - /* add the menubitmap */ - menuinfo = FM_GetMenuInfo(pMyItem->hMenu); - if (menuinfo->nBorderWidth) - lpmis->itemWidth += menuinfo->nBorderWidth; - - TRACE("-- 0x%04x 0x%04x\n", lpmis->itemWidth, lpmis->itemHeight); - ReleaseDC (hWnd, hdc); - return 0; -} -/************************************************************************* - * FileMenu_DrawItem [SHELL32.105] - */ -LRESULT WINAPI FileMenu_DrawItem( - HWND hWnd, - LPDRAWITEMSTRUCT lpdis) -{ - LPFMITEM pMyItem = (LPFMITEM)(lpdis->itemData); - COLORREF clrPrevText, clrPrevBkgnd; - int xi,yi,xt,yt; - HIMAGELIST hImageList; - RECT TextRect; - LPFMINFO menuinfo; - - TRACE("%p %p %s\n", hWnd, lpdis, debugstr_w(pMyItem->szItemText)); - - if (lpdis->itemState & ODS_SELECTED) - { - clrPrevText = SetTextColor(lpdis->hDC, GetSysColor (COLOR_HIGHLIGHTTEXT)); - clrPrevBkgnd = SetBkColor(lpdis->hDC, GetSysColor (COLOR_HIGHLIGHT)); - } - else - { - clrPrevText = SetTextColor(lpdis->hDC, GetSysColor (COLOR_MENUTEXT)); - clrPrevBkgnd = SetBkColor(lpdis->hDC, GetSysColor (COLOR_MENU)); - } - - CopyRect(&TextRect, &(lpdis->rcItem)); - - /* add the menubitmap */ - menuinfo = FM_GetMenuInfo(pMyItem->hMenu); - if (menuinfo->nBorderWidth) - TextRect.left += menuinfo->nBorderWidth; - - TextRect.left += FM_LEFTBORDER; - xi = TextRect.left + FM_SPACE1; - yi = TextRect.top + FM_Y_SPACE/2; - TextRect.bottom -= FM_Y_SPACE/2; - - xt = xi + FM_ICON_SIZE + FM_SPACE2; - yt = yi; - - ExtTextOutW (lpdis->hDC, xt , yt, ETO_OPAQUE, &TextRect, pMyItem->szItemText, pMyItem->cchItemText, NULL); - - Shell_GetImageLists(0, &hImageList); - ImageList_Draw(hImageList, pMyItem->iIconIndex, lpdis->hDC, xi, yi, ILD_NORMAL); - - TRACE("-- 0x%04x 0x%04x 0x%04x 0x%04x\n", TextRect.left, TextRect.top, TextRect.right, TextRect.bottom); - - SetTextColor(lpdis->hDC, clrPrevText); - SetBkColor(lpdis->hDC, clrPrevBkgnd); - - return TRUE; -} - -/************************************************************************* - * FileMenu_InitMenuPopup [SHELL32.109] - * - * NOTES - * The filemenu is an ownerdrawn menu. Call this function responding to - * WM_INITPOPUPMENU - * - */ -BOOL WINAPI FileMenu_InitMenuPopup (HMENU hmenu) -{ - FM_InitMenuPopup(hmenu, NULL); - return TRUE; -} - -/************************************************************************* - * FileMenu_HandleMenuChar [SHELL32.108] - */ -LRESULT WINAPI FileMenu_HandleMenuChar( - HMENU hMenu, - WPARAM wParam) -{ - FIXME("%p 0x%08lx\n",hMenu,wParam); - return 0; -} - -/************************************************************************* - * FileMenu_DeleteAllItems [SHELL32.104] - * - * NOTES - * exported by name - */ -BOOL WINAPI FileMenu_DeleteAllItems (HMENU hmenu) -{ - MENUITEMINFOW mii; - LPFMINFO menudata; - - int i; - - TRACE("%p\n", hmenu); - - ZeroMemory ( &mii, sizeof(MENUITEMINFOW)); - mii.cbSize = sizeof(MENUITEMINFOW); - mii.fMask = MIIM_SUBMENU|MIIM_DATA; - - for (i = 0; i < GetMenuItemCount( hmenu ); i++) - { GetMenuItemInfoW(hmenu, i, TRUE, &mii ); - - SHFree((LPFMINFO)mii.dwItemData); - - if (mii.hSubMenu) - FileMenu_Destroy(mii.hSubMenu); - } - - while (DeleteMenu (hmenu, 0, MF_BYPOSITION)){}; - - menudata = FM_GetMenuInfo(hmenu); - - menudata->bInitialized = FALSE; - - return TRUE; -} - -/************************************************************************* - * FileMenu_DeleteItemByCmd [SHELL32.117] - * - */ -BOOL WINAPI FileMenu_DeleteItemByCmd (HMENU hMenu, UINT uID) -{ - MENUITEMINFOW mii; - - TRACE("%p 0x%08x\n", hMenu, uID); - - ZeroMemory ( &mii, sizeof(MENUITEMINFOW)); - mii.cbSize = sizeof(MENUITEMINFOW); - mii.fMask = MIIM_SUBMENU; - - GetMenuItemInfoW(hMenu, uID, FALSE, &mii ); - if ( mii.hSubMenu ) - { - /* FIXME: Do what? */ - } - - DeleteMenu(hMenu, MF_BYCOMMAND, uID); - return TRUE; -} - -/************************************************************************* - * FileMenu_DeleteItemByIndex [SHELL32.140] - */ -BOOL WINAPI FileMenu_DeleteItemByIndex ( HMENU hMenu, UINT uPos) -{ - MENUITEMINFOW mii; - - TRACE("%p 0x%08x\n", hMenu, uPos); - - ZeroMemory ( &mii, sizeof(MENUITEMINFOW)); - mii.cbSize = sizeof(MENUITEMINFOW); - mii.fMask = MIIM_SUBMENU; - - GetMenuItemInfoW(hMenu, uPos, TRUE, &mii ); - if ( mii.hSubMenu ) - { - /* FIXME: Do what? */ - } - - DeleteMenu(hMenu, MF_BYPOSITION, uPos); - return TRUE; -} - -/************************************************************************* - * FileMenu_DeleteItemByFirstID [SHELL32.141] - */ -BOOL WINAPI FileMenu_DeleteItemByFirstID( - HMENU hMenu, - UINT uID) -{ - TRACE("%p 0x%08x\n", hMenu, uID); - return 0; -} - -/************************************************************************* - * FileMenu_DeleteSeparator [SHELL32.142] - */ -BOOL WINAPI FileMenu_DeleteSeparator(HMENU hMenu) -{ - TRACE("%p\n", hMenu); - return 0; -} - -/************************************************************************* - * FileMenu_EnableItemByCmd [SHELL32.143] - */ -BOOL WINAPI FileMenu_EnableItemByCmd( - HMENU hMenu, - UINT uID, - BOOL bEnable) -{ - TRACE("%p 0x%08x 0x%08x\n", hMenu, uID,bEnable); - return 0; -} - -/************************************************************************* - * FileMenu_GetItemExtent [SHELL32.144] - * - * NOTES - * if the menu is too big, entries are getting cut away!! - */ -DWORD WINAPI FileMenu_GetItemExtent (HMENU hMenu, UINT uPos) -{ RECT rect; - - FIXME("%p 0x%08x\n", hMenu, uPos); - - if (GetMenuItemRect(0, hMenu, uPos, &rect)) - { FIXME("0x%04x 0x%04x 0x%04x 0x%04x\n", - rect.right, rect.left, rect.top, rect.bottom); - return ((rect.right-rect.left)<<16) + (rect.top-rect.bottom); - } - return 0x00100010; /*FIXME*/ -} - -/************************************************************************* - * FileMenu_AbortInitMenu [SHELL32.120] - * - */ -void WINAPI FileMenu_AbortInitMenu (void) -{ TRACE("\n"); - bAbortInit = TRUE; -} - -/************************************************************************* - * SHFind_InitMenuPopup [SHELL32.149] - * - * Get the IContextMenu instance for the submenu of options displayed - * for the Search entry in the Classic style Start menu. - * - * PARAMETERS - * hMenu [in] handle of menu previously created - * hWndParent [in] parent window - * w [in] no pointer (0x209 over here) perhaps menu IDs ??? - * x [in] no pointer (0x226 over here) - * - * RETURNS - * LPXXXXX pointer to struct containing a func addr at offset 8 - * or NULL at failure. - */ -IContextMenu * WINAPI SHFind_InitMenuPopup (HMENU hMenu, HWND hWndParent, UINT w, UINT x) -{ - FIXME("hmenu=%p hwnd=%p 0x%08x 0x%08x stub\n", - hMenu,hWndParent,w,x); - return NULL; /* this is supposed to be a pointer */ -} - -/************************************************************************* - * _SHIsMenuSeparator (internal) - */ -static BOOL _SHIsMenuSeparator(HMENU hm, int i) -{ - MENUITEMINFOW mii; - - mii.cbSize = sizeof(MENUITEMINFOW); - mii.fMask = MIIM_TYPE; - mii.cch = 0; /* WARNING: We MUST initialize it to 0*/ - if (!GetMenuItemInfoW(hm, i, TRUE, &mii)) - { - return(FALSE); - } - - if (mii.fType & MFT_SEPARATOR) - { - return(TRUE); - } - - return(FALSE); -} - -/************************************************************************* - * Shell_MergeMenus [SHELL32.67] - */ -UINT WINAPI Shell_MergeMenus (HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags) -{ int nItem; - HMENU hmSubMenu; - BOOL bAlreadySeparated; - MENUITEMINFOW miiSrc; - WCHAR szName[256]; - UINT uTemp, uIDMax = uIDAdjust; - - TRACE("hmenu1=%p hmenu2=%p 0x%04x 0x%04x 0x%04x 0x%04x\n", - hmDst, hmSrc, uInsert, uIDAdjust, uIDAdjustMax, uFlags); - - if (!hmDst || !hmSrc) - return uIDMax; - - nItem = GetMenuItemCount(hmDst); - if (nItem == -1) - return uIDMax; - - if (uInsert >= (UINT)nItem) /* insert position inside menu? */ - { - uInsert = (UINT)nItem; /* append on the end */ - bAlreadySeparated = TRUE; - } - else - { - bAlreadySeparated = _SHIsMenuSeparator(hmDst, uInsert); - } - - if ((uFlags & MM_ADDSEPARATOR) && !bAlreadySeparated) - { - /* Add a separator between the menus */ - InsertMenuA(hmDst, uInsert, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); - bAlreadySeparated = TRUE; - } - - - /* Go through the menu items and clone them*/ - for (nItem = GetMenuItemCount(hmSrc) - 1; nItem >= 0; nItem--) - { - miiSrc.cbSize = sizeof(MENUITEMINFOW); - miiSrc.fMask = MIIM_STATE | MIIM_ID | MIIM_SUBMENU | MIIM_CHECKMARKS | MIIM_TYPE | MIIM_DATA; - - /* We need to reset this every time through the loop in case menus DON'T have IDs*/ - miiSrc.fType = MFT_STRING; - miiSrc.dwTypeData = szName; - miiSrc.dwItemData = 0; - miiSrc.cch = sizeof(szName)/sizeof(WCHAR); - - if (!GetMenuItemInfoW(hmSrc, nItem, TRUE, &miiSrc)) - { - continue; - } - -/* TRACE("found menu=0x%04x %s id=0x%04x mask=0x%08x smenu=0x%04x\n", hmSrc, debugstr_a(miiSrc.dwTypeData), miiSrc.wID, miiSrc.fMask, miiSrc.hSubMenu); -*/ - if (miiSrc.fType & MFT_SEPARATOR) - { - /* This is a separator; don't put two of them in a row */ - if (bAlreadySeparated) - continue; - - bAlreadySeparated = TRUE; - } - else if (miiSrc.hSubMenu) - { - if (uFlags & MM_SUBMENUSHAVEIDS) - { - miiSrc.wID += uIDAdjust; /* add uIDAdjust to the ID */ - - if (uIDAdjustMax != 0xFFFF && miiSrc.wID > uIDAdjustMax) /* skip ID's higher uIDAdjustMax */ - continue; - - if (uIDMax <= miiSrc.wID) /* remember the highest ID */ - uIDMax = miiSrc.wID + 1; - } - else - { - miiSrc.fMask &= ~MIIM_ID; /* Don't set IDs for submenus that didn't have them already */ - } - hmSubMenu = miiSrc.hSubMenu; - - miiSrc.hSubMenu = CreatePopupMenu(); - - if (!miiSrc.hSubMenu) return(uIDMax); - - uTemp = Shell_MergeMenus(miiSrc.hSubMenu, hmSubMenu, 0, uIDAdjust, uIDAdjustMax, uFlags & MM_SUBMENUSHAVEIDS); - - if (uIDMax <= uTemp) - uIDMax = uTemp; - - bAlreadySeparated = FALSE; - } - else /* normal menu item */ - { - miiSrc.wID += uIDAdjust; /* add uIDAdjust to the ID */ - - if (uIDAdjustMax != 0xFFFF && miiSrc.wID > uIDAdjustMax) /* skip ID's higher uIDAdjustMax */ - continue; - - if (uIDMax <= miiSrc.wID) /* remember the highest ID */ - uIDMax = miiSrc.wID + 1; - - bAlreadySeparated = FALSE; - } - -/* TRACE("inserting menu=0x%04x %s id=0x%04x mask=0x%08x smenu=0x%04x\n", hmDst, debugstr_a(miiSrc.dwTypeData), miiSrc.wID, miiSrc.fMask, miiSrc.hSubMenu); -*/ - if (!InsertMenuItemW(hmDst, uInsert, TRUE, &miiSrc)) - { - return(uIDMax); - } - } - - /* Ensure the correct number of separators at the beginning of the - inserted menu items*/ - if (uInsert == 0) - { - if (bAlreadySeparated) - { - DeleteMenu(hmDst, uInsert, MF_BYPOSITION); - } - } - else - { - if (_SHIsMenuSeparator(hmDst, uInsert-1)) - { - if (bAlreadySeparated) - { - DeleteMenu(hmDst, uInsert, MF_BYPOSITION); - } - } - else - { - if ((uFlags & MM_ADDSEPARATOR) && !bAlreadySeparated) - { - /* Add a separator between the menus*/ - InsertMenuW(hmDst, uInsert, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); - } - } - } - return(uIDMax); -} diff --git a/reactos/dll/win32/shell32/shlview.c b/reactos/dll/win32/shell32/shlview.c deleted file mode 100644 index f731b0b535b..00000000000 --- a/reactos/dll/win32/shell32/shlview.c +++ /dev/null @@ -1,2823 +0,0 @@ -/* - * ShellView - * - * Copyright 1998,1999 - * - * This is the view visualizing the data provided by the shellfolder. - * No direct access to data from pidls should be done from here. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - * - * FIXME: The order by part of the background context menu should be - * built according to the columns shown. - * - * FIXME: Load/Save the view state from/into the stream provided by - * the ShellBrowser - * - * FIXME: CheckToolbar: handle the "new folder" and "folder up" button - * - * FIXME: ShellView_FillList: consider sort orders - * - * FIXME: implement the drag and drop in the old (msg-based) way - * - * FIXME: when the ShellView_WndProc gets a WM_NCDESTROY should we do a - * Release() ??? - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -#undef SV_CLASS_NAME - -static const WCHAR SV_CLASS_NAME[] = {'S','H','E','L','L','D','L','L','_','D','e','f','V','i','e','w',0}; - -typedef struct -{ BOOL bIsAscending; - INT nHeaderID; - INT nLastHeaderID; -}LISTVIEW_SORT_INFO, *LPLISTVIEW_SORT_INFO; - -typedef struct -{ - const IShellViewVtbl* lpVtbl; - LONG ref; - const IOleCommandTargetVtbl* lpvtblOleCommandTarget; - const IDropTargetVtbl* lpvtblDropTarget; - const IDropSourceVtbl* lpvtblDropSource; - const IViewObjectVtbl* lpvtblViewObject; - IShellFolder* pSFParent; - IShellFolder2* pSF2Parent; - IShellBrowser* pShellBrowser; - ICommDlgBrowser* pCommDlgBrowser; - HWND hWnd; /* SHELLDLL_DefView */ - HWND hWndList; /* ListView control */ - HWND hWndParent; - FOLDERSETTINGS FolderSettings; - HMENU hMenu; - UINT uState; - UINT cidl; - LPITEMIDLIST *apidl; - LISTVIEW_SORT_INFO ListViewSortInfo; - ULONG hNotify; /* change notification handle */ - HANDLE hAccel; - DWORD dwAspects; - DWORD dwAdvf; - IAdviseSink *pAdvSink; - IDropTarget* pCurDropTarget; /* The sub-item, which is currently dragged over */ - IDataObject* pCurDataObject; /* The dragged data-object */ - LONG iDragOverItem; /* Dragged over item's index, iff pCurDropTarget != NULL */ - UINT cScrollDelay; /* Send a WM_*SCROLL msg every 250 ms during drag-scroll */ - POINT ptLastMousePos; /* Mouse position at last DragOver call */ - IContextMenu2 *pCM; -} IShellViewImpl, *LPIShellViewImpl; - -static const IShellViewVtbl svvt; -static const IOleCommandTargetVtbl ctvt; -static const IDropTargetVtbl dtvt; -static const IDropSourceVtbl dsvt; -static const IViewObjectVtbl vovt; - - -static LPIShellViewImpl __inline impl_from_IOleCommandTarget( IOleCommandTarget *iface ) -{ - return (LPIShellViewImpl)((char*)iface - FIELD_OFFSET(IShellViewImpl, lpvtblOleCommandTarget)); -} - -static LPIShellViewImpl __inline impl_from_IDropTarget( IDropTarget *iface ) -{ - return (LPIShellViewImpl)((char*)iface - FIELD_OFFSET(IShellViewImpl, lpvtblDropTarget)); -} - -static LPIShellViewImpl __inline impl_from_IDropSource( IDropSource *iface ) -{ - return (LPIShellViewImpl)((char*)iface - FIELD_OFFSET(IShellViewImpl, lpvtblDropSource)); -} - -static LPIShellViewImpl __inline impl_from_IViewObject( IViewObject *iface ) -{ - return (LPIShellViewImpl)((char*)iface - FIELD_OFFSET(IShellViewImpl, lpvtblViewObject)); -} - -/* ListView Header ID's */ -#define LISTVIEW_COLUMN_NAME 0 -#define LISTVIEW_COLUMN_SIZE 1 -#define LISTVIEW_COLUMN_TYPE 2 -#define LISTVIEW_COLUMN_TIME 3 -#define LISTVIEW_COLUMN_ATTRIB 4 - -/*menu items */ -#define IDM_VIEW_FILES (FCIDM_SHVIEWFIRST + 0x500) -#define IDM_VIEW_IDW (FCIDM_SHVIEWFIRST + 0x501) -#define IDM_MYFILEITEM (FCIDM_SHVIEWFIRST + 0x502) - -#define ID_LISTVIEW 1 - -#define SHV_CHANGE_NOTIFY WM_USER + 0x1111 - -/*windowsx.h */ -#define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp) -#define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp) -#define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp) - -/* - Items merged into the toolbar and the filemenu -*/ -typedef struct -{ int idCommand; - int iImage; - int idButtonString; - int idMenuString; - BYTE bState; - BYTE bStyle; -} MYTOOLINFO, *LPMYTOOLINFO; - -static const MYTOOLINFO Tools[] = -{ -{ FCIDM_SHVIEW_BIGICON, 0, 0, IDS_VIEW_LARGE, TBSTATE_ENABLED, BTNS_BUTTON }, -{ FCIDM_SHVIEW_SMALLICON, 0, 0, IDS_VIEW_SMALL, TBSTATE_ENABLED, BTNS_BUTTON }, -{ FCIDM_SHVIEW_LISTVIEW, 0, 0, IDS_VIEW_LIST, TBSTATE_ENABLED, BTNS_BUTTON }, -{ FCIDM_SHVIEW_REPORTVIEW, 0, 0, IDS_VIEW_DETAILS, TBSTATE_ENABLED, BTNS_BUTTON }, -{ -1, 0, 0, 0, 0, 0} -}; - -typedef void (CALLBACK *PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask); - -/********************************************************** - * IShellView_Constructor - */ -IShellView * IShellView_Constructor( IShellFolder * pFolder) -{ IShellViewImpl * sv; - sv=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IShellViewImpl)); - sv->ref=1; - sv->lpVtbl=&svvt; - sv->lpvtblOleCommandTarget=&ctvt; - sv->lpvtblDropTarget=&dtvt; - sv->lpvtblDropSource=&dsvt; - sv->lpvtblViewObject=&vovt; - - sv->pSFParent = pFolder; - if(pFolder) IShellFolder_AddRef(pFolder); - IShellFolder_QueryInterface(sv->pSFParent, &IID_IShellFolder2, (LPVOID*)&sv->pSF2Parent); - - sv->pCurDropTarget = NULL; - sv->pCurDataObject = NULL; - sv->iDragOverItem = 0; - sv->cScrollDelay = 0; - sv->ptLastMousePos.x = 0; - sv->ptLastMousePos.y = 0; - - TRACE("(%p)->(%p)\n",sv, pFolder); - return (IShellView *) sv; -} - -/********************************************************** - * - * ##### helperfunctions for communication with ICommDlgBrowser ##### - */ -static BOOL IsInCommDlg(IShellViewImpl * This) -{ return(This->pCommDlgBrowser != NULL); -} - -static HRESULT IncludeObject(IShellViewImpl * This, LPCITEMIDLIST pidl) -{ - HRESULT ret = S_OK; - - if ( IsInCommDlg(This) ) - { - TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl); - ret = ICommDlgBrowser_IncludeObject(This->pCommDlgBrowser, (IShellView*)This, pidl); - TRACE("--0x%08x\n", ret); - } - return ret; -} - -static HRESULT OnDefaultCommand(IShellViewImpl * This) -{ - HRESULT ret = S_FALSE; - - if (IsInCommDlg(This)) - { - TRACE("ICommDlgBrowser::OnDefaultCommand\n"); - ret = ICommDlgBrowser_OnDefaultCommand(This->pCommDlgBrowser, (IShellView*)This); - TRACE("-- returns %08x\n", ret); - } - return ret; -} - -static HRESULT OnStateChange(IShellViewImpl * This, UINT uFlags) -{ - HRESULT ret = S_FALSE; - - if (IsInCommDlg(This)) - { - TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags); - ret = ICommDlgBrowser_OnStateChange(This->pCommDlgBrowser, (IShellView*)This, uFlags); - TRACE("--\n"); - } - return ret; -} -/********************************************************** - * set the toolbar of the filedialog buttons - * - * - activates the buttons from the shellbrowser according to - * the view state - */ -static void CheckToolbar(IShellViewImpl * This) -{ - LRESULT result; - - TRACE("\n"); - - if (IsInCommDlg(This)) - { - IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON, - FCIDM_TB_SMALLICON, (This->FolderSettings.ViewMode==FVM_LIST)? TRUE : FALSE, &result); - IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON, - FCIDM_TB_REPORTVIEW, (This->FolderSettings.ViewMode==FVM_DETAILS)? TRUE : FALSE, &result); - IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON, - FCIDM_TB_SMALLICON, TRUE, &result); - IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON, - FCIDM_TB_REPORTVIEW, TRUE, &result); - } -} - -/********************************************************** - * - * ##### helperfunctions for initializing the view ##### - */ -/********************************************************** - * change the style of the listview control - */ -static void SetStyle(IShellViewImpl * This, DWORD dwAdd, DWORD dwRemove) -{ - DWORD tmpstyle; - - TRACE("(%p)\n", This); - - tmpstyle = GetWindowLongPtrW(This->hWndList, GWL_STYLE); - SetWindowLongPtrW(This->hWndList, GWL_STYLE, dwAdd | (tmpstyle & ~dwRemove)); -} - -/********************************************************** -* ShellView_CreateList() -* -* - creates the list view window -*/ -static BOOL ShellView_CreateList (IShellViewImpl * This) -{ DWORD dwStyle, dwExStyle; - - TRACE("%p\n",This); - - dwStyle = WS_TABSTOP | WS_VISIBLE | WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | - LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_AUTOARRANGE; - dwExStyle = WS_EX_CLIENTEDGE; - - if (This->FolderSettings.fFlags & FWF_DESKTOP) - dwStyle |= LVS_ALIGNLEFT; - else - dwStyle |= LVS_ALIGNTOP; - - switch (This->FolderSettings.ViewMode) - { - case FVM_ICON: dwStyle |= LVS_ICON; break; - case FVM_DETAILS: dwStyle |= LVS_REPORT; break; - case FVM_SMALLICON: dwStyle |= LVS_SMALLICON; break; - case FVM_LIST: dwStyle |= LVS_LIST; break; - default: dwStyle |= LVS_LIST; break; - } - - if (This->FolderSettings.fFlags & FWF_AUTOARRANGE) dwStyle |= LVS_AUTOARRANGE; - if (This->FolderSettings.fFlags & FWF_DESKTOP) - This->FolderSettings.fFlags |= FWF_NOCLIENTEDGE | FWF_NOSCROLL; - if (This->FolderSettings.fFlags & FWF_SINGLESEL) dwStyle |= LVS_SINGLESEL; - if (This->FolderSettings.fFlags & FWF_NOCLIENTEDGE) - dwExStyle &= ~WS_EX_CLIENTEDGE; - - This->hWndList=CreateWindowExW( dwExStyle, - WC_LISTVIEWW, - NULL, - dwStyle, - 0,0,0,0, - This->hWnd, - (HMENU)ID_LISTVIEW, - shell32_hInstance, - NULL); - - if(!This->hWndList) - return FALSE; - - This->ListViewSortInfo.bIsAscending = TRUE; - This->ListViewSortInfo.nHeaderID = -1; - This->ListViewSortInfo.nLastHeaderID = -1; - - if (This->FolderSettings.fFlags & FWF_DESKTOP) { - /* - * FIXME: look at the registry value - * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ListviewShadow - * and activate drop shadows if necessary - */ - if (1) - { - SendMessageW(This->hWndList, LVM_SETTEXTBKCOLOR, 0, CLR_NONE); - SendMessageW(This->hWndList, LVM_SETBKCOLOR, 0, CLR_NONE); - } - else - { - SendMessageW(This->hWndList, LVM_SETTEXTBKCOLOR, 0, GetSysColor(COLOR_DESKTOP)); - SendMessageW(This->hWndList, LVM_SETBKCOLOR, 0, GetSysColor(COLOR_DESKTOP)); - } - - SendMessageW(This->hWndList, LVM_SETTEXTCOLOR, 0, RGB(255,255,255)); - } - - /* UpdateShellSettings(); */ - return TRUE; -} - -/********************************************************** -* ShellView_InitList() -* -* - adds all needed columns to the shellview -*/ -static BOOL ShellView_InitList(IShellViewImpl * This) -{ - LVCOLUMNW lvColumn; - SHELLDETAILS sd; - int i; - WCHAR szTemp[50]; - - TRACE("%p\n",This); - - SendMessageW(This->hWndList, LVM_DELETEALLITEMS, 0, 0); - - lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT; - lvColumn.pszText = szTemp; - - if (This->pSF2Parent) - { - for (i=0; 1; i++) - { - if (FAILED(IShellFolder2_GetDetailsOf(This->pSF2Parent, NULL, i, &sd))) - break; - lvColumn.fmt = sd.fmt; - lvColumn.cx = sd.cxChar*8; /* chars->pixel */ - StrRetToStrNW( szTemp, 50, &sd.str, NULL); - SendMessageW(This->hWndList, LVM_INSERTCOLUMNW, i, (LPARAM) &lvColumn); - } - } - else - { - FIXME("no SF2\n"); - } - - SendMessageW(This->hWndList, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ShellSmallIconList); - SendMessageW(This->hWndList, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)ShellBigIconList); - - return TRUE; -} -/********************************************************** -* ShellView_CompareItems() -* -* NOTES -* internal, CALLBACK for DSA_Sort -*/ -static INT CALLBACK ShellView_CompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData) -{ - int ret; - TRACE("pidl1=%p pidl2=%p lpsf=%p\n", lParam1, lParam2, (LPVOID) lpData); - - if(!lpData) return 0; - - ret = (SHORT) SCODE_CODE(IShellFolder_CompareIDs((LPSHELLFOLDER)lpData, 0, (LPITEMIDLIST)lParam1, (LPITEMIDLIST)lParam2)); - TRACE("ret=%i\n",ret); - return ret; -} - -/************************************************************************* - * ShellView_ListViewCompareItems - * - * Compare Function for the Listview (FileOpen Dialog) - * - * PARAMS - * lParam1 [I] the first ItemIdList to compare with - * lParam2 [I] the second ItemIdList to compare with - * lpData [I] The column ID for the header Ctrl to process - * - * RETURNS - * A negative value if the first item should precede the second, - * a positive value if the first item should follow the second, - * or zero if the two items are equivalent - * - * NOTES - * FIXME: function does what ShellView_CompareItems is supposed to do. - * unify it and figure out how to use the undocumented first parameter - * of IShellFolder_CompareIDs to do the job this function does and - * move this code to IShellFolder. - * make LISTVIEW_SORT_INFO obsolete - * the way this function works is only usable if we had only - * filesystemfolders (25/10/99 jsch) - */ -static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData) -{ - INT nDiff=0; - FILETIME fd1, fd2; - char strName1[MAX_PATH], strName2[MAX_PATH]; - BOOL bIsFolder1, bIsFolder2,bIsBothFolder; - LPITEMIDLIST pItemIdList1 = lParam1; - LPITEMIDLIST pItemIdList2 = lParam2; - LISTVIEW_SORT_INFO *pSortInfo = (LPLISTVIEW_SORT_INFO) lpData; - - - bIsFolder1 = _ILIsFolder(pItemIdList1); - bIsFolder2 = _ILIsFolder(pItemIdList2); - bIsBothFolder = bIsFolder1 && bIsFolder2; - - /* When sorting between a File and a Folder, the Folder gets sorted first */ - if( (bIsFolder1 || bIsFolder2) && !bIsBothFolder) - { - nDiff = bIsFolder1 ? -1 : 1; - } - else - { - /* Sort by Time: Folders or Files can be sorted */ - - if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TIME) - { - _ILGetFileDateTime(pItemIdList1, &fd1); - _ILGetFileDateTime(pItemIdList2, &fd2); - nDiff = CompareFileTime(&fd2, &fd1); - } - /* Sort by Attribute: Folder or Files can be sorted */ - else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_ATTRIB) - { - _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH); - _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH); - nDiff = lstrcmpiA(strName1, strName2); - } - /* Sort by FileName: Folder or Files can be sorted */ - else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder) - { - /* Sort by Text */ - _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH); - _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH); - nDiff = lstrcmpiA(strName1, strName2); - } - /* Sort by File Size, Only valid for Files */ - else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE) - { - nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0)); - } - /* Sort by File Type, Only valid for Files */ - else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE) - { - /* Sort by Type */ - _ILGetFileType(pItemIdList1, strName1, MAX_PATH); - _ILGetFileType(pItemIdList2, strName2, MAX_PATH); - nDiff = lstrcmpiA(strName1, strName2); - } - } - /* If the Date, FileSize, FileType, Attrib was the same, sort by FileName */ - - if(nDiff == 0) - { - _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH); - _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH); - nDiff = lstrcmpiA(strName1, strName2); - } - - if(!pSortInfo->bIsAscending) - { - nDiff = -nDiff; - } - - return nDiff; - -} - -/********************************************************** -* LV_FindItemByPidl() -*/ -static int LV_FindItemByPidl( - IShellViewImpl * This, - LPCITEMIDLIST pidl) -{ - LVITEMW lvItem; - lvItem.iSubItem = 0; - lvItem.mask = LVIF_PARAM; - for(lvItem.iItem = 0; - SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem); - lvItem.iItem++) - { - LPITEMIDLIST currentpidl = (LPITEMIDLIST) lvItem.lParam; - HRESULT hr = IShellFolder_CompareIDs(This->pSFParent, 0, pidl, currentpidl); - if(SUCCEEDED(hr) && !HRESULT_CODE(hr)) - { - return lvItem.iItem; - } - } - return -1; -} - -/********************************************************** -* LV_AddItem() -*/ -static BOOLEAN LV_AddItem(IShellViewImpl * This, LPCITEMIDLIST pidl) -{ - LVITEMW lvItem; - - TRACE("(%p)(pidl=%p)\n", This, pidl); - - lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; /*set the mask*/ - lvItem.iItem = ListView_GetItemCount(This->hWndList); /*add the item to the end of the list*/ - lvItem.iSubItem = 0; - lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidl)); /*set the item's data*/ - lvItem.pszText = LPSTR_TEXTCALLBACKW; /*get text on a callback basis*/ - lvItem.iImage = I_IMAGECALLBACK; /*get the image on a callback basis*/ - if (SendMessageW(This->hWndList, LVM_INSERTITEMW, 0, (LPARAM)&lvItem) == -1) - return FALSE; - else - return TRUE; -} - -/********************************************************** -* LV_DeleteItem() -*/ -static BOOLEAN LV_DeleteItem(IShellViewImpl * This, LPCITEMIDLIST pidl) -{ - int nIndex; - - TRACE("(%p)(pidl=%p)\n", This, pidl); - - nIndex = LV_FindItemByPidl(This, ILFindLastID(pidl)); - return (-1==ListView_DeleteItem(This->hWndList, nIndex))? FALSE: TRUE; -} - -/********************************************************** -* LV_RenameItem() -*/ -static BOOLEAN LV_RenameItem(IShellViewImpl * This, LPCITEMIDLIST pidlOld, LPCITEMIDLIST pidlNew ) -{ - int nItem; - LVITEMW lvItem; - - TRACE("(%p)(pidlold=%p pidlnew=%p)\n", This, pidlOld, pidlNew); - - nItem = LV_FindItemByPidl(This, ILFindLastID(pidlOld)); - if ( -1 != nItem ) - { - lvItem.mask = LVIF_PARAM; /* only the pidl */ - lvItem.iItem = nItem; - SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem); - - SHFree((LPITEMIDLIST)lvItem.lParam); - lvItem.mask = LVIF_PARAM; - lvItem.iItem = nItem; - lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidlNew)); /* set the item's data */ - SendMessageW(This->hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem); - SendMessageW(This->hWndList, LVM_UPDATE, nItem, 0); - return TRUE; /* FIXME: better handling */ - } - return FALSE; -} -/********************************************************** -* ShellView_FillList() -* -* - gets the objectlist from the shellfolder -* - sorts the list -* - fills the list into the view -*/ - -static INT CALLBACK fill_list( LPVOID ptr, LPVOID arg ) -{ - LPITEMIDLIST pidl = ptr; - IShellViewImpl *This = arg; - /* in a commdlg This works as a filemask*/ - if ( IncludeObject(This, pidl)==S_OK ) LV_AddItem(This, pidl); - SHFree(pidl); - return TRUE; -} - -static HRESULT ShellView_FillList(IShellViewImpl * This) -{ - LPENUMIDLIST pEnumIDList; - LPITEMIDLIST pidl; - DWORD dwFetched; - HRESULT hRes; - HDPA hdpa; - - TRACE("%p\n",This); - - /* get the itemlist from the shfolder*/ - hRes = IShellFolder_EnumObjects(This->pSFParent,This->hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList); - if (hRes != S_OK) - { - if (hRes==S_FALSE) - return(NOERROR); - return(hRes); - } - - /* create a pointer array */ - hdpa = DPA_Create(16); - if (!hdpa) - { - return(E_OUTOFMEMORY); - } - - /* copy the items into the array*/ - while((S_OK == IEnumIDList_Next(pEnumIDList,1, &pidl, &dwFetched)) && dwFetched) - { - if (DPA_InsertPtr(hdpa, 0x7fff, pidl) == -1) - { - SHFree(pidl); - } - } - - /* sort the array */ - DPA_Sort(hdpa, ShellView_CompareItems, (LPARAM)This->pSFParent); - - /*turn the listview's redrawing off*/ - SendMessageA(This->hWndList, WM_SETREDRAW, FALSE, 0); - - DPA_DestroyCallback( hdpa, fill_list, This ); - - /*turn the listview's redrawing back on and force it to draw*/ - SendMessageA(This->hWndList, WM_SETREDRAW, TRUE, 0); - - IEnumIDList_Release(pEnumIDList); /* destroy the list*/ - - return S_OK; -} - -/********************************************************** -* ShellView_OnCreate() -*/ -static LRESULT ShellView_OnCreate(IShellViewImpl * This) -{ - IDropTarget* pdt; - SHChangeNotifyEntry ntreg; - IPersistFolder2 * ppf2 = NULL; - - TRACE("%p\n",This); - - if(ShellView_CreateList(This)) - { - if(ShellView_InitList(This)) - { - ShellView_FillList(This); - } - } - - if (SUCCEEDED(IUnknown_QueryInterface((IUnknown*)&This->lpVtbl, &IID_IDropTarget, (LPVOID*)&pdt))) - { - RegisterDragDrop(This->hWnd, pdt); - IDropTarget_Release(pdt); - } - - /* register for receiving notifications */ - IShellFolder_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&ppf2); - if (ppf2) - { - IPersistFolder2_GetCurFolder(ppf2, (LPITEMIDLIST*)&ntreg.pidl); - ntreg.fRecursive = TRUE; - This->hNotify = SHChangeNotifyRegister(This->hWnd, SHCNF_IDLIST, SHCNE_ALLEVENTS, SHV_CHANGE_NOTIFY, 1, &ntreg); - SHFree((LPITEMIDLIST)ntreg.pidl); - IPersistFolder2_Release(ppf2); - } - - This->hAccel = LoadAcceleratorsA(shell32_hInstance, "shv_accel"); - - return S_OK; -} - -/********************************************************** - * #### Handling of the menus #### - */ - -/********************************************************** -* ShellView_BuildFileMenu() -*/ -static HMENU ShellView_BuildFileMenu(IShellViewImpl * This) -{ WCHAR szText[MAX_PATH]; - MENUITEMINFOW mii; - int nTools,i; - HMENU hSubMenu; - - TRACE("(%p)\n",This); - - hSubMenu = CreatePopupMenu(); - if(hSubMenu) - { /*get the number of items in our global array*/ - for(nTools = 0; Tools[nTools].idCommand != -1; nTools++){} - - /*add the menu items*/ - for(i = 0; i < nTools; i++) - { - LoadStringW(shell32_hInstance, Tools[i].idMenuString, szText, MAX_PATH); - - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE; - - if(BTNS_SEP != Tools[i].bStyle) /* no separator*/ - { - mii.fType = MFT_STRING; - mii.fState = MFS_ENABLED; - mii.dwTypeData = szText; - mii.wID = Tools[i].idCommand; - } - else - { - mii.fType = MFT_SEPARATOR; - } - /* tack This item onto the end of the menu */ - InsertMenuItemW(hSubMenu, (UINT)-1, TRUE, &mii); - } - } - TRACE("-- return (menu=%p)\n",hSubMenu); - return hSubMenu; -} -/********************************************************** -* ShellView_MergeFileMenu() -*/ -static void ShellView_MergeFileMenu(IShellViewImpl * This, HMENU hSubMenu) -{ TRACE("(%p)->(submenu=%p) stub\n",This,hSubMenu); - - if(hSubMenu) - { /*insert This item at the beginning of the menu */ - _InsertMenuItemW(hSubMenu, 0, TRUE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED); - _InsertMenuItemW(hSubMenu, 0, TRUE, IDM_MYFILEITEM, MFT_STRING, L"dummy45", MFS_ENABLED); - - } - TRACE("--\n"); -} - -/********************************************************** -* ShellView_MergeViewMenu() -*/ - -static void ShellView_MergeViewMenu(IShellViewImpl * This, HMENU hSubMenu) -{ - TRACE("(%p)->(submenu=%p)\n",This,hSubMenu); - - if(hSubMenu) - { /*add a separator at the correct position in the menu*/ - MENUITEMINFOW mii; - static WCHAR view[] = L"View"; - - _InsertMenuItemW(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED); - - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA; - mii.fType = MFT_STRING; - mii.dwTypeData = view; - mii.hSubMenu = LoadMenuW(shell32_hInstance, L"MENU_001"); - InsertMenuItemW(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii); - } -} - -/********************************************************** -* ShellView_GetSelections() -* -* - fills the this->apidl list with the selected objects -* -* RETURNS -* number of selected items -*/ -static UINT ShellView_GetSelections(IShellViewImpl * This) -{ - LVITEMW lvItem; - UINT i = 0; - - SHFree(This->apidl); - - This->cidl = ListView_GetSelectedCount(This->hWndList); - This->apidl = (LPITEMIDLIST*)SHAlloc(This->cidl * sizeof(LPITEMIDLIST)); - - TRACE("selected=%i\n", This->cidl); - - if(This->apidl) - { - TRACE("-- Items selected =%u\n", This->cidl); - - lvItem.mask = LVIF_STATE | LVIF_PARAM; - lvItem.stateMask = LVIS_SELECTED; - lvItem.iItem = 0; - lvItem.iSubItem = 0; - - while(SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM)&lvItem) && (i < This->cidl)) - { - if(lvItem.state & LVIS_SELECTED) - { - This->apidl[i] = (LPITEMIDLIST)lvItem.lParam; - i++; - if (i == This->cidl) - break; - TRACE("-- selected Item found\n"); - } - lvItem.iItem++; - } - } - return This->cidl; - -} - -/********************************************************** - * ShellView_OpenSelectedItems() - */ -static HRESULT ShellView_OpenSelectedItems(IShellViewImpl * This) -{ - static UINT CF_IDLIST = 0; - HRESULT hr; - IDataObject* selection; - IContextMenu * cm; - HMENU hmenu; - FORMATETC fetc; - STGMEDIUM stgm; - LPIDA pIDList; - LPCITEMIDLIST parent_pidl; - WCHAR parent_path[MAX_PATH]; - LPCWSTR parent_dir = NULL; - SFGAOF attribs; - int i; - CMINVOKECOMMANDINFOEX ici; - MENUITEMINFOW info; - - if (0 == ShellView_GetSelections(This)) - { - return S_OK; - } - - hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, - (LPCITEMIDLIST*)This->apidl, &IID_IContextMenu, - 0, (LPVOID *)&cm); - - if (SUCCEEDED(hr)) - { - hmenu = CreatePopupMenu(); - if (hmenu) - { - if (SUCCEEDED(IContextMenu_QueryContextMenu( cm, hmenu, 0, 0x20, 0x7fff, CMF_DEFAULTONLY))) - { - INT def = -1, n = GetMenuItemCount(hmenu); - - for ( i = 0; i < n; i++ ) - { - memset( &info, 0, sizeof info ); - info.cbSize = sizeof info; - info.fMask = MIIM_FTYPE | MIIM_STATE | MIIM_ID; - if (GetMenuItemInfoW( hmenu, i, TRUE, &info)) - { - if (info.fState & MFS_DEFAULT) - { - def = info.wID; - break; - } - } - } - if (def != -1) - { - memset( &ici, 0, sizeof ici ); - ici.cbSize = sizeof ici; - ici.lpVerb = MAKEINTRESOURCEA( def ); - ici.hwnd = This->hWnd; - - if (IContextMenu_InvokeCommand(cm, (LPCMINVOKECOMMANDINFO) &ici ) == S_OK) - { - IContextMenu_Release(cm); - DestroyMenu( hmenu ); - return S_OK; - } - } - - } - DestroyMenu( hmenu ); - } - IContextMenu_Release(cm); - } - - - - hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, - (LPCITEMIDLIST*)This->apidl, &IID_IDataObject, - 0, (LPVOID *)&selection); - - - - if (FAILED(hr)) - return hr; - - if (0 == CF_IDLIST) - { - CF_IDLIST = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); - } - fetc.cfFormat = CF_IDLIST; - fetc.ptd = NULL; - fetc.dwAspect = DVASPECT_CONTENT; - fetc.lindex = -1; - fetc.tymed = TYMED_HGLOBAL; - - hr = IDataObject_QueryGetData(selection, &fetc); - if (FAILED(hr)) - return hr; - - hr = IDataObject_GetData(selection, &fetc, &stgm); - if (FAILED(hr)) - return hr; - - pIDList = GlobalLock(stgm.u.hGlobal); - - parent_pidl = (LPCITEMIDLIST) ((LPBYTE)pIDList+pIDList->aoffset[0]); - hr = IShellFolder_GetAttributesOf(This->pSFParent, 1, &parent_pidl, &attribs); - if (SUCCEEDED(hr) && (attribs & SFGAO_FILESYSTEM) && - SHGetPathFromIDListW(parent_pidl, parent_path)) - { - parent_dir = parent_path; - } - - for (i = pIDList->cidl; i > 0; --i) - { - LPCITEMIDLIST pidl; - - pidl = (LPCITEMIDLIST)((LPBYTE)pIDList+pIDList->aoffset[i]); - - attribs = SFGAO_FOLDER; - hr = IShellFolder_GetAttributesOf(This->pSFParent, 1, &pidl, &attribs); - - if (SUCCEEDED(hr) && ! (attribs & SFGAO_FOLDER)) - { - SHELLEXECUTEINFOW shexinfo; - - shexinfo.cbSize = sizeof(SHELLEXECUTEINFOW); - shexinfo.fMask = SEE_MASK_INVOKEIDLIST; /* SEE_MASK_IDLIST is also possible. */ - shexinfo.hwnd = NULL; - shexinfo.lpVerb = NULL; - shexinfo.lpFile = NULL; - shexinfo.lpParameters = NULL; - shexinfo.lpDirectory = parent_dir; - shexinfo.nShow = SW_NORMAL; - shexinfo.lpIDList = ILCombine(parent_pidl, pidl); - - ShellExecuteExW(&shexinfo); /* Discard error/success info */ - - ILFree((LPITEMIDLIST)shexinfo.lpIDList); - } - } - - GlobalUnlock(stgm.u.hGlobal); - ReleaseStgMedium(&stgm); - - IDataObject_Release(selection); - - return S_OK; -} - -/********************************************************** - * ShellView_DoContextMenu() - */ -static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL bDefault) -{ UINT uCommand; - DWORD wFlags; - HMENU hMenu; - BOOL fExplore = FALSE; - HWND hwndTree = 0; - CMINVOKECOMMANDINFO cmi; - - TRACE("(%p)->(0x%08x 0x%08x 0x%08x) stub\n",This, x, y, bDefault); - - /* look, what's selected and create a context menu object of it*/ - if( ShellView_GetSelections(This) ) - { - IShellFolder_GetUIObjectOf( This->pSFParent, This->hWndParent, This->cidl, (LPCITEMIDLIST*)This->apidl, - (REFIID)&IID_IContextMenu, NULL, (LPVOID *)&This->pCM); - - if(This->pCM) - { - TRACE("-- pContextMenu\n"); - hMenu = CreatePopupMenu(); - - if( hMenu ) - { - /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/ - if(SUCCEEDED(IShellBrowser_GetControlWindow(This->pShellBrowser,FCW_TREE, &hwndTree)) && hwndTree) - { - TRACE("-- explore mode\n"); - fExplore = TRUE; - } - - /* build the flags depending on what we can do with the selected item */ - wFlags = CMF_NORMAL | (This->cidl != 1 ? 0 : CMF_CANRENAME) | (fExplore ? CMF_EXPLORE : 0); - - /* let the ContextMenu merge its items in */ - if (SUCCEEDED(IContextMenu_QueryContextMenu( This->pCM, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, wFlags ))) - { - if (This->FolderSettings.fFlags & FWF_DESKTOP) - SetMenuDefaultItem(hMenu, FCIDM_SHVIEW_OPEN, MF_BYCOMMAND); - - if( bDefault ) - { - TRACE("-- get menu default command\n"); - uCommand = GetMenuDefaultItem(hMenu, FALSE, GMDI_GOINTOPOPUPS); - } - else - { - TRACE("-- track popup\n"); - uCommand = TrackPopupMenu( hMenu,TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL); - } - - if(uCommand > 0) - { - TRACE("-- uCommand=%u\n", uCommand); - if (uCommand==FCIDM_SHVIEW_OPEN && IsInCommDlg(This)) - { - TRACE("-- dlg: OnDefaultCommand\n"); - if (OnDefaultCommand(This) != S_OK) - { - ShellView_OpenSelectedItems(This); - } - } - else - { - TRACE("-- explore -- invoke command\n"); - ZeroMemory(&cmi, sizeof(cmi)); - cmi.cbSize = sizeof(cmi); - cmi.hwnd = This->hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */ - cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand); - IContextMenu_InvokeCommand(This->pCM, &cmi); - } - } - DestroyMenu(hMenu); - } - } - if (This->pCM) - { - IContextMenu_Release(This->pCM); - This->pCM = NULL; - } - } - } - else /* background context menu */ - { - hMenu = CreatePopupMenu(); - - CDefFolderMenu_Create2(NULL, NULL, This->cidl, (LPCITEMIDLIST*)This->apidl, This->pSFParent, NULL, 0, NULL, (IContextMenu**)&This->pCM); - IContextMenu2_QueryContextMenu(This->pCM, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0); - - uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL); - DestroyMenu(hMenu); - - TRACE("-- (%p)->(uCommand=0x%08x )\n",This, uCommand); - - ZeroMemory(&cmi, sizeof(cmi)); - cmi.cbSize = sizeof(cmi); - cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand); - cmi.hwnd = This->hWndParent; - IContextMenu2_InvokeCommand(This->pCM, &cmi); - - IContextMenu2_Release(This->pCM); - This->pCM = NULL; - } -} - -/********************************************************** - * ##### message handling ##### - */ - -/********************************************************** -* ShellView_OnSize() -*/ -static LRESULT ShellView_OnSize(IShellViewImpl * This, WORD wWidth, WORD wHeight) -{ - TRACE("%p width=%u height=%u\n",This, wWidth,wHeight); - - /*resize the ListView to fit our window*/ - if(This->hWndList) - { - MoveWindow(This->hWndList, 0, 0, wWidth, wHeight, TRUE); - } - - return S_OK; -} -/********************************************************** -* ShellView_OnDeactivate() -* -* NOTES -* internal -*/ -static void ShellView_OnDeactivate(IShellViewImpl * This) -{ - TRACE("%p\n",This); - - if(This->uState != SVUIA_DEACTIVATE) - { - if(This->hMenu) - { - IShellBrowser_SetMenuSB(This->pShellBrowser,0, 0, 0); - IShellBrowser_RemoveMenusSB(This->pShellBrowser,This->hMenu); - DestroyMenu(This->hMenu); - This->hMenu = 0; - } - - This->uState = SVUIA_DEACTIVATE; - } -} - -/********************************************************** -* ShellView_OnActivate() -*/ -static LRESULT ShellView_OnActivate(IShellViewImpl * This, UINT uState) -{ OLEMENUGROUPWIDTHS omw = { {0, 0, 0, 0, 0, 0} }; - MENUITEMINFOA mii; - CHAR szText[MAX_PATH]; - - TRACE("%p uState=%x\n",This,uState); - - /*don't do anything if the state isn't really changing */ - if(This->uState == uState) - { - return S_OK; - } - - ShellView_OnDeactivate(This); - - /*only do This if we are active */ - if(uState != SVUIA_DEACTIVATE) - { - /*merge the menus */ - This->hMenu = CreateMenu(); - - if(This->hMenu) - { - IShellBrowser_InsertMenusSB(This->pShellBrowser, This->hMenu, &omw); - TRACE("-- after fnInsertMenusSB\n"); - - /*build the top level menu get the menu item's text*/ - strcpy(szText,"dummy 31"); - - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE; - mii.fType = MFT_STRING; - mii.fState = MFS_ENABLED; - mii.dwTypeData = szText; - mii.hSubMenu = ShellView_BuildFileMenu(This); - - /*insert our menu into the menu bar*/ - if(mii.hSubMenu) - { - InsertMenuItemA(This->hMenu, FCIDM_MENU_HELP, FALSE, &mii); - } - - /*get the view menu so we can merge with it*/ - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_SUBMENU; - - if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_VIEW, FALSE, &mii)) - { - ShellView_MergeViewMenu(This, mii.hSubMenu); - } - - /*add the items that should only be added if we have the focus*/ - if(SVUIA_ACTIVATE_FOCUS == uState) - { - /*get the file menu so we can merge with it */ - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_SUBMENU; - - if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_FILE, FALSE, &mii)) - { - ShellView_MergeFileMenu(This, mii.hSubMenu); - } - } - TRACE("-- before fnSetMenuSB\n"); - IShellBrowser_SetMenuSB(This->pShellBrowser, This->hMenu, 0, This->hWnd); - } - } - This->uState = uState; - TRACE("--\n"); - return S_OK; -} - -/********************************************************** -* ShellView_OnSetFocus() -* -*/ -static LRESULT ShellView_OnSetFocus(IShellViewImpl * This) -{ - TRACE("%p\n",This); - - /* Tell the browser one of our windows has received the focus. This - should always be done before merging menus (OnActivate merges the - menus) if one of our windows has the focus.*/ - - IShellBrowser_OnViewWindowActive(This->pShellBrowser,(IShellView*) This); - ShellView_OnActivate(This, SVUIA_ACTIVATE_FOCUS); - - /* Set the focus to the listview */ - SetFocus(This->hWndList); - - /* Notify the ICommDlgBrowser interface */ - OnStateChange(This,CDBOSC_SETFOCUS); - - return 0; -} - -/********************************************************** -* ShellView_OnKillFocus() -*/ -static LRESULT ShellView_OnKillFocus(IShellViewImpl * This) -{ - TRACE("(%p) stub\n",This); - - ShellView_OnActivate(This, SVUIA_ACTIVATE_NOFOCUS); - /* Notify the ICommDlgBrowser */ - OnStateChange(This,CDBOSC_KILLFOCUS); - - return 0; -} - -/********************************************************** -* ShellView_OnCommand() -* -* NOTES -* the CmdID's are the ones from the context menu -*/ -static LRESULT ShellView_OnCommand(IShellViewImpl * This,DWORD dwCmdID, DWORD dwCmd, HWND hwndCmd) -{ - TRACE("(%p)->(0x%08x 0x%08x %p) stub\n",This, dwCmdID, dwCmd, hwndCmd); - - switch(dwCmdID) - { - case FCIDM_SHVIEW_SMALLICON: - This->FolderSettings.ViewMode = FVM_SMALLICON; - SetStyle (This, LVS_SMALLICON, LVS_TYPEMASK); - CheckToolbar(This); - break; - - case FCIDM_SHVIEW_BIGICON: - This->FolderSettings.ViewMode = FVM_ICON; - SetStyle (This, LVS_ICON, LVS_TYPEMASK); - CheckToolbar(This); - break; - - case FCIDM_SHVIEW_LISTVIEW: - This->FolderSettings.ViewMode = FVM_LIST; - SetStyle (This, LVS_LIST, LVS_TYPEMASK); - CheckToolbar(This); - break; - - case FCIDM_SHVIEW_REPORTVIEW: - This->FolderSettings.ViewMode = FVM_DETAILS; - SetStyle (This, LVS_REPORT, LVS_TYPEMASK); - CheckToolbar(This); - break; - - /* the menu-ID's for sorting are 0x30... see shrec.rc */ - case 0x30: - case 0x31: - case 0x32: - case 0x33: - This->ListViewSortInfo.nHeaderID = (LPARAM) (dwCmdID - 0x30); - This->ListViewSortInfo.bIsAscending = TRUE; - This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID; - SendMessageA(This->hWndList, LVM_SORTITEMS, (WPARAM) &This->ListViewSortInfo, (LPARAM)ShellView_ListViewCompareItems); - break; - - default: - TRACE("-- COMMAND 0x%04x unhandled\n", dwCmdID); - } - return 0; -} - -/********************************************************** -* ShellView_OnNotify() -*/ - -static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpnmh) -{ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lpnmh; - NMLVDISPINFOW *lpdi = (NMLVDISPINFOW *)lpnmh; - LPITEMIDLIST pidl; - - TRACE("%p CtlID=%u lpnmh->code=%x\n",This,CtlID,lpnmh->code); - - switch(lpnmh->code) - { - case NM_SETFOCUS: - TRACE("-- NM_SETFOCUS %p\n",This); - ShellView_OnSetFocus(This); - break; - - case NM_KILLFOCUS: - TRACE("-- NM_KILLFOCUS %p\n",This); - ShellView_OnDeactivate(This); - /* Notify the ICommDlgBrowser interface */ - OnStateChange(This,CDBOSC_KILLFOCUS); - break; - - case NM_CUSTOMDRAW: - TRACE("-- NM_CUSTOMDRAW %p\n",This); - return CDRF_DODEFAULT; - - case NM_RELEASEDCAPTURE: - TRACE("-- NM_RELEASEDCAPTURE %p\n",This); - break; - - case NM_CLICK: - TRACE("-- NM_CLICK %p\n",This); - break; - - case NM_RCLICK: - TRACE("-- NM_RCLICK %p\n",This); - break; - - case NM_DBLCLK: - TRACE("-- NM_DBLCLK %p\n",This); - if (OnDefaultCommand(This) != S_OK) ShellView_OpenSelectedItems(This); - break; - - case NM_RETURN: - TRACE("-- NM_RETURN %p\n",This); - if (OnDefaultCommand(This) != S_OK) ShellView_OpenSelectedItems(This); - break; - - case HDN_ENDTRACKW: - TRACE("-- HDN_ENDTRACKW %p\n",This); - /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0); - nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/ - break; - - case LVN_DELETEITEM: - TRACE("-- LVN_DELETEITEM %p\n",This); - SHFree((LPITEMIDLIST)lpnmlv->lParam); /*delete the pidl because we made a copy of it*/ - break; - - case LVN_DELETEALLITEMS: - TRACE("-- LVN_DELETEALLITEMS %p\n",This); - return FALSE; - - case LVN_INSERTITEM: - TRACE("-- LVN_INSERTITEM (STUB)%p\n",This); - break; - - case LVN_ITEMACTIVATE: - TRACE("-- LVN_ITEMACTIVATE %p\n",This); - OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */ - break; - - case LVN_COLUMNCLICK: - This->ListViewSortInfo.nHeaderID = lpnmlv->iSubItem; - if(This->ListViewSortInfo.nLastHeaderID == This->ListViewSortInfo.nHeaderID) - { - This->ListViewSortInfo.bIsAscending = !This->ListViewSortInfo.bIsAscending; - } - else - { - This->ListViewSortInfo.bIsAscending = TRUE; - } - This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID; - - SendMessageW(lpnmlv->hdr.hwndFrom, LVM_SORTITEMS, (WPARAM) &This->ListViewSortInfo, (LPARAM)ShellView_ListViewCompareItems); - break; - - case LVN_GETDISPINFOA: - case LVN_GETDISPINFOW: - TRACE("-- LVN_GETDISPINFO %p\n",This); - pidl = (LPITEMIDLIST)lpdi->item.lParam; - - if(lpdi->item.mask & LVIF_TEXT) /* text requested */ - { - if (This->pSF2Parent) - { - SHELLDETAILS sd; - IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd); - if (lpnmh->code == LVN_GETDISPINFOA) - { - /* shouldn't happen */ - NMLVDISPINFOA *lpdiA = (NMLVDISPINFOA *)lpnmh; - StrRetToStrNA( lpdiA->item.pszText, lpdiA->item.cchTextMax, &sd.str, NULL); - TRACE("-- text=%s\n",lpdiA->item.pszText); - } - else /* LVN_GETDISPINFOW */ - { - StrRetToStrNW( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL); - TRACE("-- text=%s\n",debugstr_w(lpdi->item.pszText)); - } - } - else - { - FIXME("no SF2\n"); - } - } - if(lpdi->item.mask & LVIF_IMAGE) /* image requested */ - { - lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0); - } - break; - - case LVN_ITEMCHANGED: - TRACE("-- LVN_ITEMCHANGED %p\n",This); - OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */ - break; - - case LVN_BEGINDRAG: - case LVN_BEGINRDRAG: - TRACE("-- LVN_BEGINDRAG\n"); - - if (ShellView_GetSelections(This)) - { - IDataObject * pda; - DWORD dwAttributes = SFGAO_CANLINK; - DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE; - - if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, &IID_IDataObject,0,(LPVOID *)&pda))) - { - IDropSource * pds = (IDropSource*)&(This->lpvtblDropSource); /* own DropSource interface */ - - if (SUCCEEDED(IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, (LPCITEMIDLIST*)This->apidl, &dwAttributes))) - { - if (dwAttributes & SFGAO_CANLINK) - { - dwEffect |= DROPEFFECT_LINK; - } - } - - if (pds) - { - DWORD dwEffect2; - DoDragDrop(pda, pds, dwEffect, &dwEffect2); - } - IDataObject_Release(pda); - } - } - break; - - case LVN_BEGINLABELEDITW: - { - DWORD dwAttr = SFGAO_CANRENAME; - pidl = (LPITEMIDLIST)lpdi->item.lParam; - - TRACE("-- LVN_BEGINLABELEDITW %p\n",This); - - IShellFolder_GetAttributesOf(This->pSFParent, 1, (LPCITEMIDLIST*)&pidl, &dwAttr); - if (SFGAO_CANRENAME & dwAttr) - { - return FALSE; - } - return TRUE; - } - - case LVN_ENDLABELEDITW: - { - TRACE("-- LVN_ENDLABELEDITW %p\n",This); - if (lpdi->item.pszText) - { - HRESULT hr; - LVITEMW lvItem; - - lvItem.iItem = lpdi->item.iItem; - lvItem.iSubItem = 0; - lvItem.mask = LVIF_PARAM; - SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem); - - pidl = (LPITEMIDLIST)lpdi->item.lParam; - hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, lpdi->item.pszText, SHGDN_INFOLDER, &pidl); - - if(SUCCEEDED(hr) && pidl) - { - lvItem.mask = LVIF_PARAM; - lvItem.lParam = (LPARAM)pidl; - SendMessageW(This->hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem); - return TRUE; - } - } - return FALSE; - } - - case LVN_KEYDOWN: - { - /* MSG msg; - msg.hwnd = This->hWnd; - msg.message = WM_KEYDOWN; - msg.wParam = plvKeyDown->wVKey; - msg.lParam = 0; - msg.time = 0; - msg.pt = 0;*/ - - LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh; - SHORT ctrl = GetKeyState(VK_CONTROL) & 0x8000; - - /* initiate a rename of the selected file or directory */ - if(plvKeyDown->wVKey == VK_F2) - { - /* see how many files are selected */ - int i = ListView_GetSelectedCount(This->hWndList); - - /* get selected item */ - if(i == 1) - { - /* get selected item */ - i = ListView_GetNextItem(This->hWndList, -1, - LVNI_SELECTED); - - SendMessageW(This->hWndList, LVM_ENSUREVISIBLE, i, 0); - SendMessageW(This->hWndList, LVM_EDITLABELW, i, 0); - } - } -#if 0 - TranslateAccelerator(This->hWnd, This->hAccel, &msg) -#endif - else if(plvKeyDown->wVKey == VK_DELETE) - { - UINT i; - int item_index; - LVITEMA item; - LPITEMIDLIST* pItems; - ISFHelper *psfhlp; - - IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, - (LPVOID*)&psfhlp); - - if (psfhlp == NULL) - break; - - if(!(i = ListView_GetSelectedCount(This->hWndList))) - break; - - /* allocate memory for the pidl array */ - pItems = HeapAlloc(GetProcessHeap(), 0, - sizeof(LPITEMIDLIST) * i); - - /* retrieve all selected items */ - i = 0; - item_index = -1; - while(ListView_GetSelectedCount(This->hWndList) > i) - { - /* get selected item */ - item_index = ListView_GetNextItem(This->hWndList, - item_index, LVNI_SELECTED); - item.iItem = item_index; - item.mask = LVIF_PARAM; - SendMessageA(This->hWndList, LVM_GETITEMA, 0, (LPARAM) &item); - - /* get item pidl */ - pItems[i] = (LPITEMIDLIST)item.lParam; - - i++; - } - - /* perform the item deletion */ - ISFHelper_DeleteItems(psfhlp, i, (LPCITEMIDLIST*)pItems); - - /* free pidl array memory */ - HeapFree(GetProcessHeap(), 0, pItems); - } - - /* Initiate a refresh */ - else if(plvKeyDown->wVKey == VK_F5) - { - IShellView_Refresh((IShellView*)This); - } - else if(plvKeyDown->wVKey == VK_BACK) - { - LPSHELLBROWSER lpSb; - if((lpSb = (LPSHELLBROWSER)SendMessageW(This->hWndParent, CWM_GETISHELLBROWSER, 0, 0))) - { - IShellBrowser_BrowseObject(lpSb, NULL, SBSP_PARENT); - } - } - else if(plvKeyDown->wVKey == 'C' && ctrl) - { - if (ShellView_GetSelections(This)) - { - IDataObject * pda; - - if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, &IID_IDataObject,0,(LPVOID *)&pda))) - { - HRESULT hr = OleSetClipboard(pda); - if (FAILED(hr)) - { - WARN("OleSetClipboard failed"); - } - IDataObject_Release(pda); - } - } - break; - } - else if(plvKeyDown->wVKey == 'V' && ctrl) - { - IDataObject * pda; - STGMEDIUM medium; - FORMATETC formatetc; - LPITEMIDLIST * apidl; - LPITEMIDLIST pidl; - IShellFolder *psfFrom = NULL, *psfDesktop, *psfTarget = NULL; - LPIDA lpcida; - ISFHelper *psfhlpdst, *psfhlpsrc; - HRESULT hr; - - hr = OleGetClipboard(&pda); - if (hr != S_OK) - { - ERR("Failed to get clipboard with %lx\n", hr); - return E_FAIL; - } - - InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); - hr = IDataObject_GetData(pda,&formatetc,&medium); - - if (FAILED(hr)) - { - ERR("Failed to get clipboard data with %lx\n", hr); - IDataObject_Release(pda); - return E_FAIL; - } - - /* lock the handle */ - lpcida = GlobalLock(medium.u.hGlobal); - if (!lpcida) - { - ERR("failed to lock pidl\n"); - ReleaseStgMedium(&medium); - IDataObject_Release(pda); - return E_FAIL; - } - - /* convert the data into pidl */ - apidl = _ILCopyCidaToaPidl(&pidl, lpcida); - - if (!apidl) - { - ERR("failed to copy pidl\n"); - return E_FAIL; - } - - if (FAILED(SHGetDesktopFolder(&psfDesktop))) - { - ERR("failed to get desktop folder\n"); - SHFree(pidl); - _ILFreeaPidl(apidl, lpcida->cidl); - ReleaseStgMedium(&medium); - IDataObject_Release(pda); - return E_FAIL; - } - - if (_ILIsDesktop(pidl)) - { - /* use desktop shellfolder */ - psfFrom = psfDesktop; - } - else if (FAILED(IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (LPVOID*)&psfFrom))) - { - ERR("no IShellFolder\n"); - - IShellFolder_Release(psfDesktop); - SHFree(pidl); - _ILFreeaPidl(apidl, lpcida->cidl); - ReleaseStgMedium(&medium); - IDataObject_Release(pda); - - return E_FAIL; - } - - psfTarget = This->pSFParent; - - - /* get source and destination shellfolder */ - if (FAILED(IShellFolder_QueryInterface(psfTarget, &IID_ISFHelper, (LPVOID*)&psfhlpdst))) - { - ERR("no IID_ISFHelper for destination\n"); - - IShellFolder_Release(psfFrom); - IShellFolder_Release(psfTarget); - SHFree(pidl); - _ILFreeaPidl(apidl, lpcida->cidl); - ReleaseStgMedium(&medium); - IDataObject_Release(pda); - - return E_FAIL; - } - - if (FAILED(IShellFolder_QueryInterface(psfFrom, &IID_ISFHelper, (LPVOID*)&psfhlpsrc))) - { - ERR("no IID_ISFHelper for source\n"); - - ISFHelper_Release(psfhlpdst); - IShellFolder_Release(psfFrom); - IShellFolder_Release(psfTarget); - SHFree(pidl); - _ILFreeaPidl(apidl, lpcida->cidl); - ReleaseStgMedium(&medium); - IDataObject_Release(pda); - return E_FAIL; - } - - /* FIXXME - * do we want to perform a copy or move ??? - */ - hr = ISFHelper_CopyItems(psfhlpdst, psfFrom, lpcida->cidl, (LPCITEMIDLIST*)apidl); - - ISFHelper_Release(psfhlpdst); - ISFHelper_Release(psfhlpsrc); - IShellFolder_Release(psfFrom); - SHFree(pidl); - _ILFreeaPidl(apidl, lpcida->cidl); - ReleaseStgMedium(&medium); - IDataObject_Release(pda); - TRACE("paste end hr %x\n", hr); - break; - } - else - FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey); - } - break; - - default: - TRACE("-- %p WM_COMMAND %x unhandled\n", This, lpnmh->code); - break; - } - return 0; -} - -/********************************************************** -* ShellView_OnChange() -*/ - -static LRESULT ShellView_OnChange(IShellViewImpl * This, LPITEMIDLIST * Pidls, LONG wEventId) -{ - - TRACE("(%p)(%p,%p,0x%08x)\n", This, Pidls[0], Pidls[1], wEventId); - switch(wEventId) - { - case SHCNE_MKDIR: - case SHCNE_CREATE: - LV_AddItem(This, Pidls[0]); - break; - case SHCNE_RMDIR: - case SHCNE_DELETE: - LV_DeleteItem(This, Pidls[0]); - break; - case SHCNE_RENAMEFOLDER: - case SHCNE_RENAMEITEM: - LV_RenameItem(This, Pidls[0], Pidls[1]); - break; - case SHCNE_UPDATEITEM: - break; - } - return TRUE; -} - -/********************************************************** -* ShellView_DoMeasureItem -*/ - -static LRESULT ShellView_DoCustomItem(IShellViewImpl * pThis, HWND hWnd, UINT uMsg, LPARAM lParam) -{ - if (!pThis->pCM) - { - /* no menu */ - ERR("no menu!!!\n"); - return FALSE; - } - - if (pThis->pCM->lpVtbl->HandleMenuMsg(pThis->pCM, uMsg, (WPARAM)hWnd, lParam) == S_OK) - return TRUE; - else - return FALSE; -} - -/********************************************************** -* ShellView_WndProc -*/ - -static LRESULT CALLBACK ShellView_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) -{ - IShellViewImpl * pThis = (IShellViewImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA); - LPCREATESTRUCTW lpcs; - - TRACE("(hwnd=%p msg=%x wparm=%lx lparm=%lx)\n",hWnd, uMessage, wParam, lParam); - - switch (uMessage) - { - case WM_NCCREATE: - lpcs = (LPCREATESTRUCTW)lParam; - pThis = (IShellViewImpl*)(lpcs->lpCreateParams); - SetWindowLongPtrW(hWnd, GWLP_USERDATA, (ULONG_PTR)pThis); - pThis->hWnd = hWnd; /*set the window handle*/ - break; - - case WM_SIZE: return ShellView_OnSize(pThis,LOWORD(lParam), HIWORD(lParam)); - case WM_SETFOCUS: return ShellView_OnSetFocus(pThis); - case WM_KILLFOCUS: return ShellView_OnKillFocus(pThis); - case WM_CREATE: return ShellView_OnCreate(pThis); - case WM_ACTIVATE: return ShellView_OnActivate(pThis, SVUIA_ACTIVATE_FOCUS); - case WM_NOTIFY: return ShellView_OnNotify(pThis,(UINT)wParam, (LPNMHDR)lParam); - case WM_COMMAND: return ShellView_OnCommand(pThis, - GET_WM_COMMAND_ID(wParam, lParam), - GET_WM_COMMAND_CMD(wParam, lParam), - GET_WM_COMMAND_HWND(wParam, lParam)); - case SHV_CHANGE_NOTIFY: return ShellView_OnChange(pThis, (LPITEMIDLIST*)wParam, (LONG)lParam); - - case WM_CONTEXTMENU: ShellView_DoContextMenu(pThis, LOWORD(lParam), HIWORD(lParam), FALSE); - return 0; - case WM_DRAWITEM: - case WM_MEASUREITEM: - return ShellView_DoCustomItem(pThis, hWnd, uMessage, lParam); - - case WM_SHOWWINDOW: UpdateWindow(pThis->hWndList); - break; - - case WM_GETDLGCODE: return SendMessageW(pThis->hWndList,uMessage,0,0); - - case WM_DESTROY: - RevokeDragDrop(pThis->hWnd); - SHChangeNotifyDeregister(pThis->hNotify); - break; - - case WM_ERASEBKGND: - if ((pThis->FolderSettings.fFlags & FWF_DESKTOP) || - (pThis->FolderSettings.fFlags & FWF_TRANSPARENT)) - return SendMessageW(pThis->hWndParent, WM_ERASEBKGND, wParam, lParam); /* redirect to parent */ - break; - - case WM_SYSCOLORCHANGE: - /* Forward WM_SYSCOLORCHANGE to common controls */ - SendMessage(pThis->hWndList, WM_SYSCOLORCHANGE, 0, 0); - break; - - case CWM_GETISHELLBROWSER: - return (LRESULT)pThis->pShellBrowser; - } - return DefWindowProcW(hWnd, uMessage, wParam, lParam); -} -/********************************************************** -* -* -* The INTERFACE of the IShellView object -* -* -********************************************************** -* IShellView_QueryInterface -*/ -static HRESULT WINAPI IShellView_fnQueryInterface(IShellView * iface,REFIID riid, LPVOID *ppvObj) -{ - IShellViewImpl *This = (IShellViewImpl *)iface; - - TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj); - - *ppvObj = NULL; - - if(IsEqualIID(riid, &IID_IUnknown)) - { - *ppvObj = This; - } - else if(IsEqualIID(riid, &IID_IShellView)) - { - *ppvObj = (IShellView*)This; - } - else if(IsEqualIID(riid, &IID_IOleCommandTarget)) - { - *ppvObj = (IOleCommandTarget*)&(This->lpvtblOleCommandTarget); - } - else if(IsEqualIID(riid, &IID_IDropTarget)) - { - *ppvObj = (IDropTarget*)&(This->lpvtblDropTarget); - } - else if(IsEqualIID(riid, &IID_IDropSource)) - { - *ppvObj = (IDropSource*)&(This->lpvtblDropSource); - } - else if(IsEqualIID(riid, &IID_IViewObject)) - { - *ppvObj = (IViewObject*)&(This->lpvtblViewObject); - } - - if(*ppvObj) - { - IUnknown_AddRef( (IUnknown*)*ppvObj ); - TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj); - return S_OK; - } - TRACE("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -/********************************************************** -* IShellView_AddRef -*/ -static ULONG WINAPI IShellView_fnAddRef(IShellView * iface) -{ - IShellViewImpl *This = (IShellViewImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE("(%p)->(count=%u)\n", This, refCount - 1); - - return refCount; -} -/********************************************************** -* IShellView_Release -*/ -static ULONG WINAPI IShellView_fnRelease(IShellView * iface) -{ - IShellViewImpl *This = (IShellViewImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(count=%i)\n", This, refCount + 1); - - if (!refCount) - { - TRACE(" destroying IShellView(%p)\n",This); - - DestroyWindow(This->hWndList); - - if(This->pSFParent) - IShellFolder_Release(This->pSFParent); - - if(This->pSF2Parent) - IShellFolder2_Release(This->pSF2Parent); - - SHFree(This->apidl); - - if(This->pAdvSink) - IAdviseSink_Release(This->pAdvSink); - - if (This->pCM) - IContextMenu_Release(This->pCM); - - HeapFree(GetProcessHeap(),0,This); - } - return refCount; -} - -/********************************************************** -* ShellView_GetWindow -*/ -static HRESULT WINAPI IShellView_fnGetWindow(IShellView * iface,HWND * phWnd) -{ - IShellViewImpl *This = (IShellViewImpl *)iface; - - TRACE("(%p)\n",This); - - *phWnd = This->hWnd; - - return S_OK; -} - -static HRESULT WINAPI IShellView_fnContextSensitiveHelp(IShellView * iface,BOOL fEnterMode) -{ - IShellViewImpl *This = (IShellViewImpl *)iface; - - FIXME("(%p) stub\n",This); - - return E_NOTIMPL; -} - -/********************************************************** -* IShellView_TranslateAccelerator -* -* FIXME: -* use the accel functions -*/ -static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView * iface,LPMSG lpmsg) -{ -#if 0 - IShellViewImpl *This = (IShellViewImpl *)iface; - - FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%x wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam); -#endif - - if ((lpmsg->message>=WM_KEYFIRST) && (lpmsg->message>=WM_KEYLAST)) - { - TRACE("-- key=0x04%lx\n",lpmsg->wParam) ; - } - return S_FALSE; /* not handled */ -} - -static HRESULT WINAPI IShellView_fnEnableModeless(IShellView * iface,BOOL fEnable) -{ - IShellViewImpl *This = (IShellViewImpl *)iface; - - FIXME("(%p) stub\n",This); - - return E_NOTIMPL; -} - -static HRESULT WINAPI IShellView_fnUIActivate(IShellView * iface,UINT uState) -{ - IShellViewImpl *This = (IShellViewImpl *)iface; - -/* - CHAR szName[MAX_PATH]; -*/ - LRESULT lResult; - int nPartArray[1] = {-1}; - - TRACE("(%p)->(state=%x) stub\n",This, uState); - - /*don't do anything if the state isn't really changing*/ - if(This->uState == uState) - { - return S_OK; - } - - /*OnActivate handles the menu merging and internal state*/ - ShellView_OnActivate(This, uState); - - /*only do This if we are active*/ - if(uState != SVUIA_DEACTIVATE) - { - -/* - GetFolderPath is not a method of IShellFolder - IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) ); -*/ - /* set the number of parts */ - IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETPARTS, 1, - (LPARAM)nPartArray, &lResult); - - /* set the text for the parts */ -/* - IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA, - 0, (LPARAM)szName, &lResult); -*/ - } - - return S_OK; -} - -static HRESULT WINAPI IShellView_fnRefresh(IShellView * iface) -{ - IShellViewImpl *This = (IShellViewImpl *)iface; - - TRACE("(%p)\n",This); - - SendMessageW(This->hWndList, LVM_DELETEALLITEMS, 0, 0); - ShellView_FillList(This); - - return S_OK; -} - -static HRESULT WINAPI IShellView_fnCreateViewWindow( - IShellView * iface, - IShellView *lpPrevView, - LPCFOLDERSETTINGS lpfs, - IShellBrowser * psb, - RECT * prcView, - HWND *phWnd) -{ - IShellViewImpl *This = (IShellViewImpl *)iface; - - WNDCLASSW wc; - *phWnd = 0; - - - TRACE("(%p)->(shlview=%p set=%p shlbrs=%p rec=%p hwnd=%p) incomplete\n",This, lpPrevView,lpfs, psb, prcView, phWnd); - if (lpfs != NULL) - TRACE("-- vmode=%x flags=%x\n", lpfs->ViewMode, lpfs->fFlags); - if (prcView != NULL) - TRACE("-- left=%i top=%i right=%i bottom=%i\n", prcView->left, prcView->top, prcView->right, prcView->bottom); - - /* Validate the Shell Browser */ - if (psb == NULL) - return E_UNEXPECTED; - - /*set up the member variables*/ - This->pShellBrowser = psb; - This->FolderSettings = *lpfs; - - /*get our parent window*/ - IShellBrowser_AddRef(This->pShellBrowser); - IShellBrowser_GetWindow(This->pShellBrowser, &(This->hWndParent)); - - /* try to get the ICommDlgBrowserInterface, adds a reference !!! */ - This->pCommDlgBrowser=NULL; - if ( SUCCEEDED (IShellBrowser_QueryInterface( This->pShellBrowser, - (REFIID)&IID_ICommDlgBrowser, (LPVOID*) &This->pCommDlgBrowser))) - { - TRACE("-- CommDlgBrowser\n"); - } - - /*if our window class has not been registered, then do so*/ - if(!GetClassInfoW(shell32_hInstance, SV_CLASS_NAME, &wc)) - { - ZeroMemory(&wc, sizeof(wc)); - wc.style = 0; - wc.lpfnWndProc = ShellView_WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = shell32_hInstance; - wc.hIcon = 0; - wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW); - wc.hbrBackground = (HBRUSH) (COLOR_BACKGROUND+1); - wc.lpszMenuName = NULL; - wc.lpszClassName = SV_CLASS_NAME; - - if(!RegisterClassW(&wc)) - return E_FAIL; - } - - *phWnd = CreateWindowExW(0, - SV_CLASS_NAME, - NULL, - WS_CHILD | WS_TABSTOP, - prcView->left, - prcView->top, - prcView->right - prcView->left, - prcView->bottom - prcView->top, - This->hWndParent, - 0, - shell32_hInstance, - (LPVOID)This); - - CheckToolbar(This); - - if(!*phWnd) return E_FAIL; - - SetWindowPos(*phWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); - UpdateWindow(*phWnd); - - return S_OK; -} - -static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView * iface) -{ - IShellViewImpl *This = (IShellViewImpl *)iface; - - TRACE("(%p)\n",This); - - /*Make absolutely sure all our UI is cleaned up.*/ - IShellView_UIActivate((IShellView*)This, SVUIA_DEACTIVATE); - - if(This->hMenu) - { - DestroyMenu(This->hMenu); - } - - DestroyWindow(This->hWnd); - if(This->pShellBrowser) IShellBrowser_Release(This->pShellBrowser); - if(This->pCommDlgBrowser) ICommDlgBrowser_Release(This->pCommDlgBrowser); - - - return S_OK; -} - -static HRESULT WINAPI IShellView_fnGetCurrentInfo(IShellView * iface, LPFOLDERSETTINGS lpfs) -{ - IShellViewImpl *This = (IShellViewImpl *)iface; - - TRACE("(%p)->(%p) vmode=%x flags=%x\n",This, lpfs, - This->FolderSettings.ViewMode, This->FolderSettings.fFlags); - - if (!lpfs) return E_INVALIDARG; - - *lpfs = This->FolderSettings; - return NOERROR; -} - -static HRESULT WINAPI IShellView_fnAddPropertySheetPages(IShellView * iface, DWORD dwReserved,LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam) -{ - IShellViewImpl *This = (IShellViewImpl *)iface; - - FIXME("(%p) stub\n",This); - - return E_NOTIMPL; -} - -static HRESULT WINAPI IShellView_fnSaveViewState(IShellView * iface) -{ - IShellViewImpl *This = (IShellViewImpl *)iface; - - FIXME("(%p) stub\n",This); - - return S_OK; -} - -static HRESULT WINAPI IShellView_fnSelectItem( - IShellView * iface, - LPCITEMIDLIST pidl, - UINT uFlags) -{ - IShellViewImpl *This = (IShellViewImpl *)iface; - int i; - - TRACE("(%p)->(pidl=%p, 0x%08x) stub\n",This, pidl, uFlags); - - i = LV_FindItemByPidl(This, pidl); - - if (i != -1) - { - LVITEMW lvItem; - - if(uFlags & SVSI_ENSUREVISIBLE) - SendMessageW(This->hWndList, LVM_ENSUREVISIBLE, i, 0); - - lvItem.mask = LVIF_STATE; - lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED; - lvItem.iItem = 0; - lvItem.iSubItem = 0; - - while(SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem)) - { - if (lvItem.iItem == i) - { - if (uFlags & SVSI_SELECT) - lvItem.state |= LVIS_SELECTED; - else - lvItem.state &= ~LVIS_SELECTED; - - if(uFlags & SVSI_FOCUSED) - lvItem.state &= ~LVIS_FOCUSED; - } - else - { - if (uFlags & SVSI_DESELECTOTHERS) - lvItem.state &= ~LVIS_SELECTED; - } - SendMessageW(This->hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem); - lvItem.iItem++; - } - - - if(uFlags & SVSI_EDIT) - SendMessageW(This->hWndList, LVM_EDITLABELW, i, 0); - - } - return S_OK; -} - -static HRESULT WINAPI IShellView_fnGetItemObject(IShellView * iface, UINT uItem, REFIID riid, LPVOID *ppvOut) -{ - HRESULT hr = E_FAIL; - IShellViewImpl *This = (IShellViewImpl *)iface; - - TRACE("(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n",This, uItem, debugstr_guid(riid), ppvOut); - - *ppvOut = NULL; - - switch(uItem) - { - case SVGIO_BACKGROUND: - //*ppvOut = ISvBgCm_Constructor(This->pSFParent, FALSE); - CDefFolderMenu_Create2(NULL, NULL, This->cidl, (LPCITEMIDLIST*)This->apidl, This->pSFParent, NULL, 0, NULL, (IContextMenu**)ppvOut); - if (!ppvOut) hr = E_OUTOFMEMORY; - break; - - case SVGIO_SELECTION: - ShellView_GetSelections(This); - hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, riid, 0, ppvOut); - break; - } - TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut); - - return hr; -} - -static const IShellViewVtbl svvt = -{ - IShellView_fnQueryInterface, - IShellView_fnAddRef, - IShellView_fnRelease, - IShellView_fnGetWindow, - IShellView_fnContextSensitiveHelp, - IShellView_fnTranslateAccelerator, - IShellView_fnEnableModeless, - IShellView_fnUIActivate, - IShellView_fnRefresh, - IShellView_fnCreateViewWindow, - IShellView_fnDestroyViewWindow, - IShellView_fnGetCurrentInfo, - IShellView_fnAddPropertySheetPages, - IShellView_fnSaveViewState, - IShellView_fnSelectItem, - IShellView_fnGetItemObject -}; - - -/********************************************************** - * ISVOleCmdTarget_QueryInterface (IUnknown) - */ -static HRESULT WINAPI ISVOleCmdTarget_QueryInterface( - IOleCommandTarget * iface, - REFIID iid, - LPVOID* ppvObj) -{ - IShellViewImpl *This = impl_from_IOleCommandTarget(iface); - - return IShellFolder_QueryInterface((IShellFolder*)This, iid, ppvObj); -} - -/********************************************************** - * ISVOleCmdTarget_AddRef (IUnknown) - */ -static ULONG WINAPI ISVOleCmdTarget_AddRef( - IOleCommandTarget * iface) -{ - IShellViewImpl *This = impl_from_IOleCommandTarget(iface); - - return IShellFolder_AddRef((IShellFolder*)This); -} - -/********************************************************** - * ISVOleCmdTarget_Release (IUnknown) - */ -static ULONG WINAPI ISVOleCmdTarget_Release( - IOleCommandTarget * iface) -{ - IShellViewImpl *This = impl_from_IOleCommandTarget(iface); - - return IShellFolder_Release((IShellFolder*)This); -} - -/********************************************************** - * ISVOleCmdTarget_QueryStatus (IOleCommandTarget) - */ -static HRESULT WINAPI ISVOleCmdTarget_QueryStatus( - IOleCommandTarget *iface, - const GUID* pguidCmdGroup, - ULONG cCmds, - OLECMD * prgCmds, - OLECMDTEXT* pCmdText) -{ - UINT i; - IShellViewImpl *This = impl_from_IOleCommandTarget(iface); - - FIXME("(%p)->(%p(%s) 0x%08x %p %p\n", - This, pguidCmdGroup, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText); - - if (!prgCmds) - return E_POINTER; - for (i = 0; i < cCmds; i++) - { - FIXME("\tprgCmds[%d].cmdID = %d\n", i, prgCmds[i].cmdID); - prgCmds[i].cmdf = 0; - } - return OLECMDERR_E_UNKNOWNGROUP; -} - -/********************************************************** - * ISVOleCmdTarget_Exec (IOleCommandTarget) - * - * nCmdID is the OLECMDID_* enumeration - */ -static HRESULT WINAPI ISVOleCmdTarget_Exec( - IOleCommandTarget *iface, - const GUID* pguidCmdGroup, - DWORD nCmdID, - DWORD nCmdexecopt, - VARIANT* pvaIn, - VARIANT* pvaOut) -{ - IShellViewImpl *This = impl_from_IOleCommandTarget(iface); - - FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08x Opt:0x%08x %p %p)\n", - This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, pvaIn, pvaOut); - - if (IsEqualIID(pguidCmdGroup, &CGID_Explorer) && - (nCmdID == 0x29) && - (nCmdexecopt == 4) && pvaOut) - return S_OK; - if (IsEqualIID(pguidCmdGroup, &CGID_ShellDocView) && - (nCmdID == 9) && - (nCmdexecopt == 0)) - return 1; - - return OLECMDERR_E_UNKNOWNGROUP; -} - -static const IOleCommandTargetVtbl ctvt = -{ - ISVOleCmdTarget_QueryInterface, - ISVOleCmdTarget_AddRef, - ISVOleCmdTarget_Release, - ISVOleCmdTarget_QueryStatus, - ISVOleCmdTarget_Exec -}; - -/********************************************************** - * ISVDropTarget implementation - */ - -static HRESULT WINAPI ISVDropTarget_QueryInterface( - IDropTarget *iface, - REFIID riid, - LPVOID *ppvObj) -{ - IShellViewImpl *This = impl_from_IDropTarget(iface); - - TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj); - - return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj); -} - -static ULONG WINAPI ISVDropTarget_AddRef( IDropTarget *iface) -{ - IShellViewImpl *This = impl_from_IDropTarget(iface); - - TRACE("(%p)->(count=%u)\n",This,This->ref); - - return IShellFolder_AddRef((IShellFolder*)This); -} - -static ULONG WINAPI ISVDropTarget_Release( IDropTarget *iface) -{ - IShellViewImpl *This = impl_from_IDropTarget(iface); - - TRACE("(%p)->(count=%u)\n",This,This->ref); - - return IShellFolder_Release((IShellFolder*)This); -} - -/****************************************************************************** - * drag_notify_subitem [Internal] - * - * Figure out the shellfolder object, which is currently under the mouse cursor - * and notify it via the IDropTarget interface. - */ - -#define SCROLLAREAWIDTH 20 - -static HRESULT drag_notify_subitem(IShellViewImpl *This, DWORD grfKeyState, POINTL pt, - DWORD *pdwEffect) -{ - LVHITTESTINFO htinfo; - LVITEMW lvItem; - LONG lResult; - HRESULT hr; - RECT clientRect; - - /* Map from global to client coordinates and query the index of the listview-item, which is - * currently under the mouse cursor. */ - htinfo.pt.x = pt.x; - htinfo.pt.y = pt.y; - htinfo.flags = LVHT_ONITEM; - ScreenToClient(This->hWndList, &htinfo.pt); - lResult = SendMessageW(This->hWndList, LVM_HITTEST, 0, (LPARAM)&htinfo); - - /* Send WM_*SCROLL messages every 250 ms during drag-scrolling */ - GetClientRect(This->hWndList, &clientRect); - if (htinfo.pt.x == This->ptLastMousePos.x && htinfo.pt.y == This->ptLastMousePos.y && - (htinfo.pt.x < SCROLLAREAWIDTH || htinfo.pt.x > clientRect.right - SCROLLAREAWIDTH || - htinfo.pt.y < SCROLLAREAWIDTH || htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH )) - { - This->cScrollDelay = (This->cScrollDelay + 1) % 5; /* DragOver is called every 50 ms */ - if (This->cScrollDelay == 0) { /* Mouse did hover another 250 ms over the scroll-area */ - if (htinfo.pt.x < SCROLLAREAWIDTH) - SendMessageW(This->hWndList, WM_HSCROLL, SB_LINEUP, 0); - if (htinfo.pt.x > clientRect.right - SCROLLAREAWIDTH) - SendMessageW(This->hWndList, WM_HSCROLL, SB_LINEDOWN, 0); - if (htinfo.pt.y < SCROLLAREAWIDTH) - SendMessageW(This->hWndList, WM_VSCROLL, SB_LINEUP, 0); - if (htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH) - SendMessageW(This->hWndList, WM_VSCROLL, SB_LINEDOWN, 0); - } - } else { - This->cScrollDelay = 0; /* Reset, if the cursor is not over the listview's scroll-area */ - } - This->ptLastMousePos = htinfo.pt; - - /* If we are still over the previous sub-item, notify it via DragOver and return. */ - if (This->pCurDropTarget && lResult == This->iDragOverItem) - return IDropTarget_DragOver(This->pCurDropTarget, grfKeyState, pt, pdwEffect); - - /* We've left the previous sub-item, notify it via DragLeave and Release it. */ - if (This->pCurDropTarget) { - IDropTarget_DragLeave(This->pCurDropTarget); - IDropTarget_Release(This->pCurDropTarget); - This->pCurDropTarget = NULL; - } - - This->iDragOverItem = lResult; - if (lResult == -1) { - /* We are not above one of the listview's subitems. Bind to the parent folder's - * DropTarget interface. */ - hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IDropTarget, - (LPVOID*)&This->pCurDropTarget); - } else { - /* Query the relative PIDL of the shellfolder object represented by the currently - * dragged over listview-item ... */ - lvItem.mask = LVIF_PARAM; - lvItem.iItem = lResult; - lvItem.iSubItem = 0; - SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem); - - /* ... and bind pCurDropTarget to the IDropTarget interface of an UIObject of this object */ - hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWndList, 1, - (LPCITEMIDLIST*)&lvItem.lParam, &IID_IDropTarget, NULL, (LPVOID*)&This->pCurDropTarget); - } - - /* If anything failed, pCurDropTarget should be NULL now, which ought to be a save state. */ - if (FAILED(hr)) - return hr; - - /* Notify the item just entered via DragEnter. */ - return IDropTarget_DragEnter(This->pCurDropTarget, This->pCurDataObject, grfKeyState, pt, pdwEffect); -} - -static HRESULT WINAPI ISVDropTarget_DragEnter(IDropTarget *iface, IDataObject *pDataObject, - DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) -{ - IShellViewImpl *This = impl_from_IDropTarget(iface); - - /* Get a hold on the data object for later calls to DragEnter on the sub-folders */ - This->pCurDataObject = pDataObject; - IDataObject_AddRef(pDataObject); - - return drag_notify_subitem(This, grfKeyState, pt, pdwEffect); -} - -static HRESULT WINAPI ISVDropTarget_DragOver(IDropTarget *iface, DWORD grfKeyState, POINTL pt, - DWORD *pdwEffect) -{ - IShellViewImpl *This = impl_from_IDropTarget(iface); - return drag_notify_subitem(This, grfKeyState, pt, pdwEffect); -} - -static HRESULT WINAPI ISVDropTarget_DragLeave(IDropTarget *iface) { - IShellViewImpl *This = impl_from_IDropTarget(iface); - - if (This->pCurDropTarget) - { - IDropTarget_DragLeave(This->pCurDropTarget); - IDropTarget_Release(This->pCurDropTarget); - This->pCurDropTarget = NULL; - } - - if (This->pCurDataObject != NULL) - { - IDataObject_Release(This->pCurDataObject); - This->pCurDataObject = NULL; - } - - This->iDragOverItem = 0; - - return S_OK; -} - -static HRESULT WINAPI ISVDropTarget_Drop(IDropTarget *iface, IDataObject* pDataObject, - DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) -{ - IShellViewImpl *This = impl_from_IDropTarget(iface); - - if (This->pCurDropTarget) - { - IDropTarget_Drop(This->pCurDropTarget, pDataObject, grfKeyState, pt, pdwEffect); - IDropTarget_Release(This->pCurDropTarget); - This->pCurDropTarget = NULL; - } - - if (This->pCurDataObject != NULL) - { - IDataObject_Release(This->pCurDataObject); - This->pCurDataObject = NULL; - } - - This->iDragOverItem = 0; - - return S_OK; -} - -static const IDropTargetVtbl dtvt = -{ - ISVDropTarget_QueryInterface, - ISVDropTarget_AddRef, - ISVDropTarget_Release, - ISVDropTarget_DragEnter, - ISVDropTarget_DragOver, - ISVDropTarget_DragLeave, - ISVDropTarget_Drop -}; - -/********************************************************** - * ISVDropSource implementation - */ - -static HRESULT WINAPI ISVDropSource_QueryInterface( - IDropSource *iface, - REFIID riid, - LPVOID *ppvObj) -{ - IShellViewImpl *This = impl_from_IDropSource(iface); - - TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj); - - return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj); -} - -static ULONG WINAPI ISVDropSource_AddRef( IDropSource *iface) -{ - IShellViewImpl *This = impl_from_IDropSource(iface); - - TRACE("(%p)->(count=%u)\n",This,This->ref); - - return IShellFolder_AddRef((IShellFolder*)This); -} - -static ULONG WINAPI ISVDropSource_Release( IDropSource *iface) -{ - IShellViewImpl *This = impl_from_IDropSource(iface); - - TRACE("(%p)->(count=%u)\n",This,This->ref); - - return IShellFolder_Release((IShellFolder*)This); -} -static HRESULT WINAPI ISVDropSource_QueryContinueDrag( - IDropSource *iface, - BOOL fEscapePressed, - DWORD grfKeyState) -{ - IShellViewImpl *This = impl_from_IDropSource(iface); - TRACE("(%p)\n",This); - - if (fEscapePressed) - return DRAGDROP_S_CANCEL; - else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON)) - return DRAGDROP_S_DROP; - else - return NOERROR; -} - -static HRESULT WINAPI ISVDropSource_GiveFeedback( - IDropSource *iface, - DWORD dwEffect) -{ - IShellViewImpl *This = impl_from_IDropSource(iface); - TRACE("(%p)\n",This); - - return DRAGDROP_S_USEDEFAULTCURSORS; -} - -static const IDropSourceVtbl dsvt = -{ - ISVDropSource_QueryInterface, - ISVDropSource_AddRef, - ISVDropSource_Release, - ISVDropSource_QueryContinueDrag, - ISVDropSource_GiveFeedback -}; -/********************************************************** - * ISVViewObject implementation - */ - -static HRESULT WINAPI ISVViewObject_QueryInterface( - IViewObject *iface, - REFIID riid, - LPVOID *ppvObj) -{ - IShellViewImpl *This = impl_from_IViewObject(iface); - - TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj); - - return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj); -} - -static ULONG WINAPI ISVViewObject_AddRef( IViewObject *iface) -{ - IShellViewImpl *This = impl_from_IViewObject(iface); - - TRACE("(%p)->(count=%u)\n",This,This->ref); - - return IShellFolder_AddRef((IShellFolder*)This); -} - -static ULONG WINAPI ISVViewObject_Release( IViewObject *iface) -{ - IShellViewImpl *This = impl_from_IViewObject(iface); - - TRACE("(%p)->(count=%u)\n",This,This->ref); - - return IShellFolder_Release((IShellFolder*)This); -} - -static HRESULT WINAPI ISVViewObject_Draw( - IViewObject *iface, - DWORD dwDrawAspect, - LONG lindex, - void* pvAspect, - DVTARGETDEVICE* ptd, - HDC hdcTargetDev, - HDC hdcDraw, - LPCRECTL lprcBounds, - LPCRECTL lprcWBounds, - BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), - ULONG_PTR dwContinue) -{ - - IShellViewImpl *This = impl_from_IViewObject(iface); - - FIXME("Stub: This=%p\n",This); - - return E_NOTIMPL; -} -static HRESULT WINAPI ISVViewObject_GetColorSet( - IViewObject *iface, - DWORD dwDrawAspect, - LONG lindex, - void *pvAspect, - DVTARGETDEVICE* ptd, - HDC hicTargetDevice, - LOGPALETTE** ppColorSet) -{ - - IShellViewImpl *This = impl_from_IViewObject(iface); - - FIXME("Stub: This=%p\n",This); - - return E_NOTIMPL; -} -static HRESULT WINAPI ISVViewObject_Freeze( - IViewObject *iface, - DWORD dwDrawAspect, - LONG lindex, - void* pvAspect, - DWORD* pdwFreeze) -{ - - IShellViewImpl *This = impl_from_IViewObject(iface); - - FIXME("Stub: This=%p\n",This); - - return E_NOTIMPL; -} -static HRESULT WINAPI ISVViewObject_Unfreeze( - IViewObject *iface, - DWORD dwFreeze) -{ - - IShellViewImpl *This = impl_from_IViewObject(iface); - - FIXME("Stub: This=%p\n",This); - - return E_NOTIMPL; -} -static HRESULT WINAPI ISVViewObject_SetAdvise( - IViewObject *iface, - DWORD aspects, - DWORD advf, - IAdviseSink* pAdvSink) -{ - - IShellViewImpl *This = impl_from_IViewObject(iface); - - FIXME("partial stub: %p %08x %08x %p\n", - This, aspects, advf, pAdvSink); - - /* FIXME: we set the AdviseSink, but never use it to send any advice */ - This->pAdvSink = pAdvSink; - This->dwAspects = aspects; - This->dwAdvf = advf; - - return S_OK; -} - -static HRESULT WINAPI ISVViewObject_GetAdvise( - IViewObject *iface, - DWORD* pAspects, - DWORD* pAdvf, - IAdviseSink** ppAdvSink) -{ - - IShellViewImpl *This = impl_from_IViewObject(iface); - - TRACE("This=%p pAspects=%p pAdvf=%p ppAdvSink=%p\n", - This, pAspects, pAdvf, ppAdvSink); - - if( ppAdvSink ) - { - IAdviseSink_AddRef( This->pAdvSink ); - *ppAdvSink = This->pAdvSink; - } - if( pAspects ) - *pAspects = This->dwAspects; - if( pAdvf ) - *pAdvf = This->dwAdvf; - - return S_OK; -} - - -static const IViewObjectVtbl vovt = -{ - ISVViewObject_QueryInterface, - ISVViewObject_AddRef, - ISVViewObject_Release, - ISVViewObject_Draw, - ISVViewObject_GetColorSet, - ISVViewObject_Freeze, - ISVViewObject_Unfreeze, - ISVViewObject_SetAdvise, - ISVViewObject_GetAdvise -}; diff --git a/reactos/dll/win32/shell32/shpolicy.c b/reactos/dll/win32/shell32/shpolicy.c deleted file mode 100644 index 9678fb39cee..00000000000 --- a/reactos/dll/win32/shell32/shpolicy.c +++ /dev/null @@ -1,905 +0,0 @@ -/* - * shpolicy.c - Data for shell/system policies. - * - * Copyright 1999 Ian Schmidt - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - * - * NOTES: - * - * Some of these policies can be tweaked via the System Policy - * Editor which came with the Win95 Migration Guide, although - * there doesn't appear to be an updated Win98 version that - * would handle the many new policies introduced since then. - * You could easily write one with the information in - * this file... - * - * Up to date as of SHELL32 v5.00 (W2K) - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -#define SHELL_NO_POLICY 0xffffffff - -typedef struct tagPOLICYDAT -{ - DWORD policy; /* policy value passed to SHRestricted */ - LPCSTR appstr; /* application str such as "Explorer" */ - LPCSTR keystr; /* name of the actual registry key / policy */ - DWORD cache; /* cached value or 0xffffffff for invalid */ -} POLICYDATA, *LPPOLICYDATA; - -/* registry strings */ -static const CHAR strRegistryPolicyA[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies"; -static const WCHAR strRegistryPolicyW[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o', - 's','o','f','t','\\','W','i','n','d','o','w','s','\\', - 'C','u','r','r','e','n','t','V','e','r','s','i','o','n', - '\\','P','o','l','i','c','i','e','s',0}; -static const CHAR strPolicyA[] = "Policy"; -static const WCHAR strPolicyW[] = {'P','o','l','i','c','y',0}; - -/* application strings */ - -static const char strExplorer[] = {"Explorer"}; -static const char strActiveDesk[] = {"ActiveDesktop"}; -static const char strWinOldApp[] = {"WinOldApp"}; -static const char strAddRemoveProgs[] = {"AddRemoveProgs"}; - -/* key strings */ - -static const char strNoFileURL[] = {"NoFileUrl"}; -static const char strNoFolderOptions[] = {"NoFolderOptions"}; -static const char strNoChangeStartMenu[] = {"NoChangeStartMenu"}; -static const char strNoWindowsUpdate[] = {"NoWindowsUpdate"}; -static const char strNoSetActiveDesktop[] = {"NoSetActiveDesktop"}; -static const char strNoForgetSoftwareUpdate[] = {"NoForgetSoftwareUpdate"}; -static const char strNoMSAppLogo[] = {"NoMSAppLogo5ChannelNotify"}; -static const char strForceCopyACLW[] = {"ForceCopyACLWithFile"}; -static const char strNoResolveTrk[] = {"NoResolveTrack"}; -static const char strNoResolveSearch[] = {"NoResolveSearch"}; -static const char strNoEditComponent[] = {"NoEditingComponents"}; -static const char strNoMovingBand[] = {"NoMovingBands"}; -static const char strNoCloseDragDrop[] = {"NoCloseDragDropBands"}; -static const char strNoCloseComponent[] = {"NoClosingComponents"}; -static const char strNoDelComponent[] = {"NoDeletingComponents"}; -static const char strNoAddComponent[] = {"NoAddingComponents"}; -static const char strNoComponent[] = {"NoComponents"}; -static const char strNoChangeWallpaper[] = {"NoChangingWallpaper"}; -static const char strNoHTMLWallpaper[] = {"NoHTMLWallpaper"}; -static const char strNoCustomWebView[] = {"NoCustomizeWebView"}; -static const char strClassicShell[] = {"ClassicShell"}; -static const char strClearRecentDocs[] = {"ClearRecentDocsOnExit"}; -static const char strNoFavoritesMenu[] = {"NoFavoritesMenu"}; -static const char strNoActiveDesktopChanges[] = {"NoActiveDesktopChanges"}; -static const char strNoActiveDesktop[] = {"NoActiveDesktop"}; -static const char strNoRecentDocMenu[] = {"NoRecentDocsMenu"}; -static const char strNoRecentDocHistory[] = {"NoRecentDocsHistory"}; -static const char strNoInetIcon[] = {"NoInternetIcon"}; -static const char strNoSettingsWizard[] = {"NoSettingsWizards"}; -static const char strNoLogoff[] = {"NoLogoff"}; -static const char strNoNetConDis[] = {"NoNetConnectDisconnect"}; -static const char strNoViewContextMenu[] = {"NoViewContextMenu"}; -static const char strNoTrayContextMenu[] = {"NoTrayContextMenu"}; -static const char strNoWebMenu[] = {"NoWebMenu"}; -static const char strLnkResolveIgnoreLnkInfo[] = {"LinkResolveIgnoreLinkInfo"}; -static const char strNoCommonGroups[] = {"NoCommonGroups"}; -static const char strEnforceShlExtSecurity[] = {"EnforceShellExtensionSecurity"}; -static const char strNoRealMode[] = {"NoRealMode"}; -static const char strMyDocsOnNet[] = {"MyDocsOnNet"}; -static const char strNoStartMenuSubfolder[] = {"NoStartMenuSubFolders"}; -static const char strNoAddPrinters[] = {"NoAddPrinter"}; -static const char strNoDeletePrinters[] = {"NoDeletePrinter"}; -static const char strNoPrintTab[] = {"NoPrinterTabs"}; -static const char strRestrictRun[] = {"RestrictRun"}; -static const char strNoStartBanner[] = {"NoStartBanner"}; -static const char strNoNetworkNeighborhood[] = {"NoNetHood"}; -static const char strNoDriveTypeAtRun[] = {"NoDriveTypeAutoRun"}; -static const char strNoDrivesAutoRun[] = {"NoDriveAutoRun"}; -static const char strSeparateProcess[] = {"SeparateProcess"}; -static const char strNoDrives[] = {"NoDrives"}; -static const char strNoFind[] = {"NoFind"}; -static const char strNoDesktop[] = {"NoDesktop"}; -static const char strNoSetTaskBar[] = {"NoSetTaskbar"}; -static const char strNoSetFld[] = {"NoSetFolders"}; -static const char strNoFileMenu[] = {"NoFileMenu"}; -static const char strNoSaveSetting[] = {"NoSaveSettings"}; -static const char strNoClose[] = {"NoClose"}; -static const char strNoRun[] = {"NoRun"}; - -/* policy data array */ -static POLICYDATA sh32_policy_table[] = -{ - { - REST_NORUN, - strExplorer, - strNoRun, - SHELL_NO_POLICY - }, - { - REST_NOCLOSE, - strExplorer, - strNoClose, - SHELL_NO_POLICY - }, - { - REST_NOSAVESET, - strExplorer, - strNoSaveSetting, - SHELL_NO_POLICY - }, - { - REST_NOFILEMENU, - strExplorer, - strNoFileMenu, - SHELL_NO_POLICY - }, - { - REST_NOSETFOLDERS, - strExplorer, - strNoSetFld, - SHELL_NO_POLICY - }, - { - REST_NOSETTASKBAR, - strExplorer, - strNoSetTaskBar, - SHELL_NO_POLICY - }, - { - REST_NODESKTOP, - strExplorer, - strNoDesktop, - SHELL_NO_POLICY - }, - { - REST_NOFIND, - strExplorer, - strNoFind, - SHELL_NO_POLICY - }, - { - REST_NODRIVES, - strExplorer, - strNoDrives, - SHELL_NO_POLICY - }, - { - REST_NODRIVEAUTORUN, - strExplorer, - strNoDrivesAutoRun, - SHELL_NO_POLICY - }, - { - REST_NODRIVETYPEAUTORUN, - strExplorer, - strNoDriveTypeAtRun, - SHELL_NO_POLICY - }, - { - REST_NONETHOOD, - strExplorer, - strNoNetworkNeighborhood, - SHELL_NO_POLICY - }, - { - REST_STARTBANNER, - strExplorer, - strNoStartBanner, - SHELL_NO_POLICY - }, - { - REST_RESTRICTRUN, - strExplorer, - strRestrictRun, - SHELL_NO_POLICY - }, - { - REST_NOPRINTERTABS, - strExplorer, - strNoPrintTab, - SHELL_NO_POLICY - }, - { - REST_NOPRINTERDELETE, - strExplorer, - strNoDeletePrinters, - SHELL_NO_POLICY - }, - { - REST_NOPRINTERADD, - strExplorer, - strNoAddPrinters, - SHELL_NO_POLICY - }, - { - REST_NOSTARTMENUSUBFOLDERS, - strExplorer, - strNoStartMenuSubfolder, - SHELL_NO_POLICY - }, - { - REST_MYDOCSONNET, - strExplorer, - strMyDocsOnNet, - SHELL_NO_POLICY - }, - { - REST_NOEXITTODOS, - strWinOldApp, - strNoRealMode, - SHELL_NO_POLICY - }, - { - REST_ENFORCESHELLEXTSECURITY, - strExplorer, - strEnforceShlExtSecurity, - SHELL_NO_POLICY - }, - { - REST_LINKRESOLVEIGNORELINKINFO, - strExplorer, - strLnkResolveIgnoreLnkInfo, - SHELL_NO_POLICY - }, - { - REST_NOCOMMONGROUPS, - strExplorer, - strNoCommonGroups, - SHELL_NO_POLICY - }, - { - REST_SEPARATEDESKTOPPROCESS, - strExplorer, - strSeparateProcess, - SHELL_NO_POLICY - }, - { - REST_NOWEB, - strExplorer, - strNoWebMenu, - SHELL_NO_POLICY - }, - { - REST_NOTRAYCONTEXTMENU, - strExplorer, - strNoTrayContextMenu, - SHELL_NO_POLICY - }, - { - REST_NOVIEWCONTEXTMENU, - strExplorer, - strNoViewContextMenu, - SHELL_NO_POLICY - }, - { - REST_NONETCONNECTDISCONNECT, - strExplorer, - strNoNetConDis, - SHELL_NO_POLICY - }, - { - REST_STARTMENULOGOFF, - strExplorer, - strNoLogoff, - SHELL_NO_POLICY - }, - { - REST_NOSETTINGSASSIST, - strExplorer, - strNoSettingsWizard, - SHELL_NO_POLICY - }, - { - REST_NOINTERNETICON, - strExplorer, - strNoInetIcon, - SHELL_NO_POLICY - }, - { - REST_NORECENTDOCSHISTORY, - strExplorer, - strNoRecentDocHistory, - SHELL_NO_POLICY - }, - { - REST_NORECENTDOCSMENU, - strExplorer, - strNoRecentDocMenu, - SHELL_NO_POLICY - }, - { - REST_NOACTIVEDESKTOP, - strExplorer, - strNoActiveDesktop, - SHELL_NO_POLICY - }, - { - REST_NOACTIVEDESKTOPCHANGES, - strExplorer, - strNoActiveDesktopChanges, - SHELL_NO_POLICY - }, - { - REST_NOFAVORITESMENU, - strExplorer, - strNoFavoritesMenu, - SHELL_NO_POLICY - }, - { - REST_CLEARRECENTDOCSONEXIT, - strExplorer, - strClearRecentDocs, - SHELL_NO_POLICY - }, - { - REST_CLASSICSHELL, - strExplorer, - strClassicShell, - SHELL_NO_POLICY - }, - { - REST_NOCUSTOMIZEWEBVIEW, - strExplorer, - strNoCustomWebView, - SHELL_NO_POLICY - }, - { - REST_NOHTMLWALLPAPER, - strActiveDesk, - strNoHTMLWallpaper, - SHELL_NO_POLICY - }, - { - REST_NOCHANGINGWALLPAPER, - strActiveDesk, - strNoChangeWallpaper, - SHELL_NO_POLICY - }, - { - REST_NODESKCOMP, - strActiveDesk, - strNoComponent, - SHELL_NO_POLICY - }, - { - REST_NOADDDESKCOMP, - strActiveDesk, - strNoAddComponent, - SHELL_NO_POLICY - }, - { - REST_NODELDESKCOMP, - strActiveDesk, - strNoDelComponent, - SHELL_NO_POLICY - }, - { - REST_NOCLOSEDESKCOMP, - strActiveDesk, - strNoCloseComponent, - SHELL_NO_POLICY - }, - { - REST_NOCLOSE_DRAGDROPBAND, - strActiveDesk, - strNoCloseDragDrop, - SHELL_NO_POLICY - }, - { - REST_NOMOVINGBAND, - strActiveDesk, - strNoMovingBand, - SHELL_NO_POLICY - }, - { - REST_NOEDITDESKCOMP, - strActiveDesk, - strNoEditComponent, - SHELL_NO_POLICY - }, - { - REST_NORESOLVESEARCH, - strExplorer, - strNoResolveSearch, - SHELL_NO_POLICY - }, - { - REST_NORESOLVETRACK, - strExplorer, - strNoResolveTrk, - SHELL_NO_POLICY - }, - { - REST_FORCECOPYACLWITHFILE, - strExplorer, - strForceCopyACLW, - SHELL_NO_POLICY - }, -#if (NTDDI_VERSION < NTDDI_LONGHORN) - { - REST_NOLOGO3CHANNELNOTIFY, - strExplorer, - strNoMSAppLogo, - SHELL_NO_POLICY - }, -#endif - { - REST_NOFORGETSOFTWAREUPDATE, - strExplorer, - strNoForgetSoftwareUpdate, - SHELL_NO_POLICY - }, - { - REST_NOSETACTIVEDESKTOP, - strExplorer, - strNoSetActiveDesktop, - SHELL_NO_POLICY - }, - { - REST_NOUPDATEWINDOWS, - strExplorer, - strNoWindowsUpdate, - SHELL_NO_POLICY - }, - { - REST_NOCHANGESTARMENU, - strExplorer, - strNoChangeStartMenu, - SHELL_NO_POLICY - }, - { - REST_NOFOLDEROPTIONS, - strExplorer, - strNoFolderOptions, - SHELL_NO_POLICY - }, - { - REST_HASFINDCOMPUTERS, - strExplorer, - "FindComputers", - SHELL_NO_POLICY - }, - { - REST_INTELLIMENUS, - strExplorer, - "IntelliMenus", - SHELL_NO_POLICY - }, - { - REST_RUNDLGMEMCHECKBOX, - strExplorer, - "MemCheckBoxInRunDlg", - SHELL_NO_POLICY - }, - { - REST_ARP_ShowPostSetup, - strAddRemoveProgs, - "ShowPostSetup", - SHELL_NO_POLICY - }, - { - REST_NOCSC, - strExplorer, - "NoSyncAll", - SHELL_NO_POLICY - }, - { - REST_NOCONTROLPANEL, - strExplorer, - "NoControlPanel", - SHELL_NO_POLICY - }, - { - REST_ENUMWORKGROUP, - strExplorer, - "EnumWorkgroup", - SHELL_NO_POLICY - }, - { - REST_ARP_NOARP, - strAddRemoveProgs, - "NoAddRemovePrograms", - SHELL_NO_POLICY - }, - { - REST_ARP_NOREMOVEPAGE, - strAddRemoveProgs, - "NoRemovePage", - SHELL_NO_POLICY - }, - { - REST_ARP_NOADDPAGE, - strAddRemoveProgs, - "NoAddPage", - SHELL_NO_POLICY - }, - { - REST_ARP_NOWINSETUPPAGE, - strAddRemoveProgs, - "NoWindowsSetupPage", - SHELL_NO_POLICY - }, - { - REST_GREYMSIADS, - strExplorer, - "", - SHELL_NO_POLICY - }, - { - REST_NOCHANGEMAPPEDDRIVELABEL, - strExplorer, - "NoChangeMappedDriveLabel", - SHELL_NO_POLICY - }, - { - REST_NOCHANGEMAPPEDDRIVECOMMENT, - strExplorer, - "NoChangeMappedDriveComment", - SHELL_NO_POLICY - }, - { - REST_MaxRecentDocs, - strExplorer, - "MaxRecentDocs", - SHELL_NO_POLICY - }, - { - REST_NONETWORKCONNECTIONS, - strExplorer, - "NoNetworkConnections", - SHELL_NO_POLICY - }, - { - REST_FORCESTARTMENULOGOFF, - strExplorer, - "ForceStartMenuLogoff", - SHELL_NO_POLICY - }, - { - REST_NOWEBVIEW, - strExplorer, - "NoWebView", - SHELL_NO_POLICY - }, - { - REST_NOCUSTOMIZETHISFOLDER, - strExplorer, - "NoCustomizeThisFolder", - SHELL_NO_POLICY - }, - { - REST_NOENCRYPTION, - strExplorer, - "NoEncryption", - SHELL_NO_POLICY - }, - { - REST_ALLOWFRENCHENCRYPTION, - strExplorer, - "AllowFrenchEncryption", - SHELL_NO_POLICY - }, - { - REST_DONTSHOWSUPERHIDDEN, - strExplorer, - "DontShowSuperHidden", - SHELL_NO_POLICY - }, - { - REST_NOSHELLSEARCHBUTTON, - strExplorer, - "NoShellSearchButton", - SHELL_NO_POLICY - }, - { - REST_NOHARDWARETAB, - strExplorer, - "NoHardwareTab", - SHELL_NO_POLICY - }, - { - REST_NORUNASINSTALLPROMPT, - strExplorer, - "NoRunasInstallPrompt", - SHELL_NO_POLICY - }, - { - REST_PROMPTRUNASINSTALLNETPATH, - strExplorer, - "PromptRunasInstallNetPath", - SHELL_NO_POLICY - }, - { - REST_NOMANAGEMYCOMPUTERVERB, - strExplorer, - "NoManageMyComputerVerb", - SHELL_NO_POLICY - }, - { - REST_NORECENTDOCSNETHOOD, - strExplorer, - "NoRecentDocsNetHood", - SHELL_NO_POLICY - }, - { - REST_DISALLOWRUN, - strExplorer, - "DisallowRun", - SHELL_NO_POLICY - }, - { - REST_NOWELCOMESCREEN, - strExplorer, - "NoWelcomeScreen", - SHELL_NO_POLICY - }, - { - REST_RESTRICTCPL, - strExplorer, - "RestrictCpl", - SHELL_NO_POLICY - }, - { - REST_DISALLOWCPL, - strExplorer, - "DisallowCpl", - SHELL_NO_POLICY - }, - { - REST_NOSMBALLOONTIP, - strExplorer, - "NoSMBalloonTip", - SHELL_NO_POLICY - }, - { - REST_NOSMHELP, - strExplorer, - "NoSMHelp", - SHELL_NO_POLICY - }, - { - REST_NOWINKEYS, - strExplorer, - "NoWinKeys", - SHELL_NO_POLICY - }, - { - REST_NOENCRYPTONMOVE, - strExplorer, - "NoEncryptOnMove", - SHELL_NO_POLICY - }, - { - REST_NOLOCALMACHINERUN, - strExplorer, - "DisableLocalMachineRun", - SHELL_NO_POLICY - }, - { - REST_NOCURRENTUSERRUN, - strExplorer, - "DisableCurrentUserRun", - SHELL_NO_POLICY - }, - { - REST_NOLOCALMACHINERUNONCE, - strExplorer, - "DisableLocalMachineRunOnce", - SHELL_NO_POLICY - }, - { - REST_NOCURRENTUSERRUNONCE, - strExplorer, - "DisableCurrentUserRunOnce", - SHELL_NO_POLICY - }, - { - REST_FORCEACTIVEDESKTOPON, - strExplorer, - "ForceActiveDesktopOn", - SHELL_NO_POLICY - }, - { - REST_NOCOMPUTERSNEARME, - strExplorer, - "NoComputersNearMe", - SHELL_NO_POLICY - }, - { - REST_NOVIEWONDRIVE, - strExplorer, - "NoViewOnDrive", - SHELL_NO_POLICY - }, - { - REST_NONETCRAWL, - strExplorer, - "NoNetCrawl", - SHELL_NO_POLICY - }, - { - REST_NOSHAREDDOCUMENTS, - strExplorer, - "NoSharedDocs", - SHELL_NO_POLICY - }, - { - REST_NOSMMYDOCS, - strExplorer, - "NoSMMyDocs", - SHELL_NO_POLICY - }, -/* 0x4000050 - 0x4000060 */ - { - REST_NONLEGACYSHELLMODE, - strExplorer, - "NoneLegacyShellMode", - SHELL_NO_POLICY - }, - { - REST_STARTRUNNOHOMEPATH, - strExplorer, - "StartRunNoHOMEPATH", - SHELL_NO_POLICY - }, -/* 0x4000061 - 0x4000086 */ - { - REST_NODISCONNECT, - strExplorer, - "NoDisconnect", - SHELL_NO_POLICY - }, - { - REST_NOSECURITY, - strExplorer, - "NoNTSecurity", - SHELL_NO_POLICY - }, - { - REST_NOFILEASSOCIATE, - strExplorer, - "NoFileAssociate", - SHELL_NO_POLICY - }, - { - 0x50000024, - strExplorer, - strNoFileURL, - SHELL_NO_POLICY - }, - { - 0, - 0, - 0, - SHELL_NO_POLICY - } -}; - -/************************************************************************* - * SHRestricted [SHELL32.100] - * - * Get the value associated with a policy Id. - * - * PARAMS - * pol [I] Policy Id - * - * RETURNS - * The queried value for the policy. - * - * NOTES - * Exported by ordinal. - * This function caches the retrieved values to prevent unnecessary registry access, - * if SHInitRestricted() was previously called. - * - * REFERENCES - * a: MS System Policy Editor. - * b: 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/ - * c: 'The Windows 95 Registry', by John Woram, 1996 MIS: Press - */ -DWORD WINAPI SHRestricted (RESTRICTIONS policy) -{ - char regstr[256]; - HKEY xhkey; - DWORD retval, datsize = 4; - LPPOLICYDATA p; - - TRACE("(%08x)\n", policy); - - /* scan to see if we know this policy ID */ - for (p = sh32_policy_table; p->policy; p++) - { - if (policy == p->policy) - { - break; - } - } - - if (p->policy == 0) - { - /* we don't know this policy, return 0 */ - TRACE("unknown policy: (%08x)\n", policy); - return 0; - } - - /* we have a known policy */ - - /* first check if this policy has been cached, return it if so */ - if (p->cache != SHELL_NO_POLICY) - { - return p->cache; - } - - lstrcpyA(regstr, strRegistryPolicyA); - lstrcatA(regstr, p->appstr); - - /* return 0 and don't set the cache if any registry errors occur */ - retval = 0; - if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS) - { - if (RegQueryValueExA(xhkey, p->keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS) - { - p->cache = retval; - } - RegCloseKey(xhkey); - } - return retval; -} - -/************************************************************************* - * SHInitRestricted [SHELL32.244] - * - * Initialise the policy cache to speed up calls to SHRestricted(). - * - * PARAMS - * unused [I] Reserved. - * inpRegKey [I] Registry key to scan. - * - * RETURNS - * Success: -1. The policy cache is initialised. - * Failure: 0, if inpRegKey is any value other than NULL, "Policy", or - * "Software\Microsoft\Windows\CurrentVersion\Policies". - * - * NOTES - * Exported by ordinal. Introduced in Win98. - */ -BOOL WINAPI SHInitRestricted(LPCVOID unused, LPCVOID inpRegKey) -{ - TRACE("(%p, %p)\n", unused, inpRegKey); - - /* first check - if input is non-NULL and points to the secret - key string, then pass. Otherwise return 0. - */ - if (inpRegKey != NULL) - { - if (SHELL_OsIsUnicode()) - { - if (lstrcmpiW((LPCWSTR)inpRegKey, strRegistryPolicyW) && - lstrcmpiW((LPCWSTR)inpRegKey, strPolicyW)) - /* doesn't match, fail */ - return 0; - } - else - { - if (lstrcmpiA((LPCSTR)inpRegKey, strRegistryPolicyA) && - lstrcmpiA((LPCSTR)inpRegKey, strPolicyA)) - /* doesn't match, fail */ - return 0; - } - } - - return TRUE; -} diff --git a/reactos/dll/win32/shell32/shv_def_cmenu.c b/reactos/dll/win32/shell32/shv_def_cmenu.c deleted file mode 100644 index 701a3caffb6..00000000000 --- a/reactos/dll/win32/shell32/shv_def_cmenu.c +++ /dev/null @@ -1,1783 +0,0 @@ -/* - * PROJECT: shell32 - * LICENSE: GPL - See COPYING in the top level directory - * FILE: dll/win32/shell32/shv_item_new.c - * PURPOSE: provides default context menu implementation - * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(dmenu); - -typedef struct _DynamicShellEntry_ -{ - UINT iIdCmdFirst; - UINT NumIds; - CLSID ClassID; - IContextMenu * CMenu; - struct _DynamicShellEntry_ * Next; -}DynamicShellEntry, *PDynamicShellEntry; - -typedef struct _StaticShellEntry_ -{ - LPWSTR szVerb; - LPWSTR szClass; - struct _StaticShellEntry_ * Next; -}StaticShellEntry, *PStaticShellEntry; - - -typedef struct -{ - const IContextMenu2Vtbl *lpVtbl; - LONG ref; - DEFCONTEXTMENU dcm; - IDataObject * pDataObj; - DWORD bGroupPolicyActive; - PDynamicShellEntry dhead; /* first dynamic shell extension entry */ - UINT iIdSHEFirst; /* first used id */ - UINT iIdSHELast; /* last used id */ - PStaticShellEntry shead; /* first static shell extension entry */ - UINT iIdSCMFirst; /* first static used id */ - UINT iIdSCMLast; /* last static used id */ -}IDefaultContextMenuImpl, *LPIDefaultContextMenuImpl; - -static LPIDefaultContextMenuImpl __inline impl_from_IContextMenu( IContextMenu2 *iface ) -{ - return (LPIDefaultContextMenuImpl)((char*)iface - FIELD_OFFSET(IDefaultContextMenuImpl, lpVtbl)); -} - -VOID INewItem_SetCurrentShellFolder(IShellFolder * psfParent); // HACK -WCHAR *build_paths_list(LPCWSTR wszBasePath, int cidl, LPCITEMIDLIST *pidls); - -static -HRESULT -WINAPI -IDefaultContextMenu_fnQueryInterface( - IContextMenu2 *iface, - REFIID riid, - LPVOID *ppvObj) -{ - IDefaultContextMenuImpl *This = (IDefaultContextMenuImpl *)iface; - - TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj); - - *ppvObj = NULL; - - if(IsEqualIID(riid, &IID_IUnknown) || - IsEqualIID(riid, &IID_IContextMenu) || - IsEqualIID(riid, &IID_IContextMenu2)) - { - *ppvObj = This; - } - - if(*ppvObj) - { - IUnknown_AddRef((IUnknown*)*ppvObj); - TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj); - return S_OK; - } - TRACE("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - - -static -ULONG -WINAPI -IDefaultContextMenu_fnAddRef( - IContextMenu2 *iface) -{ - IDefaultContextMenuImpl *This = (IDefaultContextMenuImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); - - TRACE("(%p)->(count=%u)\n", This, refCount - 1); - - return refCount; -} - -static -ULONG -WINAPI -IDefaultContextMenu_fnRelease( - IContextMenu2 *iface) -{ - PDynamicShellEntry dEntry, dNext; - PStaticShellEntry sEntry, sNext; - IDefaultContextMenuImpl *This = (IDefaultContextMenuImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(count=%u)\n", This, refCount + 1); - if (!refCount) - { - /* free dynamic shell extension entries */ - dEntry = This->dhead; - while(dEntry) - { - dNext = dEntry->Next; - IContextMenu_Release(dEntry->CMenu); - HeapFree(GetProcessHeap(), 0, dEntry); - dEntry = dNext; - } - /* free static shell extension entries */ - sEntry = This->shead; - while(sEntry) - { - sNext = sEntry->Next; - HeapFree(GetProcessHeap(), 0, sEntry->szClass); - HeapFree(GetProcessHeap(), 0, sEntry->szVerb); - HeapFree(GetProcessHeap(), 0, sEntry); - sEntry = sNext; - } - HeapFree(GetProcessHeap(),0,This); - } - - return refCount; -} - -static -void -SH_AddStaticEntry(IDefaultContextMenuImpl * This, WCHAR *szVerb, WCHAR * szClass) -{ - PStaticShellEntry curEntry; - PStaticShellEntry lastEntry = NULL; - - curEntry = This->shead; - while(curEntry) - { - if (!wcsicmp(curEntry->szVerb, szVerb)) - { - /* entry already exists */ - return; - } - lastEntry = curEntry; - curEntry = curEntry->Next; - } - - TRACE("adding verb %s szClass %s\n", debugstr_w(szVerb), debugstr_w(szClass)); - - curEntry = HeapAlloc(GetProcessHeap(), 0, sizeof(StaticShellEntry)); - if (curEntry) - { - curEntry->Next = NULL; - curEntry->szVerb = HeapAlloc(GetProcessHeap(), 0, (wcslen(szVerb)+1) * sizeof(WCHAR)); - if (curEntry->szVerb) - wcscpy(curEntry->szVerb, szVerb); - curEntry->szClass = HeapAlloc(GetProcessHeap(), 0, (wcslen(szClass)+1) * sizeof(WCHAR)); - if (curEntry->szClass) - wcscpy(curEntry->szClass, szClass); - } - - if (!wcsicmp(szVerb, L"open")) - { - /* open verb is always inserted in front */ - curEntry->Next = This->shead; - This->shead = curEntry; - return; - } - - - - if (lastEntry) - { - lastEntry->Next = curEntry; - } - else - { - This->shead = curEntry; - } -} - -static -void -SH_AddStaticEntryForKey(IDefaultContextMenuImpl * This, HKEY hKey, WCHAR * szClass) -{ - LONG result; - DWORD dwIndex; - WCHAR szName[40]; - DWORD dwName; - - dwIndex = 0; - do - { - szName[0] = 0; - dwName = sizeof(szName) / sizeof(WCHAR); - result = RegEnumKeyExW(hKey, dwIndex, szName, &dwName, NULL, NULL, NULL, NULL); - szName[(sizeof(szName)/sizeof(WCHAR))-1] = 0; - if (result == ERROR_SUCCESS) - { - SH_AddStaticEntry(This, szName, szClass); - } - dwIndex++; - }while(result == ERROR_SUCCESS); -} - -static -void -SH_AddStaticEntryForFileClass(IDefaultContextMenuImpl * This, WCHAR * szExt) -{ - WCHAR szBuffer[100]; - HKEY hKey; - LONG result; - DWORD dwBuffer; - UINT Length; - static WCHAR szShell[] = L"\\shell"; - static WCHAR szShellAssoc[] = L"SystemFileAssociations\\"; - - TRACE("SH_AddStaticEntryForFileClass entered with %s\n", debugstr_w(szExt)); - - Length = wcslen(szExt); - if (Length + (sizeof(szShell)/sizeof(WCHAR)) + 1 < sizeof(szBuffer)/sizeof(WCHAR)) - { - wcscpy(szBuffer, szExt); - wcscpy(&szBuffer[Length], szShell); - result = RegOpenKeyExW(HKEY_CLASSES_ROOT, szBuffer, 0, KEY_READ | KEY_QUERY_VALUE, &hKey); - if (result == ERROR_SUCCESS) - { - szBuffer[Length] = 0; - SH_AddStaticEntryForKey(This, hKey, szExt); - RegCloseKey(hKey); - } - } - - dwBuffer = sizeof(szBuffer); - result = RegGetValueW(HKEY_CLASSES_ROOT, szExt, NULL, RRF_RT_REG_SZ, NULL, (LPBYTE)szBuffer, &dwBuffer); - if (result == ERROR_SUCCESS) - { - Length = wcslen(szBuffer); - if (Length + (sizeof(szShell)/sizeof(WCHAR)) + 1 < sizeof(szBuffer)/sizeof(WCHAR)) - { - wcscpy(&szBuffer[Length], szShell); - TRACE("szBuffer %s\n", debugstr_w(szBuffer)); - - result = RegOpenKeyExW(HKEY_CLASSES_ROOT, szBuffer, 0, KEY_READ | KEY_QUERY_VALUE, &hKey); - if (result == ERROR_SUCCESS) - { - szBuffer[Length] = 0; - SH_AddStaticEntryForKey(This, hKey, szBuffer); - RegCloseKey(hKey); - } - } - } - - wcscpy(szBuffer, szShellAssoc); - dwBuffer = sizeof(szBuffer) - sizeof(szShellAssoc) - sizeof(WCHAR); - result = RegGetValueW(HKEY_CLASSES_ROOT, szExt, L"PerceivedType", RRF_RT_REG_SZ, NULL, (LPBYTE)&szBuffer[(sizeof(szShellAssoc)/sizeof(WCHAR))], &dwBuffer); - if (result == ERROR_SUCCESS) - { - Length = wcslen(&szBuffer[(sizeof(szShellAssoc)/sizeof(WCHAR))]) + (sizeof(szShellAssoc)/sizeof(WCHAR)); - wcscat(&szBuffer[(sizeof(szShellAssoc)/sizeof(WCHAR))], szShell); - TRACE("szBuffer %s\n", debugstr_w(szBuffer)); - - result = RegOpenKeyExW(HKEY_CLASSES_ROOT, szBuffer, 0, KEY_READ | KEY_QUERY_VALUE, &hKey); - if (result == ERROR_SUCCESS) - { - szBuffer[Length] = 0; - SH_AddStaticEntryForKey(This, hKey, szBuffer); - RegCloseKey(hKey); - } - } -} - -static -BOOL -HasClipboardData() -{ - BOOL ret = FALSE; - IDataObject * pda; - - if(SUCCEEDED(OleGetClipboard(&pda))) - { - STGMEDIUM medium; - FORMATETC formatetc; - - TRACE("pda=%p\n", pda); - - /* Set the FORMATETC structure*/ - InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); - if(SUCCEEDED(IDataObject_GetData(pda,&formatetc,&medium))) - { - ret = TRUE; - ReleaseStgMedium(&medium); - } - - IDataObject_Release(pda); - } - - return ret; -} - -VOID -DisablePasteOptions(HMENU hMenu) -{ - MENUITEMINFOW mii; - - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_STATE; - mii.fState = MFS_DISABLED; - - TRACE("result %d\n", SetMenuItemInfoW(hMenu, FCIDM_SHVIEW_INSERT, FALSE, &mii)); - TRACE("result %d\n", SetMenuItemInfoW(hMenu, FCIDM_SHVIEW_INSERTLINK, FALSE, &mii)); -} - -BOOL -IsShellExtensionAlreadyLoaded(IDefaultContextMenuImpl * This, const CLSID * szClass) -{ - PDynamicShellEntry curEntry = This->dhead; - - while(curEntry) - { - if (!memcmp(&curEntry->ClassID, szClass, sizeof(CLSID))) - return TRUE; - curEntry = curEntry->Next; - } - return FALSE; -} - - -static -HRESULT -SH_LoadDynamicContextMenuHandler(IDefaultContextMenuImpl * This, HKEY hKey, const CLSID * szClass, BOOL bExternalInit) -{ - HRESULT hr; - IContextMenu * cmobj; - IShellExtInit *shext; - PDynamicShellEntry curEntry; - //WCHAR szTemp[100]; - LPOLESTR pstr; - - StringFromCLSID(szClass, &pstr); - - TRACE("SH_LoadDynamicContextMenuHandler entered with This %p hKey %p szClass %s bExternalInit %u\n",This, hKey, wine_dbgstr_guid(szClass), bExternalInit); - //swprintf(szTemp, L"This %p hKey %p szClass %s bExternalInit %u", This, hKey, pstr, bExternalInit); - //MessageBoxW(NULL, szTemp, NULL, MB_OK); - - if (IsShellExtensionAlreadyLoaded(This, szClass)) - return S_OK; - - hr = SHCoCreateInstance(NULL, szClass, NULL, &IID_IContextMenu, (void**)&cmobj); - if (hr != S_OK) - { - TRACE("SHCoCreateInstance failed %x\n", GetLastError()); - return hr; - } - - if (bExternalInit) - { - hr = IContextMenu_QueryInterface(cmobj, &IID_IShellExtInit, (void**)&shext); - if (hr != S_OK) - { - TRACE("Failed to query for interface IID_IShellExtInit\n"); - IContextMenu_Release(cmobj); - return FALSE; - } - hr = IShellExtInit_Initialize(shext, NULL, This->pDataObj, hKey); - IShellExtInit_Release(shext); - if (hr != S_OK) - { - TRACE("Failed to initialize shell extension error %x\n", hr); - IContextMenu_Release(cmobj); - return hr; - } - } - - curEntry = HeapAlloc(GetProcessHeap(), 0, sizeof(DynamicShellEntry)); - if(!curEntry) - { - IContextMenu_Release(cmobj); - return E_OUTOFMEMORY; - } - - curEntry->iIdCmdFirst = 0; - curEntry->Next = NULL; - curEntry->NumIds = 0; - curEntry->CMenu = cmobj; - memcpy(&curEntry->ClassID, szClass, sizeof(CLSID)); - - if (This->dhead) - { - PDynamicShellEntry pEntry = This->dhead; - - while(pEntry->Next) - { - pEntry = pEntry->Next; - } - - pEntry->Next = curEntry; - } - else - { - This->dhead = curEntry; - } - - - if (!memcmp(szClass, &CLSID_NewMenu, sizeof(CLSID))) - { - /* A REAL UGLY HACK */ - INewItem_SetCurrentShellFolder(This->dcm.psf); - } - - - return hr; -} - -static -UINT -EnumerateDynamicContextHandlerForKey(IDefaultContextMenuImpl *This, HKEY hRootKey) -{ - WCHAR szKey[MAX_PATH] = {0}; - WCHAR szName[MAX_PATH] = {0}; - DWORD dwIndex, dwName; - LONG res; - HRESULT hResult; - UINT index; - CLSID clsid; - HKEY hKey; - - static const WCHAR szShellEx[] = { 's','h','e','l','l','e','x','\\','C','o','n','t','e','x','t','M','e','n','u','H','a','n','d','l','e','r','s',0 }; - - if (RegOpenKeyExW(hRootKey, szShellEx, 0, KEY_READ, &hKey) != ERROR_SUCCESS) - { - TRACE("RegOpenKeyExW failed for key %s\n", debugstr_w(szKey)); - return 0; - } - - dwIndex = 0; - index = 0; - do - { - dwName = MAX_PATH; - res = RegEnumKeyExW(hKey, dwIndex, szName, &dwName, NULL, NULL, NULL, NULL); - if (res == ERROR_SUCCESS) - { - hResult = CLSIDFromString(szName, &clsid); - if (hResult != S_OK) - { - dwName = MAX_PATH; - if (RegGetValueW(hKey, szName, NULL, RRF_RT_REG_SZ, NULL, szKey, &dwName) == ERROR_SUCCESS) - { - hResult = CLSIDFromString(szKey, &clsid); - } - } - if (SUCCEEDED(hResult)) - { - if (This->bGroupPolicyActive) - { - if (RegGetValueW(HKEY_LOCAL_MACHINE, - L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", - szKey, - RRF_RT_REG_SZ, - NULL, - NULL, - &dwName) == ERROR_SUCCESS) - { - SH_LoadDynamicContextMenuHandler(This, hKey, &clsid, TRUE); - } - } - else - { - SH_LoadDynamicContextMenuHandler(This, hKey, &clsid, TRUE); - } - } - } - dwIndex++; - }while(res == ERROR_SUCCESS); - - RegCloseKey(hKey); - return index; -} - - -static -UINT -InsertMenuItemsOfDynamicContextMenuExtension(IDefaultContextMenuImpl * This, HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast) -{ - PDynamicShellEntry curEntry; - HRESULT hResult; - - if (!This->dhead) - { - This->iIdSHEFirst = 0; - This->iIdSHELast = 0; - return indexMenu; - } - - curEntry = This->dhead; - idCmdFirst = 0x5000; - idCmdLast = 0x6000; - This->iIdSHEFirst = idCmdFirst; - do - { - hResult = IContextMenu_QueryContextMenu(curEntry->CMenu, hMenu, indexMenu++, idCmdFirst, idCmdLast, CMF_NORMAL); - if (SUCCEEDED(hResult)) - { - curEntry->iIdCmdFirst = idCmdFirst; - curEntry->NumIds = LOWORD(hResult); - indexMenu += curEntry->NumIds; - idCmdFirst += curEntry->NumIds + 0x10; - } - TRACE("curEntry %p hresult %x contextmenu %p cmdfirst %x num ids %x\n", curEntry, hResult, curEntry->CMenu, curEntry->iIdCmdFirst, curEntry->NumIds); - curEntry = curEntry->Next; - }while(curEntry); - - This->iIdSHELast = idCmdFirst; - TRACE("SH_LoadContextMenuHandlers first %x last %x\n", This->iIdSHEFirst, This->iIdSHELast); - return indexMenu; -} - -UINT -BuildBackgroundContextMenu( - IDefaultContextMenuImpl * This, - HMENU hMenu, - UINT iIdCmdFirst, - UINT iIdCmdLast, - UINT uFlags) -{ - MENUITEMINFOW mii; - WCHAR szBuffer[MAX_PATH]; - UINT indexMenu = 0; - HMENU hSubMenu; - HKEY hKey; - - ZeroMemory(&mii, sizeof(mii)); - - TRACE("BuildBackgroundContextMenu entered\n"); - - if (!_ILIsDesktop(This->dcm.pidlFolder)) - { - /* view option is only available in browsing mode */ - hSubMenu = LoadMenuA(shell32_hInstance, "MENU_001"); - if (hSubMenu) - { - szBuffer[0] = 0; - LoadStringW(shell32_hInstance, FCIDM_SHVIEW_VIEW, szBuffer, MAX_PATH); - szBuffer[MAX_PATH-1] = 0; - - TRACE("szBuffer %s\n", debugstr_w(szBuffer)); - - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_TYPE | MIIM_STATE | MIIM_SUBMENU | MIIM_ID; - mii.fType = MFT_STRING; - mii.wID = iIdCmdFirst++; - mii.dwTypeData = szBuffer; - mii.cch = wcslen( mii.dwTypeData ); - mii.fState = MFS_ENABLED; - mii.hSubMenu = hSubMenu; - InsertMenuItemW(hMenu, indexMenu++, TRUE, &mii); - DestroyMenu(hSubMenu); - } - } - hSubMenu = LoadMenuW(shell32_hInstance, L"MENU_002"); - if (hSubMenu) - { - /* merge general background context menu in */ - iIdCmdFirst = Shell_MergeMenus(hMenu, GetSubMenu(hSubMenu, 0), indexMenu, 0, 0xFFFF, MM_DONTREMOVESEPS | MM_SUBMENUSHAVEIDS) + 1; - DestroyMenu(hSubMenu); - } - - if (!HasClipboardData()) - { - TRACE("disabling paste options\n"); - DisablePasteOptions(hMenu); - } - /* load extensions from HKCR\* key */ - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, - L"*", - 0, - KEY_READ, - &hKey) == ERROR_SUCCESS) - { - EnumerateDynamicContextHandlerForKey(This, hKey); - RegCloseKey(hKey); - } - - /* load create new shell extension */ - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, - L"CLSID\\{D969A300-E7FF-11d0-A93B-00A0C90F2719}", - 0, - KEY_READ, - &hKey) == ERROR_SUCCESS) - { - SH_LoadDynamicContextMenuHandler(This, hKey, &CLSID_NewMenu, TRUE); - RegCloseKey(hKey); - } - - if (InsertMenuItemsOfDynamicContextMenuExtension(This, hMenu, GetMenuItemCount(hMenu)-1, iIdCmdFirst, iIdCmdLast)) - { - /* seperate dynamic context menu items */ - _InsertMenuItemW(hMenu, GetMenuItemCount(hMenu)-1, TRUE, -1, MFT_SEPARATOR, NULL, MFS_ENABLED); - } - - return iIdCmdLast; -} - -static -UINT -AddStaticContextMenusToMenu( - HMENU hMenu, - UINT indexMenu, - IDefaultContextMenuImpl * This) -{ - MENUITEMINFOW mii; - UINT idResource; - PStaticShellEntry curEntry; - WCHAR szVerb[40]; - WCHAR szTemp[50]; - DWORD dwSize; - UINT fState; - UINT Length; - - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | MIIM_DATA; - mii.fType = MFT_STRING; - mii.fState = MFS_ENABLED; - mii.wID = 0x4000; - This->iIdSCMFirst = mii.wID; - - curEntry = This->shead; - - while(curEntry) - { - fState = MFS_ENABLED; - if (!wcsicmp(curEntry->szVerb, L"open")) - { - fState |= MFS_DEFAULT; - idResource = IDS_OPEN_VERB; - } - else if (!wcsicmp(curEntry->szVerb, L"explore")) - idResource = IDS_EXPLORE_VERB; - else if (!wcsicmp(curEntry->szVerb, L"runas")) - idResource = IDS_RUNAS_VERB; - else if (!wcsicmp(curEntry->szVerb, L"edit")) - idResource = IDS_EDIT_VERB; - else if (!wcsicmp(curEntry->szVerb, L"find")) - idResource = IDS_FIND_VERB; - else if (!wcsicmp(curEntry->szVerb, L"print")) - idResource = IDS_PRINT_VERB; - else - idResource = 0; - - if (idResource > 0) - { - if (LoadStringW(shell32_hInstance, idResource, szVerb, sizeof(szVerb)/sizeof(WCHAR))) - { - /* use translated verb */ - szVerb[(sizeof(szVerb)/sizeof(WCHAR))-1] = L'\0'; - mii.dwTypeData = szVerb; - } - } - else - { - Length = wcslen(curEntry->szClass) + wcslen(curEntry->szVerb) + 8; - if (Length < sizeof(szTemp)/sizeof(WCHAR)) - { - wcscpy(szTemp, curEntry->szClass); - wcscat(szTemp, L"\\shell\\"); - wcscat(szTemp, curEntry->szVerb); - dwSize = sizeof(szVerb); - - if (RegGetValueW(HKEY_CLASSES_ROOT, szTemp, NULL, RRF_RT_REG_SZ, NULL, szVerb, &dwSize) == ERROR_SUCCESS) - { - /* use description for the menu entry */ - mii.dwTypeData = szVerb; - } - else - { - /* use verb for the menu entry */ - mii.dwTypeData = curEntry->szVerb; - } - } - - } - - mii.cch = wcslen(mii.dwTypeData); - mii.fState = fState; - InsertMenuItemW(hMenu, indexMenu++, TRUE, &mii); - - mii.wID++; - curEntry = curEntry->Next; - } - This->iIdSCMLast = mii.wID - 1; - return indexMenu; -} - -void WINAPI _InsertMenuItemW ( - HMENU hmenu, - UINT indexMenu, - BOOL fByPosition, - UINT wID, - UINT fType, - LPCWSTR dwTypeData, - UINT fState) -{ - MENUITEMINFOW mii; - WCHAR szText[100]; - - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - if (fType == MFT_SEPARATOR) - { - mii.fMask = MIIM_ID | MIIM_TYPE; - } - else if (fType == MFT_STRING) - { - mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE; - if ((ULONG_PTR)HIWORD((ULONG_PTR)dwTypeData) == 0) - { - if (LoadStringW(shell32_hInstance, LOWORD((ULONG_PTR)dwTypeData), szText, sizeof(szText)/sizeof(WCHAR))) - { - szText[(sizeof(szText)/sizeof(WCHAR))-1] = 0; - mii.dwTypeData = szText; - } - else - { - TRACE("failed to load string %p\n", dwTypeData); - return; - } - } - else - { - mii.dwTypeData = (LPWSTR) dwTypeData; - } - mii.fState = fState; - } - - mii.wID = wID; - mii.fType = fType; - InsertMenuItemW( hmenu, indexMenu, fByPosition, &mii); -} - -UINT -BuildShellItemContextMenu( - IDefaultContextMenuImpl * This, - HMENU hMenu, - UINT iIdCmdFirst, - UINT iIdCmdLast, - UINT uFlags) -{ - WCHAR szPath[MAX_PATH]; - WCHAR szTemp[40]; - HKEY hKey; - UINT indexMenu; - SFGAOF rfg; - HRESULT hr; - BOOL bAddSep; - GUID * guid; - BOOL bClipboardData; - STRRET strFile; - LPWSTR pOffset; - DWORD dwSize; - - TRACE("BuildShellItemContextMenu entered\n"); - - if (IShellFolder2_GetDisplayNameOf(This->dcm.psf, This->dcm.apidl[0], SHGDN_FORPARSING, &strFile) == S_OK) - { - if (StrRetToBufW(&strFile, This->dcm.apidl[0], szPath, MAX_PATH) == S_OK) - { - pOffset = wcsrchr(szPath, L'.'); - if (pOffset) - { - /* enumerate dynamic/static for a given file class */ - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, pOffset, 0, KEY_READ, &hKey) == ERROR_SUCCESS) - { - /* add static verbs */ - SH_AddStaticEntryForFileClass(This, pOffset); - /* load dynamic extensions from file extension key */ - EnumerateDynamicContextHandlerForKey(This, hKey); - RegCloseKey(hKey); - } - dwSize = sizeof(szTemp); - if (RegGetValueW(HKEY_CLASSES_ROOT, pOffset, NULL, RRF_RT_REG_SZ, NULL, szTemp, &dwSize) == ERROR_SUCCESS) - { - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szTemp, 0, KEY_READ, &hKey) == ERROR_SUCCESS) - { - /* add static verbs from progid key */ - SH_AddStaticEntryForFileClass(This, szTemp); - /* load dynamic extensions from progid key */ - EnumerateDynamicContextHandlerForKey(This, hKey); - RegCloseKey(hKey); - } - } - } - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"*", 0, KEY_READ, &hKey) == ERROR_SUCCESS) - { - /* load default extensions */ - EnumerateDynamicContextHandlerForKey(This, hKey); - RegCloseKey(hKey); - } - } - } - - guid = _ILGetGUIDPointer(This->dcm.apidl[0]); - if (guid) - { - LPOLESTR pwszCLSID; - WCHAR buffer[60]; - - wcscpy(buffer, L"CLSID\\"); - hr = StringFromCLSID(guid, &pwszCLSID); - if (hr == S_OK) - { - wcscpy(&buffer[6], pwszCLSID); - TRACE("buffer %s\n", debugstr_w(buffer)); - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, buffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS) - { - EnumerateDynamicContextHandlerForKey(This, hKey); - SH_AddStaticEntryForFileClass(This, buffer); - RegCloseKey(hKey); - } - CoTaskMemFree(pwszCLSID); - } - } - - - if (_ILIsDrive(This->dcm.apidl[0])) - { - SH_AddStaticEntryForFileClass(This, L"Drive"); - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"Drive", 0, KEY_READ, &hKey) == ERROR_SUCCESS) - { - EnumerateDynamicContextHandlerForKey(This, hKey); - RegCloseKey(hKey); - } - - } - - /* add static actions */ - rfg = SFGAO_BROWSABLE | SFGAO_CANCOPY | SFGAO_CANLINK | SFGAO_CANMOVE | SFGAO_CANDELETE | SFGAO_CANRENAME | SFGAO_HASPROPSHEET | SFGAO_FILESYSTEM | SFGAO_FOLDER; - hr = IShellFolder_GetAttributesOf(This->dcm.psf, This->dcm.cidl, This->dcm.apidl, &rfg); - if (!SUCCEEDED(hr)) - rfg = 0; - - if (rfg & SFGAO_FOLDER) - { - /* add the default verbs open / explore */ - SH_AddStaticEntryForFileClass(This, L"Folder"); - SH_AddStaticEntryForFileClass(This, L"Directory"); - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"Folder", 0, KEY_READ, &hKey) == ERROR_SUCCESS) - { - EnumerateDynamicContextHandlerForKey(This, hKey); - RegCloseKey(hKey); - } - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"Directory", 0, KEY_READ, &hKey) == ERROR_SUCCESS) - { - EnumerateDynamicContextHandlerForKey(This, hKey); - RegCloseKey(hKey); - } - } - - - if (rfg & SFGAO_FILESYSTEM) - { - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"AllFilesystemObjects", 0, KEY_READ, &hKey) == ERROR_SUCCESS) - { - /* sendto service is registered here */ - EnumerateDynamicContextHandlerForKey(This, hKey); - RegCloseKey(hKey); - } - } - - /* add static context menu handlers */ - indexMenu = AddStaticContextMenusToMenu(hMenu, 0, This); - /* now process dynamic context menu handlers */ - indexMenu = InsertMenuItemsOfDynamicContextMenuExtension(This, hMenu, indexMenu, iIdCmdFirst, iIdCmdLast); - TRACE("indexMenu %d\n", indexMenu); - - if (_ILIsDrive(This->dcm.apidl[0])) - { - /* The 'Format' option must be always available, - * thus it is not registered as a static shell extension - */ - _InsertMenuItemW(hMenu, indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0); - _InsertMenuItemW(hMenu, indexMenu++, TRUE, 0x7ABC, MFT_STRING, MAKEINTRESOURCEW(IDS_FORMATDRIVE), MFS_ENABLED); - bAddSep = TRUE; - } - - bClipboardData = (HasClipboardData() && (rfg & SFGAO_FILESYSTEM)); - if (rfg & (SFGAO_CANCOPY | SFGAO_CANMOVE) || bClipboardData) - { - _InsertMenuItemW(hMenu, indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0); - if (rfg & SFGAO_CANMOVE) - _InsertMenuItemW(hMenu, indexMenu++, TRUE, FCIDM_SHVIEW_CUT, MFT_STRING, MAKEINTRESOURCEW(IDS_CUT), MFS_ENABLED); - if (rfg & SFGAO_CANCOPY) - _InsertMenuItemW(hMenu, indexMenu++, TRUE, FCIDM_SHVIEW_COPY, MFT_STRING, MAKEINTRESOURCEW(IDS_COPY), MFS_ENABLED); - if (bClipboardData) - _InsertMenuItemW(hMenu, indexMenu++, TRUE, FCIDM_SHVIEW_INSERT, MFT_STRING, MAKEINTRESOURCEW(IDS_INSERT), MFS_ENABLED); - - bAddSep = TRUE; - } - - - if (rfg & SFGAO_CANLINK) - { - bAddSep = FALSE; - _InsertMenuItemW(hMenu, indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0); - _InsertMenuItemW(hMenu, indexMenu++, TRUE, FCIDM_SHVIEW_CREATELINK, MFT_STRING, MAKEINTRESOURCEW(IDS_CREATELINK), MFS_ENABLED); - } - - - if (rfg & SFGAO_CANDELETE) - { - if (bAddSep) - { - bAddSep = FALSE; - _InsertMenuItemW(hMenu, indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0); - } - _InsertMenuItemW(hMenu, indexMenu++, TRUE, FCIDM_SHVIEW_DELETE, MFT_STRING, MAKEINTRESOURCEW(IDS_DELETE), MFS_ENABLED); - } - - if (rfg & SFGAO_CANRENAME) - { - if (bAddSep) - { - _InsertMenuItemW(hMenu, indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0); - } - _InsertMenuItemW(hMenu, indexMenu++, TRUE, FCIDM_SHVIEW_RENAME, MFT_STRING, MAKEINTRESOURCEW(IDS_RENAME), MFS_ENABLED); - bAddSep = TRUE; - } - - if (rfg & SFGAO_HASPROPSHEET) - { - _InsertMenuItemW(hMenu, indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0); - _InsertMenuItemW(hMenu, indexMenu++, TRUE, FCIDM_SHVIEW_PROPERTIES, MFT_STRING, MAKEINTRESOURCEW(IDS_PROPERTIES), MFS_ENABLED); - } - - return iIdCmdLast; -} - -static -HRESULT -WINAPI -IDefaultContextMenu_fnQueryContextMenu( - IContextMenu2 *iface, - HMENU hmenu, - UINT indexMenu, - UINT idCmdFirst, - UINT idCmdLast, - UINT uFlags) -{ - IDefaultContextMenuImpl * This = impl_from_IContextMenu(iface); - if (This->dcm.cidl) - { - idCmdFirst = BuildShellItemContextMenu(This, hmenu, idCmdFirst, idCmdLast, uFlags); - } - else - { - idCmdFirst = BuildBackgroundContextMenu(This, hmenu, idCmdFirst, idCmdLast, uFlags); - } - - return S_OK; -} - -static -HRESULT -NotifyShellViewWindow(LPCMINVOKECOMMANDINFO lpcmi, BOOL bRefresh) -{ - LPSHELLBROWSER lpSB; - LPSHELLVIEW lpSV = NULL; - HWND hwndSV = NULL; - - if((lpSB = (LPSHELLBROWSER)SendMessageA(lpcmi->hwnd, CWM_GETISHELLBROWSER,0,0))) - { - if(SUCCEEDED(IShellBrowser_QueryActiveShellView(lpSB, &lpSV))) - { - IShellView_GetWindow(lpSV, &hwndSV); - } - } - - if (LOWORD(lpcmi->lpVerb) == FCIDM_SHVIEW_REFRESH || bRefresh) - { - if (lpSV) - IShellView_Refresh(lpSV); - - return S_OK; - } - - SendMessageW(hwndSV, WM_COMMAND, MAKEWPARAM(LOWORD(lpcmi->lpVerb), 0), 0); - - return S_OK; -} - -static -HRESULT -DoPaste( - IDefaultContextMenuImpl *This, - LPCMINVOKECOMMANDINFO lpcmi) -{ - IDataObject * pda; - STGMEDIUM medium; - FORMATETC formatetc; - LPITEMIDLIST * apidl; - LPITEMIDLIST pidl; - IShellFolder *psfFrom = NULL, *psfDesktop, *psfTarget = NULL; - LPIDA lpcida; - ISFHelper *psfhlpdst, *psfhlpsrc; - HRESULT hr; - - if (OleGetClipboard(&pda) != S_OK) - return E_FAIL; - - InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); - hr = IDataObject_GetData(pda,&formatetc,&medium); - - if (FAILED(hr)) - { - IDataObject_Release(pda); - return E_FAIL; - } - - /* lock the handle */ - lpcida = GlobalLock(medium.u.hGlobal); - if (!lpcida) - { - ReleaseStgMedium(&medium); - IDataObject_Release(pda); - return E_FAIL; - } - - /* convert the data into pidl */ - apidl = _ILCopyCidaToaPidl(&pidl, lpcida); - - if (!apidl) - return E_FAIL; - - if (FAILED(SHGetDesktopFolder(&psfDesktop))) - { - SHFree(pidl); - _ILFreeaPidl(apidl, lpcida->cidl); - ReleaseStgMedium(&medium); - IDataObject_Release(pda); - return E_FAIL; - } - - if (_ILIsDesktop(pidl)) - { - /* use desktop shellfolder */ - psfFrom = psfDesktop; - } - else if (FAILED(IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (LPVOID*)&psfFrom))) - { - ERR("no IShellFolder\n"); - - IShellFolder_Release(psfDesktop); - SHFree(pidl); - _ILFreeaPidl(apidl, lpcida->cidl); - ReleaseStgMedium(&medium); - IDataObject_Release(pda); - - return E_FAIL; - } - - if (This->dcm.cidl) - { - IShellFolder_Release(psfDesktop); - hr = IShellFolder_BindToObject(This->dcm.psf, This->dcm.apidl[0], NULL, &IID_IShellFolder, (LPVOID*)&psfTarget); - } - else - { - IPersistFolder2 *ppf2 = NULL; - LPITEMIDLIST pidl; - - /* cidl is zero due to explorer view */ - hr = IShellFolder_QueryInterface (This->dcm.psf, &IID_IPersistFolder2, (LPVOID *) &ppf2); - if (SUCCEEDED(hr)) - { - hr = IPersistFolder2_GetCurFolder (ppf2, &pidl); - IPersistFolder2_Release(ppf2); - if (SUCCEEDED(hr)) - { - if (_ILIsDesktop(pidl)) - { - /* use desktop shellfolder */ - psfTarget = psfDesktop; - } - else - { - /* retrieve target desktop folder */ - hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (LPVOID*)&psfTarget); - } - TRACE("psfTarget %x %p, Desktop %u\n", hr, psfTarget, _ILIsDesktop(pidl)); - ILFree(pidl); - } - } - } - - if (FAILED(hr)) - { - ERR("no IShellFolder\n"); - - IShellFolder_Release(psfFrom); - SHFree(pidl); - _ILFreeaPidl(apidl, lpcida->cidl); - ReleaseStgMedium(&medium); - IDataObject_Release(pda); - - return E_FAIL; - } - - - /* get source and destination shellfolder */ - if (FAILED(IShellFolder_QueryInterface(psfTarget, &IID_ISFHelper, (LPVOID*)&psfhlpdst))) - { - ERR("no IID_ISFHelper for destination\n"); - - IShellFolder_Release(psfFrom); - IShellFolder_Release(psfTarget); - SHFree(pidl); - _ILFreeaPidl(apidl, lpcida->cidl); - ReleaseStgMedium(&medium); - IDataObject_Release(pda); - - return E_FAIL; - } - - if (FAILED(IShellFolder_QueryInterface(psfFrom, &IID_ISFHelper, (LPVOID*)&psfhlpsrc))) - { - ERR("no IID_ISFHelper for source\n"); - - ISFHelper_Release(psfhlpdst); - IShellFolder_Release(psfFrom); - IShellFolder_Release(psfTarget); - SHFree(pidl); - _ILFreeaPidl(apidl, lpcida->cidl); - ReleaseStgMedium(&medium); - IDataObject_Release(pda); - return E_FAIL; - } - - /* FIXXME - * do we want to perform a copy or move ??? - */ - hr = ISFHelper_CopyItems(psfhlpdst, psfFrom, lpcida->cidl, (LPCITEMIDLIST*)apidl); - - ISFHelper_Release(psfhlpdst); - ISFHelper_Release(psfhlpsrc); - IShellFolder_Release(psfFrom); - IShellFolder_Release(psfTarget); - SHFree(pidl); - _ILFreeaPidl(apidl, lpcida->cidl); - ReleaseStgMedium(&medium); - IDataObject_Release(pda); - TRACE("CP result %x\n",hr); - return S_OK; -} - -static -HRESULT -DoOpenOrExplore( - IDefaultContextMenuImpl *iface, - LPCMINVOKECOMMANDINFO lpcmi) -{ - - - return E_FAIL; -} - -BOOL -GetUniqueFileName(LPWSTR szBasePath, LPWSTR szExt, LPWSTR szTarget, BOOL bShortcut) -{ - UINT RetryCount = 0, Length; - WCHAR szLnk[40]; - HANDLE hFile; - - if (!bShortcut) - { - Length = LoadStringW(shell32_hInstance, IDS_LNK_FILE, szLnk, sizeof(szLnk)/sizeof(WCHAR)); - } - - do - { - if (!bShortcut) - { - if (RetryCount) - swprintf(szTarget, L"%s%s(%u).%s", szLnk, szBasePath, RetryCount, szExt); - else - swprintf(szTarget, L"%s%s.%s", szLnk, szBasePath, szExt); - } - else - { - if (RetryCount) - swprintf(szTarget, L"%s(%u).%s", szBasePath, RetryCount, szExt); - else - swprintf(szTarget, L"%s.%s", szBasePath, szExt); - } - - hFile = CreateFileW(szTarget, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); - if (hFile != INVALID_HANDLE_VALUE) - { - CloseHandle(hFile); - return TRUE; - } - - }while(RetryCount++ < 100); - - return FALSE; - -} - -static -HRESULT -DoCreateLink( - IDefaultContextMenuImpl *This, - LPCMINVOKECOMMANDINFO lpcmi) -{ - WCHAR szPath[MAX_PATH]; - WCHAR szTarget[MAX_PATH] = {0}; - WCHAR szDirPath[MAX_PATH]; - LPWSTR pszFile; - STRRET strFile; - LPWSTR pszExt; - HRESULT hr; - IShellLinkW * nLink; - IPersistFile * ipf; - static WCHAR szLnk[] = L"lnk"; - - if (IShellFolder2_GetDisplayNameOf(This->dcm.psf, This->dcm.apidl[0], SHGDN_FORPARSING, &strFile) != S_OK) - { - ERR("IShellFolder_GetDisplayNameOf failed for apidl\n"); - return E_FAIL; - } - - if (StrRetToBufW(&strFile, This->dcm.apidl[0], szPath, MAX_PATH) != S_OK) - return E_FAIL; - - pszExt = wcsrchr(szPath, L'.'); - - if (pszExt && !wcsicmp(pszExt + 1, szLnk)) - { - if (!GetUniqueFileName(szPath, pszExt + 1, szTarget, TRUE)) - return E_FAIL; - - hr = IShellLink_ConstructFromFile(NULL, &IID_IPersistFile, This->dcm.apidl[0], (LPVOID*)&ipf); - if (hr != S_OK) - { - return hr; - } - hr = IPersistFile_Save(ipf, szTarget, FALSE); - IPersistFile_Release(ipf); - NotifyShellViewWindow(lpcmi, TRUE); - return hr; - } - else - { - if (!GetUniqueFileName(szPath, szLnk, szTarget, TRUE)) - return E_FAIL; - - hr = IShellLink_Constructor(NULL, &IID_IShellLinkW, (LPVOID*)&nLink); - if (hr != S_OK) - { - return E_FAIL; - } - - GetFullPathName(szPath, MAX_PATH, szDirPath, &pszFile); - if (pszFile) pszFile[0] = 0; - - if (SUCCEEDED(IShellLinkW_SetPath(nLink, szPath)) && - SUCCEEDED(IShellLinkW_SetWorkingDirectory(nLink, szDirPath))) - { - if (SUCCEEDED(IShellLinkW_QueryInterface(nLink, &IID_IPersistFile, (LPVOID*)&ipf))) - { - hr = IPersistFile_Save(ipf, szTarget, TRUE); - IPersistFile_Release(ipf); - } - } - IShellLinkW_Release(nLink); - NotifyShellViewWindow(lpcmi, TRUE); - return hr; - } -} - -static -HRESULT -DoDelete( - IDefaultContextMenuImpl *This, - LPCMINVOKECOMMANDINFO lpcmi) -{ - HRESULT hr; - STRRET strTemp; - WCHAR szPath[MAX_PATH]; - LPWSTR wszPath, wszPos; - SHFILEOPSTRUCTW op; - int ret; - LPSHELLBROWSER lpSB; - HWND hwnd; - - hr = IShellFolder2_GetDisplayNameOf(This->dcm.psf, This->dcm.apidl[0], SHGDN_FORPARSING, &strTemp); - if(hr != S_OK) - { - ERR("IShellFolder_GetDisplayNameOf failed with %x\n", hr); - return hr; - } - ZeroMemory(szPath, sizeof(szPath)); - hr = StrRetToBufW(&strTemp, This->dcm.apidl[0], szPath, MAX_PATH); - if (hr != S_OK) - { - ERR("StrRetToBufW failed with %x\n", hr); - return hr; - } - - /* Only keep the base path */ - wszPos = strrchrW(szPath, '\\'); - if (wszPos != NULL) - { - *(wszPos + 1) = '\0'; - } - - wszPath = build_paths_list(szPath, This->dcm.cidl, This->dcm.apidl); - - ZeroMemory(&op, sizeof(op)); - op.hwnd = GetActiveWindow(); - op.wFunc = FO_DELETE; - op.pFrom = wszPath; - op.fFlags = FOF_ALLOWUNDO; - ret = SHFileOperationW(&op); - - if (ret) - { - ERR("SHFileOperation failed with 0x%x for %s\n", GetLastError(), debugstr_w(wszPath)); - return S_OK; - } - - /* get the active IShellView */ - if ((lpSB = (LPSHELLBROWSER)SendMessageA(lpcmi->hwnd, CWM_GETISHELLBROWSER,0,0))) - { - /* is the treeview focused */ - if (SUCCEEDED(IShellBrowser_GetControlWindow(lpSB, FCW_TREE, &hwnd))) - { - HTREEITEM hItem = TreeView_GetSelection(hwnd); - if (hItem) - { - (void)TreeView_DeleteItem(hwnd, hItem); - } - } - } - NotifyShellViewWindow(lpcmi, TRUE); - - HeapFree(GetProcessHeap(), 0, wszPath); - return S_OK; - -} - -static -HRESULT -DoCopyOrCut( - IDefaultContextMenuImpl *iface, - LPCMINVOKECOMMANDINFO lpcmi, - BOOL bCopy) -{ - LPSHELLBROWSER lpSB; - LPSHELLVIEW lpSV; - LPDATAOBJECT pDataObj; - HRESULT hr; - - if (SUCCEEDED(SHCreateDataObject(iface->dcm.pidlFolder, iface->dcm.cidl, iface->dcm.apidl, NULL, &IID_IDataObject, (void**)&pDataObj))) - { - hr = OleSetClipboard(pDataObj); - IDataObject_Release(pDataObj); - return hr; - } - - lpSB = (LPSHELLBROWSER)SendMessageA(lpcmi->hwnd, CWM_GETISHELLBROWSER,0,0); - if (!lpSB) - { - TRACE("failed to get shellbrowser\n"); - return E_FAIL; - } - - hr = IShellBrowser_QueryActiveShellView(lpSB, &lpSV); - if (FAILED(hr)) - { - TRACE("failed to query the active shellview\n"); - return hr; - } - - hr = IShellView_GetItemObject(lpSV, SVGIO_SELECTION, &IID_IDataObject, (LPVOID*)&pDataObj); - if (FAILED(hr)) - { - TRACE("failed to get item object\n"); - return hr; - } - - hr = OleSetClipboard(pDataObj); - if (FAILED(hr)) - { - WARN("OleSetClipboard failed"); - } - IDataObject_Release(pDataObj); - IShellView_Release(lpSV); - return S_OK; -} - -static -HRESULT -DoRename( - IDefaultContextMenuImpl *This, - LPCMINVOKECOMMANDINFO lpcmi) -{ - LPSHELLBROWSER lpSB; - LPSHELLVIEW lpSV; - HWND hwnd; - - /* get the active IShellView */ - if ((lpSB = (LPSHELLBROWSER)SendMessageA(lpcmi->hwnd, CWM_GETISHELLBROWSER,0,0))) - { - /* is the treeview focused */ - if (SUCCEEDED(IShellBrowser_GetControlWindow(lpSB, FCW_TREE, &hwnd))) - { - HTREEITEM hItem = TreeView_GetSelection(hwnd); - if (hItem) - { - (void)TreeView_EditLabel(hwnd, hItem); - } - } - - if(SUCCEEDED(IShellBrowser_QueryActiveShellView(lpSB, &lpSV))) - { - IShellView_SelectItem(lpSV, This->dcm.apidl[0], - SVSI_DESELECTOTHERS|SVSI_EDIT|SVSI_ENSUREVISIBLE|SVSI_FOCUSED|SVSI_SELECT); - IShellView_Release(lpSV); - return S_OK; - } - } - return E_FAIL; -} - -static -HRESULT -DoProperties( - IDefaultContextMenuImpl *This, - LPCMINVOKECOMMANDINFO lpcmi) -{ - WCHAR szDrive[MAX_PATH]; - STRRET strFile; - - if (This->dcm.cidl &&_ILIsMyComputer(This->dcm.apidl[0])) - { - ShellExecuteW(lpcmi->hwnd, L"open", L"rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl", NULL, NULL, SW_SHOWNORMAL); - return S_OK; - } - else if (This->dcm.cidl == 0 && _ILIsDesktop(This->dcm.pidlFolder)) - { - ShellExecuteW(lpcmi->hwnd, L"open", L"rundll32.exe shell32.dll,Control_RunDLL desk.cpl", NULL, NULL, SW_SHOWNORMAL); - return S_OK; - } - else if (_ILIsDrive(This->dcm.apidl[0])) - { - ILGetDisplayName(This->dcm.apidl[0], szDrive); - SH_ShowDriveProperties(szDrive, This->dcm.pidlFolder, This->dcm.apidl); - return S_OK; - } - else if (_ILIsNetHood(This->dcm.apidl[0])) - { - //FIXME path! - ShellExecuteW(NULL, L"open", L"explorer.exe", - L"/n,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}", - NULL, SW_SHOWDEFAULT); - return S_OK; - } - else if (_ILIsBitBucket(This->dcm.apidl[0])) - { - /* FIXME - * detect the drive path of bitbucket if appropiate - */ - - SH_ShowRecycleBinProperties(L'C'); - return S_OK; - } - - if (This->dcm.cidl > 1) - WARN("SHMultiFileProperties is not yet implemented\n"); - - if (IShellFolder2_GetDisplayNameOf(This->dcm.psf, This->dcm.apidl[0], SHGDN_FORPARSING, &strFile) != S_OK) - { - ERR("IShellFolder_GetDisplayNameOf failed for apidl\n"); - return E_FAIL; - } - - if (StrRetToBufW(&strFile, This->dcm.apidl[0], szDrive, MAX_PATH) != S_OK) - return E_FAIL; - - return SH_ShowPropertiesDialog(szDrive, This->dcm.pidlFolder, This->dcm.apidl); -} - -static -HRESULT -DoFormat( - IDefaultContextMenuImpl *This, - LPCMINVOKECOMMANDINFO lpcmi) -{ - char sDrive[5] = {0}; - - if (!_ILGetDrive(This->dcm.apidl[0], sDrive, sizeof(sDrive))) - { - ERR("pidl is not a drive\n"); - return E_FAIL; - } - - SHFormatDrive(lpcmi->hwnd, sDrive[0] - 'A', SHFMT_ID_DEFAULT, 0); - return S_OK; -} - -static -HRESULT -DoDynamicShellExtensions( - IDefaultContextMenuImpl *This, - LPCMINVOKECOMMANDINFO lpcmi) -{ - UINT verb = LOWORD(lpcmi->lpVerb); - PDynamicShellEntry pCurrent = This->dhead; - - TRACE("verb %p first %x last %x", lpcmi->lpVerb, This->iIdSHEFirst, This->iIdSHELast); - - while(pCurrent && verb > pCurrent->iIdCmdFirst + pCurrent->NumIds) - pCurrent = pCurrent->Next; - - if (!pCurrent) - return E_FAIL; - - if (verb >= pCurrent->iIdCmdFirst && verb <= pCurrent->iIdCmdFirst + pCurrent->NumIds) - { - /* invoke the dynamic context menu */ - lpcmi->lpVerb = MAKEINTRESOURCEA(verb - pCurrent->iIdCmdFirst); - return IContextMenu_InvokeCommand(pCurrent->CMenu, lpcmi); - } - - return E_FAIL; -} - - -static -HRESULT -DoStaticShellExtensions( - IDefaultContextMenuImpl *This, - LPCMINVOKECOMMANDINFO lpcmi) -{ - STRRET strFile; - WCHAR szPath[MAX_PATH]; - WCHAR szDir[MAX_PATH]; - SHELLEXECUTEINFOW sei; - PStaticShellEntry pCurrent = This->shead; - int verb = LOWORD(lpcmi->lpVerb) - This->iIdSCMFirst; - - - while(pCurrent && verb-- > 0) - pCurrent = pCurrent->Next; - - if (verb > 0) - return E_FAIL; - - - if (IShellFolder2_GetDisplayNameOf(This->dcm.psf, This->dcm.apidl[0], SHGDN_FORPARSING, &strFile) != S_OK) - { - ERR("IShellFolder_GetDisplayNameOf failed for apidl\n"); - return E_FAIL; - } - - if (StrRetToBufW(&strFile, This->dcm.apidl[0], szPath, MAX_PATH) != S_OK) - return E_FAIL; - - wcscpy(szDir, szPath); - PathRemoveFileSpec(szDir); - - ZeroMemory(&sei, sizeof(sei)); - sei.cbSize = sizeof(sei); - sei.fMask = SEE_MASK_CLASSNAME; - sei.lpClass = pCurrent->szClass; - sei.hwnd = lpcmi->hwnd; - sei.nShow = SW_SHOWNORMAL; - sei.lpVerb = pCurrent->szVerb; - sei.lpFile = szPath; - sei.lpDirectory = szDir; - ShellExecuteExW(&sei); - return S_OK; - -} - -static -HRESULT -WINAPI -IDefaultContextMenu_fnInvokeCommand( - IContextMenu2 *iface, - LPCMINVOKECOMMANDINFO lpcmi) -{ - IDefaultContextMenuImpl * This = impl_from_IContextMenu(iface); - - switch(LOWORD(lpcmi->lpVerb)) - { - case FCIDM_SHVIEW_BIGICON: - case FCIDM_SHVIEW_SMALLICON: - case FCIDM_SHVIEW_LISTVIEW: - case FCIDM_SHVIEW_REPORTVIEW: - case 0x30: /* FIX IDS in resource files */ - case 0x31: - case 0x32: - case 0x33: - case FCIDM_SHVIEW_AUTOARRANGE: - case FCIDM_SHVIEW_SNAPTOGRID: - case FCIDM_SHVIEW_REFRESH: - return NotifyShellViewWindow(lpcmi, FALSE); - case FCIDM_SHVIEW_INSERT: - case FCIDM_SHVIEW_INSERTLINK: - return DoPaste(This, lpcmi); - case FCIDM_SHVIEW_OPEN: - case FCIDM_SHVIEW_EXPLORE: - return DoOpenOrExplore(This, lpcmi); - case FCIDM_SHVIEW_COPY: - case FCIDM_SHVIEW_CUT: - return DoCopyOrCut(This, lpcmi, LOWORD(lpcmi->lpVerb) == FCIDM_SHVIEW_COPY); - case FCIDM_SHVIEW_CREATELINK: - return DoCreateLink(This, lpcmi); - case FCIDM_SHVIEW_DELETE: - return DoDelete(This, lpcmi); - case FCIDM_SHVIEW_RENAME: - return DoRename(This, lpcmi); - case FCIDM_SHVIEW_PROPERTIES: - return DoProperties(This, lpcmi); - case 0x7ABC: - return DoFormat(This, lpcmi); - } - - if (This->iIdSHEFirst && This->iIdSHELast) - { - if (LOWORD(lpcmi->lpVerb) >= This->iIdSHEFirst && LOWORD(lpcmi->lpVerb) <= This->iIdSHELast) - { - return DoDynamicShellExtensions(This, lpcmi); - } - } - - if (This->iIdSCMFirst && This->iIdSCMLast) - { - if (LOWORD(lpcmi->lpVerb) >= This->iIdSCMFirst && LOWORD(lpcmi->lpVerb) <= This->iIdSCMLast) - { - return DoStaticShellExtensions(This, lpcmi); - } - } - - FIXME("Unhandled Verb %xl\n",LOWORD(lpcmi->lpVerb)); - return E_UNEXPECTED; -} - -static -HRESULT -WINAPI -IDefaultContextMenu_fnGetCommandString( - IContextMenu2 *iface, - UINT_PTR idCommand, - UINT uFlags, - UINT* lpReserved, - LPSTR lpszName, - UINT uMaxNameLen) -{ - - return S_OK; -} - -static -HRESULT -WINAPI -IDefaultContextMenu_fnHandleMenuMsg( - IContextMenu2 *iface, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) -{ - - return S_OK; -} - -static const IContextMenu2Vtbl cmvt = -{ - IDefaultContextMenu_fnQueryInterface, - IDefaultContextMenu_fnAddRef, - IDefaultContextMenu_fnRelease, - IDefaultContextMenu_fnQueryContextMenu, - IDefaultContextMenu_fnInvokeCommand, - IDefaultContextMenu_fnGetCommandString, - IDefaultContextMenu_fnHandleMenuMsg -}; -static -HRESULT -IDefaultContextMenu_Constructor( - const DEFCONTEXTMENU *pdcm, - REFIID riid, - void **ppv) -{ - IDefaultContextMenuImpl * This; - HRESULT hr = E_FAIL; - IDataObject * pDataObj; - - This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDefaultContextMenuImpl)); - if (This) - { - This->lpVtbl = &cmvt; - This->ref = 1; - TRACE("cidl %u\n", This->dcm.cidl); - if (SUCCEEDED(SHCreateDataObject(pdcm->pidlFolder, pdcm->cidl, pdcm->apidl, NULL, &IID_IDataObject, (void**)&pDataObj))) - { - This->pDataObj = pDataObj; - } - CopyMemory(&This->dcm, pdcm, sizeof(DEFCONTEXTMENU)); - hr = IDefaultContextMenu_fnQueryInterface((IContextMenu2*)This, riid, ppv); - if (SUCCEEDED(hr)) - IContextMenu_Release((IContextMenu2*)This); - } - - TRACE("This(%p)(%x) cidl %u\n",This, hr, This->dcm.cidl); - return hr; -} - -/************************************************************************* - * SHCreateDefaultContextMenu [SHELL32.325] Vista API - * - */ - -HRESULT -WINAPI -SHCreateDefaultContextMenu( - const DEFCONTEXTMENU *pdcm, - REFIID riid, - void **ppv) -{ - HRESULT hr = E_FAIL; - - *ppv = NULL; - hr = IDefaultContextMenu_Constructor( pdcm, riid, ppv ); - - TRACE("pcm %p hr %x\n", pdcm, hr); - return hr; -} - -/************************************************************************* - * CDefFolderMenu_Create2 [SHELL32.701] - * - */ - -HRESULT -WINAPI -CDefFolderMenu_Create2( - LPCITEMIDLIST pidlFolder, - HWND hwnd, - UINT cidl, - LPCITEMIDLIST *apidl, - IShellFolder *psf, - LPFNDFMCALLBACK lpfn, - UINT nKeys, - const HKEY *ahkeyClsKeys, - IContextMenu **ppcm) -{ - DEFCONTEXTMENU pdcm; - HRESULT hr; - - pdcm.hwnd = hwnd; - pdcm.pcmcb = NULL; - pdcm.pidlFolder = pidlFolder; - pdcm.psf = psf; - pdcm.cidl = cidl; - pdcm.apidl = apidl; - pdcm.punkAssociationInfo = NULL; - pdcm.cKeys = nKeys; - pdcm.aKeys = ahkeyClsKeys; - - hr = SHCreateDefaultContextMenu(&pdcm, &IID_IContextMenu, (void**)ppcm); - return hr; -} - diff --git a/reactos/dll/win32/shell32/shv_item_new.c b/reactos/dll/win32/shell32/shv_item_new.c deleted file mode 100644 index 228efd27316..00000000000 --- a/reactos/dll/win32/shell32/shv_item_new.c +++ /dev/null @@ -1,847 +0,0 @@ -/* - * PROJECT: shell32 - * LICENSE: GPL - See COPYING in the top level directory - * FILE: dll/win32/shell32/shv_item_new.c - * PURPOSE: provides new shell item service - * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -typedef enum -{ - SHELLNEW_TYPE_COMMAND = 1, - SHELLNEW_TYPE_DATA = 2, - SHELLNEW_TYPE_FILENAME = 4, - SHELLNEW_TYPE_NULLFILE = 8 -}SHELLNEW_TYPE; - - -typedef struct __SHELLNEW_ITEM__ -{ - SHELLNEW_TYPE Type; - LPWSTR szExt; - LPWSTR szTarget; - LPWSTR szDesc; - LPWSTR szIcon; - struct __SHELLNEW_ITEM__ * Next; -}SHELLNEW_ITEM, *PSHELLNEW_ITEM; - -typedef struct -{ - const IContextMenu2Vtbl *lpVtblContextMenu; - const IShellExtInitVtbl *lpvtblShellExtInit; - LPWSTR szPath; - IShellFolder *pSFParent; - PSHELLNEW_ITEM s_SnHead; -}INewMenuImpl, *LPINewMenuImpl; - -//static const IContextMenu2Vtbl cmvt; -//static const IShellExtInitVtbl sei; -static WCHAR szNew[MAX_PATH]; - - -static -BOOL -GetKeyDescription(LPWSTR szKeyName, LPWSTR szResult) -{ - HKEY hKey; - DWORD dwDesc, dwError; - WCHAR szDesc[100]; - - static const WCHAR szFriendlyTypeName[] = { '\\','F','r','i','e','n','d','l','y','T','y','p','e','N','a','m','e',0 }; - - TRACE("GetKeyDescription: keyname %s\n", debugstr_w(szKeyName)); - - if (RegOpenKeyExW(HKEY_CLASSES_ROOT,szKeyName,0, KEY_READ | KEY_QUERY_VALUE,&hKey) != ERROR_SUCCESS) - return FALSE; - - if (RegLoadMUIStringW(hKey,szFriendlyTypeName,szResult,MAX_PATH,&dwDesc,0,NULL) == ERROR_SUCCESS) - { - TRACE("result %s\n", debugstr_w(szResult)); - RegCloseKey(hKey); - return TRUE; - } - /* fetch default value */ - dwDesc = sizeof(szDesc); - dwError = RegGetValueW(hKey,NULL,NULL, RRF_RT_REG_SZ,NULL,szDesc,&dwDesc); - if(dwError == ERROR_SUCCESS) - { - if (wcsncmp(szKeyName, szDesc, dwDesc / sizeof(WCHAR))) - { - /* recurse for to a linked key */ - if (!GetKeyDescription(szDesc, szResult)) - { - /* use description */ - wcscpy(szResult, szDesc); - } - } - else - { - /* use default value as description */ - wcscpy(szResult, szDesc); - } - } - else - { - /* registry key w/o default key?? */ - TRACE("RegGetValue failed with %x\n", dwError); - wcscpy(szResult, szKeyName); - } - - RegCloseKey(hKey); - return TRUE; -} - - -PSHELLNEW_ITEM LoadItem(LPWSTR szKeyName) -{ - HKEY hKey; - DWORD dwIndex; - WCHAR szName[MAX_PATH]; - WCHAR szCommand[MAX_PATH]; - WCHAR szDesc[MAX_PATH] = {0}; - WCHAR szIcon[MAX_PATH] = {0}; - DWORD dwName, dwCommand; - LONG result; - PSHELLNEW_ITEM pNewItem; - - static const WCHAR szShellNew[] = { '\\','S','h','e','l','l','N','e','w',0 }; - static const WCHAR szCmd[] = { 'C','o','m','m','a','n','d',0 }; - static const WCHAR szData[] = { 'D','a','t','a',0 }; - static const WCHAR szFileName[] = { 'F','i','l','e','N','a','m','e', 0 }; - static const WCHAR szNullFile[] = { 'N','u','l','l','F','i','l','e', 0 }; - - - wcscpy(szName, szKeyName); - GetKeyDescription(szKeyName, szDesc); - wcscat(szName, szShellNew); - result = RegOpenKeyExW(HKEY_CLASSES_ROOT,szName,0,KEY_READ,&hKey); - - //TRACE("LoadItem dwName %d keyname %s szName %s szDesc %s szIcon %s\n", dwName, debugstr_w(szKeyName), debugstr_w(szName), debugstr_w(szDesc), debugstr_w(szIcon)); - - if (result != ERROR_SUCCESS) - { - return NULL; - } - - dwIndex = 0; - pNewItem = NULL; - - do - { - dwName = MAX_PATH; - dwCommand = MAX_PATH; - result = RegEnumValueW(hKey,dwIndex,szName,&dwName,NULL,NULL,(LPBYTE)szCommand, &dwCommand); - if (result == ERROR_SUCCESS) - { - long type = -1; - LPWSTR szTarget = szCommand; - //TRACE("szName %s szCommand %s\n", debugstr_w(szName), debugstr_w(szCommand)); - if (!wcsicmp(szName, szCmd)) - { - type = SHELLNEW_TYPE_COMMAND; - }else if (!wcsicmp(szName, szData)) - { - type = SHELLNEW_TYPE_DATA; - } - else if (!wcsicmp(szName, szFileName)) - { - type = SHELLNEW_TYPE_FILENAME; - } - else if (!wcsicmp(szName, szNullFile)) - { - type = SHELLNEW_TYPE_NULLFILE; - szTarget = NULL; - } - if (type != -1) - { - pNewItem = HeapAlloc(GetProcessHeap(), 0, sizeof(SHELLNEW_ITEM)); - pNewItem->Type = type; - if (szTarget) - pNewItem->szTarget = _wcsdup(szTarget); - else - pNewItem->szTarget = NULL; - - pNewItem->szDesc = _wcsdup(szDesc); - pNewItem->szIcon = _wcsdup(szIcon); - pNewItem->szExt = _wcsdup(szKeyName); - pNewItem->Next = NULL; - break; - } - } - dwIndex++; - }while(result != ERROR_NO_MORE_ITEMS); - RegCloseKey(hKey); - return pNewItem; -} - - -BOOL -LoadShellNewItems(INewMenuImpl * This) -{ - DWORD dwIndex; - WCHAR szName[MAX_PATH]; - LONG result; - PSHELLNEW_ITEM pNewItem; - PSHELLNEW_ITEM pCurItem = NULL; - static WCHAR szLnk[] = { '.','l','n','k',0 }; - - /* insert do new folder action */ - if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEW, szNew, sizeof(szNew) / sizeof(WCHAR))) - szNew[0] = 0; - szNew[MAX_PATH-1] = 0; - - dwIndex = 0; - do - { - result = RegEnumKeyW(HKEY_CLASSES_ROOT,dwIndex,szName,MAX_PATH); - if (result == ERROR_SUCCESS) - { - pNewItem = LoadItem(szName); - if (pNewItem) - { - if (!wcsicmp(pNewItem->szExt, szLnk)) - { - if (This->s_SnHead) - { - pNewItem->Next = This->s_SnHead; - This->s_SnHead = pNewItem; - } - else - { - This->s_SnHead = pCurItem = pNewItem; - } - } - else - { - if (pCurItem) - { - pCurItem->Next = pNewItem; - pCurItem = pNewItem; - } - else - { - pCurItem = This->s_SnHead = pNewItem; - } - } - } - } - dwIndex++; - }while(result != ERROR_NO_MORE_ITEMS); - - if (This->s_SnHead == NULL) - return FALSE; - else - return TRUE; -} - -UINT -InsertShellNewItems(HMENU hMenu, UINT idFirst, UINT idMenu, INewMenuImpl * This) -{ - MENUITEMINFOW mii; - PSHELLNEW_ITEM pCurItem; - UINT i; - WCHAR szBuffer[MAX_PATH]; - - if (This->s_SnHead == NULL) - { - if (!LoadShellNewItems(This)) - return 0; - } - - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - - /* insert do new shortcut action */ - if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEWFOLDER, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]))) - szBuffer[0] = 0; - szBuffer[MAX_PATH-1] = 0; - mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | MIIM_DATA; - mii.fType = MFT_STRING; - mii.dwTypeData = szBuffer; - mii.cch = wcslen(mii.dwTypeData); - mii.wID = idFirst++; - InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); - - /* insert do new shortcut action */ - if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEWLINK, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]))) - szBuffer[0] = 0; - szBuffer[MAX_PATH-1] = 0; - mii.dwTypeData = szBuffer; - mii.cch = wcslen(mii.dwTypeData); - mii.wID = idFirst++; - InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); - - /* insert seperator for custom new action */ - mii.fMask = MIIM_TYPE | MIIM_ID; - mii.fType = MFT_SEPARATOR; - mii.wID = -1; - InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); - - mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | MIIM_DATA; - /* - * FIXME - * implement loading of icons - * and using MFT_OWNERDRAWN - */ - mii.fType = MFT_STRING; - mii.fState = MFS_ENABLED; - - pCurItem = This->s_SnHead; - i = 0; - - while(pCurItem) - { - if (i >= 1) - { - TRACE("szDesc %s\n", debugstr_w(pCurItem->szDesc)); - mii.dwTypeData = pCurItem->szDesc; - mii.cch = wcslen(mii.dwTypeData); - mii.wID = idFirst++; - InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); - } - pCurItem = pCurItem->Next; - i++; - } - return (i+2); -} - -HRESULT -DoShellNewCmd(INewMenuImpl * This, LPCMINVOKECOMMANDINFO lpcmi) -{ - PSHELLNEW_ITEM pCurItem = This->s_SnHead; - IPersistFolder3 * psf; - LPITEMIDLIST pidl; - STRRET strTemp; - WCHAR szTemp[MAX_PATH]; - WCHAR szBuffer[MAX_PATH]; - WCHAR szPath[MAX_PATH]; - STARTUPINFOW sInfo; - PROCESS_INFORMATION pi; - UINT i, target; - HANDLE hFile; - DWORD dwWritten, dwError; - - static const WCHAR szP1[] = { '%', '1', 0 }; - static const WCHAR szFormat[] = {'%','s',' ','(','%','d',')','%','s',0 }; - - i = 1; - target = LOWORD(lpcmi->lpVerb); - - while(pCurItem) - { - if (i == target) - break; - - pCurItem = pCurItem->Next; - i++; - } - - if (!pCurItem) - return E_UNEXPECTED; - - if (IShellFolder2_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&psf) != S_OK) - { - ERR("Failed to get interface IID_IPersistFolder2\n"); - return E_FAIL; - } - if (IPersistFolder2_GetCurFolder(psf, &pidl) != S_OK) - { - ERR("IPersistFolder2_GetCurFolder failed\n"); - return E_FAIL; - } - - if (IShellFolder2_GetDisplayNameOf(This->pSFParent, pidl, SHGDN_FORPARSING, &strTemp) != S_OK) - { - ERR("IShellFolder_GetDisplayNameOf failed\n"); - return E_FAIL; - } - StrRetToBufW(&strTemp, pidl, szPath, MAX_PATH); - - switch(pCurItem->Type) - { - case SHELLNEW_TYPE_COMMAND: - { - LPWSTR ptr; - LPWSTR szCmd; - - if (!ExpandEnvironmentStringsW(pCurItem->szTarget, szBuffer, MAX_PATH)) - { - TRACE("ExpandEnvironmentStrings failed\n"); - break; - } - - ptr = wcsstr(szBuffer, szP1); - if (ptr) - { - ptr[1] = 's'; - swprintf(szTemp, szBuffer, szPath); - ptr = szTemp; - } - else - { - ptr = szBuffer; - } - - ZeroMemory(&sInfo, sizeof(sInfo)); - sInfo.cb = sizeof(sInfo); - szCmd = _wcsdup(ptr); - if (!szCmd) - break; - if (CreateProcessW(NULL, szCmd, NULL, NULL,FALSE,0,NULL,NULL,&sInfo, &pi)) - { - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); - } - free(szCmd); - break; - } - case SHELLNEW_TYPE_DATA: - case SHELLNEW_TYPE_FILENAME: - case SHELLNEW_TYPE_NULLFILE: - { - i = 2; - - PathAddBackslashW(szPath); - wcscat(szPath, szNew); - wcscat(szPath, L" "); - wcscat(szPath, pCurItem->szDesc); - wcscpy(szBuffer, szPath); - wcscat(szBuffer, pCurItem->szExt); - do - { - hFile = CreateFileW(szBuffer, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); - if (hFile != INVALID_HANDLE_VALUE) - break; - dwError = GetLastError(); - - TRACE("FileName %s szBuffer %s i %u error %x\n", debugstr_w(szBuffer), debugstr_w(szPath), i, dwError); - swprintf(szBuffer, szFormat, szPath, i, pCurItem->szExt); - i++; - }while(hFile == INVALID_HANDLE_VALUE && dwError == ERROR_FILE_EXISTS); - - if (hFile == INVALID_HANDLE_VALUE) - return E_FAIL; - - if (pCurItem->Type == SHELLNEW_TYPE_DATA) - { - i = WideCharToMultiByte(CP_ACP, 0, pCurItem->szTarget, -1, (LPSTR)szTemp, MAX_PATH*2, NULL, NULL); - if (i) - { - WriteFile(hFile, (LPCVOID)szTemp, i, &dwWritten, NULL); - } - } - CloseHandle(hFile); - if (pCurItem->Type == SHELLNEW_TYPE_FILENAME) - { - if (!CopyFileW(pCurItem->szTarget, szBuffer, FALSE)) - break; - } - TRACE("Notifying fs %s\n", debugstr_w(szBuffer)); - SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, (LPCVOID)szBuffer, NULL); - break; - } - } - return S_OK; -} -/************************************************************************** -* DoMeasureItem -*/ -HRESULT -DoMeasureItem(INewMenuImpl *This, HWND hWnd, MEASUREITEMSTRUCT * lpmis) -{ - PSHELLNEW_ITEM pCurItem; - PSHELLNEW_ITEM pItem; - UINT i; - HDC hDC; - SIZE size; - - TRACE("DoMeasureItem entered with id %x\n", lpmis->itemID); - - pCurItem = This->s_SnHead; - - i = 1; - pItem = NULL; - while(pCurItem) - { - if (i == lpmis->itemID) - { - pItem = pCurItem; - break; - } - pCurItem = pCurItem->Next; - i++; - } - - if (!pItem) - { - TRACE("DoMeasureItem no item found\n"); - return E_FAIL; - } - hDC = GetDC(hWnd); - GetTextExtentPoint32W(hDC, pCurItem->szDesc, wcslen(pCurItem->szDesc), &size); - lpmis->itemWidth = size.cx + 32; - lpmis->itemHeight = max(size.cy, 20); - ReleaseDC (hWnd, hDC); - return S_OK; -} -/************************************************************************** -* DoDrawItem -*/ -HRESULT -DoDrawItem(INewMenuImpl *This, HWND hWnd, DRAWITEMSTRUCT * drawItem) -{ - PSHELLNEW_ITEM pCurItem; - PSHELLNEW_ITEM pItem; - UINT i; - pCurItem = This->s_SnHead; - - TRACE("DoDrawItem entered with id %x\n", drawItem->itemID); - - i = 1; - pItem = NULL; - while(pCurItem) - { - if (i == drawItem->itemID) - { - pItem = pCurItem; - break; - } - pCurItem = pCurItem->Next; - i++; - } - - if (!pItem) - return E_FAIL; - - drawItem->rcItem.left += 20; - - DrawTextW(drawItem->hDC, pCurItem->szDesc, wcslen(pCurItem->szDesc), &drawItem->rcItem, 0); - return S_OK; -} - -/************************************************************************** -* DoNewFolder -*/ -static void DoNewFolder( - INewMenuImpl *This, - IShellView *psv) -{ - ISFHelper * psfhlp; - WCHAR wszName[MAX_PATH]; - - IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (LPVOID*)&psfhlp); - if (psfhlp) - { - LPITEMIDLIST pidl; - - if (ISFHelper_GetUniqueName(psfhlp, wszName, MAX_PATH) != S_OK) - return; - if (ISFHelper_AddFolder(psfhlp, 0, wszName, &pidl) != S_OK) - return; - - if(psv) - { - IShellView_Refresh(psv); - /* if we are in a shellview do labeledit */ - IShellView_SelectItem(psv, - pidl,(SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE - |SVSI_FOCUSED|SVSI_SELECT)); - IShellView_Refresh(psv); - } - SHFree(pidl); - - ISFHelper_Release(psfhlp); - } -} - - -static LPINewMenuImpl __inline impl_from_IShellExtInit( IShellExtInit *iface ) -{ - return (INewMenuImpl *)((char*)iface - FIELD_OFFSET(INewMenuImpl, lpvtblShellExtInit)); -} - -static LPINewMenuImpl __inline impl_from_IContextMenu( IContextMenu2 *iface ) -{ - return (INewMenuImpl *)((char*)iface - FIELD_OFFSET(INewMenuImpl, lpVtblContextMenu)); -} - -static HRESULT WINAPI INewItem_fnQueryInterface(INewMenuImpl * This, REFIID riid, LPVOID *ppvObj) -{ - TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj); - - *ppvObj = NULL; - - if(IsEqualIID(riid, &IID_IUnknown) || - IsEqualIID(riid, &IID_IContextMenu) || - IsEqualIID(riid, &IID_IContextMenu2)) - { - *ppvObj = (void *)&This->lpVtblContextMenu; - } - else if(IsEqualIID(riid, &IID_IShellExtInit)) - { - *ppvObj = (void *)&This->lpvtblShellExtInit; - } - - - if(*ppvObj) - { - IUnknown_AddRef((IUnknown*)*ppvObj); - TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj); - return S_OK; - } - TRACE("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; -} - -static ULONG WINAPI INewItem_fnAddRef(INewMenuImpl *iface) -{ - /* INewItem service is singleton */ - return 2; -} - -static ULONG WINAPI INewItem_fnRelease(INewMenuImpl *This) -{ - /* INewItem service is singleton */ - return 1; -} - -static -HRESULT -WINAPI -INewItem_IContextMenu_fnQueryInterface( IContextMenu2* iface, REFIID riid, void** ppvObject ) -{ - INewMenuImpl *This = impl_from_IContextMenu(iface); - return INewItem_fnQueryInterface(This, riid, ppvObject); -} - -static -ULONG -WINAPI -INewItem_IContextMenu_fnAddRef(IContextMenu2 *iface) -{ - INewMenuImpl *This = impl_from_IContextMenu(iface); - return INewItem_fnAddRef(This); -} - -static -ULONG -WINAPI -INewItem_IContextMenu_fnRelease(IContextMenu2 *iface) -{ - INewMenuImpl *This = impl_from_IContextMenu(iface); - return INewItem_fnRelease(This); -} - -static -HRESULT -WINAPI -INewItem_IContextMenu_fnQueryContextMenu(IContextMenu2 *iface, - HMENU hmenu, - UINT indexMenu, - UINT idCmdFirst, - UINT idCmdLast, - UINT uFlags) -{ - WCHAR szBuffer[200]; - MENUITEMINFOW mii; - HMENU hSubMenu; - int id = 1; - INewMenuImpl *This = impl_from_IContextMenu(iface); - - TRACE("%p %p %u %u %u %u\n", This, - hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags ); - - if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEW, szBuffer, 200)) - { - szBuffer[0] = 0; - } - szBuffer[199] = 0; - - hSubMenu = CreateMenu(); - memset( &mii, 0, sizeof(mii) ); - mii.cbSize = sizeof (mii); - mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE; - mii.fType = MFT_STRING; - mii.wID = idCmdFirst + id++; - mii.dwTypeData = szBuffer; - mii.cch = wcslen( mii.dwTypeData ); - mii.fState = MFS_ENABLED; - - if (hSubMenu) - { - id += InsertShellNewItems( hSubMenu, idCmdFirst, 0, This); - mii.fMask |= MIIM_SUBMENU; - mii.hSubMenu = hSubMenu; - } - - - if (!InsertMenuItemW( hmenu, indexMenu, TRUE, &mii )) - return E_FAIL; - - return MAKE_HRESULT( SEVERITY_SUCCESS, 0, id ); -} - -static -HRESULT -WINAPI -INewItem_IContextMenu_fnInvokeCommand( IContextMenu2* iface, - LPCMINVOKECOMMANDINFO lpici ) -{ - LPSHELLBROWSER lpSB; - LPSHELLVIEW lpSV = NULL; - HRESULT hr; - INewMenuImpl *This = impl_from_IContextMenu(iface); - - if((lpSB = (LPSHELLBROWSER)SendMessageA(lpici->hwnd, CWM_GETISHELLBROWSER,0,0))) - { - IShellBrowser_QueryActiveShellView(lpSB, &lpSV); - } - - if (LOWORD(lpici->lpVerb) == 0) - { - DoNewFolder(This, lpSV); - return S_OK; - } - - hr = DoShellNewCmd(This, lpici); - if (SUCCEEDED(hr) && lpSV) - { - IShellView_Refresh(lpSV); - } - - TRACE("INewItem_IContextMenu_fnInvokeCommand %x\n", hr); - return hr; -} - -static -HRESULT -WINAPI -INewItem_IContextMenu_fnGetCommandString( IContextMenu2* iface, - UINT_PTR idCmd, - UINT uType, - UINT* pwReserved, - LPSTR pszName, - UINT cchMax ) -{ - INewMenuImpl *This = impl_from_IContextMenu(iface); - - FIXME("%p %lu %u %p %p %u\n", This, - idCmd, uType, pwReserved, pszName, cchMax ); - - return E_NOTIMPL; -} - -static -HRESULT -WINAPI -INewItem_IContextMenu_fnHandleMenuMsg(IContextMenu2 *iface, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) -{ - INewMenuImpl *This = impl_from_IContextMenu(iface); - DRAWITEMSTRUCT * lpids = (DRAWITEMSTRUCT*) lParam; - MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*) lParam; - - TRACE("INewItem_IContextMenu_fnHandleMenuMsg (%p)->(msg=%x wp=%lx lp=%lx)\n",This, uMsg, wParam, lParam); - - - switch(uMsg) - { - case WM_MEASUREITEM: - return DoMeasureItem(This, (HWND)wParam, lpmis); - break; - case WM_DRAWITEM: - return DoDrawItem(This, (HWND)wParam, lpids); - break; - } - return S_OK; - - return E_UNEXPECTED; -} - -static const IContextMenu2Vtbl cmvt = -{ - INewItem_IContextMenu_fnQueryInterface, - INewItem_IContextMenu_fnAddRef, - INewItem_IContextMenu_fnRelease, - INewItem_IContextMenu_fnQueryContextMenu, - INewItem_IContextMenu_fnInvokeCommand, - INewItem_IContextMenu_fnGetCommandString, - INewItem_IContextMenu_fnHandleMenuMsg -}; - -static HRESULT WINAPI -INewItem_ExtInit_fnQueryInterface( IShellExtInit* iface, REFIID riid, void** ppvObject ) -{ - return INewItem_fnQueryInterface(impl_from_IShellExtInit(iface), riid, ppvObject); -} - -static ULONG WINAPI -INewItem_ExtInit_AddRef( IShellExtInit* iface ) -{ - return INewItem_fnAddRef(impl_from_IShellExtInit(iface)); -} - -static ULONG WINAPI -INewItem_ExtInit_Release( IShellExtInit* iface ) -{ - return INewItem_fnRelease(impl_from_IShellExtInit(iface)); -} - -static HRESULT WINAPI -INewItem_ExtInit_Initialize( IShellExtInit* iface, LPCITEMIDLIST pidlFolder, - IDataObject *pdtobj, HKEY hkeyProgID ) -{ - - return S_OK; -} - -static const IShellExtInitVtbl sei = -{ - INewItem_ExtInit_fnQueryInterface, - INewItem_ExtInit_AddRef, - INewItem_ExtInit_Release, - INewItem_ExtInit_Initialize -}; -static INewMenuImpl *cached_ow = NULL; - -VOID -INewItem_SetCurrentShellFolder(IShellFolder * psfParent) -{ - if (cached_ow) - cached_ow->pSFParent = psfParent; -} - -HRESULT WINAPI INewItem_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID *ppv) -{ - INewMenuImpl * ow; - HRESULT res; - - if (!cached_ow) - { - ow = LocalAlloc(LMEM_ZEROINIT, sizeof(INewMenuImpl)); - if (!ow) - { - return E_OUTOFMEMORY; - } - - ow->lpVtblContextMenu = &cmvt; - ow->lpvtblShellExtInit = &sei; - ow->s_SnHead = NULL; - ow->szPath = NULL; - - if (InterlockedCompareExchangePointer((void *)&cached_ow, ow, NULL) != NULL) - { - /* some other thread already been here */ - LocalFree( ow ); - } - } - - res = INewItem_fnQueryInterface( cached_ow, riid, ppv ); - return res; -} diff --git a/reactos/dll/win32/shell32/startmenu.c b/reactos/dll/win32/shell32/startmenu.c deleted file mode 100644 index 5e81610deb7..00000000000 --- a/reactos/dll/win32/shell32/startmenu.c +++ /dev/null @@ -1,583 +0,0 @@ -/* - * Start menu object - * - * Copyright 2007 Hervé Poussineau - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell32start); - -typedef struct _tagStartMenu { - const IMenuPopupVtbl *vtbl; - const IObjectWithSiteVtbl *objectSiteVtbl; - const IInitializeObjectVtbl *initObjectVtbl; - const IMenuBandVtbl *menuBandVtbl; - IUnknown *pUnkSite; - LONG refCount; - IBandSite * pBandSite; -} StartMenu, *LPStartMenu; - -typedef struct _tagMenuBandSite { - const IBandSiteVtbl * lpVtbl; - LONG refCount; - - IUnknown ** Objects; - LONG ObjectsCount; - -} MenuBandSite, *LPMenuBandSite; - -static const IMenuPopupVtbl StartMenuVtbl; -static const IObjectWithSiteVtbl StartMenu_ObjectWithSiteVtbl; -static const IInitializeObjectVtbl StartMenu_InitializeObjectVtbl; -static const IBandSiteVtbl StartMenu_BandSiteVtbl; -static const IMenuBandVtbl StartMenu_MenuBandVtbl; - -static LPStartMenu __inline impl_from_IMenuPopup(IMenuPopup *iface) -{ - return (LPStartMenu)((char *)iface - FIELD_OFFSET(StartMenu, vtbl)); -} - -static LPStartMenu __inline impl_from_IObjectWithSite(IObjectWithSite *iface) -{ - return (LPStartMenu)((char *)iface - FIELD_OFFSET(StartMenu, objectSiteVtbl)); -} - -static LPStartMenu __inline impl_from_IInitializeObject(IInitializeObject *iface) -{ - return (LPStartMenu)((char *)iface - FIELD_OFFSET(StartMenu, initObjectVtbl)); -} - -HRESULT WINAPI StartMenu_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv) -{ - StartMenu *This; - - TRACE("StartMenu_Constructor(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppv); - - if (pUnkOuter) - return E_POINTER; - - This = CoTaskMemAlloc(sizeof(StartMenu)); - if (!This) - return E_OUTOFMEMORY; - ZeroMemory(This, sizeof(*This)); - This->vtbl = &StartMenuVtbl; - This->objectSiteVtbl = &StartMenu_ObjectWithSiteVtbl; - This->initObjectVtbl = &StartMenu_InitializeObjectVtbl; - This->menuBandVtbl = &StartMenu_MenuBandVtbl; - This->refCount = 1; - - TRACE("StartMenu_Constructor returning %p\n", This); - *ppv = (IUnknown *)This; - return S_OK; -} - -static void WINAPI StartMenu_Destructor(StartMenu *This) -{ - TRACE("destroying %p\n", This); - if (This->pUnkSite) IUnknown_Release(This->pUnkSite); - CoTaskMemFree(This); -} - -static HRESULT WINAPI StartMenu_QueryInterface(IMenuPopup *iface, REFIID iid, LPVOID *ppvOut) -{ - StartMenu *This = impl_from_IMenuPopup(iface); - *ppvOut = NULL; - - TRACE("StartMenu_QueryInterface (%p, %s, %p)\n", iface, debugstr_guid(iid), ppvOut); - - if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_IOleWindow) - || IsEqualIID(iid, &IID_IDeskBar) || IsEqualIID(iid, &IID_IMenuPopup)) - { - *ppvOut = (void *)&This->vtbl; - } - else if (IsEqualIID(iid, &IID_IObjectWithSite)) - { - *ppvOut = (void *)&This->objectSiteVtbl; - } - else if (IsEqualIID(iid, &IID_IInitializeObject)) - { - *ppvOut = (void *)&This->initObjectVtbl; - } - - if (*ppvOut) - { - IUnknown_AddRef(iface); - return S_OK; - } - - WARN("unsupported interface: %s\n", debugstr_guid(iid)); - return E_NOINTERFACE; -} - -static ULONG WINAPI StartMenu_AddRef(IMenuPopup *iface) -{ - StartMenu *This = impl_from_IMenuPopup(iface); - TRACE("StartMenu_AddRef(%p)\n", iface); - return InterlockedIncrement(&This->refCount); -} - -static ULONG WINAPI StartMenu_Release(IMenuPopup *iface) -{ - StartMenu *This = impl_from_IMenuPopup(iface); - ULONG ret; - - TRACE("StartMenu_Release(%p)\n", iface); - - ret = InterlockedDecrement(&This->refCount); - if (ret == 0) - StartMenu_Destructor(This); - return ret; -} - -static HRESULT WINAPI StartMenu_GetWindow(IMenuPopup *iface, HWND *phwnd) -{ - FIXME("(%p, %p)\n", iface, phwnd); - return E_NOTIMPL; -} - -static HRESULT WINAPI StartMenu_ContextSensitiveHelp(IMenuPopup *iface, BOOL fEnterMode) -{ - FIXME("(%p, %d)\n", iface, fEnterMode); - return E_NOTIMPL; -} - -static HRESULT WINAPI StartMenu_SetClient(IMenuPopup *iface, IUnknown *punkClient) -{ - FIXME("(%p, %p)\n", iface, punkClient); - return E_NOTIMPL; -} - -static HRESULT WINAPI StartMenu_GetClient(IMenuPopup *iface, IUnknown **ppunkClient) -{ - StartMenu * This = (StartMenu*)iface; - - TRACE("StartMenu_GetClient (%p, %p)\n", iface, ppunkClient); - - *ppunkClient = (IUnknown*)This->pBandSite; - IUnknown_AddRef(*ppunkClient); - return S_OK; -} - -static HRESULT WINAPI StartMenu_OnPosRectChangeDB(IMenuPopup *iface, LPRECT prc) -{ - FIXME("(%p, %p)\n", iface, prc); - return E_NOTIMPL; -} - -static HRESULT WINAPI StartMenu_Popup(IMenuPopup *iface, POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS dwFlags) -{ - FIXME("(%p, %p, %p, %x)\n", iface, ppt, prcExclude, dwFlags); - return E_NOTIMPL; -} - -static HRESULT WINAPI StartMenu_OnSelect(IMenuPopup *iface, DWORD dwSelectType) -{ - FIXME("(%p, %u)\n", iface, dwSelectType); - return E_NOTIMPL; -} - -static HRESULT WINAPI StartMenu_SetSubMenu(IMenuPopup *iface, IMenuPopup *pmp, BOOL fSet) -{ - FIXME("(%p, %p, %d)\n", iface, pmp, fSet); - return E_NOTIMPL; -} - -static const IMenuPopupVtbl StartMenuVtbl = -{ - /* IUnknown */ - StartMenu_QueryInterface, - StartMenu_AddRef, - StartMenu_Release, - - /* IOleWindow */ - StartMenu_GetWindow, - StartMenu_ContextSensitiveHelp, - - /* IDeskBar */ - StartMenu_SetClient, - StartMenu_GetClient, - StartMenu_OnPosRectChangeDB, - - /* IMenuPopup */ - StartMenu_Popup, - StartMenu_OnSelect, - StartMenu_SetSubMenu, -}; - -static HRESULT WINAPI StartMenu_IObjectWithSite_QueryInterface(IObjectWithSite *iface, REFIID iid, LPVOID *ppvOut) -{ - StartMenu *This = impl_from_IObjectWithSite(iface); - TRACE("(%p, %s, %p)\n", iface, debugstr_guid(iid), ppvOut); - return StartMenu_QueryInterface((IMenuPopup *)This, iid, ppvOut); -} - -static ULONG WINAPI StartMenu_IObjectWithSite_AddRef(IObjectWithSite *iface) -{ - StartMenu *This = impl_from_IObjectWithSite(iface); - TRACE("(%p)\n", iface); - return StartMenu_AddRef((IMenuPopup *)This); -} - -static ULONG WINAPI StartMenu_IObjectWithSite_Release(IObjectWithSite *iface) -{ - StartMenu *This = impl_from_IObjectWithSite(iface); - TRACE("StartMenu_IObjectWithSite_Release (%p)\n", iface); - return StartMenu_Release((IMenuPopup *)This); -} - -static HRESULT WINAPI StartMenu_IObjectWithSite_SetSite(IObjectWithSite *iface, IUnknown *pUnkSite) -{ - StartMenu *This = impl_from_IObjectWithSite(iface); - - TRACE("StartMenu_IObjectWithSite_SetSite(%p, %p)\n", iface, pUnkSite); - - if (This->pUnkSite) - IUnknown_Release(This->pUnkSite); - This->pUnkSite = pUnkSite; - if (This->pUnkSite) - IUnknown_AddRef(This->pUnkSite); - return S_OK; -} - -static HRESULT WINAPI StartMenu_IObjectWithSite_GetSite(IObjectWithSite *iface, REFIID riid, void **ppvSite) -{ - StartMenu *This = impl_from_IObjectWithSite(iface); - - TRACE("(%p, %s, %p)\n", iface, debugstr_guid(riid), ppvSite); - - if (!This->pUnkSite) - return E_FAIL; - - return IUnknown_QueryInterface(This->pUnkSite, riid, ppvSite); -} - -static const IObjectWithSiteVtbl StartMenu_ObjectWithSiteVtbl = -{ - StartMenu_IObjectWithSite_QueryInterface, - StartMenu_IObjectWithSite_AddRef, - StartMenu_IObjectWithSite_Release, - - StartMenu_IObjectWithSite_SetSite, - StartMenu_IObjectWithSite_GetSite, -}; - -static HRESULT WINAPI StartMenu_IInitializeObject_QueryInterface(IInitializeObject *iface, REFIID iid, LPVOID *ppvOut) -{ - StartMenu *This = impl_from_IInitializeObject(iface); - TRACE("(%p, %s, %p)\n", iface, debugstr_guid(iid), ppvOut); - return StartMenu_QueryInterface((IMenuPopup *)This, iid, ppvOut); -} - -static ULONG WINAPI StartMenu_IInitializeObject_AddRef(IInitializeObject *iface) -{ - StartMenu *This = impl_from_IInitializeObject(iface); - TRACE("StartMenu_IInitializeObject_AddRef(%p)\n", iface); - return StartMenu_AddRef((IMenuPopup *)This); -} - -static ULONG WINAPI StartMenu_IInitializeObject_Release(IInitializeObject *iface) -{ - StartMenu *This = impl_from_IInitializeObject(iface); - TRACE("StartMenu_IInitializeObject_Release (%p)\n", iface); - return StartMenu_Release((IMenuPopup *)This); -} - -static HRESULT WINAPI StartMenu_IInitializeObject_Initialize(IInitializeObject *iface) -{ - HRESULT hr; - StartMenu *This = impl_from_IInitializeObject(iface); - TRACE("StartMenu_IInitializeObject_Initialize (%p)\n", iface); - - hr = MenuBandSite_Constructor(NULL, &IID_IBandSite, (LPVOID*)&This->pBandSite); - if (FAILED(hr)) - return hr; - - return IBandSite_AddBand(This->pBandSite, (IUnknown*)&This->menuBandVtbl); -} - -static const IInitializeObjectVtbl StartMenu_InitializeObjectVtbl = -{ - StartMenu_IInitializeObject_QueryInterface, - StartMenu_IInitializeObject_AddRef, - StartMenu_IInitializeObject_Release, - - StartMenu_IInitializeObject_Initialize, -}; - -//-------------------------------------------------------------- -// IMenuBand interface - - -static HRESULT STDMETHODCALLTYPE StartMenu_IMenuBand_QueryInterface(IMenuBand *iface, REFIID iid, LPVOID *ppvOut) -{ - StartMenu *This = (StartMenu*)CONTAINING_RECORD(iface, StartMenu, menuBandVtbl); - - if (IsEqualIID(iid, &IID_IUnknown) || - IsEqualIID(iid, &IID_IMenuBand)) - { - *ppvOut = &This->menuBandVtbl; - IUnknown_AddRef((IUnknown*)*ppvOut); - return S_OK; - } - - WARN("unsupported interface:(%p, %s, %p)\n", iface, debugstr_guid(iid), ppvOut); - return E_NOINTERFACE; -} - -static ULONG STDMETHODCALLTYPE StartMenu_IMenuBand_AddRef(IMenuBand *iface) -{ - StartMenu *This = (StartMenu*)CONTAINING_RECORD(iface, StartMenu, menuBandVtbl); - TRACE("StartMenu_IInitializeObject_AddRef(%p)\n", This); - return StartMenu_AddRef((IMenuPopup *)This); -} - -static ULONG STDMETHODCALLTYPE StartMenu_IMenuBand_Release(IMenuBand *iface) -{ - StartMenu *This = (StartMenu*)CONTAINING_RECORD(iface, StartMenu, menuBandVtbl); - TRACE("StartMenu_IInitializeObject_Release (%p)\n", This); - return StartMenu_Release((IMenuPopup *)This); -} - -HRESULT STDMETHODCALLTYPE StartMenu_IMenuBand_IsMenuMessage(IMenuBand *iface, MSG *pmsg) -{ - StartMenu *This = (StartMenu*)CONTAINING_RECORD(iface, StartMenu, menuBandVtbl); - TRACE("StartMenu_IMenuBand_IsMenuMessage Stub(%p)\n", This); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE StartMenu_IMenuBand_TranslateMenuMessage(IMenuBand *iface, MSG *pmsg, LRESULT *plRet) -{ - StartMenu *This = (StartMenu*)CONTAINING_RECORD(iface, StartMenu, menuBandVtbl); - TRACE("StartMenu_IMenuBand_TranslateMenuMessage Stub(%p)\n", This); - return E_NOTIMPL; -} - - -static const IMenuBandVtbl StartMenu_MenuBandVtbl = -{ - /* IUnknown methods */ - StartMenu_IMenuBand_QueryInterface, - StartMenu_IMenuBand_AddRef, - StartMenu_IMenuBand_Release, - /* IMenuBand methods */ - StartMenu_IMenuBand_IsMenuMessage, - StartMenu_IMenuBand_TranslateMenuMessage, -}; - - -//--------------------------------------------------------------------------------------------------------- -// IBandSite interface - - -HRESULT WINAPI MenuBandSite_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv) -{ - MenuBandSite *This; - HRESULT hr; - - TRACE("StartMenu_Constructor(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppv); - - if (pUnkOuter) - return E_POINTER; - - This = CoTaskMemAlloc(sizeof(MenuBandSite)); - if (!This) - return E_OUTOFMEMORY; - - ZeroMemory(This, sizeof(MenuBandSite)); - This->lpVtbl = &StartMenu_BandSiteVtbl; - - hr = IUnknown_QueryInterface((IUnknown*)&This->lpVtbl, riid, ppv); - - if (FAILED(hr)) - { - CoTaskMemFree(This); - return hr; - } - - TRACE("StartMenu_Constructor returning %p\n", This); - *ppv = (IUnknown *)This; - return S_OK; -} - -static HRESULT WINAPI BandSite_QueryInterface(IBandSite *iface, REFIID iid, LPVOID *ppvOut) -{ - MenuBandSite *This = (MenuBandSite*)CONTAINING_RECORD(iface, MenuBandSite, lpVtbl); - - if (IsEqualIID(iid, &IID_IUnknown) || - IsEqualIID(iid, &IID_IBandSite)) - { - *ppvOut = &This->lpVtbl; - IUnknown_AddRef((IUnknown*)*ppvOut); - return S_OK; - } - - return E_NOINTERFACE; -} - -static ULONG WINAPI BandSite_AddRef(IBandSite *iface) -{ - MenuBandSite *This = (MenuBandSite*)CONTAINING_RECORD(iface, MenuBandSite, lpVtbl); - TRACE("BandSite_AddRef(%p)\n", iface); - return InterlockedIncrement(&This->refCount); -} - -static ULONG WINAPI BandSite_Release(IBandSite *iface) -{ - LONG ret; - MenuBandSite *This = (MenuBandSite*)CONTAINING_RECORD(iface, MenuBandSite, lpVtbl); - - ret = InterlockedDecrement(&This->refCount); - TRACE("BandSite_Release refCount %u\n", ret); - - if (ret == 0) - { - CoTaskMemFree(This->Objects); - CoTaskMemFree(This); - } - - return ret; -} - - -static HRESULT STDMETHODCALLTYPE BandSite_AddBand(IBandSite *iface, IUnknown *punk) -{ - IUnknown ** Objects; - MenuBandSite *This = (MenuBandSite*)CONTAINING_RECORD(iface, MenuBandSite, lpVtbl); - - TRACE("StartMenu_IBandSite_AddBand Stub punk %p\n", punk); - - if (!punk) - return E_FAIL; - - Objects = (IUnknown**) CoTaskMemAlloc(sizeof(IUnknown*) * (This->ObjectsCount + 1)); - if (!Objects) - return E_FAIL; - - RtlMoveMemory(Objects, This->Objects, sizeof(IUnknown*) * This->ObjectsCount); - - CoTaskMemFree(This->Objects); - - This->Objects = Objects; - Objects[This->ObjectsCount] = punk; - - IUnknown_AddRef(punk); - - This->ObjectsCount++; - - - return S_OK; -} - -static HRESULT STDMETHODCALLTYPE BandSite_EnumBands(IBandSite *iface, UINT uBand, DWORD *pdwBandID) -{ - ULONG Index, ObjectCount; - MenuBandSite *This = (MenuBandSite*)CONTAINING_RECORD(iface, MenuBandSite, lpVtbl); - - TRACE("StartMenu_IBandSite_EnumBands Stub uBand %uu pdwBandID %p\n", uBand, pdwBandID); - - if (uBand == (UINT)-1) - return This->ObjectsCount; - - ObjectCount = 0; - - for(Index = 0; Index < This->ObjectsCount; Index++) - { - if (This->Objects[Index] != NULL) - { - if (uBand == ObjectCount) - { - *pdwBandID = Index; - return S_OK; - } - ObjectCount++; - } - } - return E_FAIL; -} - -static HRESULT STDMETHODCALLTYPE BandSite_QueryBand(IBandSite *iface, DWORD dwBandID, IDeskBand **ppstb, DWORD *pdwState, LPWSTR pszName, int cchName) -{ - FIXME("StartMenu_IBandSite_QueryBand Stub dwBandID %u IDeskBand %p pdwState %p Name %p cchName %u\n", dwBandID, ppstb, pdwState, pszName, cchName); - return E_FAIL; -} - -static HRESULT STDMETHODCALLTYPE BandSite_SetBandState(IBandSite *iface, DWORD dwBandID, DWORD dwMask, DWORD dwState) -{ - FIXME("StartMenu_IBandSite_SetBandState Stub dwBandID %u dwMask %x dwState %u\n", dwBandID, dwMask, dwState); - return E_FAIL; -} -static HRESULT STDMETHODCALLTYPE BandSite_RemoveBand(IBandSite *iface, DWORD dwBandID) -{ - MenuBandSite *This = (MenuBandSite*)CONTAINING_RECORD(iface, MenuBandSite, lpVtbl); - TRACE("StartMenu_IBandSite_RemoveBand Stub dwBandID %u\n", dwBandID); - - if (This->ObjectsCount <= dwBandID) - return E_FAIL; - - if (This->Objects[dwBandID]) - { - This->Objects[dwBandID]->lpVtbl->Release(This->Objects[dwBandID]); - This->Objects[dwBandID] = NULL; - } - - return S_OK; -} - -static HRESULT STDMETHODCALLTYPE BandSite_GetBandObject(IBandSite *iface, DWORD dwBandID, REFIID riid, void **ppv) -{ - MenuBandSite *This = (MenuBandSite*)CONTAINING_RECORD(iface, MenuBandSite, lpVtbl); - - TRACE("StartMenu_IBandSite_GetBandObject Stub dwBandID %u riid %p ppv %p\n", dwBandID, riid, ppv); - - if (This->ObjectsCount <= dwBandID) - return E_FAIL; - - if (This->Objects[dwBandID]) - { - return IUnknown_QueryInterface(This->Objects[dwBandID], riid, ppv); - } - - return E_FAIL; -} -static HRESULT STDMETHODCALLTYPE BandSite_SetBandSiteInfo(IBandSite *iface, const BANDSITEINFO *pbsinfo) -{ - FIXME("StartMenu_IBandSite_SetBandSiteInfo Stub pbsinfo %p\n", pbsinfo); - return E_FAIL; - -} -static HRESULT STDMETHODCALLTYPE BandSite_GetBandSiteInfo(IBandSite *iface, BANDSITEINFO *pbsinfo) -{ - FIXME("StartMenu_IBandSite_GetBandSiteInfo Stub pbsinfo %p\n", pbsinfo); - return E_FAIL; -} - -static const IBandSiteVtbl StartMenu_BandSiteVtbl = -{ - BandSite_QueryInterface, - BandSite_AddRef, - BandSite_Release, - BandSite_AddBand, - BandSite_EnumBands, - BandSite_QueryBand, - BandSite_SetBandState, - BandSite_RemoveBand, - BandSite_GetBandObject, - BandSite_SetBandSiteInfo, - BandSite_GetBandSiteInfo -}; - diff --git a/reactos/dll/win32/shell32/stubs.c b/reactos/dll/win32/shell32/stubs.c deleted file mode 100644 index b3192ea2c25..00000000000 --- a/reactos/dll/win32/shell32/stubs.c +++ /dev/null @@ -1,1419 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: shell32.dll - * FILE: dll/win32/shell32/stubs.c - * PURPOSE: shell32.dll stubs - * PROGRAMMER: Dmitry Chapyshev (dmitry@reactos.org) - * NOTES: If you implement a function, remove it from this file - * UPDATE HISTORY: - * 03/02/2009 Created - */ - - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(shell); - -/* - * Unimplemented - */ -HLOCAL -WINAPI -SHLocalAlloc(UINT uFlags, SIZE_T uBytes) -{ - FIXME("SHLocalAlloc() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -HLOCAL -WINAPI -SHLocalFree(HLOCAL hMem) -{ - FIXME("SHLocalFree() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -HLOCAL -WINAPI -SHLocalReAlloc(HLOCAL hMem, - SIZE_T uBytes, - UINT uFlags) -{ - FIXME("SHLocalReAlloc() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -LPWSTR -WINAPI -AddCommasW(DWORD dwUnknown, LPWSTR lpNumber) -{ - LPWSTR lpRetBuf = L"0"; - - FIXME("AddCommasW() stub\n"); - return lpRetBuf; -} - -/* - * Unimplemented - */ -LPWSTR -WINAPI -ShortSizeFormatW(LONGLONG llNumber) -{ - FIXME("ShortSizeFormatW() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHFindComputer(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - FIXME("SHFindComputer() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHLimitInputEdit(HWND hWnd, LPVOID lpUnknown) -{ - FIXME("SHLimitInputEdit() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHLimitInputCombo(HWND hWnd, LPVOID lpUnknown) -{ - FIXME("SHLimitInputCombo() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -PathIsEqualOrSubFolder(LPWSTR lpFolder, LPWSTR lpSubFolder) -{ - FIXME("PathIsEqualOrSubFolder() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -SHCreateFileExtractIconW(LPCWSTR pszPath, - DWORD dwFileAttributes, - LPVOID lpUnknown1, - LPVOID lpUnknown2) -{ - FIXME("SHCreateFileExtractIconW() stub\n"); - return E_FAIL; -} - -HRESULT -WINAPI -SHGetUnreadMailCountW(HKEY hKeyUser, - LPCWSTR pszMailAddress, - DWORD *pdwCount, - FILETIME *pFileTime, - LPCWSTR pszShellExecuteCommand, - int cchShellExecuteCommand) -{ - FIXME("SHGetUnreadMailCountW() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -SHSetUnreadMailCountW(LPCWSTR pszMailAddress, - DWORD dwCount, - LPCWSTR pszShellExecuteCommand) -{ - FIXME("SHSetUnreadMailCountW() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -VOID -WINAPI -CheckDiskSpace(VOID) -{ - FIXME("CheckDiskSpace() stub\n"); -} - -/* - * Unimplemented - */ -VOID -WINAPI -SHReValidateDarwinCache(VOID) -{ - FIXME("SHReValidateDarwinCache() stub\n"); -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -CopyStreamUI(IStream *pSrc, IStream *pDst, IProgressDialog *pProgDlg) -{ - FIXME("CopyStreamUI() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -FILEDESCRIPTOR* -WINAPI -GetFileDescriptor(FILEGROUPDESCRIPTOR *pFileGroupDesc, BOOL bUnicode, INT iIndex, LPWSTR lpName) -{ - FIXME("GetFileDescriptor() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHIsTempDisplayMode(VOID) -{ - FIXME("SHIsTempDisplayMode() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -LONG -WINAPI -SHCreateSessionKey(REGSAM regSam, PHKEY phKey) -{ - FIXME("SHCreateSessionKey() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -MakeShellURLFromPathW(LPCWSTR lpPath, LPWSTR lpUrl, INT cchMax) -{ - FIXME("MakeShellURLFromPathW() stub\n"); - lpUrl = NULL; - return FALSE; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -MakeShellURLFromPathA(LPCSTR lpPath, LPSTR lpUrl, INT cchMax) -{ - FIXME("MakeShellURLFromPathA() stub\n"); - lpUrl = NULL; - return FALSE; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -SHParseDarwinIDFromCacheW(LPCWSTR lpUnknown1, LPWSTR lpUnknown2) -{ - FIXME("SHParseDarwinIDFromCacheW() stub\n"); - lpUnknown2 = NULL; - return E_FAIL; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -SHMultiFileProperties(IDataObject *pDataObject, DWORD dwFlags) -{ - FIXME("SHMultiFileProperties() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -SHCreatePropertyBag(REFIID refIId, LPVOID *lpUnknown) -{ - /* Call SHCreatePropertyBagOnMemory() from shlwapi.dll */ - FIXME("SHCreatePropertyBag() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -SHCopyMonikerToTemp(IMoniker *pMoniker, LPCWSTR lpInput, LPWSTR lpOutput, INT cchMax) -{ - /* Unimplemented in XP SP3 */ - TRACE("SHCopyMonikerToTemp() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -HLOCAL -WINAPI -CheckWinIniForAssocs(VOID) -{ - FIXME("CheckWinIniForAssocs() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -SHGetSetFolderCustomSettingsW(LPSHFOLDERCUSTOMSETTINGSW pfcs, - LPCWSTR pszPath, - DWORD dwReadWrite) -{ - FIXME("SHGetSetFolderCustomSettingsW() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -SHGetSetFolderCustomSettingsA(LPSHFOLDERCUSTOMSETTINGSA pfcs, - LPCSTR pszPath, - DWORD dwReadWrite) -{ - FIXME("SHGetSetFolderCustomSettingsA() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHOpenPropSheetA(LPSTR lpCaption, - HKEY hKeys[], - UINT uCount, - CLSID *pClsID, - IDataObject *pDataObject, - IShellBrowser *pShellBrowser, - LPSTR lpStartPage) -{ - FIXME("SHOpenPropSheetA() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHOpenPropSheetW(LPWSTR lpCaption, - HKEY hKeys[], - UINT uCount, - CLSID *pClsID, - IDataObject *pDataObject, - IShellBrowser *pShellBrowser, - LPWSTR lpStartPage) -{ - FIXME("SHOpenPropSheetW() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -VOID -WINAPI -CDefFolderMenu_MergeMenu(HINSTANCE hInstance, - UINT uMainMerge, - UINT uPopupMerge, - LPQCMINFO lpQcmInfo) -{ - FIXME("CDefFolderMenu_MergeMenu() stub\n"); -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -CDefFolderMenu_Create(LPITEMIDLIST pidlFolder, - HWND hwnd, - UINT uidl, - PCUITEMID_CHILD_ARRAY *apidl, - IShellFolder *psf, - LPFNDFMCALLBACK lpfn, - HKEY hProgID, - HKEY hBaseProgID, - IContextMenu **ppcm) -{ - FIXME("CDefFolderMenu_Create() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHChangeRegistrationReceive(LPVOID lpUnknown1, DWORD dwUnknown2) -{ - FIXME("SHChangeRegistrationReceive() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -VOID -WINAPI -SHWaitOp_Operate(LPVOID lpUnknown1, DWORD dwUnknown2) -{ - FIXME("SHWaitOp_Operate() stub\n"); -} - -/* - * Unimplemented - */ -VOID -WINAPI -SHChangeNotifyReceive(LONG lUnknown, UINT uUnknown, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - FIXME("SHChangeNotifyReceive() stub\n"); -} - -/* - * Unimplemented - */ -INT -WINAPI -RealDriveTypeFlags(INT iDrive, BOOL bUnknown) -{ - FIXME("RealDriveTypeFlags() stub\n"); - return 1; -} - -/* - * Unimplemented - */ -LPWSTR -WINAPI -StrRStrW(LPWSTR lpSrc, LPWSTR lpLast, LPWSTR lpSearch) -{ - FIXME("StrRStrW() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -LPWSTR -WINAPI -StrRStrA(LPSTR lpSrc, LPSTR lpLast, LPSTR lpSearch) -{ - FIXME("StrRStrA() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -LONG -WINAPI -ShellHookProc(INT iCode, WPARAM wParam, LPARAM lParam) -{ - /* Unimplemented in WinXP SP3 */ - TRACE("ShellHookProc() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -VOID -WINAPI -ShellExec_RunDLL(HWND hwnd, HINSTANCE hInstance, LPWSTR pszCmdLine, int nCmdShow) -{ - FIXME("ShellExec_RunDLL() stub\n"); -} - -/* - * Unimplemented - */ -VOID -WINAPI -ShellExec_RunDLLA(HWND hwnd, HINSTANCE hInstance, LPSTR pszCmdLine, int nCmdShow) -{ - FIXME("ShellExec_RunDLLA() stub\n"); -} - -/* - * Unimplemented - */ -VOID -WINAPI -ShellExec_RunDLLW(HWND hwnd, HINSTANCE hInstance, LPWSTR pszCmdLine, int nCmdShow) -{ - FIXME("ShellExec_RunDLLW() stub\n"); -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SheShortenPathW(LPWSTR lpPath, BOOL bShorten) -{ - FIXME("SheShortenPathW() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SheShortenPathA(LPSTR lpPath, BOOL bShorten) -{ - FIXME("SheShortenPathA() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -INT -WINAPI -SheSetCurDrive(INT iIndex) -{ - FIXME("SheSetCurDrive() stub\n"); - return 1; -} - -/* - * Unimplemented - */ -LPWSTR -WINAPI -SheRemoveQuotesW(LPWSTR lpInput) -{ - FIXME("SheRemoveQuotesW() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -LPSTR -WINAPI -SheRemoveQuotesA(LPSTR lpInput) -{ - FIXME("SheRemoveQuotesA() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -INT -WINAPI -SheGetPathOffsetW(LPWSTR lpPath) -{ - FIXME("SheGetPathOffsetW() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SheGetDirExW(LPWSTR lpDrive, - LPDWORD lpCurDirLen, - LPWSTR lpCurDir) -{ - FIXME("SheGetDirExW() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -INT -WINAPI -SheGetCurDrive(VOID) -{ - FIXME("SheGetCurDrive() stub\n"); - return 1; -} - -/* - * Unimplemented - */ -INT -WINAPI -SheFullPathW(LPWSTR lpFullName, DWORD dwPathSize, LPWSTR lpBuffer) -{ - FIXME("SheFullPathW() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -INT -WINAPI -SheFullPathA(LPSTR lpFullName, DWORD dwPathSize, LPSTR lpBuffer) -{ - FIXME("SheFullPathA() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SheConvertPathW(LPWSTR lpCmd, LPWSTR lpFileName, UINT uCmdLen) -{ - FIXME("SheConvertPathW() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -INT -WINAPI -SheChangeDirExW(LPWSTR lpDir) -{ - FIXME("SheChangeDirExW() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -INT -WINAPI -SheChangeDirExA(LPSTR lpDir) -{ - FIXME("SheChangeDirExA() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHInvokePrinterCommandW(HWND hwnd, - UINT uAction, - LPCWSTR lpBuf1, - LPCWSTR lpBuf2, - BOOL fModal) -{ - FIXME("SHInvokePrinterCommandW() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHInvokePrinterCommandA(HWND hwnd, - UINT uAction, - LPCSTR lpBuf1, - LPCSTR lpBuf2, - BOOL fModal) -{ - FIXME("SHInvokePrinterCommandA() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -SHCreateQueryCancelAutoPlayMoniker(IMoniker **ppmoniker) -{ - FIXME("SHCreateQueryCancelAutoPlayMoniker() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHCreateProcessAsUserW(PSHCREATEPROCESSINFOW pscpi) -{ - FIXME("SHCreateProcessAsUserW() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHChangeNotifySuspendResume(BOOL bSuspend, - LPITEMIDLIST pidl, - BOOL bRecursive, - DWORD dwReserved) -{ - FIXME("SHChangeNotifySuspendResume() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -RegenerateUserEnvironment(LPVOID *lpUnknown, BOOL bUnknown) -{ - FIXME("RegenerateUserEnvironment() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -HINSTANCE -WINAPI -RealShellExecuteExA(HWND hwnd, - LPCSTR lpOperation, - LPCSTR lpFile, - LPCSTR lpParameters, - LPCSTR lpDirectory, - LPSTR lpReturn, - LPCSTR lpTitle, - LPSTR lpReserved, - WORD nShowCmd, - HANDLE *lpProcess, - DWORD dwFlags) -{ - FIXME("RealShellExecuteExA() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -HINSTANCE -WINAPI -RealShellExecuteExW(HWND hwnd, - LPCWSTR lpOperation, - LPCWSTR lpFile, - LPCWSTR lpParameters, - LPCWSTR lpDirectory, - LPWSTR lpReturn, - LPCWSTR lpTitle, - LPWSTR lpReserved, - WORD nShowCmd, - HANDLE *lpProcess, - DWORD dwFlags) -{ - FIXME("RealShellExecuteExW() stub\n"); - return NULL; -} - -/* - * Implemented - */ -HINSTANCE -WINAPI -RealShellExecuteA(HWND hwnd, - LPCSTR lpOperation, - LPCSTR lpFile, - LPCSTR lpParameters, - LPCSTR lpDirectory, - LPSTR lpReturn, - LPCSTR lpTitle, - LPSTR lpReserved, - WORD nShowCmd, - HANDLE *lpProcess) -{ - return RealShellExecuteExA(hwnd, - lpOperation, - lpFile, - lpParameters, - lpDirectory, - lpReturn, - lpTitle, - lpReserved, - nShowCmd, - lpProcess, - 0); -} - -/* - * Implemented - */ -HINSTANCE -WINAPI -RealShellExecuteW(HWND hwnd, - LPCWSTR lpOperation, - LPCWSTR lpFile, - LPCWSTR lpParameters, - LPCWSTR lpDirectory, - LPWSTR lpReturn, - LPCWSTR lpTitle, - LPWSTR lpReserved, - WORD nShowCmd, - HANDLE *lpProcess) -{ - return RealShellExecuteExW(hwnd, - lpOperation, - lpFile, - lpParameters, - lpDirectory, - lpReturn, - lpTitle, - lpReserved, - nShowCmd, - lpProcess, - 0); -} - -/* - * Unimplemented - */ -VOID -WINAPI -PrintersGetCommand_RunDLL(HWND hwnd, HINSTANCE hInstance, LPWSTR pszCmdLine, int nCmdShow) -{ - FIXME("PrintersGetCommand_RunDLL() stub\n"); -} - -/* - * Unimplemented - */ -VOID -WINAPI -PrintersGetCommand_RunDLLA(HWND hwnd, HINSTANCE hInstance, LPSTR pszCmdLine, int nCmdShow) -{ - FIXME("PrintersGetCommand_RunDLLA() stub\n"); -} - -/* - * Unimplemented - */ -VOID -WINAPI -PrintersGetCommand_RunDLLW(HWND hwnd, HINSTANCE hInstance, LPWSTR pszCmdLine, int nCmdShow) -{ - FIXME("PrintersGetCommand_RunDLLW() stub\n"); -} - -/* - * Unimplemented - */ -IShellFolderViewCB* -WINAPI -SHGetShellFolderViewCB(HWND hwnd) -{ - FIXME("SHGetShellFolderViewCB() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -INT -WINAPI -SHLookupIconIndexA(LPCSTR lpName, INT iIndex, UINT uFlags) -{ - FIXME("SHLookupIconIndexA() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -INT -WINAPI -SHLookupIconIndexW(LPCWSTR lpName, INT iIndex, UINT uFlags) -{ - FIXME("SHLookupIconIndexW() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -HANDLE -WINAPI -PifMgr_OpenProperties(LPWSTR lpAppPath, LPWSTR lpPifPath, UINT hInfIndex, UINT uUnknown) -{ - FIXME("PifMgr_OpenProperties() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -INT -WINAPI -PifMgr_GetProperties(HANDLE hHandle, LPWSTR lpName, LPVOID lpUnknown, INT iUnknown, UINT uUnknown) -{ - FIXME("PifMgr_GetProperties() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -INT -WINAPI -PifMgr_SetProperties(HANDLE hHandle, LPWSTR lpName, LPVOID lpUnknown, INT iUnknown, UINT uUnknown) -{ - FIXME("PifMgr_SetProperties() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -SHStartNetConnectionDialogA(HWND hwnd, - LPCSTR pszRemoteName, - DWORD dwType) -{ - FIXME("SHStartNetConnectionDialogA() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -SHStartNetConnectionDialogW(HWND hwnd, - LPCWSTR pszRemoteName, - DWORD dwType) -{ - FIXME("SHStartNetConnectionDialogW() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -HANDLE -WINAPI -PifMgr_CloseProperties(HANDLE hHandle, UINT uUnknown) -{ - FIXME("PifMgr_CloseProperties() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -DAD_DragEnterEx2(HWND hwndTarget, - POINT ptStart, - IDataObject *pdtObject) -{ - FIXME("DAD_DragEnterEx2() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -IsSuspendAllowed(VOID) -{ - FIXME("IsSuspendAllowed() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -UINT -WINAPI -SHGetNetResource(LPVOID lpUnknown1, UINT iIndex, LPVOID lpUnknown2, UINT cchMax) -{ - FIXME("SHGetNetResource() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -DragQueryInfo(HDROP hDrop, DRAGINFO *pDragInfo) -{ - FIXME("DragQueryInfo() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -LPVOID -WINAPI -DDECreatePostNotify(LPVOID lpUnknown) -{ - FIXME("DDECreatePostNotify() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHIsBadInterfacePtr(LPVOID pv, UINT ucb) -{ - FIXME("SHIsBadInterfacePtr() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -Activate_RunDLL(DWORD dwProcessId, LPVOID lpUnused1, LPVOID lpUnused2, LPVOID lpUnused3) -{ - FIXME("Activate_RunDLL() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -VOID -WINAPI -AppCompat_RunDLLW(HWND hwnd, HINSTANCE hInstance, LPWSTR pszCmdLine, int nCmdShow) -{ - FIXME("AppCompat_RunDLLW() stub\n"); -} - -/* - * Unimplemented - */ -VOID -WINAPI -Control_RunDLLAsUserW(HWND hwnd, HINSTANCE hInstance, LPWSTR pszCmdLine, int nCmdShow) -{ - FIXME("Control_RunDLLAsUserW() stub\n"); -} - -/* - * Unimplemented - */ -UINT -WINAPI -DragQueryFileAorW(HDROP hDrop, UINT iIndex, LPWSTR lpFile, UINT ucb, BOOL bUnicode, BOOL bShorten) -{ - FIXME("DragQueryFileAorW() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -DWORD -WINAPI -SHNetConnectionDialog(HWND hwndOwner, - LPCWSTR lpstrRemoteName, - DWORD dwType) -{ - FIXME("SHNetConnectionDialog() stub\n"); - return ERROR_INVALID_PARAMETER; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -DAD_SetDragImageFromListView(HWND hwnd, POINT pt) -{ - FIXME("DAD_SetDragImageFromListView() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -void -WINAPI -SHHandleDiskFull(HWND hwndOwner, UINT uDrive) -{ - FIXME("SHHandleDiskFull() stub\n"); -} - -/* - * Unimplemented - */ -BOOL -WINAPI -ILGetPseudoNameW(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2, LPWSTR szStr, INT iUnknown) -{ - /* Unimplemented in WinXP SP3 */ - TRACE("ILGetPseudoNameW() stub\n"); - *szStr = 0; - return FALSE; -} - -/* - * Unimplemented - */ -VOID -WINAPI -SHGlobalDefect(DWORD dwUnknown) -{ - /* Unimplemented in WinXP SP3 */ - TRACE("SHGlobalDefect() stub\n"); -} - -/* - * Unimplemented - */ -LPITEMIDLIST -WINAPI -Printers_GetPidl(LPCITEMIDLIST pidl, LPCWSTR lpName) -{ - FIXME("Printers_GetPidl() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -INT -WINAPI -Int64ToString(LONGLONG llInt64, - LPWSTR lpOut, - UINT uSize, - BOOL bUseFormat, - NUMBERFMT *pNumberFormat, - DWORD dwNumberFlags) -{ - FIXME("Int64ToString() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -INT -WINAPI -LargeIntegerToString(LARGE_INTEGER *pLargeInt, - LPWSTR lpOut, - UINT uSize, - BOOL bUseFormat, - NUMBERFMT *pNumberFormat, - DWORD dwNumberFlags) -{ - FIXME("LargeIntegerToString() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -LONG -WINAPI -Printers_AddPrinterPropPages(LPVOID lpUnknown1, LPVOID lpUnknown2) -{ - FIXME("Printers_AddPrinterPropPages() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -WORD -WINAPI -ExtractIconResInfoA(HANDLE hHandle, - LPSTR lpFile, - WORD wIndex, - LPWORD lpSize, - LPHANDLE lpIcon) -{ - FIXME("ExtractIconResInfoA() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -WORD -WINAPI -ExtractIconResInfoW(HANDLE hHandle, - LPWSTR lpFile, - WORD wIndex, - LPWORD lpSize, - LPHANDLE lpIcon) -{ - FIXME("ExtractIconResInfoW() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -DWORD -WINAPI -ExtractVersionResource16W(LPWSTR lpName, LPHANDLE lpHandle) -{ - FIXME("ExtractVersionResource16W() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -BOOL* -WINAPI -FindExeDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - FIXME("FindExeDlgProc() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -HANDLE -WINAPI -InternalExtractIconListW(HANDLE hHandle, - LPWSTR lpFileName, - LPINT lpCount) -{ - FIXME("InternalExtractIconListW() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -HANDLE -WINAPI -InternalExtractIconListA(HANDLE hHandle, - LPSTR lpFileName, - LPINT lpCount) -{ - FIXME("InternalExtractIconListA() stub\n"); - return NULL; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -FirstUserLogon(LPWSTR lpUnknown1, LPWSTR lpUnknown2) -{ - FIXME("FirstUserLogon() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -SHSetFolderPathA(int csidl, - HANDLE hToken, - DWORD dwFlags, - LPCSTR pszPath) -{ - FIXME("SHSetFolderPathA() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -SHSetFolderPathW(int csidl, - HANDLE hToken, - DWORD dwFlags, - LPCWSTR pszPath) -{ - FIXME("SHSetFolderPathW() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -SHGetUserPicturePathW(LPCWSTR lpPath, int csidl, LPVOID lpUnknown) -{ - FIXME("SHGetUserPicturePathW() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -HRESULT -WINAPI -SHSetUserPicturePathW(LPCWSTR lpPath, int csidl, LPVOID lpUnknown) -{ - FIXME("SHGetUserPicturePathA() stub\n"); - return E_FAIL; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHOpenEffectiveToken(LPVOID Token) -{ - FIXME("SHOpenEffectiveToken() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHTestTokenPrivilegeW(HANDLE hToken, LPDWORD ReturnLength) -{ - FIXME("SHTestTokenPrivilegeW() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHShouldShowWizards(LPVOID lpUnknown) -{ - FIXME("SHShouldShowWizards() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -PathIsSlowW(LPCWSTR pszFile, DWORD dwFileAttr) -{ - FIXME("PathIsSlowW() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -PathIsSlowA(LPCSTR pszFile, DWORD dwFileAttr) -{ - FIXME("PathIsSlowA() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -DWORD -WINAPI -SHGetUserDisplayName(LPWSTR lpName, PULONG puSize) -{ - FIXME("SHGetUserDisplayName() stub\n"); - wcscpy(lpName, L"UserName"); - return ERROR_SUCCESS; -} - -/* - * Unimplemented - */ -DWORD -WINAPI -SHGetProcessDword(DWORD dwUnknown1, DWORD dwUnknown2) -{ - /* Unimplemented in WinXP SP3 */ - TRACE("SHGetProcessDword() stub\n"); - return 0; -} - -/* - * Unimplemented - */ -BOOL -WINAPI -SHTestTokenMembership(HANDLE TokenHandle, PSID SidToCheck) -{ - FIXME("SHTestTokenMembership() stub\n"); - return FALSE; -} - -/* - * Unimplemented - */ -LPVOID -WINAPI -SHGetUserSessionId(HANDLE hHandle) -{ - FIXME("SHGetUserSessionId() stub\n"); - return NULL; -} diff --git a/reactos/dll/win32/shell32/systray.c b/reactos/dll/win32/shell32/systray.c deleted file mode 100644 index 81297a78907..00000000000 --- a/reactos/dll/win32/shell32/systray.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Systray handling - * - * Copyright 1999 Kai Morich - * Copyright 2004 Mike Hearn, for CodeWeavers - * Copyright 2005 Robert Shearman - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define NONAMELESSUNION -#define NONAMELESSSTRUCT - -#include - -#include "windef.h" -#include "winbase.h" -#include "wingdi.h" -#include "winnls.h" -#include "winuser.h" -#include "shellapi.h" - -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(systray); - -static const WCHAR classname[] = /* Shell_TrayWnd */ {'S','h','e','l','l','_','T','r','a','y','W','n','d','\0'}; - -/************************************************************************* - * Shell_NotifyIcon [SHELL32.296] - * Shell_NotifyIconA [SHELL32.297] - */ -BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid) -{ - NOTIFYICONDATAW nidW; - INT cbSize; - - /* Validate the cbSize as Windows XP does */ - if (pnid->cbSize != NOTIFYICONDATAA_V1_SIZE && - pnid->cbSize != NOTIFYICONDATAA_V2_SIZE && - pnid->cbSize != NOTIFYICONDATAA_V3_SIZE && - pnid->cbSize != sizeof(NOTIFYICONDATAA)) - { - WARN("Invalid cbSize (%d) - using only Win95 fields (size=%d)\n", - pnid->cbSize, NOTIFYICONDATAA_V1_SIZE); - cbSize = NOTIFYICONDATAA_V1_SIZE; - } - else - cbSize = pnid->cbSize; - - ZeroMemory(&nidW, sizeof(nidW)); - nidW.cbSize = sizeof(nidW); - nidW.hWnd = pnid->hWnd; - nidW.uID = pnid->uID; - nidW.uFlags = pnid->uFlags; - nidW.uCallbackMessage = pnid->uCallbackMessage; - nidW.hIcon = pnid->hIcon; - - /* szTip */ - if (pnid->uFlags & NIF_TIP) - MultiByteToWideChar(CP_ACP, 0, pnid->szTip, -1, nidW.szTip, sizeof(nidW.szTip)/sizeof(WCHAR)); - - if (cbSize >= NOTIFYICONDATAA_V2_SIZE) - { - nidW.dwState = pnid->dwState; - nidW.dwStateMask = pnid->dwStateMask; - - /* szInfo, szInfoTitle */ - if (pnid->uFlags & NIF_INFO) - { - MultiByteToWideChar(CP_ACP, 0, pnid->szInfo, -1, nidW.szInfo, sizeof(nidW.szInfo)/sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, pnid->szInfoTitle, -1, nidW.szInfoTitle, sizeof(nidW.szInfoTitle)/sizeof(WCHAR)); - } - - nidW.u.uTimeout = pnid->u.uTimeout; - nidW.dwInfoFlags = pnid->dwInfoFlags; - } - - if (cbSize >= NOTIFYICONDATAA_V3_SIZE) - nidW.guidItem = pnid->guidItem; - - if (cbSize >= sizeof(NOTIFYICONDATAA)) - nidW.hBalloonIcon = pnid->hBalloonIcon; - return Shell_NotifyIconW(dwMessage, &nidW); -} - -/************************************************************************* - * Shell_NotifyIconW [SHELL32.298] - */ -BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW nid) -{ - HWND tray; - COPYDATASTRUCT cds; - char *buffer = NULL; - BOOL ret; - - TRACE("dwMessage = %d, nid->cbSize=%d\n", dwMessage, nid->cbSize); - - /* Validate the cbSize so that WM_COPYDATA doesn't crash the application */ - if (nid->cbSize != NOTIFYICONDATAW_V1_SIZE && - nid->cbSize != NOTIFYICONDATAW_V2_SIZE && - nid->cbSize != NOTIFYICONDATAW_V3_SIZE && - nid->cbSize != sizeof(NOTIFYICONDATAW)) - { - NOTIFYICONDATAW newNid; - - WARN("Invalid cbSize (%d) - using only Win95 fields (size=%d)\n", - nid->cbSize, NOTIFYICONDATAW_V1_SIZE); - CopyMemory(&newNid, nid, NOTIFYICONDATAW_V1_SIZE); - newNid.cbSize = NOTIFYICONDATAW_V1_SIZE; - return Shell_NotifyIconW(dwMessage, &newNid); - } - - tray = FindWindowExW(0, NULL, classname, NULL); - if (!tray) return FALSE; - - cds.dwData = dwMessage; - - /* FIXME: if statement only needed because we don't support interprocess - * icon handles */ - if (nid->uFlags & NIF_ICON) - { - ICONINFO iconinfo; - BITMAP bmMask; - BITMAP bmColour; - LONG cbMaskBits; - LONG cbColourBits; - - if (!GetIconInfo(nid->hIcon, &iconinfo)) - goto noicon; - - if (!GetObjectW(iconinfo.hbmMask, sizeof(bmMask), &bmMask) || - !GetObjectW(iconinfo.hbmColor, sizeof(bmColour), &bmColour)) - { - DeleteObject(iconinfo.hbmMask); - DeleteObject(iconinfo.hbmColor); - goto noicon; - } - - cbMaskBits = (bmMask.bmPlanes * bmMask.bmWidth * bmMask.bmHeight * bmMask.bmBitsPixel) / 8; - cbColourBits = (bmColour.bmPlanes * bmColour.bmWidth * bmColour.bmHeight * bmColour.bmBitsPixel) / 8; - cds.cbData = nid->cbSize + 2*sizeof(BITMAP) + cbMaskBits + cbColourBits; - buffer = HeapAlloc(GetProcessHeap(), 0, cds.cbData); - if (!buffer) - { - DeleteObject(iconinfo.hbmMask); - DeleteObject(iconinfo.hbmColor); - return FALSE; - } - cds.lpData = buffer; - - memcpy(buffer, nid, nid->cbSize); - buffer += nid->cbSize; - memcpy(buffer, &bmMask, sizeof(bmMask)); - buffer += sizeof(bmMask); - memcpy(buffer, &bmColour, sizeof(bmColour)); - buffer += sizeof(bmColour); - GetBitmapBits(iconinfo.hbmMask, cbMaskBits, buffer); - buffer += cbMaskBits; - GetBitmapBits(iconinfo.hbmColor, cbColourBits, buffer); - - /* Reset pointer to allocated block so it can be freed later. - * Note that cds.lpData cannot be passed to HeapFree since it - * points to nid when no icon info is found. */ - buffer = cds.lpData; - - DeleteObject(iconinfo.hbmMask); - DeleteObject(iconinfo.hbmColor); - } - else - { -noicon: - cds.cbData = nid->cbSize; - cds.lpData = nid; - } - - ret = SendMessageW(tray, WM_COPYDATA, (WPARAM)nid->hWnd, (LPARAM)&cds); - - /* FIXME: if statement only needed because we don't support interprocess - * icon handles */ - HeapFree(GetProcessHeap(), 0, buffer); - - return ret; -}