Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed 3rdParty/Regsvr64.exe
Binary file not shown.
Binary file removed 3rdParty/Regsvr64_64.exe
Binary file not shown.
15 changes: 13 additions & 2 deletions PathCopyCopy.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.202
# Visual Studio Version 17
VisualStudioVersion = 17.10.35027.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PathCopyCopy", "PathCopyCopy\PathCopyCopy.vcxproj", "{AA106D7B-966E-4A98-8EAD-0AE2AE0038D2}"
ProjectSection(ProjectDependencies) = postProject
Expand Down Expand Up @@ -32,6 +32,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PathCopyCopyLocalization_en
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PathCopyCopyLocalization_fr", "PathCopyCopy\localization\PathCopyCopyLocalization_fr\PathCopyCopyLocalization_fr.vcxproj", "{69A53834-5AF9-4B92-B78B-15567FE6DE30}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{B42127A5-4EEF-4EFD-93EB-F3387D71C17F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{FCDBD36A-5A37-41BC-982C-67E8DE995A26}"
ProjectSection(SolutionItems) = preProject
.github\workflows\main.yml = .github\workflows\main.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Expand Down Expand Up @@ -100,6 +107,10 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B42127A5-4EEF-4EFD-93EB-F3387D71C17F} = {0B4523A6-521E-43F6-BC87-44919C8CA492}
{FCDBD36A-5A37-41BC-982C-67E8DE995A26} = {B42127A5-4EEF-4EFD-93EB-F3387D71C17F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {95CB2D2A-C347-4A94-9C44-BDC4A9A76CB1}
EndGlobalSection
Expand Down
40 changes: 26 additions & 14 deletions PathCopyCopy/PathCopyCopy.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@
<UseOfMfc>false</UseOfMfc>
<UseOfAtl>Static</UseOfAtl>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<UseOfAtl>Static</UseOfAtl>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<UseOfAtl>Static</UseOfAtl>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<UseOfAtl>Static</UseOfAtl>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down Expand Up @@ -137,7 +137,7 @@
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<EnablePREfast>true</EnablePREfast>
<DisableSpecificWarnings>26485;26486;26487;26489;28251</DisableSpecificWarnings>
<TreatWarningAsError>true</TreatWarningAsError>
Expand All @@ -148,7 +148,7 @@
<AdditionalIncludeDirectories>$(IntDir);.\prihdr;..\prihdr;.\pubhdr;..\pubhdr;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
<RegisterOutput>true</RegisterOutput>
<RegisterOutput>false</RegisterOutput>
<AdditionalDependencies>mpr.lib;netapi32.lib;gdiplus.lib;ws2_32.lib;comsuppw.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>.\src\PathCopyCopy.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand All @@ -159,6 +159,12 @@
<Manifest>
<AdditionalManifestFiles>$(ProjectDir)rsrc\PathCopyCopy.dll.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
</Manifest>
<PostBuildEvent>
<Command>regsvr32 /s /n /i:user "$(TargetPath)"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Registering output...</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
Expand All @@ -184,7 +190,7 @@
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<EnablePREfast>true</EnablePREfast>
<DisableSpecificWarnings>26485;26486;26487;26489;28251</DisableSpecificWarnings>
<TreatWarningAsError>true</TreatWarningAsError>
Expand All @@ -203,8 +209,8 @@
<TargetMachine>MachineX64</TargetMachine>
</Link>
<PostBuildEvent>
<Message>Registering output (x64)...</Message>
<Command>"$(SolutionDir)3rdParty\Regsvr64.exe" /s "$(TargetPath)"</Command>
<Message>Registering output...</Message>
<Command>regsvr32 /s /n /i:user "$(TargetPath)"</Command>
</PostBuildEvent>
<Manifest>
<AdditionalManifestFiles>$(ProjectDir)rsrc\PathCopyCopy.dll.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
Expand Down Expand Up @@ -232,7 +238,7 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<EnablePREfast>true</EnablePREfast>
<DisableSpecificWarnings>26485;26486;26487;26489;28251</DisableSpecificWarnings>
<TreatWarningAsError>true</TreatWarningAsError>
Expand All @@ -243,7 +249,7 @@
<AdditionalIncludeDirectories>$(IntDir);.\prihdr;..\prihdr;.\pubhdr;..\pubhdr;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
<RegisterOutput>true</RegisterOutput>
<RegisterOutput>false</RegisterOutput>
<AdditionalDependencies>mpr.lib;netapi32.lib;gdiplus.lib;ws2_32.lib;comsuppw.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>.\src\PathCopyCopy.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand All @@ -255,6 +261,12 @@
<Manifest>
<AdditionalManifestFiles>$(ProjectDir)rsrc\PathCopyCopy.dll.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
</Manifest>
<PostBuildEvent>
<Command>regsvr32 /s /n /i:user "$(TargetPath)"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Registering output...</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
Expand All @@ -277,7 +289,7 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<EnablePREfast>true</EnablePREfast>
<DisableSpecificWarnings>26485;26486;26487;26489;28251</DisableSpecificWarnings>
<TreatWarningAsError>true</TreatWarningAsError>
Expand All @@ -298,8 +310,8 @@
<TargetMachine>MachineX64</TargetMachine>
</Link>
<PostBuildEvent>
<Message>Registering output (x64)...</Message>
<Command>"$(SolutionDir)3rdParty\Regsvr64.exe" /s "$(TargetPath)"</Command>
<Message>Registering output...</Message>
<Command>regsvr32 /s /n /i:user "$(TargetPath)"</Command>
</PostBuildEvent>
<Manifest>
<AdditionalManifestFiles>$(ProjectDir)rsrc\PathCopyCopy.dll.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
16 changes: 8 additions & 8 deletions PathCopyCopy/prihdr/PluginPipelineElements.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ namespace PCC
{
public:
CopyNPathPartsPipelineElement(size_t p_NumParts,
bool p_First);
bool p_First) noexcept;
CopyNPathPartsPipelineElement(const CopyNPathPartsPipelineElement&) = delete;
CopyNPathPartsPipelineElement&
operator=(const CopyNPathPartsPipelineElement&) = delete;
Expand Down Expand Up @@ -395,9 +395,9 @@ namespace PCC
class PushToStackPipelineElement : public PipelineElement
{
public:
PushToStackPipelineElement();
PushToStackPipelineElement() noexcept;
PushToStackPipelineElement(size_t p_Begin,
size_t p_End);
size_t p_End) noexcept;
PushToStackPipelineElement(const std::wstring& p_Regex,
bool p_IgnoreCase,
size_t p_Group);
Expand Down Expand Up @@ -437,9 +437,9 @@ namespace PCC
class PopFromStackPipelineElement : public PipelineElement
{
public:
explicit PopFromStackPipelineElement(PopFromStackLocation p_Location);
explicit PopFromStackPipelineElement(PopFromStackLocation p_Location) noexcept;
PopFromStackPipelineElement(size_t m_Begin,
size_t m_End);
size_t m_End) noexcept;
PopFromStackPipelineElement(const std::wstring& p_Regex,
bool p_IgnoreCase);
PopFromStackPipelineElement(const PopFromStackPipelineElement&) = delete;
Expand Down Expand Up @@ -537,7 +537,7 @@ namespace PCC
RecursiveCopyPipelineElement&
operator=(const RecursiveCopyPipelineElement&) = delete;

void ModifyOptions(PipelineOptions& p_rOptions) const override;
void ModifyOptions(PipelineOptions& p_rOptions) const noexcept override;
};

