From be39f6d31f7c7fd49b96359de4d470ad2b05011a Mon Sep 17 00:00:00 2001 From: Dan Moulding Date: Wed, 20 Mar 2013 23:27:23 -0400 Subject: [PATCH 1/2] Ensure terminating null is included when setting values via RegSetValueEx Although values set using RegSetValueEx without inclusion of the terminating null in the "cbData" parameter seem to still get null terminated by the system (based upon inspection of the binary data in Registry Editor), the MSDN page for RegSetValueEx is quite clear that the terminating null should be included in "cbData". Indeed, it is already included in one place in EnvVar.cpp. This change ensures that all calls to RegSetValueEx include the terminating null in "cbData". h/t Debra Do --- EnvVar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EnvVar.cpp b/EnvVar.cpp index b4bdcd8..4e98f9f 100755 --- a/EnvVar.cpp +++ b/EnvVar.cpp @@ -186,7 +186,7 @@ void EnvVar::paste (std::string const &text) 0, REG_EXPAND_SZ, reinterpret_cast(value_.c_str()), - value_.length()); + value_.length() + 1); RegCloseKey(key); // Notify everyone of the change. @@ -225,7 +225,7 @@ void EnvVar::set (std::string const &text) 0, REG_EXPAND_SZ, reinterpret_cast(value_.c_str()), - value_.length()); + value_.length() + 1); RegCloseKey(key); // Notify everyone of the change. From 94270844bad783c8482c65488ce3a6f49271d7c7 Mon Sep 17 00:00:00 2001 From: AraHaan Date: Mon, 8 May 2017 02:18:22 -0500 Subject: [PATCH 2/2] Hmm --- .gitignore | 3 + VS2008/editenv.sln | 29 +++ editenv.vcproj => VS2008/editenv.vcproj | 14 +- {envtest => VS2008/envtest}/envtest.vcproj | 6 +- editenv.hpp | 14 +- editenv.sln | 74 ++++--- editenv.vcxproj | 235 +++++++++++++++++++++ editenv.vcxproj.filters | 44 ++++ editenvTypes.hpp | 14 +- envtest/envtest.vcxproj | 226 ++++++++++++++++++++ envtest/envtest.vcxproj.filters | 22 ++ 11 files changed, 632 insertions(+), 49 deletions(-) create mode 100755 VS2008/editenv.sln rename editenv.vcproj => VS2008/editenv.vcproj (89%) rename {envtest => VS2008/envtest}/envtest.vcproj (91%) mode change 100755 => 100644 editenv.sln create mode 100644 editenv.vcxproj create mode 100644 editenv.vcxproj.filters create mode 100644 envtest/envtest.vcxproj create mode 100644 envtest/envtest.vcxproj.filters diff --git a/.gitignore b/.gitignore index fbbf8f7..a645c5a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ Debug Release +ReleaseStatic *.aps *.ncb *.suo +*.sdf *.vcproj.*.*.user +*.vcxproj.user diff --git a/VS2008/editenv.sln b/VS2008/editenv.sln new file mode 100755 index 0000000..d9c1b36 --- /dev/null +++ b/VS2008/editenv.sln @@ -0,0 +1,29 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "editenv", "editenv.vcproj", "{59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "envtest", "envtest\envtest.vcproj", "{0A47F2D0-47F9-4D42-AAB6-692A8C75C010}" + ProjectSection(ProjectDependencies) = postProject + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1} = {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Debug|Win32.ActiveCfg = Debug|Win32 + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Debug|Win32.Build.0 = Debug|Win32 + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Release|Win32.ActiveCfg = Release|Win32 + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Release|Win32.Build.0 = Release|Win32 + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Debug|Win32.ActiveCfg = Debug|Win32 + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Debug|Win32.Build.0 = Debug|Win32 + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Release|Win32.ActiveCfg = Release|Win32 + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/editenv.vcproj b/VS2008/editenv.vcproj similarity index 89% rename from editenv.vcproj rename to VS2008/editenv.vcproj index a858f85..5929524 100755 --- a/editenv.vcproj +++ b/VS2008/editenv.vcproj @@ -166,11 +166,11 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > @@ -180,19 +180,19 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > @@ -202,7 +202,7 @@ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" > diff --git a/envtest/envtest.vcproj b/VS2008/envtest/envtest.vcproj similarity index 91% rename from envtest/envtest.vcproj rename to VS2008/envtest/envtest.vcproj index 0de2e07..866d3e3 100755 --- a/envtest/envtest.vcproj +++ b/VS2008/envtest/envtest.vcproj @@ -40,7 +40,7 @@ diff --git a/editenv.hpp b/editenv.hpp index 4c32f54..1b14bcd 100755 --- a/editenv.hpp +++ b/editenv.hpp @@ -24,11 +24,15 @@ #ifndef EDITENV_EDITENV_HPP #define EDITENV_EDITENV_HPP -#ifdef EDITENV_BUILD -#define EDITENV_API __declspec(dllexport) -#else -#define EDITENV_API __declspec(dllimport) -#endif // EDITENV_BUILD +#ifdef EDITENV_STATIC +#define EDITENV_API /* For static linkage to work. */ +#else +#ifdef EDITENV_BUILD +#define EDITENV_API __declspec(dllexport) +#else +#define EDITENV_API __declspec(dllimport) +#endif // EDITENV_BUILD +#endif // EDITENV_STATIC #include "editenvTypes.hpp" #include "EnvVar.hpp" diff --git a/editenv.sln b/editenv.sln old mode 100755 new mode 100644 index d9c1b36..bd2bd3b --- a/editenv.sln +++ b/editenv.sln @@ -1,29 +1,45 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "editenv", "editenv.vcproj", "{59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "envtest", "envtest\envtest.vcproj", "{0A47F2D0-47F9-4D42-AAB6-692A8C75C010}" - ProjectSection(ProjectDependencies) = postProject - {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1} = {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Debug|Win32.ActiveCfg = Debug|Win32 - {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Debug|Win32.Build.0 = Debug|Win32 - {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Release|Win32.ActiveCfg = Release|Win32 - {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Release|Win32.Build.0 = Release|Win32 - {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Debug|Win32.ActiveCfg = Debug|Win32 - {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Debug|Win32.Build.0 = Debug|Win32 - {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Release|Win32.ActiveCfg = Release|Win32 - {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "editenv", "editenv.vcxproj", "{59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "envtest", "envtest\envtest.vcxproj", "{0A47F2D0-47F9-4D42-AAB6-692A8C75C010}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + ReleaseStatic|Win32 = ReleaseStatic|Win32 + ReleaseStatic|x64 = ReleaseStatic|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Debug|Win32.ActiveCfg = Debug|Win32 + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Debug|Win32.Build.0 = Debug|Win32 + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Debug|x64.ActiveCfg = Debug|x64 + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Debug|x64.Build.0 = Debug|x64 + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Release|Win32.ActiveCfg = Release|Win32 + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Release|Win32.Build.0 = Release|Win32 + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Release|x64.ActiveCfg = Release|x64 + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.Release|x64.Build.0 = Release|x64 + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.ReleaseStatic|Win32.ActiveCfg = ReleaseStatic|Win32 + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.ReleaseStatic|Win32.Build.0 = ReleaseStatic|Win32 + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.ReleaseStatic|x64.ActiveCfg = ReleaseStatic|x64 + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1}.ReleaseStatic|x64.Build.0 = ReleaseStatic|x64 + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Debug|Win32.ActiveCfg = Debug|Win32 + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Debug|Win32.Build.0 = Debug|Win32 + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Debug|x64.ActiveCfg = Debug|x64 + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Debug|x64.Build.0 = Debug|x64 + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Release|Win32.ActiveCfg = Release|Win32 + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Release|Win32.Build.0 = Release|Win32 + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Release|x64.ActiveCfg = Release|x64 + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.Release|x64.Build.0 = Release|x64 + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.ReleaseStatic|Win32.ActiveCfg = ReleaseStatic|Win32 + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.ReleaseStatic|x64.ActiveCfg = ReleaseStatic|x64 + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010}.ReleaseStatic|x64.Build.0 = ReleaseStatic|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/editenv.vcxproj b/editenv.vcxproj new file mode 100644 index 0000000..2dbc0fb --- /dev/null +++ b/editenv.vcxproj @@ -0,0 +1,235 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + ReleaseStatic + Win32 + + + ReleaseStatic + x64 + + + Release + Win32 + + + Release + x64 + + + + {59489F1B-1D27-43DB-9EB2-3BCB6F3D67F1} + editenv + + + + DynamicLibrary + MultiByte + true + + + StaticLibrary + MultiByte + true + + + DynamicLibrary + MultiByte + true + + + StaticLibrary + MultiByte + true + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Configuration)\ + $(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + + + + Disabled + EDITENV_BUILD;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Level3 + EditAndContinue + + + true + true + MachineX86 + Windows + + + + + Disabled + EDITENV_BUILD;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Level3 + ProgramDatabase + + + true + true + Windows + + + + + MaxSpeed + true + EDITENV_BUILD;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + ProgramDatabase + + + true + true + true + true + MachineX86 + Windows + + + + + MaxSpeed + true + EDITENV_STATIC;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + ProgramDatabase + NoListing + + + true + true + true + true + MachineX86 + Windows + + + true + MachineX86 + + + + + MaxSpeed + true + EDITENV_BUILD;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + ProgramDatabase + + + true + true + true + true + Windows + + + + + MaxSpeed + true + EDITENV_STATIC;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + ProgramDatabase + NoListing + + + true + true + true + true + MachineX64 + Windows + + + true + MachineX64 + + + + + + + + + + + + + + + true + true + + + + + + \ No newline at end of file diff --git a/editenv.vcxproj.filters b/editenv.vcxproj.filters new file mode 100644 index 0000000..d126f98 --- /dev/null +++ b/editenv.vcxproj.filters @@ -0,0 +1,44 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/editenvTypes.hpp b/editenvTypes.hpp index 4aa74e9..03cb893 100755 --- a/editenvTypes.hpp +++ b/editenvTypes.hpp @@ -24,11 +24,15 @@ #ifndef EDITENV_EDITENV_TYPES_HPP #define EDITENV_EDITENV_TYPES_HPP -#ifdef EDITENV_BUILD -#define EDITENV_API __declspec(dllexport) -#else -#define EDITENV_API __declspec(dllimport) -#endif // EDITENV_BUILD +#ifdef EDITENV_STATIC +#define EDITENV_API +#else +#ifdef EDITENV_BUILD +#define EDITENV_API __declspec(dllexport) +#else +#define EDITENV_API __declspec(dllimport) +#endif // EDITENV_BUILD +#endif // EDITENV_STATIC namespace editenv { // Possible environment variable scopes: diff --git a/envtest/envtest.vcxproj b/envtest/envtest.vcxproj new file mode 100644 index 0000000..81c7faf --- /dev/null +++ b/envtest/envtest.vcxproj @@ -0,0 +1,226 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + ReleaseStatic + Win32 + + + ReleaseStatic + x64 + + + Release + Win32 + + + Release + x64 + + + + {0A47F2D0-47F9-4D42-AAB6-692A8C75C010} + envtest + + + + Application + MultiByte + true + + + Application + MultiByte + true + + + Application + MultiByte + true + + + Application + MultiByte + true + + + Application + MultiByte + + + Application + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + $(Configuration)\ + $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + $(Configuration)\ + $(Configuration)\ + $(Configuration)\ + + + + Disabled + ..\;%(AdditionalIncludeDirectories) + true + EnableFastChecks + MultiThreadedDebugDLL + Level3 + EditAndContinue + + + %(AdditionalLibraryDirectories) + true + MachineX86 + false + true + + + + + Disabled + ..\;%(AdditionalIncludeDirectories) + EnableFastChecks + MultiThreadedDebugDLL + Level3 + ProgramDatabase + + + %(AdditionalLibraryDirectories) + true + Console + false + true + + + + + MaxSpeed + true + ..\;%(AdditionalIncludeDirectories) + MultiThreadedDLL + true + Level3 + ProgramDatabase + + + %(AdditionalLibraryDirectories) + true + true + true + MachineX86 + false + true + + + + + MaxSpeed + true + ..\;%(AdditionalIncludeDirectories) + MultiThreadedDLL + true + Level3 + ProgramDatabase + + + %(AdditionalLibraryDirectories) + true + true + true + MachineX86 + false + true + + + + + MaxSpeed + true + ..\;%(AdditionalIncludeDirectories) + MultiThreadedDLL + true + Level3 + ProgramDatabase + + + %(AdditionalLibraryDirectories) + true + true + true + Console + false + true + + + + + MaxSpeed + true + ..\;%(AdditionalIncludeDirectories) + MultiThreadedDLL + true + Level3 + ProgramDatabase + + + %(AdditionalLibraryDirectories) + true + true + true + Console + false + true + + + + + + + + {59489f1b-1d27-43db-9eb2-3bcb6f3d67f1} + false + + + + + + \ No newline at end of file diff --git a/envtest/envtest.vcxproj.filters b/envtest/envtest.vcxproj.filters new file mode 100644 index 0000000..0270521 --- /dev/null +++ b/envtest/envtest.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + \ No newline at end of file