mirror of
https://github.com/emtee40/NanaZip
synced 2026-04-25 16:24:56 +02:00
Remove C++/WinRT dependency for NanaZip.Core and NanaZip.Shared projects.
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
<MileProjectType>ConsoleApplication</MileProjectType>
|
||||
<MileProjectManifestFile>NanaZip.Core.Sfx.Console.manifest</MileProjectManifestFile>
|
||||
<MileProjectEnableVCLTLSupport>true</MileProjectEnableVCLTLSupport>
|
||||
<MileProjectEnableCppWinRTSupport>true</MileProjectEnableCppWinRTSupport>
|
||||
<MileProjectUseProjectProperties>true</MileProjectUseProjectProperties>
|
||||
<MileProjectCompanyName>M2-Team</MileProjectCompanyName>
|
||||
<MileProjectFileDescription>NanaZip Self Extracting Executable (Console)</MileProjectFileDescription>
|
||||
@@ -28,7 +27,6 @@
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WINRT_NO_SOURCE_LOCATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<EnableEnhancedInstructionSet Condition="'$(Platform)'=='Win32'">NoExtensions</EnableEnhancedInstructionSet>
|
||||
<AdditionalOptions>%(AdditionalOptions) /Wv:18</AdditionalOptions>
|
||||
</ClCompile>
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
<MileProjectType>WindowsApplication</MileProjectType>
|
||||
<MileProjectManifestFile>NanaZip.Core.Sfx.Setup.manifest</MileProjectManifestFile>
|
||||
<MileProjectEnableVCLTLSupport>true</MileProjectEnableVCLTLSupport>
|
||||
<MileProjectEnableCppWinRTSupport>true</MileProjectEnableCppWinRTSupport>
|
||||
<MileProjectUseProjectProperties>true</MileProjectUseProjectProperties>
|
||||
<MileProjectCompanyName>M2-Team</MileProjectCompanyName>
|
||||
<MileProjectFileDescription>NanaZip Self Extracting Executable (Setup)</MileProjectFileDescription>
|
||||
@@ -31,7 +30,7 @@
|
||||
<ClCompile>
|
||||
<EnableEnhancedInstructionSet Condition="'$(Platform)'=='Win32'">NoExtensions</EnableEnhancedInstructionSet>
|
||||
<AdditionalOptions>%(AdditionalOptions) /Wv:18</AdditionalOptions>
|
||||
<PreprocessorDefinitions>Z7_NO_REGISTRY;Z7_NO_CRYPTO;WINRT_NO_SOURCE_LOCATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>Z7_NO_REGISTRY;Z7_NO_CRYPTO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<LargeAddressAware>true</LargeAddressAware>
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
<MileProjectType>WindowsApplication</MileProjectType>
|
||||
<MileProjectManifestFile>NanaZip.Core.Sfx.Windows.manifest</MileProjectManifestFile>
|
||||
<MileProjectEnableVCLTLSupport>true</MileProjectEnableVCLTLSupport>
|
||||
<MileProjectEnableCppWinRTSupport>true</MileProjectEnableCppWinRTSupport>
|
||||
<MileProjectUseProjectProperties>true</MileProjectUseProjectProperties>
|
||||
<MileProjectCompanyName>M2-Team</MileProjectCompanyName>
|
||||
<MileProjectFileDescription>NanaZip Self Extracting Executable (Windows)</MileProjectFileDescription>
|
||||
@@ -31,7 +30,7 @@
|
||||
<ClCompile>
|
||||
<EnableEnhancedInstructionSet Condition="'$(Platform)'=='Win32'">NoExtensions</EnableEnhancedInstructionSet>
|
||||
<AdditionalOptions>%(AdditionalOptions) /Wv:18</AdditionalOptions>
|
||||
<PreprocessorDefinitions>Z7_NO_REGISTRY;Z7_LANG;WINRT_NO_SOURCE_LOCATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>Z7_NO_REGISTRY;Z7_LANG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<LargeAddressAware>true</LargeAddressAware>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<EnableEnhancedInstructionSet Condition="'$(Platform)'=='Win32'">NoExtensions</EnableEnhancedInstructionSet>
|
||||
<PreprocessorDefinitions>Z7_EXTERNAL_CODECS;Z7_LARGE_PAGES;NSIS_SCRIPT;ZSTD_LEGACY_SUPPORT;ZSTD_MULTITHREAD;NO_XXHASH;FL2_7ZIP_BUILD;WINRT_NO_SOURCE_LOCATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>Z7_EXTERNAL_CODECS;Z7_LARGE_PAGES;NSIS_SCRIPT;ZSTD_LEGACY_SUPPORT;ZSTD_MULTITHREAD;NO_XXHASH;FL2_7ZIP_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Platform)'=='x64'">Z7_LZMA_DEC_OPT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4100;4113;4127;4146;4189;4200;4244;4267;4334;4702;</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
|
||||
@@ -5,78 +5,79 @@
|
||||
*
|
||||
* LICENSE: The MIT License
|
||||
*
|
||||
* DEVELOPER: reflectronic (john-tur@outlook.com)
|
||||
* MouriNaruto (KurikoMouri@outlook.jp)
|
||||
* MAINTAINER: MouriNaruto (Kenji.Mouri@outlook.com)
|
||||
* reflectronic (john-tur@outlook.com)
|
||||
*/
|
||||
|
||||
#include <Windows.h>
|
||||
#include <ShlObj_core.h>
|
||||
#include <winrt/base.h>
|
||||
|
||||
EXTERN_C PIDLIST_ABSOLUTE WINAPI ModernSHBrowseForFolderW(LPBROWSEINFOW uType)
|
||||
EXTERN_C PIDLIST_ABSOLUTE WINAPI ModernSHBrowseForFolderW(
|
||||
_In_ LPBROWSEINFOW lpbi)
|
||||
{
|
||||
winrt::com_ptr<IFileDialog> fileDialog = winrt::try_create_instance<IFileDialog>(CLSID_FileOpenDialog);
|
||||
LPITEMIDLIST IDList = nullptr;
|
||||
|
||||
if (!fileDialog)
|
||||
IFileDialog* FileDialog = nullptr;
|
||||
if (SUCCEEDED(::CoCreateInstance(
|
||||
CLSID_FileOpenDialog,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(&FileDialog))))
|
||||
{
|
||||
return nullptr;
|
||||
DWORD Flags = 0;
|
||||
if (SUCCEEDED(FileDialog->GetOptions(
|
||||
&Flags)))
|
||||
{
|
||||
if (SUCCEEDED(FileDialog->SetOptions(
|
||||
Flags | FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM)))
|
||||
{
|
||||
if (SUCCEEDED(FileDialog->SetTitle(
|
||||
lpbi->lpszTitle)))
|
||||
{
|
||||
// 7-Zip does not use the pidlRoot parameter to configure
|
||||
// the default folder. Instead, it sets it by configuring
|
||||
// the message loop for the shell dialog, passing the path
|
||||
// of the default folder through the lParam, and navigating
|
||||
// to that folder inside the message loop.
|
||||
//
|
||||
// Since we cannot augment the IFileDialog's message loop,
|
||||
// we will reach into the lParam given to us to find the
|
||||
// initial path and hope that 7-Zip does not change this
|
||||
// behavior.
|
||||
|
||||
IShellItem* DefaultFolder = nullptr;
|
||||
if (SUCCEEDED(::SHCreateItemFromParsingName(
|
||||
reinterpret_cast<PCWSTR>(lpbi->lParam),
|
||||
nullptr,
|
||||
IID_PPV_ARGS(&DefaultFolder))))
|
||||
{
|
||||
if (SUCCEEDED(FileDialog->SetDefaultFolder(
|
||||
DefaultFolder)))
|
||||
{
|
||||
if (SUCCEEDED(FileDialog->Show(
|
||||
lpbi->hwndOwner)))
|
||||
{
|
||||
IShellItem* Result = nullptr;
|
||||
if (SUCCEEDED(FileDialog->GetResult(
|
||||
&Result)))
|
||||
{
|
||||
::SHGetIDListFromObject(Result, &IDList);
|
||||
|
||||
Result->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DefaultFolder->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileDialog->Release();
|
||||
}
|
||||
|
||||
DWORD flags;
|
||||
if (FAILED(fileDialog->GetOptions(&flags)))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (FAILED(fileDialog->SetOptions(flags | FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM)))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (FAILED(fileDialog->SetTitle(uType->lpszTitle)))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// 7-Zip does not use the pidlRoot parameter to configure the default folder.
|
||||
// Instead, it sets it by configuring the message loop for the shell dialog,
|
||||
// passing the path of the default folder through the lParam, and navigating
|
||||
// to that folder inside the message loop.
|
||||
//
|
||||
// Since we cannot augment the IFileDialog's message loop, we will reach into
|
||||
// the lParam given to us to find the initial path and hope that 7-Zip does
|
||||
// not change this behavior.
|
||||
|
||||
winrt::com_ptr<IShellItem> defaultFolder;
|
||||
if (FAILED(SHCreateItemFromParsingName(reinterpret_cast<PCWSTR>(uType->lParam), nullptr, IID_IShellItem, defaultFolder.put_void())))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (FAILED(fileDialog->SetDefaultFolder(defaultFolder.get())))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HRESULT hr = fileDialog->Show(uType->hwndOwner);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
winrt::com_ptr<IShellItem> result;
|
||||
if (FAILED(fileDialog->GetResult(result.put())))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LPITEMIDLIST pidl;
|
||||
if (FAILED(SHGetIDListFromObject(result.get(), &pidl)))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return pidl;
|
||||
return IDList;
|
||||
}
|
||||
|
||||
#if defined(_M_IX86)
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
<RootNamespace>NanaZip.Shared.ModernExperienceShims</RootNamespace>
|
||||
<MileProjectType>StaticLibrary</MileProjectType>
|
||||
<MileProjectEnableVCLTLSupport>true</MileProjectEnableVCLTLSupport>
|
||||
<MileProjectEnableCppWinRTSupport>true</MileProjectEnableCppWinRTSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="..\Mile.Project.Windows\Mile.Project.Platform.x86.props" />
|
||||
<Import Project="..\Mile.Project.Windows\Mile.Project.Platform.x64.props" />
|
||||
@@ -14,7 +13,6 @@
|
||||
<Import Project="..\Mile.Project.Windows\Mile.Project.Cpp.props" />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WINRT_NO_SOURCE_LOCATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<EnableEnhancedInstructionSet Condition="'$(Platform)'=='Win32'">NoExtensions</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
Reference in New Issue
Block a user