//
Expand Down Expand Up @@ -618,12 +618,12 @@ namespace PCC
{
public:
DisplayForSelectionPipelineElement(bool p_ShowForFiles,
bool p_ShowForFolders);
bool p_ShowForFolders) noexcept;
DisplayForSelectionPipelineElement(const DisplayForSelectionPipelineElement&) = delete;
DisplayForSelectionPipelineElement&
operator=(const DisplayForSelectionPipelineElement&) = delete;

void ModifyOptions(PipelineOptions& p_rOptions) const override;
void ModifyOptions(PipelineOptions& p_rOptions) const noexcept override;

private:
bool m_ShowForFiles; // Whether the plugin should be displayed when files are selected.
Expand Down
4 changes: 4 additions & 0 deletions PathCopyCopy/prihdr/dllmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public :
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_PATHCOPYCOPY, "{44F7E5A2-1286-45F5-9A7A-A95A41B72918}")

CPathCopyCopyModule();
CPathCopyCopyModule(const CPathCopyCopyModule&) = delete;
CPathCopyCopyModule(CPathCopyCopyModule&&) = delete;
CPathCopyCopyModule& operator=(const CPathCopyCopyModule&) = delete;
CPathCopyCopyModule& operator=(CPathCopyCopyModule&&) = delete;
~CPathCopyCopyModule();

HRESULT DllRegisterServer(BOOL p_RegisterTypeLib = TRUE) throw();
Expand Down
38 changes: 18 additions & 20 deletions PathCopyCopy/src/PathCopyCopyContextMenuExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@

namespace {

const wchar_t* const DEFAULT_PATHS_SEPARATOR = L"\r\n"; // Default separator used between paths when copying multiple file names.
const wchar_t* const DEFAULT_PATHS_SEPARATOR = L"\r\n"; // Default separator used between paths when copying multiple file names.

const int32_t DEFAULT_ICON_SIZE = 16; // Default width & height for loaded icons.
constexpr int32_t DEFAULT_ICON_SIZE = 16; // Default width & height for loaded icons.

}

Expand Down Expand Up @@ -243,7 +243,7 @@ STDMETHODIMP CPathCopyCopyContextMenuExt::Initialize(
// Get each file in turn.
for (UINT i = 0; i < fileCount; ++i) {
const auto bufferSize = ::DragQueryFileW(static_cast<HDROP>(stgMedium.Get().hGlobal), i, nullptr, 0);
std::wstring buffer(bufferSize + 1, L'\0');
std::wstring buffer(static_cast<std::wstring::size_type>(bufferSize) + 1, L'\0');
::DragQueryFileW(static_cast<HDROP>(stgMedium.Get().hGlobal), i, &*buffer.begin(), gsl::narrow<UINT>(buffer.size()));
m_vFiles.emplace_back(buffer.c_str());
}
Expand Down Expand Up @@ -411,7 +411,7 @@ STDMETHODIMP CPathCopyCopyContextMenuExt::QueryContextMenu(
try {
// Fetch list of plugins to display in the submenu.
PCC::PluginSPV vspPlugins;
const PCC::PluginSPV* pvspPlugins = nullptr;
gsl::not_null<const PCC::PluginSPV*> pvspPlugins{&m_vspPluginsInDefaultOrder};
vPluginIds.clear();
rSettings.GetSubmenuPluginDisplayOrder(vPluginIds);
if (!vPluginIds.empty()) {
Expand All @@ -420,7 +420,6 @@ STDMETHODIMP CPathCopyCopyContextMenuExt::QueryContextMenu(
pvspPlugins = &vspPlugins;
} else {
// No plugin specified, use all plugins in default order.
pvspPlugins = &m_vspPluginsInDefaultOrder;
}

// Iterate plugins and try to add them to the submenu.
Expand Down Expand Up @@ -830,13 +829,13 @@ HRESULT CPathCopyCopyContextMenuExt::AddPluginToMenu(const PCC::PluginSP& p_spPl

// In some language, this will leave the first letter in lowercase.
// Convert it to uppercase in that case.
if (!description.empty() && ::iswlower(description[0])) {
description[0] = ::towupper(description[0]);
if (!description.empty() && ::iswlower(description.front())) {
description.front() = ::towupper(description.front());
}

// ...or maybe the first letter is the shortcut character...
if (description.size() >= 2 && description[0] == L'&' && ::iswlower(description[1])) {
description[1] = ::towupper(description[1]);
if (description.size() >= 2 && description.at(0) == L'&' && ::iswlower(description.at(1))) {
description.at(1) = ::towupper(description.at(1));
}
}
}
Expand Down Expand Up @@ -1030,24 +1029,23 @@ HBITMAP CPathCopyCopyContextMenuExt::GetIconForIconFile(const std::wstring& p_Ic
StGdiplusStartup gdiPlusStartup;
if (gdiPlusStartup.Started()) {
// Load original bitmap using GDI+.
std::shared_ptr<Gdiplus::Bitmap> spFileBitmap(Gdiplus::Bitmap::FromStream(cpIconFileStream, FALSE));
std::unique_ptr<Gdiplus::Bitmap> upFileBitmap{Gdiplus::Bitmap::FromStream(cpIconFileStream, FALSE)};

// If necessary, rescale bitmap to fit.
auto spTempBitmap = std::make_shared<Gdiplus::Bitmap>(DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
Gdiplus::Bitmap bitmap{DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE};
{
Gdiplus::Graphics graphics(spTempBitmap.get());
graphics.ScaleTransform(static_cast<Gdiplus::REAL>(DEFAULT_ICON_SIZE) / static_cast<Gdiplus::REAL>(spFileBitmap->GetWidth()),
static_cast<Gdiplus::REAL>(DEFAULT_ICON_SIZE) / static_cast<Gdiplus::REAL>(spFileBitmap->GetHeight()));
graphics.DrawImage(spFileBitmap.get(), 0, 0);
Gdiplus::Graphics graphics{&bitmap};
graphics.ScaleTransform(static_cast<Gdiplus::REAL>(DEFAULT_ICON_SIZE) / static_cast<Gdiplus::REAL>(upFileBitmap->GetWidth()),
static_cast<Gdiplus::REAL>(DEFAULT_ICON_SIZE) / static_cast<Gdiplus::REAL>(upFileBitmap->GetHeight()));
graphics.DrawImage(upFileBitmap.get(), 0, 0);
}
spFileBitmap = spTempBitmap;

// Extract HBITMAP using GDI+.
HBITMAP hFileBitmap = nullptr;
if (spFileBitmap->GetHBITMAP(Gdiplus::Color(), &hFileBitmap) == Gdiplus::Ok) {
HBITMAP hBitmap = nullptr;
if (bitmap.GetHBITMAP(Gdiplus::Color(), &hBitmap) == Gdiplus::Ok) {
// We have HBITMAP, save it in the map.
#pragma warning(suppress: 26414) // spImage IS copied in emplace, but the compiler can't see it
const auto spImage = std::make_shared<StImage>(hFileBitmap, IMAGE_BITMAP, false);
const auto spImage = std::make_shared<StImage>(hBitmap, IMAGE_BITMAP, false);
m_mspIcons.emplace(lowerIconFile, spImage);
if (spImage->GetLoadResult() == ERROR_SUCCESS) {
hIconBitmap = spImage->GetBitmap();
Expand Down Expand Up @@ -1178,7 +1176,7 @@ PCC::FilesV CPathCopyCopyContextMenuExt::GetFilesToActOn(const bool p_Recursivel
PCC::FilesV vFilesToScan;
vFilesToScan.swap(vNewFiles);
for (const auto& fileToScan : vFilesToScan) {
auto attributes = ::GetFileAttributesW(fileToScan.c_str());
const auto attributes = ::GetFileAttributesW(fileToScan.c_str());
if (attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
WIN32_FIND_DATAW findData;
HANDLE hFind = ::FindFirstFileW((fileToScan + L"\\*").c_str(), &findData);
Expand Down
Loading
Loading