Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2005-11-18 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:45 +0300
commite18587ba512abb4b3c81d4ff307c59e31589207d (patch)
treeb126317daa618d406b648c38498d250e99aaaac6
parentbcd1db2f5aeac20842db7ad64ba2f5716618c1c9 (diff)
4.30 beta
-rwxr-xr-x7zip/Archive/7z/7zEncode.cpp38
-rwxr-xr-x7zip/Archive/7z/7zEncode.h4
-rwxr-xr-x7zip/Archive/7z/7zHandlerOut.cpp2
-rwxr-xr-x7zip/Archive/7z/7zOut.cpp4
-rwxr-xr-x7zip/Archive/7z/7zUpdate.cpp16
-rwxr-xr-x7zip/Archive/7z/DllExports.cpp23
-rwxr-xr-x7zip/Archive/Arj/ArjHandler.cpp1
-rwxr-xr-x7zip/Archive/BZip2/DllExports.cpp20
-rwxr-xr-x7zip/Archive/Chm/ChmHandler.cpp1
-rwxr-xr-x7zip/Archive/Common/FilterCoder.cpp4
-rwxr-xr-x7zip/Archive/Common/InStreamWithCRC.h2
-rwxr-xr-x7zip/Archive/GZip/DllExports.cpp20
-rwxr-xr-x7zip/Archive/GZip/GZipHandlerOut.cpp4
-rwxr-xr-x7zip/Archive/Lzh/LzhHandler.cpp1
-rwxr-xr-x7zip/Archive/Rar/DllExports.cpp16
-rwxr-xr-x7zip/Archive/Split/SplitHandler.cpp1
-rwxr-xr-x7zip/Archive/Tar/TarHandler.cpp1
-rwxr-xr-x7zip/Archive/Tar/TarIn.cpp6
-rwxr-xr-x7zip/Archive/Z/DllExports.cpp5
-rwxr-xr-x7zip/Archive/Zip/DllExports.cpp16
-rwxr-xr-x7zip/Archive/Zip/Zip.dsp8
-rwxr-xr-x7zip/Archive/Zip/ZipAddCommon.cpp20
-rwxr-xr-x7zip/Archive/Zip/ZipAddCommon.h2
-rwxr-xr-x7zip/Archive/Zip/ZipHandler.cpp1
-rwxr-xr-x7zip/Archive/Zip/ZipHandlerOut.cpp2
-rwxr-xr-x7zip/Archive/Zip/ZipUpdate.cpp37
-rwxr-xr-x7zip/Archive/cpio/CpioHandler.cpp1
-rwxr-xr-x7zip/Bundles/Alone/Alone.dsp8
-rwxr-xr-x7zip/Bundles/Alone/makefile3
-rwxr-xr-x7zip/Bundles/Alone7z/StdAfx.cpp3
-rwxr-xr-x7zip/Bundles/Alone7z/StdAfx.h9
-rwxr-xr-x7zip/Bundles/Alone7z/makefile179
-rwxr-xr-x7zip/Bundles/Alone7z/resource.rc3
-rwxr-xr-x7zip/Bundles/SFXCon/SFXCon.dsp2
-rwxr-xr-x7zip/Bundles/SFXSetup/Main.cpp17
-rwxr-xr-x7zip/Bundles/SFXWin/Main.cpp15
-rwxr-xr-x7zip/Bundles/SFXWin/SFXWin.dsp2
-rwxr-xr-x7zip/Common/InBuffer.cpp4
-rwxr-xr-x7zip/Common/OutBuffer.cpp4
-rwxr-xr-x7zip/Compress/BZip2/DllExports.cpp7
-rwxr-xr-x7zip/Compress/Branch/x86_2.cpp4
-rwxr-xr-x7zip/Compress/Copy/CopyCoder.cpp4
-rwxr-xr-x7zip/Compress/Deflate/DeflateEncoder.cpp9
-rwxr-xr-x7zip/Compress/Deflate/DeflateEncoder.h1
-rwxr-xr-x7zip/Compress/LZMA/DllExports.cpp13
-rwxr-xr-x7zip/Compress/LZMA/LZMAEncoder.cpp107
-rwxr-xr-x7zip/Compress/PPMD/DllExports.cpp7
-rwxr-xr-x7zip/Compress/Rar29/makefile4
-rwxr-xr-x7zip/Crypto/7zAES/DllExports.cpp16
-rwxr-xr-x7zip/FileManager/App.cpp66
-rwxr-xr-x7zip/FileManager/ExtractCallback.h2
-rwxr-xr-x7zip/FileManager/FM.cpp161
-rwxr-xr-x7zip/FileManager/FM.dsp44
-rwxr-xr-x7zip/FileManager/FSDrives.cpp52
-rwxr-xr-x7zip/FileManager/FSDrives.h22
-rwxr-xr-x7zip/FileManager/FSFolder.cpp119
-rwxr-xr-x7zip/FileManager/FSFolder.h35
-rwxr-xr-x7zip/FileManager/FSFolderCopy.cpp151
-rwxr-xr-x7zip/FileManager/FormatUtils.cpp46
-rwxr-xr-x7zip/FileManager/FormatUtils.h11
-rwxr-xr-x7zip/FileManager/HelpUtils.cpp3
-rwxr-xr-x7zip/FileManager/IFolder.h44
-rwxr-xr-x7zip/FileManager/LangUtils.cpp60
-rwxr-xr-x7zip/FileManager/LangUtils.h13
-rwxr-xr-x7zip/FileManager/MyLoadMenu.cpp195
-rwxr-xr-x7zip/FileManager/NetFolder.cpp63
-rwxr-xr-x7zip/FileManager/NetFolder.h20
-rwxr-xr-x7zip/FileManager/OpenCallback.cpp2
-rwxr-xr-x7zip/FileManager/OptionsDialog.cpp78
-rwxr-xr-x7zip/FileManager/Panel.cpp65
-rwxr-xr-x7zip/FileManager/Panel.h15
-rwxr-xr-x7zip/FileManager/PanelCopy.cpp18
-rwxr-xr-x7zip/FileManager/PanelDrag.cpp108
-rwxr-xr-x7zip/FileManager/PanelFolderChange.cpp78
-rwxr-xr-x7zip/FileManager/PanelItemOpen.cpp144
-rwxr-xr-x7zip/FileManager/PanelItems.cpp46
-rwxr-xr-x7zip/FileManager/PanelKey.cpp2
-rwxr-xr-x7zip/FileManager/PanelListNotify.cpp50
-rwxr-xr-x7zip/FileManager/PanelMenu.cpp24
-rwxr-xr-x7zip/FileManager/PanelOperations.cpp147
-rwxr-xr-x7zip/FileManager/PanelSelect.cpp6
-rwxr-xr-x7zip/FileManager/PanelSplitFile.cpp20
-rwxr-xr-x7zip/FileManager/PhysDriveFolder.cpp274
-rwxr-xr-x7zip/FileManager/PhysDriveFolder.h89
-rwxr-xr-x7zip/FileManager/PluginLoader.h2
-rwxr-xr-x7zip/FileManager/PropertyName.cpp2
-rwxr-xr-x7zip/FileManager/RegistryAssociations.cpp45
-rwxr-xr-x7zip/FileManager/RegistryAssociations.h6
-rwxr-xr-x7zip/FileManager/RegistryPlugins.cpp30
-rwxr-xr-x7zip/FileManager/RegistryPlugins.h2
-rwxr-xr-x7zip/FileManager/RegistryUtils.cpp111
-rwxr-xr-x7zip/FileManager/RegistryUtils.h14
-rwxr-xr-x7zip/FileManager/Resource/AboutDialog/AboutDialog.h3
-rwxr-xr-x7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp63
-rwxr-xr-x7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h6
-rwxr-xr-x7zip/FileManager/Resource/ComboDialog/ComboDialog.h5
-rwxr-xr-x7zip/FileManager/Resource/CopyDialog/CopyDialog.cpp12
-rwxr-xr-x7zip/FileManager/Resource/CopyDialog/CopyDialog.h3
-rwxr-xr-x7zip/FileManager/Resource/EditPage/EditPage.cpp84
-rwxr-xr-x7zip/FileManager/Resource/LangPage/LangPage.cpp16
-rwxr-xr-x7zip/FileManager/Resource/LangPage/LangPage.h2
-rwxr-xr-x7zip/FileManager/Resource/ListViewDialog/ListViewDialog.cpp4
-rwxr-xr-x7zip/FileManager/Resource/ListViewDialog/ListViewDialog.h5
-rwxr-xr-x7zip/FileManager/Resource/MessagesDialog/MessagesDialog.cpp34
-rwxr-xr-x7zip/FileManager/Resource/MessagesDialog/MessagesDialog.h5
-rwxr-xr-x7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.cpp7
-rwxr-xr-x7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.h3
-rwxr-xr-x7zip/FileManager/Resource/PasswordDialog/PasswordDialog.cpp2
-rwxr-xr-x7zip/FileManager/Resource/PasswordDialog/PasswordDialog.h3
-rwxr-xr-x7zip/FileManager/Resource/PluginsPage/PluginsPage.cpp82
-rwxr-xr-x7zip/FileManager/Resource/PluginsPage/PluginsPage.h1
-rwxr-xr-x7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp4
-rwxr-xr-x7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h6
-rwxr-xr-x7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.cpp77
-rwxr-xr-x7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.h6
-rwxr-xr-x7zip/FileManager/Resource/SettingsPage/SettingsPage.cpp15
-rwxr-xr-x7zip/FileManager/Resource/SettingsPage/resource.h1
-rwxr-xr-x7zip/FileManager/Resource/SettingsPage/resource.rc3
-rwxr-xr-x7zip/FileManager/Resource/SplitDialog/SplitDialog.cpp10
-rwxr-xr-x7zip/FileManager/Resource/SplitDialog/SplitDialog.h2
-rwxr-xr-x7zip/FileManager/Resource/SystemPage/SystemPage.cpp78
-rwxr-xr-x7zip/FileManager/RootFolder.cpp65
-rwxr-xr-x7zip/FileManager/RootFolder.h12
-rwxr-xr-x7zip/FileManager/StringUtils.cpp10
-rwxr-xr-x7zip/FileManager/SysIconUtils.cpp66
-rwxr-xr-x7zip/FileManager/SysIconUtils.h16
-rwxr-xr-x7zip/FileManager/UpdateCallback100.cpp2
-rwxr-xr-x7zip/FileManager/ViewSettings.cpp21
-rwxr-xr-x7zip/FileManager/ViewSettings.h8
-rwxr-xr-x7zip/FileManager/makefile6
-rwxr-xr-x7zip/Guid.txt1
-rwxr-xr-x7zip/MyVersion.h8
-rwxr-xr-x7zip/UI/Common/ArchiveCommandLine.cpp18
-rwxr-xr-x7zip/UI/Common/ArchiveCommandLine.h4
-rwxr-xr-x7zip/UI/Common/ArchiveExtractCallback.cpp5
-rwxr-xr-x7zip/UI/Common/ArchiveExtractCallback.h3
-rwxr-xr-x7zip/UI/Common/ArchiverInfo.cpp42
-rwxr-xr-x7zip/UI/Common/CompressCall.cpp87
-rwxr-xr-x7zip/UI/Common/CompressCall.h3
-rwxr-xr-x7zip/UI/Common/OpenArchive.h1
-rwxr-xr-x7zip/UI/Common/Update.cpp8
-rwxr-xr-x7zip/UI/Common/ZipRegistry.cpp22
-rwxr-xr-x7zip/UI/Common/ZipRegistry.h8
-rwxr-xr-x7zip/UI/Console/Console.dsp8
-rwxr-xr-x7zip/UI/Console/Main.cpp14
-rwxr-xr-x7zip/UI/Console/MainAr.cpp18
-rwxr-xr-x7zip/UI/Console/UpdateCallbackConsole.cpp4
-rwxr-xr-x7zip/UI/Console/makefile1
-rwxr-xr-x7zip/UI/Explorer/ContextMenu.cpp147
-rwxr-xr-x7zip/UI/Explorer/ContextMenu.h2
-rwxr-xr-x7zip/UI/Explorer/DllExports.cpp58
-rwxr-xr-x7zip/UI/Explorer/Explorer.dsp10
-rwxr-xr-x7zip/UI/Explorer/FoldersPage/FoldersPage.cpp50
-rwxr-xr-x7zip/UI/Explorer/FoldersPage/FoldersPage.h7
-rwxr-xr-x7zip/UI/Explorer/MyMessages.cpp2
-rwxr-xr-x7zip/UI/Explorer/OptionsDialog.cpp70
-rwxr-xr-x7zip/UI/Explorer/RegistryContextMenu.h2
-rwxr-xr-x7zip/UI/Explorer/SystemPage/SystemPage.cpp18
-rwxr-xr-x7zip/UI/Explorer/makefile1
-rwxr-xr-x7zip/UI/Far/Main.cpp17
-rwxr-xr-x7zip/UI/GUI/CompressDialog.cpp145
-rwxr-xr-x7zip/UI/GUI/CompressDialog.h4
-rwxr-xr-x7zip/UI/GUI/ExtractDialog.cpp34
-rwxr-xr-x7zip/UI/GUI/ExtractDialog.h2
-rwxr-xr-x7zip/UI/GUI/ExtractGUI.cpp12
-rwxr-xr-x7zip/UI/GUI/GUI.cpp25
-rwxr-xr-x7zip/UI/GUI/GUI.dsp16
-rwxr-xr-x7zip/UI/GUI/UpdateGUI.cpp5
-rwxr-xr-x7zip/UI/GUI/makefile2
-rwxr-xr-xCommon/Alloc.cpp74
-rwxr-xr-xCommon/Alloc.h17
-rwxr-xr-xCommon/ComTry.h11
-rwxr-xr-xDOC/7zip.nsi72
-rwxr-xr-xDOC/history.txt7
-rwxr-xr-xDOC/readme.txt2
-rwxr-xr-xWindows/CommonDialog.cpp164
-rwxr-xr-xWindows/CommonDialog.h17
-rwxr-xr-xWindows/Control/ComboBox.cpp56
-rwxr-xr-xWindows/Control/ComboBox.h29
-rwxr-xr-xWindows/Control/Dialog.cpp55
-rwxr-xr-xWindows/Control/Dialog.h10
-rwxr-xr-xWindows/Control/ListView.h19
-rwxr-xr-xWindows/Control/PropertyPage.cpp106
-rwxr-xr-xWindows/Control/PropertyPage.h8
-rwxr-xr-xWindows/Control/StatusBar.h12
-rwxr-xr-xWindows/Control/ToolBar.h4
-rwxr-xr-xWindows/Control/Window2.cpp86
-rwxr-xr-xWindows/Control/Window2.h11
-rwxr-xr-xWindows/DLL.cpp44
-rwxr-xr-xWindows/Error.cpp45
-rwxr-xr-xWindows/FileDevice.cpp49
-rwxr-xr-xWindows/FileDevice.h119
-rwxr-xr-xWindows/FileDir.cpp275
-rwxr-xr-xWindows/FileFind.cpp112
-rwxr-xr-xWindows/FileFind.h16
-rwxr-xr-xWindows/FileIO.cpp160
-rwxr-xr-xWindows/FileIO.h44
-rwxr-xr-xWindows/FileSystem.cpp65
-rwxr-xr-xWindows/FileSystem.h27
-rwxr-xr-xWindows/MemoryLock.cpp78
-rwxr-xr-xWindows/MemoryLock.h13
-rwxr-xr-xWindows/Menu.cpp178
-rwxr-xr-xWindows/Menu.h47
-rwxr-xr-xWindows/Net.cpp242
-rwxr-xr-xWindows/Net.h47
-rwxr-xr-xWindows/Registry.cpp166
-rwxr-xr-xWindows/Registry.h38
-rwxr-xr-xWindows/ResourceString.cpp35
-rwxr-xr-xWindows/Security.cpp181
-rwxr-xr-xWindows/Security.h168
-rwxr-xr-xWindows/Shell.cpp118
-rwxr-xr-xWindows/Shell.h20
-rwxr-xr-xWindows/Window.cpp141
-rwxr-xr-xWindows/Window.h107
214 files changed, 5381 insertions, 2708 deletions
diff --git a/7zip/Archive/7z/7zEncode.cpp b/7zip/Archive/7z/7zEncode.cpp
index 5a9dd86e..a4fb7159 100755
--- a/7zip/Archive/7z/7zEncode.cpp
+++ b/7zip/Archive/7z/7zEncode.cpp
@@ -18,9 +18,10 @@ static NArchive::N7z::CMethodID k_Copy = { { 0x0 }, 1 };
#include "../../Compress/Copy/CopyCoder.h"
#endif
+static NArchive::N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
+
#ifdef COMPRESS_LZMA
#include "../../Compress/LZMA/LZMAEncoder.h"
-static NArchive::N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
#endif
#ifdef COMPRESS_PPMD
@@ -114,7 +115,7 @@ static void ConvertBindInfoToFolderItemInfo(const NCoderMixer2::CBindInfo &bindI
folder.PackStreams.Add(bindInfo.InStreams[i]);
}
-HRESULT CEncoder::CreateMixerCoder()
+HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
{
_mixerCoderSpec = new NCoderMixer2::CCoderMixer2MT;
_mixerCoder = _mixerCoderSpec;
@@ -203,6 +204,30 @@ HRESULT CEncoder::CreateMixerCoder()
return E_FAIL;
#endif
}
+
+ bool tryReduce = false;
+ UInt32 reducedDictionarySize = 1 << 10;
+ if (inSizeForReduce != 0 && methodFull.MethodID == k_LZMA)
+ {
+ while (true)
+ {
+ const UInt32 step = (reducedDictionarySize >> 1);
+ if (reducedDictionarySize >= *inSizeForReduce)
+ {
+ tryReduce = true;
+ break;
+ }
+ reducedDictionarySize += step;
+ if (reducedDictionarySize >= *inSizeForReduce)
+ {
+ tryReduce = true;
+ break;
+ }
+ if (reducedDictionarySize >= ((UInt32)11 << 30))
+ break;
+ reducedDictionarySize += step;
+ }
+ }
if (methodFull.CoderProperties.Size() > 0)
{
@@ -215,7 +240,10 @@ HRESULT CEncoder::CreateMixerCoder()
{
const CProperty &property = methodFull.CoderProperties[i];
propIDs.Add(property.PropID);
- values[i] = property.Value;
+ NWindows::NCOM::CPropVariant value = property.Value;
+ if (tryReduce && property.PropID == NCoderPropID::kDictionarySize && value.vt == VT_UI4 && reducedDictionarySize < value.ulVal)
+ value.ulVal = reducedDictionarySize;
+ values[i] = value;
}
CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
if (methodFull.IsSimpleCoder())
@@ -308,7 +336,7 @@ HRESULT CEncoder::CreateMixerCoder()
}
HRESULT CEncoder::Encode(ISequentialInStream *inStream,
- const UInt64 *inStreamSize,
+ const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
CFolder &folderItem,
ISequentialOutStream *outStream,
CRecordVector<UInt64> &packSizes,
@@ -316,7 +344,7 @@ HRESULT CEncoder::Encode(ISequentialInStream *inStream,
{
if (_mixerCoderSpec == NULL)
{
- RINOK(CreateMixerCoder());
+ RINOK(CreateMixerCoder(inSizeForReduce));
}
_mixerCoderSpec->ReInit();
// _mixerCoderSpec->SetCoderInfo(0, NULL, NULL, progress);
diff --git a/7zip/Archive/7z/7zEncode.h b/7zip/Archive/7z/7zEncode.h
index 14ef9394..04a8c37b 100755
--- a/7zip/Archive/7z/7zEncode.h
+++ b/7zip/Archive/7z/7zEncode.h
@@ -38,13 +38,13 @@ class CEncoder
NCoderMixer2::CBindReverseConverter *_bindReverseConverter;
CRecordVector<CMethodID> _decompressionMethods;
- HRESULT CreateMixerCoder();
+ HRESULT CreateMixerCoder(const UInt64 *inSizeForReduce);
public:
CEncoder(const CCompressionMethodMode &options);
~CEncoder();
HRESULT Encode(ISequentialInStream *inStream,
- const UInt64 *inStreamSize,
+ const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
CFolder &folderItem,
ISequentialOutStream *outStream,
CRecordVector<UInt64> &packSizes,
diff --git a/7zip/Archive/7z/7zHandlerOut.cpp b/7zip/Archive/7z/7zHandlerOut.cpp
index 29d02ca9..13f74c4f 100755
--- a/7zip/Archive/7z/7zHandlerOut.cpp
+++ b/7zip/Archive/7z/7zHandlerOut.cpp
@@ -81,7 +81,7 @@ const wchar_t *kDefaultMethodName = kLZMAMethodName;
static const wchar_t *kMatchFinderForHeaders = L"BT2";
static const UInt32 kDictionaryForHeaders = 1 << 20;
-static const UInt32 kNumFastBytesForHeaders = 254;
+static const UInt32 kNumFastBytesForHeaders = 273;
static bool IsLZMAMethod(const UString &methodName)
{ return (methodName.CompareNoCase(kLZMAMethodName) == 0); }
diff --git a/7zip/Archive/7z/7zOut.cpp b/7zip/Archive/7z/7zOut.cpp
index 116cb0cc..b1ad2677 100755
--- a/7zip/Archive/7z/7zOut.cpp
+++ b/7zip/Archive/7z/7zOut.cpp
@@ -576,8 +576,8 @@ HRESULT COutArchive::EncodeStream(CEncoder &encoder, const Byte *data, size_t da
CFolder folderItem;
folderItem.UnPackCRCDefined = true;
folderItem.UnPackCRC = CCRC::CalculateDigest(data, dataSize);
- RINOK(encoder.Encode(stream, NULL, folderItem, SeqStream,
- packSizes, NULL));
+ UInt64 dataSize64 = dataSize;
+ RINOK(encoder.Encode(stream, NULL, &dataSize64, folderItem, SeqStream, packSizes, NULL));
folders.Add(folderItem);
return S_OK;
}
diff --git a/7zip/Archive/7z/7zUpdate.cpp b/7zip/Archive/7z/7zUpdate.cpp
index 8017c75d..c45c85f3 100755
--- a/7zip/Archive/7z/7zUpdate.cpp
+++ b/7zip/Archive/7z/7zUpdate.cpp
@@ -566,11 +566,21 @@ static HRESULT Update2(
UInt64 complexity = 0;
for(i = 0; i < folderRefs.Size(); i++)
complexity += database->GetFolderFullPackSize(folderRefs[i]);
+ UInt64 inSizeForReduce = 0;
for(i = 0; i < updateItems.Size(); i++)
{
const CUpdateItem &updateItem = updateItems[i];
if (updateItem.NewData)
+ {
complexity += updateItem.Size;
+ if (numSolidFiles == 1)
+ {
+ if (updateItem.Size > inSizeForReduce)
+ inSizeForReduce = updateItem.Size;
+ }
+ else
+ inSizeForReduce += updateItem.Size;
+ }
}
RINOK(updateCallback->SetTotal(complexity));
complexity = 0;
@@ -636,6 +646,10 @@ static HRESULT Update2(
SplitFilesToGroups(*options.Method, options.UseFilters, options.MaxFilter,
updateItems, groups);
+ const UInt32 kMinReduceSize = (1 << 16);
+ if (inSizeForReduce < kMinReduceSize)
+ inSizeForReduce = kMinReduceSize;
+
for (int groupIndex = 0; groupIndex < groups.Size(); groupIndex++)
{
const CSolidGroup &group = groups[groupIndex];
@@ -708,7 +722,7 @@ static HRESULT Update2(
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
localCompressProgressSpec->Init(localProgress, &complexity, NULL);
- RINOK(encoder.Encode(solidInStream, NULL, folderItem,
+ RINOK(encoder.Encode(solidInStream, NULL, &inSizeForReduce, folderItem,
archive.SeqStream, newDatabase.PackSizes, compressProgress));
// for()
// newDatabase.PackCRCsDefined.Add(false);
diff --git a/7zip/Archive/7z/DllExports.cpp b/7zip/Archive/7z/DllExports.cpp
index 812d19d3..c8d31b3b 100755
--- a/7zip/Archive/7z/DllExports.cpp
+++ b/7zip/Archive/7z/DllExports.cpp
@@ -4,6 +4,9 @@
#include "../../../Common/MyInitGuid.h"
#include "../../../Common/ComTry.h"
+#ifdef _WIN32
+#include "../../../Common/Alloc.h"
+#endif
#include "../../ICoder.h"
@@ -18,12 +21,32 @@ DEFINE_GUID(CLSID_CCrypto7zAESEncoder,
#endif
HINSTANCE g_hInstance;
+#ifndef _UNICODE
+bool g_IsNT = false;
+static bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
+
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
+ {
g_hInstance = hInstance;
+ #ifndef _UNICODE
+ g_IsNT = IsItWindowsNT();
+ #endif
+ #ifdef _WIN32
+ SetLargePageSize();
+ #endif
+ }
return TRUE;
}
diff --git a/7zip/Archive/Arj/ArjHandler.cpp b/7zip/Archive/Arj/ArjHandler.cpp
index ab75493f..b3edb02d 100755
--- a/7zip/Archive/Arj/ArjHandler.cpp
+++ b/7zip/Archive/Arj/ArjHandler.cpp
@@ -256,6 +256,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
STDMETHODIMP CHandler::Close()
{
+ _items.Clear();
_stream.Release();
return S_OK;
}
diff --git a/7zip/Archive/BZip2/DllExports.cpp b/7zip/Archive/BZip2/DllExports.cpp
index 932a75bb..5a861318 100755
--- a/7zip/Archive/BZip2/DllExports.cpp
+++ b/7zip/Archive/BZip2/DllExports.cpp
@@ -21,6 +21,17 @@ DEFINE_GUID(CLSID_CBZip2Handler,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x02, 0x00, 0x00);
HINSTANCE g_hInstance;
+#ifndef _UNICODE
+bool g_IsNT = false;
+static bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
#ifndef COMPRESS_BZIP2
#include "../Common/CodecsPath.h"
@@ -34,7 +45,12 @@ extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
+ {
g_hInstance = hInstance;
+ #ifndef _UNICODE
+ g_IsNT = IsItWindowsNT();
+ #endif
+ }
return TRUE;
}
@@ -86,10 +102,10 @@ STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
return S_OK;
}
case NArchive::kExtension:
- propVariant = L"bz2 tbz2";
+ propVariant = L"bz2 bzip2 tbz2 tbz";
break;
case NArchive::kAddExtension:
- propVariant = L"* .tar";
+ propVariant = L"* * .tar .tar";
break;
case NArchive::kUpdate:
propVariant = true;
diff --git a/7zip/Archive/Chm/ChmHandler.cpp b/7zip/Archive/Chm/ChmHandler.cpp
index 3f2d3cc7..6baf35c6 100755
--- a/7zip/Archive/Chm/ChmHandler.cpp
+++ b/7zip/Archive/Chm/ChmHandler.cpp
@@ -224,6 +224,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
STDMETHODIMP CHandler::Close()
{
+ m_Database.Clear();
m_Stream.Release();
return S_OK;
}
diff --git a/7zip/Archive/Common/FilterCoder.cpp b/7zip/Archive/Common/FilterCoder.cpp
index 5d24aed7..19ba8b81 100755
--- a/7zip/Archive/Common/FilterCoder.cpp
+++ b/7zip/Archive/Common/FilterCoder.cpp
@@ -11,12 +11,12 @@ static const int kBufferSize = 1 << 17;
CFilterCoder::CFilterCoder()
{
- _buffer = (Byte *)::BigAlloc(kBufferSize);
+ _buffer = (Byte *)::MidAlloc(kBufferSize);
}
CFilterCoder::~CFilterCoder()
{
- BigFree(_buffer);
+ ::MidFree(_buffer);
}
HRESULT CFilterCoder::WriteWithLimit(ISequentialOutStream *outStream, UInt32 size)
diff --git a/7zip/Archive/Common/InStreamWithCRC.h b/7zip/Archive/Common/InStreamWithCRC.h
index 9628a6f2..ba7e8564 100755
--- a/7zip/Archive/Common/InStreamWithCRC.h
+++ b/7zip/Archive/Common/InStreamWithCRC.h
@@ -36,7 +36,7 @@ class CInStreamWithCRC:
public CMyUnknownImp
{
public:
- MY_UNKNOWN_IMP
+ MY_UNKNOWN_IMP1(IInStream)
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
diff --git a/7zip/Archive/GZip/DllExports.cpp b/7zip/Archive/GZip/DllExports.cpp
index 2b32f16b..3bddcfb9 100755
--- a/7zip/Archive/GZip/DllExports.cpp
+++ b/7zip/Archive/GZip/DllExports.cpp
@@ -21,6 +21,17 @@ DEFINE_GUID(CLSID_CCompressDeflateDecoder,
0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00);
HINSTANCE g_hInstance;
+#ifndef _UNICODE
+bool g_IsNT = false;
+static bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
#ifndef COMPRESS_DEFLATE
#include "../Common/CodecsPath.h"
@@ -34,7 +45,12 @@ extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
+ {
g_hInstance = hInstance;
+ #ifndef _UNICODE
+ g_IsNT = IsItWindowsNT();
+ #endif
+ }
return TRUE;
}
@@ -85,10 +101,10 @@ STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
return S_OK;
}
case NArchive::kExtension:
- propVariant = L"gz tgz";
+ propVariant = L"gz gzip tgz tpz";
break;
case NArchive::kAddExtension:
- propVariant = L"* .tar";
+ propVariant = L"* * .tar .tar";
break;
case NArchive::kUpdate:
propVariant = true;
diff --git a/7zip/Archive/GZip/GZipHandlerOut.cpp b/7zip/Archive/GZip/GZipHandlerOut.cpp
index 7f367e0e..577e74c0 100755
--- a/7zip/Archive/GZip/GZipHandlerOut.cpp
+++ b/7zip/Archive/GZip/GZipHandlerOut.cpp
@@ -192,7 +192,7 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
if (value.vt != VT_UI4)
return E_INVALIDARG;
m_Method.NumPasses = value.ulVal;
- if (m_Method.NumPasses < 1 || m_Method.NumPasses > 4)
+ if (m_Method.NumPasses < 1 || m_Method.NumPasses > 10)
return E_INVALIDARG;
}
else if (name == L"FB")
@@ -200,8 +200,10 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
if (value.vt != VT_UI4)
return E_INVALIDARG;
m_Method.NumFastBytes = value.ulVal;
+ /*
if (m_Method.NumFastBytes < 3 || m_Method.NumFastBytes > 255)
return E_INVALIDARG;
+ */
}
else
return E_INVALIDARG;
diff --git a/7zip/Archive/Lzh/LzhHandler.cpp b/7zip/Archive/Lzh/LzhHandler.cpp
index 9502e5e9..f66cf352 100755
--- a/7zip/Archive/Lzh/LzhHandler.cpp
+++ b/7zip/Archive/Lzh/LzhHandler.cpp
@@ -270,6 +270,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
STDMETHODIMP CHandler::Close()
{
+ _items.Clear();
_stream.Release();
return S_OK;
}
diff --git a/7zip/Archive/Rar/DllExports.cpp b/7zip/Archive/Rar/DllExports.cpp
index 0df1ac47..921bffb2 100755
--- a/7zip/Archive/Rar/DllExports.cpp
+++ b/7zip/Archive/Rar/DllExports.cpp
@@ -16,6 +16,17 @@ DEFINE_GUID(CLSID_CCrypto_AES128_Decoder,
#include "RarHandler.h"
HINSTANCE g_hInstance;
+#ifndef _UNICODE
+bool g_IsNT = false;
+static bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
void GetCryptoFolderPrefix(TCHAR *path)
{
@@ -54,7 +65,12 @@ extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
+ {
g_hInstance = hInstance;
+ #ifndef _UNICODE
+ g_IsNT = IsItWindowsNT();
+ #endif
+ }
return TRUE;
}
diff --git a/7zip/Archive/Split/SplitHandler.cpp b/7zip/Archive/Split/SplitHandler.cpp
index fddf0c70..7bdada56 100755
--- a/7zip/Archive/Split/SplitHandler.cpp
+++ b/7zip/Archive/Split/SplitHandler.cpp
@@ -276,6 +276,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
STDMETHODIMP CHandler::Close()
{
+ _sizes.Clear();
_streams.Clear();
return S_OK;
}
diff --git a/7zip/Archive/Tar/TarHandler.cpp b/7zip/Archive/Tar/TarHandler.cpp
index e4162e48..4e5c6cde 100755
--- a/7zip/Archive/Tar/TarHandler.cpp
+++ b/7zip/Archive/Tar/TarHandler.cpp
@@ -130,6 +130,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
STDMETHODIMP CHandler::Close()
{
+ _items.Clear();
_inStream.Release();
return S_OK;
}
diff --git a/7zip/Archive/Tar/TarIn.cpp b/7zip/Archive/Tar/TarIn.cpp
index fad27587..ec73ce76 100755
--- a/7zip/Archive/Tar/TarIn.cpp
+++ b/7zip/Archive/Tar/TarIn.cpp
@@ -120,10 +120,12 @@ HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item)
RIF(OctalToNumber32(cur, 8, item.Mode));
cur += 8;
- RIF(OctalToNumber32(cur, 8, item.UID));
+ if (!OctalToNumber32(cur, 8, item.UID))
+ item.UID = 0;
cur += 8;
- RIF(OctalToNumber32(cur, 8, item.GID));
+ if (!OctalToNumber32(cur, 8, item.GID))
+ item.GID = 0;
cur += 8;
RIF(OctalToNumber(cur, 12, item.Size));
diff --git a/7zip/Archive/Z/DllExports.cpp b/7zip/Archive/Z/DllExports.cpp
index d96cd303..9de69c9c 100755
--- a/7zip/Archive/Z/DllExports.cpp
+++ b/7zip/Archive/Z/DllExports.cpp
@@ -70,7 +70,10 @@ STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
return S_OK;
}
case NArchive::kExtension:
- propVariant = L"z";
+ propVariant = L"z taz";
+ break;
+ case NArchive::kAddExtension:
+ propVariant = L"* .tar";
break;
case NArchive::kUpdate:
propVariant = false;
diff --git a/7zip/Archive/Zip/DllExports.cpp b/7zip/Archive/Zip/DllExports.cpp
index 0ecb3bcd..53d5a4b6 100755
--- a/7zip/Archive/Zip/DllExports.cpp
+++ b/7zip/Archive/Zip/DllExports.cpp
@@ -50,12 +50,28 @@ DEFINE_GUID(CLSID_CZipHandler,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x01, 0x00, 0x00);
HINSTANCE g_hInstance;
+#ifndef _UNICODE
+bool g_IsNT = false;
+static bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
+ {
g_hInstance = hInstance;
+ #ifndef _UNICODE
+ g_IsNT = IsItWindowsNT();
+ #endif
+ }
return TRUE;
}
diff --git a/7zip/Archive/Zip/Zip.dsp b/7zip/Archive/Zip/Zip.dsp
index 44852ec1..0bfb5fd1 100755
--- a/7zip/Archive/Zip/Zip.dsp
+++ b/7zip/Archive/Zip/Zip.dsp
@@ -142,6 +142,14 @@ SOURCE=..\..\..\Common\CRC.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Common\NewHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\NewHandler.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Common\Random.cpp
# End Source File
# Begin Source File
diff --git a/7zip/Archive/Zip/ZipAddCommon.cpp b/7zip/Archive/Zip/ZipAddCommon.cpp
index 26d330fd..84cada5b 100755
--- a/7zip/Archive/Zip/ZipAddCommon.cpp
+++ b/7zip/Archive/Zip/ZipAddCommon.cpp
@@ -57,7 +57,7 @@ CAddCommon::CAddCommon(const CCompressionMethodMode &options):
_cryptoStreamSpec(0)
{}
-static HRESULT GetStreamCRC(IInStream *inStream, UInt32 &resultCRC)
+static HRESULT GetStreamCRC(ISequentialInStream *inStream, UInt32 &resultCRC)
{
CCRC crc;
crc.Init();
@@ -76,7 +76,7 @@ static HRESULT GetStreamCRC(IInStream *inStream, UInt32 &resultCRC)
}
}
-HRESULT CAddCommon::Compress(IInStream *inStream, IOutStream *outStream,
+HRESULT CAddCommon::Compress(ISequentialInStream *inStream, IOutStream *outStream,
UInt64 inSize, ICompressProgressInfo *progress, CCompressingResult &operationResult)
{
/*
@@ -88,13 +88,25 @@ HRESULT CAddCommon::Compress(IInStream *inStream, IOutStream *outStream,
return S_OK;
}
*/
+ CMyComPtr<IInStream> inStream2;
int numTestMethods = _options.MethodSequence.Size();
+ if (numTestMethods > 1 || _options.PasswordIsDefined)
+ {
+ inStream->QueryInterface(IID_IInStream, (void **)&inStream2);
+ if (!inStream2)
+ {
+ if (_options.PasswordIsDefined)
+ return E_NOTIMPL;
+ numTestMethods = 1;
+ }
+ }
Byte method;
UInt64 resultSize = 0;
COutStreamReleaser outStreamReleaser;
for(int i = 0; i < numTestMethods; i++)
{
- RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
+ if (inStream2)
+ RINOK(inStream2->Seek(0, STREAM_SEEK_SET, NULL));
RINOK(outStream->Seek(0, STREAM_SEEK_SET, NULL));
if (_options.PasswordIsDefined)
{
@@ -109,7 +121,7 @@ HRESULT CAddCommon::Compress(IInStream *inStream, IOutStream *outStream,
(const Byte *)(const char *)_options.Password, _options.Password.Length()));
UInt32 crc;
RINOK(GetStreamCRC(inStream, crc));
- RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
+ RINOK(inStream2->Seek(0, STREAM_SEEK_SET, NULL));
RINOK(_cryptoStreamSpec->SetOutStream(outStream));
outStreamReleaser.FilterCoder = _cryptoStreamSpec;
RINOK(_filterSpec->CryptoSetCRC(crc));
diff --git a/7zip/Archive/Zip/ZipAddCommon.h b/7zip/Archive/Zip/ZipAddCommon.h
index 4da3840f..e116ea9c 100755
--- a/7zip/Archive/Zip/ZipAddCommon.h
+++ b/7zip/Archive/Zip/ZipAddCommon.h
@@ -41,7 +41,7 @@ class CAddCommon
public:
CAddCommon(const CCompressionMethodMode &options);
- HRESULT Compress(IInStream *inStream, IOutStream *outStream,
+ HRESULT Compress(ISequentialInStream *inStream, IOutStream *outStream,
UInt64 inSize, ICompressProgressInfo *progress, CCompressingResult &operationResult);
};
diff --git a/7zip/Archive/Zip/ZipHandler.cpp b/7zip/Archive/Zip/ZipHandler.cpp
index 00a61f57..6b6c03c9 100755
--- a/7zip/Archive/Zip/ZipHandler.cpp
+++ b/7zip/Archive/Zip/ZipHandler.cpp
@@ -323,6 +323,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
STDMETHODIMP CHandler::Close()
{
+ m_Items.Clear();
m_Archive.Close();
m_ArchiveIsOpen = false;
return S_OK;
diff --git a/7zip/Archive/Zip/ZipHandlerOut.cpp b/7zip/Archive/Zip/ZipHandlerOut.cpp
index e88873e5..a202b2db 100755
--- a/7zip/Archive/Zip/ZipHandlerOut.cpp
+++ b/7zip/Archive/Zip/ZipHandlerOut.cpp
@@ -303,8 +303,10 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
{
if (value.vt != VT_UI4)
return E_INVALIDARG;
+ /*
if (value.ulVal < 3 || value.ulVal > 255)
return E_INVALIDARG;
+ */
m_NumFastBytes = value.ulVal;
}
else
diff --git a/7zip/Archive/Zip/ZipUpdate.cpp b/7zip/Archive/Zip/ZipUpdate.cpp
index d653a31b..a14162f4 100755
--- a/7zip/Archive/Zip/ZipUpdate.cpp
+++ b/7zip/Archive/Zip/ZipUpdate.cpp
@@ -121,9 +121,22 @@ static HRESULT UpdateOneFile(IInStream *inStream,
else
{
{
- CInStreamWithCRC *inStreamSpec = new CInStreamWithCRC;
- CMyComPtr<IInStream> inStream(inStreamSpec);
- inStreamSpec->Init(fileInStream);
+ CSequentialInStreamWithCRC *inSecStreamSpec = 0;
+ CInStreamWithCRC *inStreamSpec = 0;
+ CMyComPtr<ISequentialInStream> fileSecInStream;
+ if (fileInStream)
+ {
+ inStreamSpec = new CInStreamWithCRC;
+ fileSecInStream = inStreamSpec;
+ inStreamSpec->Init(fileInStream);
+ }
+ else
+ {
+ inSecStreamSpec = new CSequentialInStreamWithCRC;
+ fileSecInStream = inSecStreamSpec;
+ inSecStreamSpec->Init(fileInStream2);
+ }
+
CCompressingResult compressingResult;
CMyComPtr<IOutStream> outStream;
archive.CreateStreamForCompressing(&outStream);
@@ -132,20 +145,26 @@ static HRESULT UpdateOneFile(IInStream *inStream,
CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
localProgressSpec->Init(updateCallback, true);
- CLocalCompressProgressInfo *localCompressProgressSpec =
- new CLocalCompressProgressInfo;
+ CLocalCompressProgressInfo *localCompressProgressSpec = new CLocalCompressProgressInfo;
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
localCompressProgressSpec->Init(localProgress, &currentComplexity, NULL);
- RINOK(compressor.Compress(inStream, outStream,
- fileSize, compressProgress, compressingResult));
+ RINOK(compressor.Compress(fileSecInStream, outStream, fileSize, compressProgress, compressingResult));
fileHeader.PackSize = compressingResult.PackSize;
fileHeader.CompressionMethod = compressingResult.Method;
fileHeader.ExtractVersion.Version = compressingResult.ExtractVersion;
- fileHeader.FileCRC = inStreamSpec->GetCRC();
- fileHeader.UnPackSize = inStreamSpec->GetSize();
+ if (inStreamSpec != 0)
+ {
+ fileHeader.FileCRC = inStreamSpec->GetCRC();
+ fileHeader.UnPackSize = inStreamSpec->GetSize();
+ }
+ else
+ {
+ fileHeader.FileCRC = inSecStreamSpec->GetCRC();
+ fileHeader.UnPackSize = inSecStreamSpec->GetSize();
+ }
}
}
fileHeader.SetEncrypted(options.PasswordIsDefined);
diff --git a/7zip/Archive/cpio/CpioHandler.cpp b/7zip/Archive/cpio/CpioHandler.cpp
index fb71e8b0..1787402d 100755
--- a/7zip/Archive/cpio/CpioHandler.cpp
+++ b/7zip/Archive/cpio/CpioHandler.cpp
@@ -138,6 +138,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
STDMETHODIMP CHandler::Close()
{
+ m_Items.Clear();
m_InStream.Release();
return S_OK;
}
diff --git a/7zip/Bundles/Alone/Alone.dsp b/7zip/Bundles/Alone/Alone.dsp
index bcb415a9..edef69bc 100755
--- a/7zip/Bundles/Alone/Alone.dsp
+++ b/7zip/Bundles/Alone/Alone.dsp
@@ -481,6 +481,14 @@ SOURCE=..\..\..\Windows\Handle.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Windows\MemoryLock.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\MemoryLock.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Windows\PropVariant.cpp
# End Source File
# Begin Source File
diff --git a/7zip/Bundles/Alone/makefile b/7zip/Bundles/Alone/makefile
index f2e890bc..0a4137d5 100755
--- a/7zip/Bundles/Alone/makefile
+++ b/7zip/Bundles/Alone/makefile
@@ -1,5 +1,5 @@
PROG = 7za.exe
-LIBS = $(LIBS) user32.lib oleaut32.lib
+LIBS = $(LIBS) user32.lib oleaut32.lib Advapi32.lib
CFLAGS = $(CFLAGS) -I ../../../ \
-DEXCLUDE_COM \
@@ -61,6 +61,7 @@ WIN_OBJS = \
$O\FileFind.obj \
$O\FileIO.obj \
$O\FileName.obj \
+ $O\MemoryLock.obj \
$O\PropVariant.obj \
$O\PropVariantConversions.obj \
$O\Synchronization.obj
diff --git a/7zip/Bundles/Alone7z/StdAfx.cpp b/7zip/Bundles/Alone7z/StdAfx.cpp
new file mode 100755
index 00000000..d0feea85
--- /dev/null
+++ b/7zip/Bundles/Alone7z/StdAfx.cpp
@@ -0,0 +1,3 @@
+// StdAfx.cpp
+
+#include "StdAfx.h"
diff --git a/7zip/Bundles/Alone7z/StdAfx.h b/7zip/Bundles/Alone7z/StdAfx.h
new file mode 100755
index 00000000..2e4be10b
--- /dev/null
+++ b/7zip/Bundles/Alone7z/StdAfx.h
@@ -0,0 +1,9 @@
+// StdAfx.h
+
+#ifndef __STDAFX_H
+#define __STDAFX_H
+
+#include "../../../Common/MyWindows.h"
+#include "../../../Common/NewHandler.h"
+
+#endif
diff --git a/7zip/Bundles/Alone7z/makefile b/7zip/Bundles/Alone7z/makefile
new file mode 100755
index 00000000..b8432887
--- /dev/null
+++ b/7zip/Bundles/Alone7z/makefile
@@ -0,0 +1,179 @@
+PROG = 7za.exe
+LIBS = $(LIBS) user32.lib oleaut32.lib Advapi32.lib
+
+CFLAGS = $(CFLAGS) -I ../../../ \
+ -DEXCLUDE_COM \
+ -DNO_REGISTRY \
+ -DFORMAT_7Z \
+ -DCOMPRESS_BCJ_X86 \
+ -DCOMPRESS_BCJ2 \
+ -DCOMPRESS_COPY \
+ -DCOMPRESS_LZMA \
+ -DCOMPRESS_MF_MT \
+
+
+CONSOLE_OBJS = \
+ $O\ConsoleClose.obj \
+ $O\ExtractCallbackConsole.obj \
+ $O\List.obj \
+ $O\Main.obj \
+ $O\MainAr.obj \
+ $O\OpenCallbackConsole.obj \
+ $O\PercentPrinter.obj \
+ $O\UpdateCallbackConsole.obj \
+ $O\UserInputUtils.obj \
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\CommandLineParser.obj \
+ $O\CRC.obj \
+ $O\IntToString.obj \
+ $O\ListFileUtils.obj \
+ $O\NewHandler.obj \
+ $O\Random.obj \
+ $O\StdInStream.obj \
+ $O\StdOutStream.obj \
+ $O\String.obj \
+ $O\StringConvert.obj \
+ $O\StringToInt.obj \
+ $O\UTFConvert.obj \
+ $O\Vector.obj \
+ $O\Wildcard.obj \
+
+WIN_OBJS = \
+ $O\DLL.obj \
+ $O\Error.obj \
+ $O\FileDir.obj \
+ $O\FileFind.obj \
+ $O\FileIO.obj \
+ $O\FileName.obj \
+ $O\MemoryLock.obj \
+ $O\PropVariant.obj \
+ $O\PropVariantConversions.obj \
+ $O\Synchronization.obj
+
+7ZIP_COMMON_OBJS = \
+ $O\FilePathAutoRename.obj \
+ $O\FileStreams.obj \
+ $O\InBuffer.obj \
+ $O\InOutTempBuffer.obj \
+ $O\LimitedStreams.obj \
+ $O\LockedStream.obj \
+ $O\OffsetStream.obj \
+ $O\OutBuffer.obj \
+ $O\ProgressUtils.obj \
+ $O\StreamBinder.obj \
+ $O\StreamObjects.obj \
+ $O\StreamUtils.obj \
+
+UI_COMMON_OBJS = \
+ $O\ArchiveCommandLine.obj \
+ $O\ArchiveExtractCallback.obj \
+ $O\ArchiveOpenCallback.obj \
+ $O\ArchiverInfo.obj \
+ $O\DefaultName.obj \
+ $O\EnumDirItems.obj \
+ $O\Extract.obj \
+ $O\ExtractingFilePath.obj \
+ $O\OpenArchive.obj \
+ $O\PropIDUtils.obj \
+ $O\SortUtils.obj \
+ $O\TempFiles.obj \
+ $O\Update.obj \
+ $O\UpdateAction.obj \
+ $O\UpdateCallback.obj \
+ $O\UpdatePair.obj \
+ $O\UpdateProduce.obj \
+ $O\WorkDir.obj \
+
+AR_COMMON_OBJS = \
+ $O\CoderMixer2.obj \
+ $O\CoderMixer2MT.obj \
+ $O\CrossThreadProgress.obj \
+ $O\DummyOutStream.obj \
+ $O\FilterCoder.obj \
+ $O\InStreamWithCRC.obj \
+ $O\ItemNameUtils.obj \
+ $O\MultiStream.obj \
+ $O\OutStreamWithCRC.obj \
+
+
+7Z_OBJS = \
+ $O\7zCompressionMode.obj \
+ $O\7zDecode.obj \
+ $O\7zEncode.obj \
+ $O\7zExtract.obj \
+ $O\7zFolderInStream.obj \
+ $O\7zFolderOutStream.obj \
+ $O\7zHandler.obj \
+ $O\7zHandlerOut.obj \
+ $O\7zHeader.obj \
+ $O\7zIn.obj \
+ $O\7zMethodID.obj \
+ $O\7zOut.obj \
+ $O\7zProperties.obj \
+ $O\7zSpecStream.obj \
+ $O\7zUpdate.obj \
+
+
+BRANCH_OPT_OBJS = \
+ $O\BranchCoder.obj \
+ $O\x86.obj \
+ $O\x86_2.obj \
+
+LZ_OBJS = \
+ $O\LZInWindow.obj \
+ $O\LZOutWindow.obj \
+
+LZMA_OPT_OBJS = \
+ $O\LZMADecoder.obj \
+ $O\LZMAEncoder.obj \
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(CONSOLE_OBJS) \
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(UI_COMMON_OBJS) \
+ $(AR_COMMON_OBJS) \
+ $(7Z_OBJS) \
+ $(BRANCH_OPT_OBJS) \
+ $(LZ_OBJS) \
+ $(LZMA_OPT_OBJS) \
+ $O\CopyCoder.obj \
+ $O\MT.obj \
+ $O\RangeCoderBit.obj \
+ $O\resource.res
+
+
+!include "../../../Build.mak"
+
+$(CONSOLE_OBJS): ../../UI/Console/$(*B).cpp
+ $(COMPL)
+
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(WIN_OBJS): ../../../Windows/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(UI_COMMON_OBJS): ../../UI/Common/$(*B).cpp
+ $(COMPL)
+$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
+ $(COMPL)
+
+$(7Z_OBJS): ../../Archive/7z/$(*B).cpp
+ $(COMPL)
+$(BRANCH_OPT_OBJS): ../../Compress/Branch/$(*B).cpp
+ $(COMPL_O2)
+$(LZ_OBJS): ../../Compress/LZ/$(*B).cpp
+ $(COMPL)
+$(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp
+ $(COMPL_O2)
+$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
+ $(COMPL)
+$O\MT.obj: ../../Compress/LZ/MT/$(*B).cpp
+ $(COMPL_O2)
+$O\RangeCoderBit.obj: ../../Compress/RangeCoder/$(*B).cpp
+ $(COMPL)
diff --git a/7zip/Bundles/Alone7z/resource.rc b/7zip/Bundles/Alone7z/resource.rc
new file mode 100755
index 00000000..fc9063c1
--- /dev/null
+++ b/7zip/Bundles/Alone7z/resource.rc
@@ -0,0 +1,3 @@
+#include "../../MyVersionInfo.rc"
+
+MY_VERSION_INFO_APP("7-Zip Standalone Console", "7za")
diff --git a/7zip/Bundles/SFXCon/SFXCon.dsp b/7zip/Bundles/SFXCon/SFXCon.dsp
index c6859282..2cc0dca5 100755
--- a/7zip/Bundles/SFXCon/SFXCon.dsp
+++ b/7zip/Bundles/SFXCon/SFXCon.dsp
@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "COMPRESS_BCJ2" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "EXTRACT_ONLY" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_COPY" /D "COMPRESS_PPMD" /D "_SFX" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "COMPRESS_BCJ2" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "EXTRACT_ONLY" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_COPY" /D "COMPRESS_PPMD" /D "_SFX" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
diff --git a/7zip/Bundles/SFXSetup/Main.cpp b/7zip/Bundles/SFXSetup/Main.cpp
index b53b4243..72cae080 100755
--- a/7zip/Bundles/SFXSetup/Main.cpp
+++ b/7zip/Bundles/SFXSetup/Main.cpp
@@ -118,14 +118,29 @@ public:
{ return BOOLToBool(::SetCurrentDirectory(m_CurrentDirectory)); }
};
+#ifndef _UNICODE
+bool g_IsNT = false;
+static inline bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
+
int APIENTRY WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
- InitCommonControls();
g_hInstance = (HINSTANCE)hInstance;
+ #ifndef _UNICODE
+ g_IsNT = IsItWindowsNT();
+ #endif
+ InitCommonControls();
UString archiveName, switches;
NCommandLineParser::SplitCommandLine(GetCommandLineW(), archiveName, switches);
diff --git a/7zip/Bundles/SFXWin/Main.cpp b/7zip/Bundles/SFXWin/Main.cpp
index 60807a3b..59c2d1dc 100755
--- a/7zip/Bundles/SFXWin/Main.cpp
+++ b/7zip/Bundles/SFXWin/Main.cpp
@@ -19,6 +19,17 @@
#include "../../UI/GUI/ExtractGUI.h"
HINSTANCE g_hInstance;
+#ifndef _UNICODE
+bool g_IsNT = false;
+static inline bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
int APIENTRY WinMain(
HINSTANCE hInstance,
@@ -27,6 +38,10 @@ int APIENTRY WinMain(
int nCmdShow)
{
g_hInstance = (HINSTANCE)hInstance;
+ #ifndef _UNICODE
+ g_IsNT = IsItWindowsNT();
+ #endif
+
UString password;
bool assumeYes = false;
bool outputFolderDefined = false;
diff --git a/7zip/Bundles/SFXWin/SFXWin.dsp b/7zip/Bundles/SFXWin/SFXWin.dsp
index ca9ce881..d3ae57e5 100755
--- a/7zip/Bundles/SFXWin/SFXWin.dsp
+++ b/7zip/Bundles/SFXWin/SFXWin.dsp
@@ -44,7 +44,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "EXTRACT_ONLY" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_PPMD" /D "_SFX" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "EXTRACT_ONLY" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_PPMD" /D "_SFX" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
diff --git a/7zip/Common/InBuffer.cpp b/7zip/Common/InBuffer.cpp
index cbc4608b..02f2adfa 100755
--- a/7zip/Common/InBuffer.cpp
+++ b/7zip/Common/InBuffer.cpp
@@ -23,13 +23,13 @@ bool CInBuffer::Create(UInt32 bufferSize)
return true;
Free();
_bufferSize = bufferSize;
- _bufferBase = (Byte *)::BigAlloc(bufferSize);
+ _bufferBase = (Byte *)::MidAlloc(bufferSize);
return (_bufferBase != 0);
}
void CInBuffer::Free()
{
- BigFree(_bufferBase);
+ ::MidFree(_bufferBase);
_bufferBase = 0;
}
diff --git a/7zip/Common/OutBuffer.cpp b/7zip/Common/OutBuffer.cpp
index 2d4871f5..f4ec1a30 100755
--- a/7zip/Common/OutBuffer.cpp
+++ b/7zip/Common/OutBuffer.cpp
@@ -15,13 +15,13 @@ bool COutBuffer::Create(UInt32 bufferSize)
return true;
Free();
_bufferSize = bufferSize;
- _buffer = (Byte *)::BigAlloc(bufferSize);
+ _buffer = (Byte *)::MidAlloc(bufferSize);
return (_buffer != 0);
}
void COutBuffer::Free()
{
- BigFree(_buffer);
+ ::MidFree(_buffer);
_buffer = 0;
}
diff --git a/7zip/Compress/BZip2/DllExports.cpp b/7zip/Compress/BZip2/DllExports.cpp
index 1f28a07c..d0b8b99e 100755
--- a/7zip/Compress/BZip2/DllExports.cpp
+++ b/7zip/Compress/BZip2/DllExports.cpp
@@ -4,6 +4,9 @@
#include "Common/MyInitGuid.h"
#include "Common/ComTry.h"
+#ifdef _WIN32
+#include "Common/Alloc.h"
+#endif
#include "BZip2Encoder.h"
#include "BZip2Decoder.h"
@@ -19,6 +22,10 @@ DEFINE_GUID(CLSID_CCompressBZip2Encoder,
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
+ #ifdef _WIN32
+ if (dwReason == DLL_PROCESS_ATTACH)
+ SetLargePageSize();
+ #endif
return TRUE;
}
diff --git a/7zip/Compress/Branch/x86_2.cpp b/7zip/Compress/Branch/x86_2.cpp
index 00f1ea7a..8f7bff21 100755
--- a/7zip/Compress/Branch/x86_2.cpp
+++ b/7zip/Compress/Branch/x86_2.cpp
@@ -31,7 +31,7 @@ bool CBCJ2_x86_Encoder::Create()
return false;
if (_buffer == 0)
{
- _buffer = (Byte *)BigAlloc(kBufferSize);
+ _buffer = (Byte *)MidAlloc(kBufferSize);
if (_buffer == 0)
return false;
}
@@ -40,7 +40,7 @@ bool CBCJ2_x86_Encoder::Create()
CBCJ2_x86_Encoder::~CBCJ2_x86_Encoder()
{
- BigFree(_buffer);
+ ::MidFree(_buffer);
}
HRESULT CBCJ2_x86_Encoder::Flush()
diff --git a/7zip/Compress/Copy/CopyCoder.cpp b/7zip/Compress/Copy/CopyCoder.cpp
index dac68711..ab81ba29 100755
--- a/7zip/Compress/Copy/CopyCoder.cpp
+++ b/7zip/Compress/Copy/CopyCoder.cpp
@@ -12,7 +12,7 @@ static const UInt32 kBufferSize = 1 << 17;
CCopyCoder::~CCopyCoder()
{
- BigFree(_buffer);
+ ::MidFree(_buffer);
}
STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
@@ -22,7 +22,7 @@ STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
{
if (_buffer == 0)
{
- _buffer = (Byte *)BigAlloc(kBufferSize);
+ _buffer = (Byte *)::MidAlloc(kBufferSize);
if (_buffer == 0)
return E_OUTOFMEMORY;
}
diff --git a/7zip/Compress/Deflate/DeflateEncoder.cpp b/7zip/Compress/Deflate/DeflateEncoder.cpp
index e2d55cd9..ce21d042 100755
--- a/7zip/Compress/Deflate/DeflateEncoder.cpp
+++ b/7zip/Compress/Deflate/DeflateEncoder.cpp
@@ -116,12 +116,11 @@ HRESULT CCoder::Create()
kNumOpts + kNumGoodBacks, m_NumFastBytes, m_MatchMaxLen - m_NumFastBytes));
if (!m_OutStream.Create(1 << 20))
return E_OUTOFMEMORY;
- m_MatchLengthEdge = m_NumFastBytes + 1;
Free();
if (m_NumPasses > 1)
{
- m_OnePosMatchesMemory = (UInt16 *)BigAlloc(kNumGoodBacks * (m_NumFastBytes + 1) * sizeof(UInt16));
+ m_OnePosMatchesMemory = (UInt16 *)::MidAlloc(kNumGoodBacks * (m_NumFastBytes + 1) * sizeof(UInt16));
if (m_OnePosMatchesMemory == 0)
return E_OUTOFMEMORY;
m_OnePosMatchesArray = (COnePosMatches *)MyAlloc(kNumGoodBacks * sizeof(COnePosMatches));
@@ -177,7 +176,7 @@ void CCoder::Free()
{
if (m_NumPasses > 1)
{
- BigFree(m_OnePosMatchesMemory);
+ ::MidFree(m_OnePosMatchesMemory);
MyFree(m_OnePosMatchesArray);
}
else
@@ -308,7 +307,7 @@ UInt32 CCoder::GetOptimal(UInt32 &backRes)
if(lenMain < kMatchMinLen)
return 1;
- if(lenMain >= m_MatchLengthEdge)
+ if(lenMain > m_NumFastBytes)
{
backRes = backMain;
MovePos(lenMain - 1);
@@ -337,7 +336,7 @@ UInt32 CCoder::GetOptimal(UInt32 &backRes)
return Backward(backRes, cur);
GetBacks(UInt32(m_BlockStartPostion + m_CurrentBlockUncompressedSize + cur));
UInt32 newLen = m_LongestMatchLength;
- if(newLen >= m_MatchLengthEdge)
+ if(newLen > m_NumFastBytes)
return Backward(backRes, cur);
UInt32 curPrice = m_Optimum[cur].Price;
diff --git a/7zip/Compress/Deflate/DeflateEncoder.h b/7zip/Compress/Deflate/DeflateEncoder.h
index d1d06311..57d86b2f 100755
--- a/7zip/Compress/Deflate/DeflateEncoder.h
+++ b/7zip/Compress/Deflate/DeflateEncoder.h
@@ -77,7 +77,6 @@ class CCoder
UInt16 *m_MatchDistances;
UInt32 m_NumFastBytes;
- UInt32 m_MatchLengthEdge;
Byte m_LiteralPrices[256];
diff --git a/7zip/Compress/LZMA/DllExports.cpp b/7zip/Compress/LZMA/DllExports.cpp
index 81c75007..efd28a46 100755
--- a/7zip/Compress/LZMA/DllExports.cpp
+++ b/7zip/Compress/LZMA/DllExports.cpp
@@ -4,6 +4,9 @@
#include "../../../Common/MyInitGuid.h"
#include "../../../Common/ComTry.h"
+#ifdef _WIN32
+#include "../../../Common/Alloc.h"
+#endif
#include "LZMAEncoder.h"
#include "LZMADecoder.h"
@@ -20,8 +23,14 @@ DEFINE_GUID(CLSID_CLZMAEncoder,
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
- // NCompress::NRangeCoder::g_PriceTables.Init();
- // CCRC::InitTable();
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ // NCompress::NRangeCoder::g_PriceTables.Init();
+ // CCRC::InitTable();
+ #ifdef _WIN32
+ SetLargePageSize();
+ #endif
+ }
return TRUE;
}
diff --git a/7zip/Compress/LZMA/LZMAEncoder.cpp b/7zip/Compress/LZMA/LZMAEncoder.cpp
index 447130e0..a88020f6 100755
--- a/7zip/Compress/LZMA/LZMAEncoder.cpp
+++ b/7zip/Compress/LZMA/LZMAEncoder.cpp
@@ -342,7 +342,7 @@ HRESULT CEncoder::Create()
if (_dictionarySize == _dictionarySizePrev && _numFastBytesPrev == _numFastBytes)
return S_OK;
RINOK(_matchFinder->Create(_dictionarySize, kNumOpts, _numFastBytes,
- kMatchMaxLen - _numFastBytes));
+ kMatchMaxLen * 2 + 1 - _numFastBytes));
_dictionarySizePrev = _dictionarySize;
_numFastBytesPrev = _numFastBytes;
return S_OK;
@@ -614,13 +614,20 @@ inline UInt32 GetMatchLen(const Byte *data, UInt32 back, UInt32 limit)
}
*/
+
+/*
+Out:
+ (lenRes == 1) && (backRes == 0xFFFFFFFF) means Literal
+*/
+
HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
{
if(_optimumEndIndex != _optimumCurrentIndex)
{
- lenRes = _optimum[_optimumCurrentIndex].PosPrev - _optimumCurrentIndex;
- backRes = _optimum[_optimumCurrentIndex].BackPrev;
- _optimumCurrentIndex = _optimum[_optimumCurrentIndex].PosPrev;
+ const COptimal &optimum = _optimum[_optimumCurrentIndex];
+ lenRes = optimum.PosPrev - _optimumCurrentIndex;
+ backRes = optimum.BackPrev;
+ _optimumCurrentIndex = optimum.PosPrev;
return S_OK;
}
_optimumCurrentIndex = 0;
@@ -649,14 +656,14 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
if (i == 0 || repLens[i] > repLens[repMaxIndex])
repMaxIndex = i;
}
- if(repLens[repMaxIndex] > _numFastBytes)
+ if(repLens[repMaxIndex] >= _numFastBytes)
{
backRes = repMaxIndex;
lenRes = repLens[repMaxIndex];
return MovePos(lenRes - 1);
}
- if(lenMain > _numFastBytes)
+ if(lenMain >= _numFastBytes)
{
backRes = _matchDistances[_numFastBytes] + kNumRepDistances;
lenRes = lenMain;
@@ -752,15 +759,16 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
return S_OK;
}
position++;
- UInt32 posPrev = _optimum[cur].PosPrev;
+ COptimal &curOptimum = _optimum[cur];
+ UInt32 posPrev = curOptimum.PosPrev;
CState state;
- if (_optimum[cur].Prev1IsChar)
+ if (curOptimum.Prev1IsChar)
{
posPrev--;
- if (_optimum[cur].Prev2)
+ if (curOptimum.Prev2)
{
- state = _optimum[_optimum[cur].PosPrev2].State;
- if (_optimum[cur].BackPrev2 < kNumRepDistances)
+ state = _optimum[curOptimum.PosPrev2].State;
+ if (curOptimum.BackPrev2 < kNumRepDistances)
state.UpdateRep();
else
state.UpdateMatch();
@@ -773,12 +781,12 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
state = _optimum[posPrev].State;
if (posPrev == cur - 1)
{
- if (_optimum[cur].IsShortRep())
+ if (curOptimum.IsShortRep())
state.UpdateShortRep();
else
state.UpdateChar();
/*
- if (_optimum[cur].Prev1IsChar)
+ if (curOptimum.Prev1IsChar)
for(int i = 0; i < kNumRepDistances; i++)
reps[i] = _optimum[posPrev].Backs[i];
*/
@@ -786,49 +794,50 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
else
{
UInt32 pos;
- if (_optimum[cur].Prev1IsChar && _optimum[cur].Prev2)
+ if (curOptimum.Prev1IsChar && curOptimum.Prev2)
{
- posPrev = _optimum[cur].PosPrev2;
- pos = _optimum[cur].BackPrev2;
+ posPrev = curOptimum.PosPrev2;
+ pos = curOptimum.BackPrev2;
state.UpdateRep();
}
else
{
- pos = _optimum[cur].BackPrev;
+ pos = curOptimum.BackPrev;
if (pos < kNumRepDistances)
state.UpdateRep();
else
state.UpdateMatch();
}
+ const COptimal &prevOptimum = _optimum[posPrev];
if (pos < kNumRepDistances)
{
- reps[0] = _optimum[posPrev].Backs[pos];
+ reps[0] = prevOptimum.Backs[pos];
UInt32 i;
for(i = 1; i <= pos; i++)
- reps[i] = _optimum[posPrev].Backs[i - 1];
+ reps[i] = prevOptimum.Backs[i - 1];
for(; i < kNumRepDistances; i++)
- reps[i] = _optimum[posPrev].Backs[i];
+ reps[i] = prevOptimum.Backs[i];
}
else
{
reps[0] = (pos - kNumRepDistances);
for(UInt32 i = 1; i < kNumRepDistances; i++)
- reps[i] = _optimum[posPrev].Backs[i - 1];
+ reps[i] = prevOptimum.Backs[i - 1];
}
}
- _optimum[cur].State = state;
+ curOptimum.State = state;
for(UInt32 i = 0; i < kNumRepDistances; i++)
- _optimum[cur].Backs[i] = reps[i];
+ curOptimum.Backs[i] = reps[i];
UInt32 newLen;
RINOK(ReadMatchDistances(newLen));
- if(newLen > _numFastBytes)
+ if(newLen >= _numFastBytes)
{
_longestMatchLength = newLen;
_longestMatchWasFound = true;
lenRes = Backward(backRes, cur);
return S_OK;
}
- UInt32 curPrice = _optimum[cur].Price;
+ UInt32 curPrice = curOptimum.Price;
// Byte currentByte = _matchFinder->GetIndexByte(0 - 1);
// Byte matchByte = _matchFinder->GetIndexByte(0 - reps[0] - 1 - 1);
const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1;
@@ -872,8 +881,9 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
continue;
*/
- UInt32 numAvailableBytes = _matchFinder->GetNumAvailableBytes() + 1;
- numAvailableBytes = MyMin(kNumOpts - 1 - cur, numAvailableBytes);
+ UInt32 numAvailableBytesFull = _matchFinder->GetNumAvailableBytes() + 1;
+ numAvailableBytesFull = MyMin(kNumOpts - 1 - cur, numAvailableBytesFull);
+ UInt32 numAvailableBytes = numAvailableBytesFull;
if (numAvailableBytes < 2)
continue;
@@ -881,6 +891,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
numAvailableBytes = _numFastBytes;
if (numAvailableBytes >= 3 && !nextIsChar)
{
+ // try Literal + rep0
UInt32 backOffset = reps[0] + 1;
UInt32 temp;
for (temp = 1; temp < numAvailableBytes; temp++)
@@ -917,11 +928,15 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
{
// UInt32 repLen = _matchFinder->GetMatchLen(0 - 1, reps[repIndex], newLen); // test it;
UInt32 backOffset = reps[repIndex] + 1;
+ if (data[0] != data[(size_t)0 - backOffset] ||
+ data[1] != data[(size_t)1 - backOffset])
+ continue;
UInt32 lenTest;
- for (lenTest = 0; lenTest < numAvailableBytes; lenTest++)
+ for (lenTest = 2; lenTest < numAvailableBytes; lenTest++)
if (data[lenTest] != data[(size_t)lenTest - backOffset])
break;
- for(; lenTest >= 2; lenTest--)
+ UInt32 lenTestTemp = lenTest;
+ do
{
while(lenEnd < cur + lenTest)
_optimum[++lenEnd].Price = kIfinityPrice;
@@ -934,21 +949,25 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
optimum.BackPrev = repIndex;
optimum.Prev1IsChar = false;
}
+ }
+ while(--lenTest >= 2);
+ lenTest = lenTestTemp;
- /*
if (_maxMode)
{
- UInt32 temp;
- for (temp = lenTest + 1; temp < numAvailableBytes; temp++)
- if (data[temp] != data[(size_t)temp - backOffset])
+ UInt32 lenTest2 = lenTest + 1;
+ UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
+ for (; lenTest2 < limit; lenTest2++)
+ if (data[lenTest2] != data[(size_t)lenTest2 - backOffset])
break;
- UInt32 lenTest2 = temp - (lenTest + 1);
+ lenTest2 -= lenTest + 1;
if (lenTest2 >= 2)
{
CState state2 = state;
state2.UpdateRep();
UInt32 posStateNext = (position + lenTest) & _posStateMask;
- UInt32 curAndLenCharPrice = curAndLenPrice +
+ UInt32 curAndLenCharPrice =
+ repMatchPrice + GetRepPrice(repIndex, lenTest, state, posState) +
_isMatch[state2.Index][posStateNext].GetPrice0() +
_literalEncoder.GetPrice(position + lenTest, data[(size_t)lenTest - 1],
true, data[(size_t)lenTest - backOffset], data[lenTest]);
@@ -978,9 +997,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
}
}
}
- */
}
- }
// for(UInt32 lenTest = 2; lenTest <= newLen; lenTest++)
if (newLen > numAvailableBytes)
@@ -1007,14 +1024,16 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
optimum.Prev1IsChar = false;
}
- if (_maxMode)
+ if (_maxMode && (lenTest == newLen || curBack != _matchDistances[lenTest + 1]))
{
+ // Try Match + Literal + Rep0
UInt32 backOffset = curBack + 1;
- UInt32 temp;
- for (temp = lenTest + 1; temp < numAvailableBytes; temp++)
- if (data[temp] != data[(size_t)temp - backOffset])
+ UInt32 lenTest2 = lenTest + 1;
+ UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
+ for (; lenTest2 < limit; lenTest2++)
+ if (data[lenTest2] != data[(size_t)lenTest2 - backOffset])
break;
- UInt32 lenTest2 = temp - (lenTest + 1);
+ lenTest2 -= lenTest + 1;
if (lenTest2 >= 2)
{
CState state2 = state;
@@ -1247,9 +1266,9 @@ HRESULT CEncoder::SetStreams(ISequentialInStream *inStream,
FillAlignPrices();
}
- _lenEncoder.SetTableSize(_numFastBytes);
+ _lenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);
_lenEncoder.UpdateTables(1 << _posStateBits);
- _repMatchLenEncoder.SetTableSize(_numFastBytes);
+ _repMatchLenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);
_repMatchLenEncoder.UpdateTables(1 << _posStateBits);
lastPosSlotFillingPos = 0;
diff --git a/7zip/Compress/PPMD/DllExports.cpp b/7zip/Compress/PPMD/DllExports.cpp
index 61f528f4..f8eb1310 100755
--- a/7zip/Compress/PPMD/DllExports.cpp
+++ b/7zip/Compress/PPMD/DllExports.cpp
@@ -4,6 +4,9 @@
#include "Common/MyInitGuid.h"
#include "Common/ComTry.h"
+#ifdef _WIN32
+#include "Common/Alloc.h"
+#endif
#include "PPMDEncoder.h"
#include "PPMDDecoder.h"
@@ -19,6 +22,10 @@ DEFINE_GUID(CLSID_CCompressPPMDEncoder,
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
+ #ifdef _WIN32
+ if (dwReason == DLL_PROCESS_ATTACH)
+ SetLargePageSize();
+ #endif
return TRUE;
}
diff --git a/7zip/Compress/Rar29/makefile b/7zip/Compress/Rar29/makefile
index 19082cb9..12fc22b1 100755
--- a/7zip/Compress/Rar29/makefile
+++ b/7zip/Compress/Rar29/makefile
@@ -1,6 +1,6 @@
PROG = Rar29.dll
DEF_FILE = ../Codec.def
-CFLAGS = $(CFLAGS) -I ../../../
+CFLAGS = $(CFLAGS) -I ../../../ -DSILENT -DNOCRYPT -DNOVOLUME
LIBS = $(LIBS) oleaut32.lib
RAR29_OBJS = \
@@ -46,7 +46,7 @@ OBJS = \
!include "../../../Build.mak"
-COMPL_SPEC = $(CPP) $(CFLAGS_O2) -DSILENT -DNOCRYPT -DNOVOLUME $**
+COMPL_SPEC = $(CPP) $(CFLAGS_O2) $**
$(RAR29_OBJS): $(*B).cpp
$(COMPL)
diff --git a/7zip/Crypto/7zAES/DllExports.cpp b/7zip/Crypto/7zAES/DllExports.cpp
index 907b74df..3de7078e 100755
--- a/7zip/Crypto/7zAES/DllExports.cpp
+++ b/7zip/Crypto/7zAES/DllExports.cpp
@@ -21,12 +21,28 @@ DEFINE_GUID(CLSID_CCrypto7zAESDecoder,
0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00);
HINSTANCE g_hInstance;
+#ifndef _UNICODE
+bool g_IsNT = false;
+static bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
+ {
g_hInstance = hInstance;
+ #ifndef _UNICODE
+ g_IsNT = IsItWindowsNT();
+ #endif
+ }
return TRUE;
}
diff --git a/7zip/FileManager/App.cpp b/7zip/FileManager/App.cpp
index c85d4cef..10e2b850 100755
--- a/7zip/FileManager/App.cpp
+++ b/7zip/FileManager/App.cpp
@@ -114,10 +114,8 @@ void CApp::CreateOnePanel(int panelIndex, const UString &mainPath)
UString path;
if (mainPath.IsEmpty())
{
- CSysString sysPath;
- if (!::ReadPanelPath(panelIndex, sysPath))
- sysPath.Empty();
- path = GetUnicodeString(sysPath);
+ if (!::ReadPanelPath(panelIndex, path))
+ path.Empty();
}
else
path = mainPath;
@@ -165,8 +163,7 @@ struct CButtonInfo
UINT Bitmap2ResID;
UINT StringResID;
UINT32 LangID;
- CSysString GetText()const
- { return LangLoadString(StringResID, LangID); };
+ UString GetText()const { return LangString(StringResID, LangID); };
};
static CButtonInfo g_StandardButtons[] =
@@ -184,7 +181,7 @@ static CButtonInfo g_ArchiveButtons[] =
{ kTestCommand , IDB_TEST, IDB_TEST2, IDS_TEST, 0x03020402}
};
-bool SetButtonText(UINT32 commandID, CButtonInfo *buttons, int numButtons, CSysString &s)
+bool SetButtonText(UINT32 commandID, CButtonInfo *buttons, int numButtons, UString &s)
{
for (int i = 0; i < numButtons; i++)
{
@@ -192,19 +189,19 @@ bool SetButtonText(UINT32 commandID, CButtonInfo *buttons, int numButtons, CSysS
if (b.commandID == commandID)
{
s = b.GetText();
- return true;
+ return true;
}
}
return false;
}
-void SetButtonText(UINT32 commandID, CSysString &s)
+void SetButtonText(UINT32 commandID, UString &s)
{
- if (SetButtonText(commandID, g_StandardButtons, sizeof(g_StandardButtons) /
- sizeof(g_StandardButtons[0]), s))
+ if (SetButtonText(commandID, g_StandardButtons,
+ sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]), s))
return;
- SetButtonText(commandID, g_ArchiveButtons, sizeof(g_StandardButtons) /
- sizeof(g_ArchiveButtons[0]), s);
+ SetButtonText(commandID, g_ArchiveButtons,
+ sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]), s);
}
static void AddButton(
@@ -223,10 +220,10 @@ static void AddButton(
;
but.dwData = 0;
- CSysString s = butInfo.GetText();
+ UString s = butInfo.GetText();
but.iString = 0;
if (showText)
- but.iString = (INT_PTR )(LPCTSTR)s;
+ but.iString = (INT_PTR)(LPCWSTR)s;
but.iBitmap = imageList.GetImageCount();
HBITMAP b = ::LoadBitmap(g_hInstance,
@@ -238,7 +235,11 @@ static void AddButton(
imageList.AddMasked(b, RGB(255, 0, 255));
::DeleteObject(b);
}
+ #ifdef _UNICODE
toolBar.AddButton(1, &but);
+ #else
+ toolBar.AddButtonW(1, &but);
+ #endif
}
static void AddBand(NControl::CReBar &reBar, NControl::CToolBar &toolBar)
@@ -402,7 +403,7 @@ void CApp::Save()
path = panel._currentFolderPrefix;
else
path = GetFolderPath(panel._parentFolders[0].ParentFolder);
- SavePanelPath(i, GetSystemString(path));
+ SavePanelPath(i, path);
listMode.Panels[i] = panel.GetListViewMode();
}
SaveListMode(listMode);
@@ -473,7 +474,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
if (!srcPanel.DoesItSupportOperations())
{
- srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
@@ -511,11 +512,11 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
copyDialog.Value = destPath;
copyDialog.Title = move ?
- LangLoadStringW(IDS_MOVE, 0x03020202):
- LangLoadStringW(IDS_COPY, 0x03020201);
+ LangString(IDS_MOVE, 0x03020202):
+ LangString(IDS_COPY, 0x03020201);
copyDialog.Static = move ?
- LangLoadStringW(IDS_MOVE_TO, 0x03020204):
- LangLoadStringW(IDS_COPY_TO, 0x03020203);
+ LangString(IDS_MOVE_TO, 0x03020204):
+ LangString(IDS_COPY_TO, 0x03020203);
if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
return;
@@ -526,7 +527,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
{
if (!srcPanel.IsFSFolder())
{
- srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
destPath = srcPanel._currentFolderPrefix + destPath;
@@ -541,7 +542,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
{
if (NumPanels < 2 || destPath != destPanel._currentFolderPrefix || !destPanel.DoesItSupportOperations())
{
- srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
useDestPanel = true;
@@ -556,7 +557,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
NDirectory::CreateComplexDirectory(prefix);
if (!CheckFolderPath(prefix))
{
- srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
}
@@ -705,7 +706,8 @@ int CApp::GetFocusedPanelIndex() const
}
*/
-static CSysString g_ToolTipBuffer;
+static UString g_ToolTipBuffer;
+static CSysString g_ToolTipBufferSys;
void CApp::OnNotify(int ctrlID, LPNMHDR pnmh)
{
@@ -729,8 +731,20 @@ void CApp::OnNotify(int ctrlID, LPNMHDR pnmh)
info->hinst = 0;
g_ToolTipBuffer.Empty();
SetButtonText(info->hdr.idFrom, g_ToolTipBuffer);
- info->lpszText = (LPTSTR)(LPCTSTR)g_ToolTipBuffer;
+ g_ToolTipBufferSys = GetSystemString(g_ToolTipBuffer);
+ info->lpszText = (LPTSTR)(LPCTSTR)g_ToolTipBufferSys;
+ return;
+ }
+ #ifndef _UNICODE
+ if (pnmh->code == TTN_GETDISPINFOW)
+ {
+ LPNMTTDISPINFOW info = (LPNMTTDISPINFOW)pnmh;
+ info->hinst = 0;
+ g_ToolTipBuffer.Empty();
+ SetButtonText(info->hdr.idFrom, g_ToolTipBuffer);
+ info->lpszText = (LPWSTR)(LPCWSTR)g_ToolTipBuffer;
return;
}
+ #endif
}
}
diff --git a/7zip/FileManager/ExtractCallback.h b/7zip/FileManager/ExtractCallback.h
index 9a1fc003..9159e4f8 100755
--- a/7zip/FileManager/ExtractCallback.h
+++ b/7zip/FileManager/ExtractCallback.h
@@ -82,8 +82,6 @@ public:
#endif
private:
- // CSysString _directoryPath;
- // CSysString m_DiskFilePath;
// bool _extractMode;
UString _currentArchivePath;
bool _needWriteArchivePath;
diff --git a/7zip/FileManager/FM.cpp b/7zip/FileManager/FM.cpp
index 704364c6..3ff56736 100755
--- a/7zip/FileManager/FM.cpp
+++ b/7zip/FileManager/FM.cpp
@@ -11,6 +11,9 @@
#include "Windows/Control/Toolbar.h"
#include "Windows/Error.h"
#include "Windows/COM.h"
+#include "Windows/DLL.h"
+#include "Windows/Security.h"
+#include "Windows/MemoryLock.h"
#include "ViewSettings.h"
@@ -19,6 +22,7 @@
#include "MyLoadMenu.h"
#include "LangUtils.h"
+#include "RegistryUtils.h"
using namespace NWindows;
@@ -28,6 +32,9 @@ using namespace NWindows;
#define MENU_HEIGHT 26
+#ifndef _UNICODE
+bool g_IsNT = false;
+#endif
HINSTANCE g_hInstance;
HWND g_HWND;
static UString g_MainPath;
@@ -39,17 +46,17 @@ int kSplitterRateMax = 1 << 16;
// bool OnMenuCommand(HWND hWnd, int id);
-static CSysString GetProgramPath()
+static UString GetProgramPath()
{
- TCHAR fullPath[MAX_PATH + 1];
- ::GetModuleFileName(g_hInstance, fullPath, MAX_PATH);
- return fullPath;
+ UString s;
+ NDLL::MyGetModuleFileName(g_hInstance, s);
+ return s;
}
-CSysString GetProgramFolderPrefix()
+UString GetProgramFolderPrefix()
{
- CSysString path = GetProgramPath();
- int pos = path.ReverseFind(TEXT('\\'));
+ UString path = GetProgramPath();
+ int pos = path.ReverseFind(L'\\');
return path.Left(pos + 1);
}
@@ -117,12 +124,21 @@ void OnSize(HWND hWnd);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
-// FUNCTION: InitInstance(HANDLE, int)
+const wchar_t *kWindowClass = L"FM";
+
+static bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+
+ // FUNCTION: InitInstance(HANDLE, int)
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
- HWND hWnd = NULL;
- TCHAR windowClass[MAX_LOADSTRING]; // The window class name
- lstrcpy(windowClass, TEXT("FM"));
+ CWindow wnd;
g_hInstance = hInstance;
@@ -131,7 +147,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
// LoadString(hInstance, IDS_CLASS, windowClass, MAX_LOADSTRING);
// LoadString(hInstance, IDS_APP_TITLE, title, MAX_LOADSTRING);
- UString title = LangLoadStringW(IDS_APP_TITLE, 0x03000000);
+ UString title = LangString(IDS_APP_TITLE, 0x03000000);
/*
//If it is already running, then focus on the window
@@ -143,7 +159,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
}
*/
- WNDCLASS wc;
+ WNDCLASSW wc;
// wc.style = CS_HREDRAW | CS_VREDRAW;
wc.style = 0;
@@ -158,10 +174,10 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
// wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
- wc.lpszMenuName = MAKEINTRESOURCE(IDM_MENU);
- wc.lpszClassName = windowClass;
+ wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MENU);
+ wc.lpszClassName = kWindowClass;
- RegisterClass(&wc);
+ MyRegisterClass(&wc);
// RECT rect;
// GetClientRect(hWnd, &rect);
@@ -200,17 +216,14 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
g_App.NumPanels = numPanels;
g_App.LastFocusedPanel = currentPanel;
- hWnd = CreateWindow(windowClass, GetSystemString(title), style,
- x, y, xSize, ySize, NULL, NULL, hInstance, NULL);
- if (!hWnd)
- return FALSE;
- g_HWND = hWnd;
-
- CWindow window(hWnd);
+ if (!wnd.Create(kWindowClass, title, style,
+ x, y, xSize, ySize, NULL, NULL, hInstance, NULL))
+ return FALSE;
+ g_HWND = (HWND)wnd;
WINDOWPLACEMENT placement;
placement.length = sizeof(placement);
- if (window.GetPlacement(&placement))
+ if (wnd.GetPlacement(&placement))
{
if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW ||
nCmdShow == SW_SHOWDEFAULT)
@@ -224,11 +237,11 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
placement.showCmd = nCmdShow;
if (windowPosIsRead)
placement.rcNormalPosition = rect;
- window.SetPlacement(&placement);
+ wnd.SetPlacement(&placement);
// window.Show(nCmdShow);
}
else
- window.Show(nCmdShow);
+ wnd.Show(nCmdShow);
return TRUE;
}
@@ -295,11 +308,65 @@ DWORD GetDllVersion(LPCTSTR lpszDllName)
DWORD g_ComCtl32Version;
+/*
+#ifndef _WIN64
+typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
+
+static bool IsWow64()
+{
+ LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
+ GetModuleHandle("kernel32"), "IsWow64Process");
+ if (fnIsWow64Process == NULL)
+ return false;
+ BOOL isWow;
+ if (!fnIsWow64Process(GetCurrentProcess(),&isWow))
+ return false;
+ return isWow != FALSE;
+}
+#endif
+*/
+
+bool IsLargePageSupported()
+{
+ #ifdef _WIN64
+ return true;
+ #else
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ if (versionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || versionInfo.dwMajorVersion < 5)
+ return false;
+ if (versionInfo.dwMajorVersion > 5)
+ return true;
+ if (versionInfo.dwMinorVersion < 1)
+ return false;
+ if (versionInfo.dwMinorVersion > 1)
+ return true;
+ // return IsWow64();
+ return false;
+ #endif
+}
+
+static void SetMemoryLock()
+{
+ if (!IsLargePageSupported())
+ return;
+ // if (ReadLockMemoryAdd())
+ NSecurity::AddLockMemoryPrivilege();
+
+ if (ReadLockMemoryEnable())
+ NSecurity::EnableLockMemoryPrivilege();
+}
+
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
+ #ifndef _UNICODE
+ g_IsNT = IsItWindowsNT();
+ #endif
InitCommonControls();
g_ComCtl32Version = ::GetDllVersion(TEXT("comctl32.dll"));
@@ -324,6 +391,7 @@ int WINAPI WinMain( HINSTANCE hInstance,
// MessageBoxW(0, paramString, L"", 0);
}
+ SetMemoryLock();
MSG msg;
if (!InitInstance (hInstance, nCmdShow))
@@ -331,19 +399,34 @@ int WINAPI WinMain( HINSTANCE hInstance,
MyLoadMenu(g_HWND);
- HACCEL hAccels = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));
- while (GetMessage(&msg, NULL, 0, 0))
- {
- if (!TranslateAccelerator(g_HWND, hAccels, &msg))
- {
- // if (g_Hwnd != NULL || !IsDialogMessage(g_Hwnd, &msg))
- // if (!IsDialogMessage(g_Hwnd, &msg))
- {
+ #ifndef _UNICODE
+ if (g_IsNT)
+ {
+ HACCEL hAccels = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR1));
+ while (GetMessageW(&msg, NULL, 0, 0))
+ {
+ if (TranslateAcceleratorW(g_HWND, hAccels, &msg) == 0)
+ {
TranslateMessage(&msg);
- DispatchMessage(&msg);
+ DispatchMessageW(&msg);
}
}
}
+ else
+ #endif
+ {
+ HACCEL hAccels = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));
+ while (GetMessage(&msg, NULL, 0, 0))
+ {
+ if (TranslateAccelerator(g_HWND, hAccels, &msg) == 0)
+ {
+ // if (g_Hwnd != NULL || !IsDialogMessage(g_Hwnd, &msg))
+ // if (!IsDialogMessage(g_Hwnd, &msg))
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ }
g_HWND = 0;
OleUninitialize();
@@ -578,7 +661,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
*/
}
- return DefWindowProc(hWnd, message, wParam, lParam);
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return DefWindowProcW(hWnd, message, wParam, lParam);
+ else
+ #endif
+ return DefWindowProc(hWnd, message, wParam, lParam);
+
}
void OnSize(HWND hWnd)
diff --git a/7zip/FileManager/FM.dsp b/7zip/FileManager/FM.dsp
index 844055d1..d3ae908b 100755
--- a/7zip/FileManager/FM.dsp
+++ b/7zip/FileManager/FM.dsp
@@ -259,6 +259,14 @@ SOURCE=.\NetFolder.h
# End Source File
# Begin Source File
+SOURCE=.\PhysDriveFolder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PhysDriveFolder.h
+# End Source File
+# Begin Source File
+
SOURCE=.\RootFolder.cpp
# End Source File
# Begin Source File
@@ -682,6 +690,14 @@ SOURCE=..\..\Windows\Control\Window2.h
# End Group
# Begin Source File
+SOURCE=..\..\Windows\CommonDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\CommonDialog.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\Windows\Defs.h
# End Source File
# Begin Source File
@@ -706,6 +722,14 @@ SOURCE=..\..\Windows\Error.h
# End Source File
# Begin Source File
+SOURCE=..\..\Windows\FileDevice.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\FileDevice.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\Windows\FileDir.cpp
# End Source File
# Begin Source File
@@ -758,6 +782,18 @@ SOURCE=..\..\Windows\Memory.h
# End Source File
# Begin Source File
+SOURCE=..\..\Windows\MemoryLock.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\MemoryLock.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Menu.cpp
+# End Source File
+# Begin Source File
+
SOURCE=..\..\Windows\Menu.h
# End Source File
# Begin Source File
@@ -806,6 +842,14 @@ SOURCE=..\..\Windows\ResourceString.h
# End Source File
# Begin Source File
+SOURCE=..\..\Windows\Security.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Security.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\Windows\Shell.cpp
# End Source File
# Begin Source File
diff --git a/7zip/FileManager/FSDrives.cpp b/7zip/FileManager/FSDrives.cpp
index 4804a331..cfc1c24c 100755
--- a/7zip/FileManager/FSDrives.cpp
+++ b/7zip/FileManager/FSDrives.cpp
@@ -15,6 +15,7 @@
#include "SysIconUtils.h"
#include "FSFolder.h"
+#include "PhysDriveFolder.h"
#include "LangUtils.h"
using namespace NWindows;
@@ -44,30 +45,26 @@ static const wchar_t *kDriveTypes[] =
L"RAM disk"
};
-static inline UINT GetCurrentFileCodePage()
- { return AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
-
STDMETHODIMP CFSDrives::LoadItems()
{
- UINT fileCodePage = GetCurrentFileCodePage();
_drives.Clear();
- CSysStringVector driveStrings;
+ UStringVector driveStrings;
MyGetLogicalDriveStrings(driveStrings);
for (int i = 0; i < driveStrings.Size(); i++)
{
CDriveInfo driveInfo;
- const CSysString &driveName = driveStrings[i];
+ const UString &driveName = driveStrings[i];
- driveInfo.FullSystemName = GetUnicodeString(driveName, fileCodePage);
+ driveInfo.FullSystemName = driveName;
driveInfo.Name = driveInfo.FullSystemName.Left(
driveInfo.FullSystemName.Length() - 1);
driveInfo.ClusterSize = 0;
driveInfo.DriveSize = 0;
driveInfo.FreeSpace = 0;
- UINT driveType = ::GetDriveType(driveName);
+ UINT driveType = NFile::NSystem::MyGetDriveType(driveName);
if (driveType < sizeof(kDriveTypes) / sizeof(kDriveTypes[0]))
{
driveInfo.Type = kDriveTypes[driveType];
@@ -87,14 +84,14 @@ STDMETHODIMP CFSDrives::LoadItems()
}
if (needRead)
{
- CSysString volumeName, fileSystemName;
+ UString volumeName, fileSystemName;
DWORD volumeSerialNumber, maximumComponentLength, fileSystemFlags;
NFile::NSystem::MyGetVolumeInformation(driveName,
volumeName,
&volumeSerialNumber, &maximumComponentLength, &fileSystemFlags,
fileSystemName);
- driveInfo.VolumeName = GetUnicodeString(volumeName, fileCodePage);
- driveInfo.FileSystemName = GetUnicodeString(fileSystemName, fileCodePage);
+ driveInfo.VolumeName = volumeName;
+ driveInfo.FileSystemName = fileSystemName;
NFile::NSystem::MyGetDiskFreeSpace(driveName,
driveInfo.ClusterSize, driveInfo.DriveSize, driveInfo.FreeSpace);
@@ -105,15 +102,15 @@ STDMETHODIMP CFSDrives::LoadItems()
return S_OK;
}
-STDMETHODIMP CFSDrives::GetNumberOfItems(UINT32 *numItems)
+STDMETHODIMP CFSDrives::GetNumberOfItems(UInt32 *numItems)
{
*numItems = _drives.Size();
return S_OK;
}
-STDMETHODIMP CFSDrives::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT *value)
+STDMETHODIMP CFSDrives::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
{
- if (itemIndex >= (UINT32)_drives.Size())
+ if (itemIndex >= (UInt32)_drives.Size())
return E_INVALIDARG;
NCOM::CPropVariant propVariant;
const CDriveInfo &driveInfo = _drives[itemIndex];
@@ -161,12 +158,22 @@ HRESULT CFSDrives::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultF
return S_OK;
}
-STDMETHODIMP CFSDrives::BindToFolder(UINT32 index, IFolderFolder **resultFolder)
+STDMETHODIMP CFSDrives::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
{
*resultFolder = 0;
- if (index >= (UINT32)_drives.Size())
+ if (index >= (UInt32)_drives.Size())
return E_INVALIDARG;
- return BindToFolderSpec(_drives[index].FullSystemName, resultFolder);
+ const CDriveInfo &driveInfo = _drives[index];
+ if (_volumeMode)
+ {
+ *resultFolder = 0;
+ CPhysDriveFolder *folderSpec = new CPhysDriveFolder;
+ CMyComPtr<IFolderFolder> subFolder = folderSpec;
+ RINOK(folderSpec->Init(driveInfo.Name));
+ *resultFolder = subFolder.Detach();
+ return S_OK;
+ }
+ return BindToFolderSpec(driveInfo.FullSystemName, resultFolder);
}
STDMETHODIMP CFSDrives::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
@@ -185,13 +192,13 @@ STDMETHODIMP CFSDrives::GetName(BSTR *name)
return E_NOTIMPL;
}
-STDMETHODIMP CFSDrives::GetNumberOfProperties(UINT32 *numProperties)
+STDMETHODIMP CFSDrives::GetNumberOfProperties(UInt32 *numProperties)
{
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
return S_OK;
}
-STDMETHODIMP CFSDrives::GetPropertyInfo(UINT32 index,
+STDMETHODIMP CFSDrives::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
@@ -213,18 +220,17 @@ STDMETHODIMP CFSDrives::GetTypeID(BSTR *name)
STDMETHODIMP CFSDrives::GetPath(BSTR *path)
{
- CMyComBSTR temp = (LangLoadStringW(IDS_COMPUTER, 0x03020300)) +
- UString(L'\\');
+ CMyComBSTR temp = LangString(IDS_COMPUTER, 0x03020300) + UString(L'\\');
*path = temp.Detach();
return S_OK;
}
-STDMETHODIMP CFSDrives::GetSystemIconIndex(UINT32 index, INT32 *iconIndex)
+STDMETHODIMP CFSDrives::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
{
*iconIndex = 0;
const CDriveInfo &driveInfo = _drives[index];
int iconIndexTemp;
- if (GetRealIconIndex(GetSystemString(driveInfo.FullSystemName), 0, iconIndexTemp) != 0)
+ if (GetRealIconIndex(driveInfo.FullSystemName, 0, iconIndexTemp) != 0)
{
*iconIndex = iconIndexTemp;
return S_OK;
diff --git a/7zip/FileManager/FSDrives.h b/7zip/FileManager/FSDrives.h
index 8a835f29..496e8fc1 100755
--- a/7zip/FileManager/FSDrives.h
+++ b/7zip/FileManager/FSDrives.h
@@ -4,6 +4,7 @@
#define __FSDRIVES_H
#include "Common/String.h"
+#include "Common/Types.h"
#include "Common/MyCom.h"
#include "Windows/FileFind.h"
#include "Windows/PropVariant.h"
@@ -15,9 +16,9 @@ struct CDriveInfo
UString Name;
UString FullSystemName;
bool KnownSizes;
- UINT64 DriveSize;
- UINT64 FreeSpace;
- UINT64 ClusterSize;
+ UInt64 DriveSize;
+ UInt64 FreeSpace;
+ UInt64 ClusterSize;
UString Type;
UString VolumeName;
UString FileSystemName;
@@ -40,25 +41,26 @@ public:
)
STDMETHOD(LoadItems)();
- STDMETHOD(GetNumberOfItems)(UINT32 *numItems);
- STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value);
- STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder);
+ STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
+ STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value);
+ STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder);
STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder);
STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder);
STDMETHOD(GetName)(BSTR *name);
- STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties);
- STDMETHOD(GetPropertyInfo)(UINT32 index,
+ STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
+ STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetTypeID)(BSTR *name);
STDMETHOD(GetPath)(BSTR *path);
- STDMETHOD(GetSystemIconIndex)(UINT32 index, INT32 *iconIndex);
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
private:
HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
CObjectVector<CDriveInfo> _drives;
+ bool _volumeMode;
public:
- void Init() {}
+ void Init() { _volumeMode = false;}
};
#endif
diff --git a/7zip/FileManager/FSFolder.cpp b/7zip/FileManager/FSFolder.cpp
index e75a73a8..667eee72 100755
--- a/7zip/FileManager/FSFolder.cpp
+++ b/7zip/FileManager/FSFolder.cpp
@@ -37,14 +37,10 @@ static STATPROPSTG kProperties[] =
{ NULL, kpidComment, VT_BSTR}
};
-static inline UINT GetCurrentFileCodePage()
- { return AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
-
HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
{
_parentFolder = parentFolder;
_path = path;
- _fileCodePage = GetCurrentFileCodePage();
if (_findChangeNotification.FindFirst(_path, false,
FILE_NOTIFY_CHANGE_FILE_NAME |
@@ -70,7 +66,7 @@ HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
return S_OK;
}
-static HRESULT GetFolderSize(const UString &path, UINT64 &size, IProgress *progress)
+static HRESULT GetFolderSize(const UString &path, UInt64 &size, IProgress *progress)
{
RINOK(progress->SetCompleted(NULL));
size = 0;
@@ -80,7 +76,7 @@ static HRESULT GetFolderSize(const UString &path, UINT64 &size, IProgress *progr
{
if (fileInfo.IsDirectory())
{
- UINT64 subSize;
+ UInt64 subSize;
RINOK(GetFolderSize(path + UString(L"\\") + fileInfo.Name,
subSize, progress));
size += subSize;
@@ -137,7 +133,7 @@ bool CFSFolder::LoadComments()
return false;
AString s;
char *p = s.GetBuffer((size_t)length + 1);
- UINT32 processedSize;
+ UInt32 processedSize;
file.Read(p, (UInt32)length, processedSize);
p[length] = 0;
s.ReleaseBuffer();
@@ -168,7 +164,7 @@ bool CFSFolder::SaveComments()
_comments.SaveToString(unicodeString);
AString utfString;
ConvertUnicodeToUTF8(unicodeString, utfString);
- UINT32 processedSize;
+ UInt32 processedSize;
if (!IsAscii(unicodeString))
{
Byte bom [] = { 0xEF, 0xBB, 0xBF, 0x0D, 0x0A };
@@ -180,28 +176,28 @@ bool CFSFolder::SaveComments()
return true;
}
-STDMETHODIMP CFSFolder::GetNumberOfItems(UINT32 *numItems)
+STDMETHODIMP CFSFolder::GetNumberOfItems(UInt32 *numItems)
{
*numItems = _files.Size();
return S_OK;
}
/*
-STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UINT32 *aNumSubFolders)
+STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders)
{
- UINT32 aNumSubFoldersLoc = 0;
+ UInt32 numSubFoldersLoc = 0;
for (int i = 0; i < _files.Size(); i++)
if (_files[i].IsDirectory())
- aNumSubFoldersLoc++;
- *aNumSubFolders = aNumSubFoldersLoc;
+ numSubFoldersLoc++;
+ *numSubFolders = numSubFoldersLoc;
return S_OK;
}
*/
-STDMETHODIMP CFSFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT *value)
+STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
{
NCOM::CPropVariant propVariant;
- if (itemIndex >= (UINT32)_files.Size())
+ if (itemIndex >= (UInt32)_files.Size())
return E_INVALIDARG;
CFileInfoEx &fileInfo = _files[itemIndex];
switch(propID)
@@ -210,7 +206,7 @@ STDMETHODIMP CFSFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT
propVariant = fileInfo.IsDirectory();
break;
case kpidName:
- propVariant = GetUnicodeString(fileInfo.Name);
+ propVariant = fileInfo.Name;
break;
case kpidSize:
propVariant = fileInfo.Size;
@@ -227,7 +223,7 @@ STDMETHODIMP CFSFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT
propVariant = fileInfo.CompressedSize;
break;
case kpidAttributes:
- propVariant = (UINT32)fileInfo.Attributes;
+ propVariant = (UInt32)fileInfo.Attributes;
break;
case kpidCreationTime:
propVariant = fileInfo.CreationTime;
@@ -241,7 +237,7 @@ STDMETHODIMP CFSFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT
case kpidComment:
LoadComments();
UString comment;
- if (_comments.GetValue(GetUnicodeString(fileInfo.Name), comment))
+ if (_comments.GetValue(fileInfo.Name, comment))
propVariant = comment;
break;
}
@@ -260,7 +256,7 @@ HRESULT CFSFolder::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultF
}
-STDMETHODIMP CFSFolder::BindToFolder(UINT32 index, IFolderFolder **resultFolder)
+STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
{
*resultFolder = 0;
const NFind::CFileInfoW &fileInfo = _files[index];
@@ -285,11 +281,11 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
}
if (_path.IsEmpty())
return E_INVALIDARG;
- int pos = _path.ReverseFind(TEXT('\\'));
+ int pos = _path.ReverseFind(L'\\');
if (pos < 0 || pos != _path.Length() - 1)
return E_FAIL;
UString parentPath = _path.Left(pos);
- pos = parentPath.ReverseFind(TEXT('\\'));
+ pos = parentPath.ReverseFind(L'\\');
if (pos < 0)
{
parentPath.Empty();
@@ -301,14 +297,14 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
}
UString parentPathReduced = parentPath.Left(pos);
parentPath = parentPath.Left(pos + 1);
- pos = parentPathReduced.ReverseFind(TEXT('\\'));
+ pos = parentPathReduced.ReverseFind(L'\\');
if (pos == 1)
{
- if (parentPath[0] != TEXT('\\'))
+ if (parentPath[0] != L'\\')
return E_FAIL;
CNetFolder *netFolderSpec = new CNetFolder;
CMyComPtr<IFolderFolder> netFolder = netFolderSpec;
- netFolderSpec->Init(GetUnicodeString(parentPath));
+ netFolderSpec->Init(parentPath);
*resultFolder = netFolder.Detach();
return S_OK;
}
@@ -329,13 +325,13 @@ STDMETHODIMP CFSFolder::GetName(BSTR *name)
*/
}
-STDMETHODIMP CFSFolder::GetNumberOfProperties(UINT32 *numProperties)
+STDMETHODIMP CFSFolder::GetNumberOfProperties(UInt32 *numProperties)
{
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
return S_OK;
}
-STDMETHODIMP CFSFolder::GetPropertyInfo(UINT32 index,
+STDMETHODIMP CFSFolder::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
@@ -357,7 +353,7 @@ STDMETHODIMP CFSFolder::GetTypeID(BSTR *name)
STDMETHODIMP CFSFolder::GetPath(BSTR *path)
{
- CMyComBSTR temp = GetUnicodeString(_path, _fileCodePage);
+ CMyComBSTR temp = _path;
*path = temp.Detach();
return S_OK;
}
@@ -397,7 +393,7 @@ STDMETHODIMP CFSFolder::Clone(IFolderFolder **resultFolder)
return S_OK;
}
-HRESULT CFSFolder::GetItemFullSize(int index, UINT64 &size, IProgress *progress)
+HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress)
{
const CFileInfoW &fileInfo = _files[index];
if (fileInfo.IsDirectory())
@@ -408,13 +404,13 @@ HRESULT CFSFolder::GetItemFullSize(int index, UINT64 &size, IProgress *progress)
CMyComPtr<IFolderReload> aFolderReload;
subFolder.QueryInterface(&aFolderReload);
aFolderReload->Reload();
- UINT32 numItems;
+ UInt32 numItems;
RINOK(subFolder->GetNumberOfItems(&numItems));
CMyComPtr<IFolderGetItemFullSize> aGetItemFullSize;
subFolder.QueryInterface(&aGetItemFullSize);
- for (UINT32 i = 0; i < numItems; i++)
+ for (UInt32 i = 0; i < numItems; i++)
{
- UINT64 size;
+ UInt64 size;
RINOK(aGetItemFullSize->GetItemFullSize(i, &size));
*totalSize += size;
}
@@ -425,12 +421,12 @@ HRESULT CFSFolder::GetItemFullSize(int index, UINT64 &size, IProgress *progress)
return S_OK;
}
-STDMETHODIMP CFSFolder::GetItemFullSize(UINT32 index, PROPVARIANT *value, IProgress *progress)
+STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress)
{
NCOM::CPropVariant propVariant;
- if (index >= (UINT32)_files.Size())
+ if (index >= (UInt32)_files.Size())
return E_INVALIDARG;
- UINT64 size = 0;
+ UInt64 size = 0;
HRESULT result = GetItemFullSize(index, size, progress);
propVariant = size;
propVariant.Detach(value);
@@ -478,7 +474,7 @@ STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress *progress)
return S_OK;
}
-STDMETHODIMP CFSFolder::Rename(UINT32 index, const wchar_t *newName, IProgress *progress)
+STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress *progress)
{
const CFileInfoW &fileInfo = _files[index];
if (!NDirectory::MyMoveFile(_path + fileInfo.Name, _path + newName))
@@ -486,11 +482,11 @@ STDMETHODIMP CFSFolder::Rename(UINT32 index, const wchar_t *newName, IProgress *
return S_OK;
}
-STDMETHODIMP CFSFolder::Delete(const UINT32 *indices, UINT32 numItems,
+STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,
IProgress *progress)
{
RINOK(progress->SetTotal(numItems));
- for (UINT32 i = 0; i < numItems; i++)
+ for (UInt32 i = 0; i < numItems; i++)
{
int index = indices[i];
const CFileInfoW &fileInfo = _files[indices[i]];
@@ -502,57 +498,23 @@ STDMETHODIMP CFSFolder::Delete(const UINT32 *indices, UINT32 numItems,
result = NDirectory::DeleteFileAlways(fullPath);
if (!result)
return GetLastError();
- UINT64 completed = i;
+ UInt64 completed = i;
RINOK(progress->SetCompleted(&completed));
}
return S_OK;
}
-/*
-STDMETHODIMP CFSFolder::DeleteToRecycleBin(const UINT32 *indices, UINT32 numItems,
- IProgress *progress)
-{
- RINOK(progress->SetTotal(numItems));
- for (UINT32 i = 0; i < numItems; i++)
- {
- int index = indices[i];
- const CFileInfoW &fileInfo = _files[indices[i]];
- const UString fullPath = _path + fileInfo.Name;
- CBuffer<TCHAR> buffer;
- const CSysString fullPathSys = GetSystemString(fullPath);
- buffer.SetCapacity(fullPathSys.Length() + 2);
- memmove((TCHAR *)buffer, (const TCHAR *)fullPathSys, (fullPathSys.Length() + 1) * sizeof(TCHAR));
- ((TCHAR *)buffer)[fullPathSys.Length() + 1] = 0;
- SHFILEOPSTRUCT fo;
- fo.hwnd = 0;
- fo.wFunc = FO_DELETE;
- fo.pFrom = (const TCHAR *)buffer;
- fo.pTo = 0;
- fo.fFlags = FOF_ALLOWUNDO;
- fo.fAnyOperationsAborted = FALSE;
- fo.hNameMappings = 0;
- fo.lpszProgressTitle = 0;
- int res = SHFileOperation(&fo);
- if (fo.fAnyOperationsAborted)
- return E_ABORT;
- UINT64 completed = i;
- RINOK(progress->SetCompleted(&completed));
- }
- return S_OK;
-}
-*/
-
-STDMETHODIMP CFSFolder::SetProperty(UINT32 index, PROPID propID,
+STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID,
const PROPVARIANT *value, IProgress *progress)
{
- if (index >= (UINT32)_files.Size())
+ if (index >= (UInt32)_files.Size())
return E_INVALIDARG;
CFileInfoEx &fileInfo = _files[index];
switch(propID)
{
case kpidComment:
{
- UString filename = GetUnicodeString(fileInfo.Name);
+ UString filename = fileInfo.Name;
filename.Trim();
if (value->vt == VT_EMPTY)
_comments.DeletePair(filename);
@@ -579,15 +541,14 @@ STDMETHODIMP CFSFolder::SetProperty(UINT32 index, PROPID propID,
return S_OK;
}
-STDMETHODIMP CFSFolder::GetSystemIconIndex(UINT32 index, INT32 *iconIndex)
+STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
{
- if (index >= (UINT32)_files.Size())
+ if (index >= (UInt32)_files.Size())
return E_INVALIDARG;
const CFileInfoEx &fileInfo = _files[index];
*iconIndex = 0;
int iconIndexTemp;
- if (GetRealIconIndex(GetSystemString(_path + fileInfo.Name),
- fileInfo.Attributes, iconIndexTemp) != 0)
+ if (GetRealIconIndex(_path + fileInfo.Name, fileInfo.Attributes, iconIndexTemp) != 0)
{
*iconIndex = iconIndexTemp;
return S_OK;
diff --git a/7zip/FileManager/FSFolder.h b/7zip/FileManager/FSFolder.h
index 3de312b1..cbe9cf59 100755
--- a/7zip/FileManager/FSFolder.h
+++ b/7zip/FileManager/FSFolder.h
@@ -17,7 +17,7 @@ class CFSFolder;
struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfoW
{
bool CompressedSizeIsDefined;
- UINT64 CompressedSize;
+ UInt64 CompressedSize;
};
@@ -34,7 +34,7 @@ class CFSFolder:
public IFolderGetSystemIconIndex,
public CMyUnknownImp
{
- UINT64 GetSizeOfItem(int anIndex) const;
+ UInt64 GetSizeOfItem(int anIndex) const;
public:
MY_QUERYINTERFACE_BEGIN
MY_QUERYINTERFACE_ENTRY(IEnumProperties)
@@ -51,41 +51,38 @@ public:
STDMETHOD(LoadItems)();
- STDMETHOD(GetNumberOfItems)(UINT32 *numItems);
- STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value);
- STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder);
+ STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
+ STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value);
+ STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder);
STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder);
STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder);
STDMETHOD(GetName)(BSTR *name);
- STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties);
- STDMETHOD(GetPropertyInfo)(UINT32 index,
+ STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
+ STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetTypeID)(BSTR *name);
STDMETHOD(GetPath)(BSTR *path);
STDMETHOD(WasChanged)(INT32 *wasChanged);
STDMETHOD(Clone)(IFolderFolder **resultFolder);
- STDMETHOD(GetItemFullSize)(UINT32 index, PROPVARIANT *value, IProgress *progress);
+ STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress);
// IFolderOperations
STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress);
STDMETHOD(CreateFile)(const wchar_t *name, IProgress *progress);
- STDMETHOD(Rename)(UINT32 index, const wchar_t *newName, IProgress *progress);
- STDMETHOD(Delete)(const UINT32 *indices, UINT32 numItems, IProgress *progress);
- STDMETHOD(CopyTo)(const UINT32 *indices, UINT32 numItems,
+ STDMETHOD(Rename)(UInt32 index, const wchar_t *newName, IProgress *progress);
+ STDMETHOD(Delete)(const UInt32 *indices, UInt32 numItems, IProgress *progress);
+ STDMETHOD(CopyTo)(const UInt32 *indices, UInt32 numItems,
const wchar_t *path, IFolderOperationsExtractCallback *callback);
- STDMETHOD(MoveTo)(const UINT32 *indices, UINT32 numItems,
+ STDMETHOD(MoveTo)(const UInt32 *indices, UInt32 numItems,
const wchar_t *path, IFolderOperationsExtractCallback *callback);
STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath,
- const wchar_t **itemsPaths, UINT32 numItems, IProgress *progress);
- STDMETHOD(SetProperty)(UINT32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress);
- STDMETHOD(GetSystemIconIndex)(UINT32 index, INT32 *iconIndex);
-
- // STDMETHOD(DeleteToRecycleBin)(const UINT32 *indices, UINT32 numItems, IProgress *progress);
+ const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress);
+ STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress);
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
private:
- UINT _fileCodePage;
UString _path;
CObjectVector<CFileInfoEx> _files;
CMyComPtr<IFolderFolder> _parentFolder;
@@ -97,7 +94,7 @@ private:
NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification;
- HRESULT GetItemFullSize(int index, UINT64 &size, IProgress *progress);
+ HRESULT GetItemFullSize(int index, UInt64 &size, IProgress *progress);
HRESULT GetComplexName(const wchar_t *name, UString &resultPath);
HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
diff --git a/7zip/FileManager/FSFolderCopy.cpp b/7zip/FileManager/FSFolderCopy.cpp
index 5eadd0d6..f46ee7b0 100755
--- a/7zip/FileManager/FSFolderCopy.cpp
+++ b/7zip/FileManager/FSFolderCopy.cpp
@@ -16,17 +16,9 @@ using namespace NWindows;
using namespace NFile;
using namespace NFind;
-static inline UINT GetCurrentCodePage()
- { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
-
-static bool IsItWindowsNT()
-{
- OSVERSIONINFO versionInfo;
- versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
- return false;
- return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
-}
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
static bool IsItWindows2000orHigher()
{
@@ -81,47 +73,48 @@ typedef BOOL (WINAPI * CopyFileExPointerW)(
IN DWORD dwCopyFlags
);
+#ifndef _UNICODE
+static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+static CSysString GetSysPath(LPCWSTR sysPath)
+ { return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
+#endif
+
static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile,
IProgress *progress, UINT64 &completedSize)
{
- // if (IsItWindowsNT())
- // {
- CProgressInfo progressInfo;
- progressInfo.Progress = progress;
- progressInfo.StartPos = completedSize;
- BOOL CancelFlag = FALSE;
+ CProgressInfo progressInfo;
+ progressInfo.Progress = progress;
+ progressInfo.StartPos = completedSize;
+ BOOL CancelFlag = FALSE;
+ #ifndef _UNICODE
+ if (g_IsNT)
+ #endif
+ {
CopyFileExPointerW copyFunctionW = (CopyFileExPointerW)
- ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
+ ::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"),
"CopyFileExW");
- if (copyFunctionW != 0)
- {
- if (copyFunctionW(existingFile, newFile, CopyProgressRoutine,
- &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
- return true;
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
- }
-
+ if (copyFunctionW == 0)
+ return false;
+ return BOOLToBool(copyFunctionW(existingFile, newFile, CopyProgressRoutine,
+ &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS));
+ }
+ #ifndef _UNICODE
+ else
+ {
CopyFileExPointer copyFunction = (CopyFileExPointer)
- ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
+ ::GetProcAddress(::GetModuleHandleA("kernel32.dll"),
"CopyFileExA");
- UINT codePage = GetCurrentCodePage();
if (copyFunction != 0)
{
- if (copyFunction(
- UnicodeStringToMultiByte(existingFile, codePage),
- UnicodeStringToMultiByte(newFile, codePage),
- CopyProgressRoutine,
- &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
+ if (copyFunction(GetSysPath(existingFile), GetSysPath(newFile),
+ CopyProgressRoutine,&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
return true;
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
return false;
}
- // }
- return BOOLToBool(::CopyFile(
- GetSystemString(existingFile, codePage),
- GetSystemString(newFile, codePage),
- TRUE));
+ return BOOLToBool(::CopyFile(GetSysPath(existingFile), GetSysPath(newFile), TRUE));
+ }
+ #endif
}
typedef BOOL (WINAPI * MoveFileWithProgressPointer)(
@@ -167,14 +160,12 @@ static HRESULT MyCopyFile(
const CFileInfoW &srcFileInfo,
const UString &destPathSpec,
IFolderOperationsExtractCallback *callback,
- UINT fileCodePage,
UINT64 &completedSize)
{
UString destPath = destPathSpec;
if (destPath.CompareNoCase(srcPath) == 0)
{
- UString message = UString(L"can not move file \'") +
- GetUnicodeString(destPath, fileCodePage) + UString(L"\' onto itself");
+ UString message = UString(L"can not move file \'") + destPath + UString(L"\' onto itself");
RINOK(callback->ShowMessage(message));
return E_ABORT;
}
@@ -182,10 +173,10 @@ static HRESULT MyCopyFile(
INT32 writeAskResult;
CMyComBSTR destPathResult;
RINOK(callback->AskWrite(
- GetUnicodeString(srcPath, fileCodePage),
+ srcPath,
BoolToInt(false),
&srcFileInfo.LastWriteTime, &srcFileInfo.Size,
- GetUnicodeString(destPath, fileCodePage),
+ destPath,
&destPathResult,
&writeAskResult));
if (IntToBool(writeAskResult))
@@ -194,9 +185,9 @@ static HRESULT MyCopyFile(
RINOK(callback->SetCurrentFilePath(srcPath));
if (!::MyCopyFile(srcPath, destPathNew, callback, completedSize))
{
- UString message = GetUnicodeString(NError::MyFormatMessage(GetLastError())) +
+ UString message = NError::MyFormatMessageW(GetLastError()) +
UString(L" \'") +
- GetUnicodeString(destPathNew, fileCodePage)+
+ UString(destPathNew) +
UString(L"\'");
RINOK(callback->ShowMessage(message));
return E_ABORT;
@@ -210,7 +201,6 @@ static HRESULT CopyFolder(
const UString &srcPath,
const UString &destPathSpec,
IFolderOperationsExtractCallback *callback,
- UINT fileCodePage,
UINT64 &completedSize)
{
RINOK(callback->SetCompleted(&completedSize));
@@ -222,7 +212,7 @@ static HRESULT CopyFolder(
if (destPath.Length() == len || destPath[len] == L'\\')
{
UString message = UString(L"can not copy folder \'") +
- GetUnicodeString(destPath, fileCodePage) + UString(L"\' onto itself");
+ destPath + UString(L"\' onto itself");
RINOK(callback->ShowMessage(message));
return E_ABORT;
}
@@ -230,8 +220,7 @@ static HRESULT CopyFolder(
if (!NDirectory::CreateComplexDirectory(destPath))
{
- UString message = UString(L"can not create folder ") +
- GetUnicodeString(destPath, fileCodePage);
+ UString message = UString(L"can not create folder ") + destPath;
RINOK(callback->ShowMessage(message));
return E_ABORT;
}
@@ -243,25 +232,23 @@ static HRESULT CopyFolder(
const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name;
if (fileInfo.IsDirectory())
{
- RINOK(CopyFolder(srcPath2, destPath2,
- callback, fileCodePage, completedSize));
+ RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize));
}
else
{
- RINOK(MyCopyFile(srcPath2, fileInfo, destPath2,
- callback, fileCodePage, completedSize));
+ RINOK(MyCopyFile(srcPath2, fileInfo, destPath2, callback, completedSize));
}
}
return S_OK;
}
-STDMETHODIMP CFSFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
+STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
const wchar_t *path, IFolderOperationsExtractCallback *callback)
{
if (numItems == 0)
return S_OK;
UINT64 totalSize = 0;
- UINT32 i;
+ UInt32 i;
for (i = 0; i < numItems; i++)
{
int index = indices[i];
@@ -285,7 +272,7 @@ STDMETHODIMP CFSFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
/*
// doesn't work in network
else
- if (!NDirectory::CreateComplexDirectory(GetSystemString(destPath, _fileCodePage)))
+ if (!NDirectory::CreateComplexDirectory(destPath)))
{
DWORD lastError = ::GetLastError();
UString message = UString(L"can not create folder ") +
@@ -306,13 +293,11 @@ STDMETHODIMP CFSFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
UString srcPath = _path + fileInfo.Name;
if (fileInfo.IsDirectory())
{
- RINOK(CopyFolder(srcPath, destPath2, callback,
- _fileCodePage, completedSize));
+ RINOK(CopyFolder(srcPath, destPath2, callback, completedSize));
}
else
{
- RINOK(MyCopyFile(srcPath, fileInfo, destPath2,
- callback, _fileCodePage, completedSize));
+ RINOK(MyCopyFile(srcPath, fileInfo, destPath2, callback, completedSize));
}
}
return S_OK;
@@ -326,14 +311,13 @@ HRESULT MyMoveFile(
const CFileInfoW &srcFileInfo,
const UString &destPathSpec,
IFolderOperationsExtractCallback *callback,
- UINT fileCodePage,
UINT64 &completedSize)
{
UString destPath = destPathSpec;
if (destPath.CompareNoCase(srcPath) == 0)
{
UString message = UString(L"can not move file \'")
- + GetUnicodeString(destPath, fileCodePage) +
+ + destPath +
UString(L"\' onto itself");
RINOK(callback->ShowMessage(message));
return E_ABORT;
@@ -342,10 +326,10 @@ HRESULT MyMoveFile(
INT32 writeAskResult;
CMyComBSTR destPathResult;
RINOK(callback->AskWrite(
- GetUnicodeString(srcPath, fileCodePage),
+ srcPath,
BoolToInt(false),
&srcFileInfo.LastWriteTime, &srcFileInfo.Size,
- GetUnicodeString(destPath, fileCodePage),
+ destPath,
&destPathResult,
&writeAskResult));
if (IntToBool(writeAskResult))
@@ -354,8 +338,7 @@ HRESULT MyMoveFile(
RINOK(callback->SetCurrentFilePath(srcPath));
if (!MyMoveFile(srcPath, destPathNew, callback, completedSize))
{
- UString message = UString(L"can not move to file ") +
- GetUnicodeString(destPathNew, fileCodePage);
+ UString message = UString(L"can not move to file ") + destPathNew;
RINOK(callback->ShowMessage(message));
}
}
@@ -368,7 +351,6 @@ HRESULT MyMoveFolder(
const UString &srcPath,
const UString &destPathSpec,
IFolderOperationsExtractCallback *callback,
- UINT fileCodePage,
UINT64 &completedSize)
{
UString destPath = destPathSpec;
@@ -377,9 +359,8 @@ HRESULT MyMoveFolder(
{
if (destPath.Length() == len || destPath[len] == L'\\')
{
- UString message = UString(L"can not move folder \'")
- + GetUnicodeString(destPath, fileCodePage) +
- UString(L"\' onto itself");
+ UString message = UString(L"can not move folder \'") +
+ destPath + UString(L"\' onto itself");
RINOK(callback->ShowMessage(message));
return E_ABORT;
}
@@ -390,8 +371,7 @@ HRESULT MyMoveFolder(
if (!NDirectory::CreateComplexDirectory(destPath))
{
- UString message = UString(L"can not create folder ") +
- GetUnicodeString(destPath, fileCodePage);
+ UString message = UString(L"can not create folder ") + destPath;
RINOK(callback->ShowMessage(message));
return E_ABORT;
}
@@ -404,20 +384,17 @@ HRESULT MyMoveFolder(
const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name;
if (fileInfo.IsDirectory())
{
- RINOK(MyMoveFolder(srcPath2, destPath2,
- callback, fileCodePage, completedSize));
+ RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize));
}
else
{
- RINOK(MyMoveFile(srcPath2, fileInfo, destPath2,
- callback, fileCodePage, completedSize));
+ RINOK(MyMoveFile(srcPath2, fileInfo, destPath2, callback, completedSize));
}
}
}
if (!NDirectory::MyRemoveDirectory(srcPath))
{
- UString message = UString(L"can not remove folder") +
- GetUnicodeString(srcPath, fileCodePage);
+ UString message = UString(L"can not remove folder") + srcPath;
RINOK(callback->ShowMessage(message));
return E_ABORT;
}
@@ -425,8 +402,8 @@ HRESULT MyMoveFolder(
}
STDMETHODIMP CFSFolder::MoveTo(
- const UINT32 *indices,
- UINT32 numItems,
+ const UInt32 *indices,
+ UInt32 numItems,
const wchar_t *path,
IFolderOperationsExtractCallback *callback)
{
@@ -434,7 +411,7 @@ STDMETHODIMP CFSFolder::MoveTo(
return S_OK;
UINT64 totalSize = 0;
- UINT32 i;
+ UInt32 i;
for (i = 0; i < numItems; i++)
{
int index = indices[i];
@@ -456,7 +433,7 @@ STDMETHODIMP CFSFolder::MoveTo(
return E_INVALIDARG;
}
else
- if (!NDirectory::CreateComplexDirectory(GetSystemString(destPath, _fileCodePage)))
+ if (!NDirectory::CreateComplexDirectory(destPath))
{
UString message = UString(L"can not create folder ") +
destPath;
@@ -475,13 +452,11 @@ STDMETHODIMP CFSFolder::MoveTo(
UString srcPath = _path + fileInfo.Name;
if (fileInfo.IsDirectory())
{
- RINOK(MyMoveFolder(srcPath, destPath2, callback,
- _fileCodePage, completedSize));
+ RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize));
}
else
{
- RINOK(MyMoveFile(srcPath, fileInfo, destPath2,
- callback, _fileCodePage, completedSize));
+ RINOK(MyMoveFile(srcPath, fileInfo, destPath2, callback, completedSize));
}
}
return S_OK;
@@ -489,7 +464,7 @@ STDMETHODIMP CFSFolder::MoveTo(
STDMETHODIMP CFSFolder::CopyFrom(
const wchar_t *fromFolderPath,
- const wchar_t **itemsPaths, UINT32 numItems, IProgress *progress)
+ const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress)
{
return E_NOTIMPL;
}
diff --git a/7zip/FileManager/FormatUtils.cpp b/7zip/FileManager/FormatUtils.cpp
index e0427df9..553d8bcd 100755
--- a/7zip/FileManager/FormatUtils.cpp
+++ b/7zip/FileManager/FormatUtils.cpp
@@ -3,49 +3,14 @@
#include "StdAfx.h"
#include "FormatUtils.h"
-#include "Windows/ResourceString.h"
#include "Common/IntToString.h"
-#include "Common/StringConvert.h"
+#include "Windows/ResourceString.h"
#ifdef LANG
#include "LangUtils.h"
#endif
-/*
-CSysString MyFormat(const CSysString &format, const CSysString &argument)
-{
- CSysString result;
- _stprintf(result.GetBuffer(format.Length() + argument.Length() + 2),
- format, argument);
- result.ReleaseBuffer();
- return result;
-}
-
-CSysString MyFormat(UINT32 resourceID,
- #ifdef LANG
- UINT32 aLangID,
- #endif
- const CSysString &argument)
-{
- return MyFormat(
- #ifdef LANG
- LangLoadString(resourceID, aLangID),
- #else
- NWindows::MyLoadString(resourceID),
- #endif
-
- argument);
-}
-*/
-
-CSysString NumberToString(UINT64 number)
-{
- TCHAR temp[32];
- ConvertUInt64ToString(number, temp);
- return temp;
-}
-
-UString NumberToStringW(UINT64 number)
+UString NumberToString(UInt64 number)
{
wchar_t numberString[32];
ConvertUInt64ToString(number, numberString);
@@ -59,16 +24,15 @@ UString MyFormatNew(const UString &format, const UString &argument)
return result;
}
-
-UString MyFormatNew(UINT32 resourceID,
+UString MyFormatNew(UINT resourceID,
#ifdef LANG
- UINT32 aLangID,
+ UInt32 langID,
#endif
const UString &argument)
{
return MyFormatNew(
#ifdef LANG
- LangLoadStringW(resourceID, aLangID),
+ LangString(resourceID, langID),
#else
NWindows::MyLoadStringW(resourceID),
#endif
diff --git a/7zip/FileManager/FormatUtils.h b/7zip/FileManager/FormatUtils.h
index 7902aeea..f7e9b193 100755
--- a/7zip/FileManager/FormatUtils.h
+++ b/7zip/FileManager/FormatUtils.h
@@ -3,18 +3,15 @@
#ifndef __FORMATUTILS_H
#define __FORMATUTILS_H
+#include "Common/Types.h"
#include "Common/String.h"
-// CSysString MyFormat(const CSysString &format, const CSysString &argument);
-
-// CSysString NumberToString(UINT64 number);
-
-UString NumberToStringW(UINT64 number);
+UString NumberToString(UInt64 number);
UString MyFormatNew(const UString &format, const UString &argument);
-UString MyFormatNew(UINT32 resourceID,
+UString MyFormatNew(UINT resourceID,
#ifdef LANG
- UINT32 aLangID,
+ UInt32 langID,
#endif
const UString &argument);
diff --git a/7zip/FileManager/HelpUtils.cpp b/7zip/FileManager/HelpUtils.cpp
index 93203449..c2bf49a5 100755
--- a/7zip/FileManager/HelpUtils.cpp
+++ b/7zip/FileManager/HelpUtils.cpp
@@ -14,10 +14,7 @@ void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile)
{
UString path;
if (!::GetProgramFolderPath(path))
- {
- // AfxMessageBox(TEXT("App Path Registry Item not found"));
return;
- }
path += kHelpFileName;
path += topicFile;
HtmlHelp(hwnd, GetSystemString(path), HH_DISPLAY_TOPIC, NULL);
diff --git a/7zip/FileManager/IFolder.h b/7zip/FileManager/IFolder.h
index 8ab4d196..72c96cc5 100755
--- a/7zip/FileManager/IFolder.h
+++ b/7zip/FileManager/IFolder.h
@@ -28,10 +28,10 @@ namespace NPlugin
FOLDER_INTERFACE(IFolderFolder, 0x00)
{
STDMETHOD(LoadItems)() PURE;
- STDMETHOD(GetNumberOfItems)(UINT32 *numItems) PURE;
- // STDMETHOD(GetNumberOfSubFolders)(UINT32 *numSubFolders) PURE;
- STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value) PURE;
- STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder) PURE;
+ STDMETHOD(GetNumberOfItems)(UInt32 *numItems) PURE;
+ // STDMETHOD(GetNumberOfSubFolders)(UInt32 *numSubFolders) PURE;
+ STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) PURE;
+ STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder) PURE;
STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder) PURE;
STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder) PURE;
STDMETHOD(GetName)(BSTR *name) PURE;
@@ -40,8 +40,8 @@ FOLDER_INTERFACE(IFolderFolder, 0x00)
FOLDER_INTERFACE(IEnumProperties, 0x01)
{
// STDMETHOD(EnumProperties)(IEnumSTATPROPSTG **enumerator) PURE;
- STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties) PURE;
- STDMETHOD(GetPropertyInfo)(UINT32 index,
+ STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) PURE;
+ STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType) PURE;
};
@@ -57,7 +57,7 @@ FOLDER_INTERFACE(IFolderGetPath, 0x03)
FOLDER_INTERFACE(IFolderWasChanged, 0x04)
{
- STDMETHOD(WasChanged)(INT32 *wasChanged) PURE;
+ STDMETHOD(WasChanged)(Int32 *wasChanged) PURE;
};
/*
@@ -71,12 +71,12 @@ FOLDER_INTERFACE_SUB(IFolderOperationsExtractCallback, IProgress, 0x06, 0x01)
{
STDMETHOD(AskWrite)(
const wchar_t *srcPath,
- INT32 srcIsFolder,
+ Int32 srcIsFolder,
const FILETIME *srcTime,
- const UINT64 *srcSize,
+ const UInt64 *srcSize,
const wchar_t *destPathRequest,
BSTR *destPathResult,
- INT32 *writeAnswer) PURE;
+ Int32 *writeAnswer) PURE;
STDMETHOD(ShowMessage)(const wchar_t *message) PURE;
STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath) PURE;
};
@@ -86,13 +86,13 @@ FOLDER_INTERFACE_SUB(IFolderOperationsUpdateCallback, IProgress, 0x06, 0x02)
{
STDMETHOD(AskOverwrite)(
const wchar_t *srcPath,
- INT32 destIsFolder,
+ Int32 destIsFolder,
const FILETIME *destTime,
- const UINT64 *destSize,
+ const UInt64 *destSize,
const wchar_t *aDestPathRequest,
const wchar_t *aDestName,
BSTR *aDestPathResult,
- INT32 *aResult);
+ Int32 *aResult);
};
*/
@@ -100,32 +100,32 @@ FOLDER_INTERFACE(IFolderOperations, 0x06)
{
STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress) PURE;
STDMETHOD(CreateFile)(const wchar_t *name, IProgress *progress) PURE;
- STDMETHOD(Rename)(UINT32 index, const wchar_t *newName, IProgress *progress) PURE;
- STDMETHOD(Delete)(const UINT32 *indices, UINT32 numItems, IProgress *progress) PURE;
- STDMETHOD(CopyTo)(const UINT32 *indices, UINT32 numItems,
+ STDMETHOD(Rename)(UInt32 index, const wchar_t *newName, IProgress *progress) PURE;
+ STDMETHOD(Delete)(const UInt32 *indices, UInt32 numItems, IProgress *progress) PURE;
+ STDMETHOD(CopyTo)(const UInt32 *indices, UInt32 numItems,
const wchar_t *path, IFolderOperationsExtractCallback *callback) PURE;
- STDMETHOD(MoveTo)(const UINT32 *indices, UINT32 numItems,
+ STDMETHOD(MoveTo)(const UInt32 *indices, UInt32 numItems,
const wchar_t *path, IFolderOperationsExtractCallback *callback) PURE;
STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath,
- const wchar_t **itemsPaths, UINT32 numItems, IProgress *progress) PURE;
- STDMETHOD(SetProperty)(UINT32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress) PURE;
+ const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress) PURE;
+ STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress) PURE;
};
/*
FOLDER_INTERFACE2(IFolderOperationsDeleteToRecycleBin, 0x06, 0x03)
{
- STDMETHOD(DeleteToRecycleBin)(const UINT32 *indices, UINT32 numItems, IProgress *progress) PURE;
+ STDMETHOD(DeleteToRecycleBin)(const UInt32 *indices, UInt32 numItems, IProgress *progress) PURE;
};
*/
FOLDER_INTERFACE(IFolderGetSystemIconIndex, 0x07)
{
- STDMETHOD(GetSystemIconIndex)(UINT32 index, INT32 *iconIndex) PURE;
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex) PURE;
};
FOLDER_INTERFACE(IFolderGetItemFullSize, 0x08)
{
- STDMETHOD(GetItemFullSize)(UINT32 index, PROPVARIANT *value, IProgress *progress) PURE;
+ STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress) PURE;
};
FOLDER_INTERFACE(IFolderClone, 0x09)
diff --git a/7zip/FileManager/LangUtils.cpp b/7zip/FileManager/LangUtils.cpp
index 2e4cd82a..1f28c52c 100755
--- a/7zip/FileManager/LangUtils.cpp
+++ b/7zip/FileManager/LangUtils.cpp
@@ -5,7 +5,6 @@
#include "LangUtils.h"
#include "Common/StringConvert.h"
#include "Common/StringToInt.h"
-#include "Windows/ResourceString.h"
#include "Windows/Synchronization.h"
#include "Windows/Window.h"
#include "Windows/FileFind.h"
@@ -15,24 +14,28 @@
using namespace NWindows;
static CLang g_Lang;
-CSysString g_LangID;
+UString g_LangID;
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
void ReloadLang()
{
ReadRegLang(g_LangID);
g_Lang.Clear();
- if (!g_LangID.IsEmpty() && g_LangID != TEXT("-"))
+ if (!g_LangID.IsEmpty() && g_LangID != L"-")
{
- CSysString langPath = g_LangID;
+ UString langPath = g_LangID;
if (langPath.Find('\\') < 0)
{
if (langPath.Find('.') < 0)
- langPath += TEXT(".txt");
+ langPath += L".txt";
UString folderPath;
if (GetProgramFolderPath(folderPath))
- langPath = GetSystemString(folderPath) + CSysString(TEXT("Lang\\")) + langPath;
+ langPath = folderPath + UString(L"Lang\\") + langPath;
}
- g_Lang.Open(langPath);
+ g_Lang.Open(GetSystemString(langPath));
}
}
@@ -48,14 +51,6 @@ void LoadLangOneTime()
ReloadLang();
}
-/*
-class CLangLoader
-{
-public:
- CLangLoader() { ReloadLang(); }
-} g_LangLoader;
-*/
-
void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems)
{
for (int i = 0; i < numItems; i++)
@@ -74,10 +69,10 @@ void LangSetWindowText(HWND window, UInt32 langID)
{
UString message;
if (g_Lang.GetMessage(langID, message))
- SetWindowText(window, GetSystemString(message));
+ MySetWindowText(window, message);
}
-UString LangLoadString(UInt32 langID)
+UString LangString(UInt32 langID)
{
UString message;
if (g_Lang.GetMessage(langID, message))
@@ -85,15 +80,7 @@ UString LangLoadString(UInt32 langID)
return UString();
}
-CSysString LangLoadString(UINT resourceID, UInt32 langID)
-{
- UString message;
- if (g_Lang.GetMessage(langID, message))
- return GetSystemString(message);
- return NWindows::MyLoadString(resourceID);
-}
-
-UString LangLoadStringW(UINT resourceID, UInt32 langID)
+UString LangString(UINT resourceID, UInt32 langID)
{
UString message;
if (g_Lang.GetMessage(langID, message))
@@ -180,16 +167,19 @@ void FindMatchLang(UString &shortName)
void ReloadLangSmart()
{
- #ifdef _UNICODE
- ReadRegLang(g_LangID);
- if (g_LangID.IsEmpty())
+ #ifndef _UNICODE
+ if (g_IsNT)
+ #endif
{
- UString shortName;
- FindMatchLang(shortName);
- if (shortName.IsEmpty())
- shortName = L"-";
- SaveRegLang(GetSystemString(shortName));
+ ReadRegLang(g_LangID);
+ if (g_LangID.IsEmpty())
+ {
+ UString shortName;
+ FindMatchLang(shortName);
+ if (shortName.IsEmpty())
+ shortName = L"-";
+ SaveRegLang(shortName);
+ }
}
- #endif
ReloadLang();
}
diff --git a/7zip/FileManager/LangUtils.h b/7zip/FileManager/LangUtils.h
index ce002716..40debdfe 100755
--- a/7zip/FileManager/LangUtils.h
+++ b/7zip/FileManager/LangUtils.h
@@ -4,8 +4,9 @@
#define __LANGUTILS_H
#include "Common/Lang.h"
+#include "Windows/ResourceString.h"
-extern CSysString g_LangID;
+extern UString g_LangID;
struct CIDLangPair
{
@@ -28,9 +29,13 @@ void LoadLangs(CObjectVector<CLangEx> &langs);
void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems);
void LangSetWindowText(HWND window, UInt32 langID);
-UString LangLoadString(UInt32 langID);
-CSysString LangLoadString(UINT resourceID, UInt32 langID);
-UString LangLoadStringW(UINT resourceID, UInt32 langID);
+UString LangString(UInt32 langID);
+UString LangString(UINT resourceID, UInt32 langID);
+#ifdef LANG
+#define LangStringSpec(resourceID, langID) LangString(resourceID, langID)
+#else
+#define LangStringSpec(resourceID, langID) NWindows::MyLoadStringW(resourceID)
+#endif
#endif
diff --git a/7zip/FileManager/MyLoadMenu.cpp b/7zip/FileManager/MyLoadMenu.cpp
index 9b684ec4..084aadfc 100755
--- a/7zip/FileManager/MyLoadMenu.cpp
+++ b/7zip/FileManager/MyLoadMenu.cpp
@@ -135,61 +135,6 @@ static int FindLangItem(int ControlID)
return -1;
}
-/*
-void MyChangeMenu(HMENU menuLoc, int baseIndex = -1)
-{
- CMenu menu;
- menu.Attach(menuLoc);
- for (int i = 0; i < menu.GetItemCount(); i++)
- {
- HMENU subMenu = menu.GetSubMenu(i);
- CSysString menuString;
- menu.GetMenuString(i, MF_BYPOSITION, menuString);
-
- // if (menu.GetItemInfo(i, true, &menuInfo))
- {
- CSysString newString;
- if (subMenu)
- {
- MyChangeMenu(subMenu);
- if (baseIndex >= 0 && baseIndex < sizeof(kStringLangPairs) /
- sizeof(kStringLangPairs[0]))
- newString = LangLoadString(kStringLangPairs[baseIndex++].LangID);
- else
- continue;
- if (newString.IsEmpty())
- continue;
-
- // int langPos = FindStringLangItem(GetUnicodeString(menuInfo.dwTypeData));
- // if (langPos >= 0)
- // newString = LangLoadString(kStringLangPairs[langPos].LangID);
- // else
- // newString = menuInfo.dwTypeData;
- }
- else
- {
- UINT id = menu.GetItemID(i);
- int langPos = FindLangItem(id);
- if (langPos < 0)
- continue;
- newString = LangLoadString(kIDLangPairs[langPos].LangID);
- if (newString.IsEmpty())
- continue;
- int tabPos = menuString.ReverseFind(wchar_t('\t'));
- if (tabPos >= 0)
- newString += menuString.Mid(tabPos);
- }
- MENUITEMINFO menuInfo;
- menuInfo.cbSize = sizeof(menuInfo);
- menuInfo.fType = MFT_STRING;
- menuInfo.fMask = MIIM_TYPE;
- menuInfo.dwTypeData = (LPTSTR)(LPCTSTR)newString;
- menu.SetItemInfo(i, true, &menuInfo);
- // HMENU subMenu = menu.GetSubMenu(i);
- }
- }
-}
-*/
/*
static bool g_IsNew_fMask = true;
@@ -241,70 +186,62 @@ static UINT Get_fMaskForFTypeAndString()
return MIIM_TYPE;
}
+
+
static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
{
CMenu menu;
menu.Attach(menuLoc);
for (int i = 0; i < menu.GetItemCount(); i++)
{
- MENUITEMINFO menuInfo;
- ZeroMemory(&menuInfo, sizeof(menuInfo));
- menuInfo.cbSize = sizeof(menuInfo);
- menuInfo.fMask = Get_fMaskForString() | MIIM_SUBMENU | MIIM_ID;
- menuInfo.fType = MFT_STRING;
- const int kBufferSize = 1024;
- TCHAR buffer[kBufferSize + 1];
- menuInfo.dwTypeData = buffer;
- menuInfo.cch = kBufferSize;
- if (menu.GetItemInfo(i, true, &menuInfo))
+ CMenuItem item;
+ item.fMask = Get_fMaskForString() | MIIM_SUBMENU | MIIM_ID;
+ item.fType = MFT_STRING;
+ if (menu.GetItem(i, true, item))
{
- CSysString newString;
- if (menuInfo.hSubMenu)
+ UString newString;
+ if (item.hSubMenu)
{
if (level == 1 && menuIndex == kBookmarksMenuIndex)
- newString = GetSystemString(LangLoadString(kAddToFavoritesLangID));
+ newString = LangString(kAddToFavoritesLangID);
else
{
- MyChangeMenu(menuInfo.hSubMenu, level + 1, i);
+ MyChangeMenu(item.hSubMenu, level + 1, i);
if (level == 1 && menuIndex == kViewMenuIndex)
{
- newString = GetSystemString(LangLoadString(kToolbarsLangID));
+ newString = LangString(kToolbarsLangID);
}
else
{
if (level == 0 && i < sizeof(kStringLangPairs) /
sizeof(kStringLangPairs[0]))
- newString = GetSystemString(LangLoadString(kStringLangPairs[i].LangID));
+ newString = LangString(kStringLangPairs[i].LangID);
else
continue;
}
}
if (newString.IsEmpty())
continue;
-
- // int langPos = FindStringLangItem(GetUnicodeString(menuInfo.dwTypeData));
- // if (langPos >= 0)
- // newString = LangLoadString(kStringLangPairs[langPos].LangID);
- // else
- // newString = menuInfo.dwTypeData;
}
else
{
- int langPos = FindLangItem(menuInfo.wID);
+ int langPos = FindLangItem(item.wID);
if (langPos < 0)
continue;
- newString = GetSystemString(LangLoadString(kIDLangPairs[langPos].LangID));
+ newString = LangString(kIDLangPairs[langPos].LangID);
if (newString.IsEmpty())
continue;
- CSysString shorcutString = menuInfo.dwTypeData;
+ UString shorcutString = item.StringValue;
int tabPos = shorcutString.ReverseFind(wchar_t('\t'));
if (tabPos >= 0)
newString += shorcutString.Mid(tabPos);
}
- menuInfo.dwTypeData = (LPTSTR)(LPCTSTR)newString;
- menuInfo.fMask = Get_fMaskForString();
- menuInfo.fType = MFT_STRING;
- menu.SetItemInfo(i, true, &menuInfo);
+ {
+ item.StringValue = newString;
+ item.fMask = Get_fMaskForString();
+ item.fType = MFT_STRING;
+ menu.SetItem(i, true, item);
+ }
}
}
}
@@ -353,20 +290,12 @@ static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec)
int startPos = 0;
for (int i = 0; i < srcMenu.GetItemCount(); i++)
{
- MENUITEMINFO menuInfo;
- ZeroMemory(&menuInfo, sizeof(menuInfo));
- menuInfo.cbSize = sizeof(menuInfo);
- menuInfo.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
- menuInfo.fType = MFT_STRING;
- const int kBufferSize = 1024;
- TCHAR buffer[kBufferSize + 1];
- menuInfo.dwTypeData = buffer;
- menuInfo.cch = kBufferSize;
- if (srcMenu.GetItemInfo(i, true, &menuInfo))
- {
- if (destMenu.InsertItem(startPos, true, &menuInfo))
+ CMenuItem item;
+ item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
+ item.fType = MFT_STRING;
+ if (srcMenu.GetItem(i, true, item))
+ if (destMenu.InsertItem(startPos, true, item))
startPos++;
- }
}
}
@@ -422,14 +351,13 @@ void OnMenuActivating(HWND hWnd, HMENU hMenu, int position)
int i;
for (i = 0; i < 10; i++)
{
- UString s = LangLoadStringW(IDS_BOOKMARK, 0x03000720);
+ UString s = LangString(IDS_BOOKMARK, 0x03000720);
s += L" ";
wchar_t c = L'0' + i;
s += c;
s += L"\tAlt+Shift+";
s += c;
- subMenu.AppendItem(MF_STRING, kSetBookmarkMenuID + i,
- GetSystemString(s));
+ subMenu.AppendItem(MF_STRING, kSetBookmarkMenuID + i, s);
}
while (menu.GetItemCount() > 2)
@@ -445,15 +373,13 @@ void OnMenuActivating(HWND hWnd, HMENU hMenu, int position)
path = path.Left(kFirstPartSize) + UString(L" ... ") +
path.Right(kMaxSize - kFirstPartSize);
}
- CSysString s = GetSystemString(path);
+ UString s = path;
if (s.IsEmpty())
- s = TEXT("-");
- s += TEXT("\tAlt+");
- s += ('0' + i);
+ s = L"-";
+ s += L"\tAlt+";
+ s += (L'0' + i);
menu.AppendItem(MF_STRING, kOpenBookmarkMenuID + i, s);
}
-
- // menu.AppendItem(MF_STRING, 100, TEXT("Test2\tAlt+2"));
}
}
@@ -490,47 +416,17 @@ void LoadFileMenu(HMENU hMenu, int startPos, bool forFileMode,
for (int i = 0; i < g_FileMenu.GetItemCount(); i++)
{
- MENUITEMINFO menuInfo;
- ZeroMemory(&menuInfo, sizeof(menuInfo));
- menuInfo.cbSize = sizeof(menuInfo);
-
- /*
- menuInfo.fMask = MIIM_STATE | MIIM_ID | MIIM_TYPE;
- menuInfo.fType = MFT_STRING;
-
- if (!srcMenu.GetItemInfo(i, true, &menuInfo))
- {
- // MessageBox(0, NError::MyFormatMessage(GetLastError()), "Error", 0);
- continue;
- }
- // menuInfo.wID = srcMenu.GetItemID(i);
- // menuInfo.fState = srcMenu.GetItemState(i, MF_BYPOSITION);
+ CMenuItem item;
- // menuInfo.hSubMenu = srcMenu.GetSubMenu(i);
- CSysString menuString;
- if (menuInfo.fType == MFT_STRING)
- {
- srcMenu.GetMenuString(i, MF_BYPOSITION, menuString);
- menuInfo.dwTypeData = (LPTSTR)(LPCTSTR)menuString;
- }
- menuInfo.dwTypeData = (LPTSTR)(LPCTSTR)menuString;
- */
-
- menuInfo.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
- menuInfo.fType = MFT_STRING;
- const int kBufferSize = 1024;
- TCHAR buffer[kBufferSize + 1];
- menuInfo.dwTypeData = buffer;
- menuInfo.cch = kBufferSize;
-
- if (g_FileMenu.GetItemInfo(i, true, &menuInfo))
+ item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
+ item.fType = MFT_STRING;
+ if (g_FileMenu.GetItem(i, true, item))
{
if (!programMenu)
- if (menuInfo.wID == IDCLOSE)
+ if (item.wID == IDCLOSE)
continue;
/*
- bool createItem = (menuInfo.wID == IDM_CREATE_FOLDER ||
- menuInfo.wID == IDM_CREATE_FILE);
+ bool createItem = (item.wID == IDM_CREATE_FOLDER || item.wID == IDM_CREATE_FILE);
if (forFileMode)
{
if (createItem)
@@ -542,21 +438,20 @@ void LoadFileMenu(HMENU hMenu, int startPos, bool forFileMode,
continue;
}
*/
- if (destMenu.InsertItem(startPos, true, &menuInfo))
+ if (destMenu.InsertItem(startPos, true, item))
startPos++;
}
}
while (destMenu.GetItemCount() > 0)
{
- MENUITEMINFO menuInfo;
- ZeroMemory(&menuInfo, sizeof(menuInfo));
- menuInfo.cbSize = sizeof(menuInfo);
- menuInfo.fMask = MIIM_TYPE;
- menuInfo.dwTypeData = 0;
+ CMenuItem item;
+ item.fMask = MIIM_TYPE;
+ item.fType = 0;
+ // item.dwTypeData = 0;
int lastIndex = destMenu.GetItemCount() - 1;
- if (!destMenu.GetItemInfo(lastIndex, true, &menuInfo))
+ if (!destMenu.GetItem(lastIndex, true, item))
break;
- if(menuInfo.fType != MFT_SEPARATOR)
+ if(item.fType != MFT_SEPARATOR)
break;
if (!destMenu.RemoveItem(lastIndex, MF_BYPOSITION))
break;
diff --git a/7zip/FileManager/NetFolder.cpp b/7zip/FileManager/NetFolder.cpp
index 78911e64..51ee5372 100755
--- a/7zip/FileManager/NetFolder.cpp
+++ b/7zip/FileManager/NetFolder.cpp
@@ -43,9 +43,9 @@ void CNetFolder::Init(const UString &path)
}
Init(0, 0 , L"");
*/
- CResource resource;
+ CResourceW resource;
resource.RemoteNameIsDefined = true;
- resource.RemoteName = GetSystemString(path.Left(path.Length() - 1));
+ resource.RemoteName = path.Left(path.Length() - 1);
resource.ProviderIsDefined = false;
resource.LocalNameIsDefined = false;
resource.CommentIsDefined = false;
@@ -53,18 +53,17 @@ void CNetFolder::Init(const UString &path)
resource.Scope = RESOURCE_GLOBALNET;
resource.Usage = 0;
resource.DisplayType = 0;
- CResource aDestResource;
- CSysString aSystemPathPart;
- DWORD result = GetResourceInformation(resource, aDestResource,
- aSystemPathPart);
+ CResourceW destResource;
+ UString systemPathPart;
+ DWORD result = GetResourceInformation(resource, destResource, systemPathPart);
if (result == NO_ERROR)
- Init(&aDestResource, 0, path);
+ Init(&destResource, 0, path);
else
Init(0, 0 , L"");
return;
}
-void CNetFolder::Init(const NWindows::NNet::CResource *netResource,
+void CNetFolder::Init(const NWindows::NNet::CResourceW *netResource,
IFolderFolder *parentFolder, const UString &path)
{
_path = path;
@@ -76,7 +75,7 @@ void CNetFolder::Init(const NWindows::NNet::CResource *netResource,
_netResourcePointer = &_netResource;
// if (_netResource.DisplayType == RESOURCEDISPLAYTYPE_SERVER)
- _path = GetUnicodeString(_netResource.RemoteName) + L'\\';
+ _path = _netResource.RemoteName + L'\\';
}
_parentFolder = parentFolder;
}
@@ -113,7 +112,7 @@ STDMETHODIMP CNetFolder::LoadItems()
{
if (!resource.RemoteNameIsDefined) // For Win 98, I don't know what's wrong
resource.RemoteName = resource.Comment;
- resource.Name = GetUnicodeString(resource.RemoteName);
+ resource.Name = resource.RemoteName;
int aPos = resource.Name.ReverseFind(L'\\');
if (aPos >= 0)
{
@@ -128,6 +127,8 @@ STDMETHODIMP CNetFolder::LoadItems()
return result;
}
+ /*
+ It's too slow for some systems.
if (_netResourcePointer && _netResource.DisplayType == RESOURCEDISPLAYTYPE_SERVER)
{
for (char c = 'a'; c <= 'z'; c++)
@@ -135,11 +136,11 @@ STDMETHODIMP CNetFolder::LoadItems()
CResourceEx resource;
resource.Name = UString(wchar_t(c)) + L'$';
resource.RemoteNameIsDefined = true;
- resource.RemoteName = GetSystemString(_path + resource.Name);
+ resource.RemoteName = _path + resource.Name;
- NFile::NFind::CFindFile aFindFile;
- NFile::NFind::CFileInfo aFileInfo;
- if (!aFindFile.FindFirst(resource.RemoteName + CSysString(TEXT("\\*")), aFileInfo))
+ NFile::NFind::CFindFile findFile;
+ NFile::NFind::CFileInfoW fileInfo;
+ if (!findFile.FindFirst(resource.RemoteName + UString(L"\\*"), fileInfo))
continue;
resource.Usage = RESOURCEUSAGE_CONNECTABLE;
resource.LocalNameIsDefined = false;
@@ -148,17 +149,18 @@ STDMETHODIMP CNetFolder::LoadItems()
_items.Add(resource);
}
}
+ */
return S_OK;
}
-STDMETHODIMP CNetFolder::GetNumberOfItems(UINT32 *numItems)
+STDMETHODIMP CNetFolder::GetNumberOfItems(UInt32 *numItems)
{
*numItems = _items.Size();
return S_OK;
}
-STDMETHODIMP CNetFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT *value)
+STDMETHODIMP CNetFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
{
NCOM::CPropVariant propVariant;
const CResourceEx &item = _items[itemIndex];
@@ -173,25 +175,22 @@ STDMETHODIMP CNetFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIAN
break;
case kpidLocalName:
if (item.LocalNameIsDefined)
- propVariant = GetUnicodeString(item.LocalName);
+ propVariant = item.LocalName;
break;
case kpidComment:
if (item.CommentIsDefined)
- propVariant = GetUnicodeString(item.Comment);
+ propVariant = item.Comment;
break;
case kpidProvider:
if (item.ProviderIsDefined)
- propVariant = GetUnicodeString(item.Provider);
+ propVariant = item.Provider;
break;
}
propVariant.Detach(value);
return S_OK;
}
-static inline UINT GetCurrentCodePage()
- { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
-
-STDMETHODIMP CNetFolder::BindToFolder(UINT32 index, IFolderFolder **resultFolder)
+STDMETHODIMP CNetFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
{
*resultFolder = 0;
const CResourceEx &resource = _items[index];
@@ -200,16 +199,14 @@ STDMETHODIMP CNetFolder::BindToFolder(UINT32 index, IFolderFolder **resultFolder
{
CFSFolder *fsFolderSpec = new CFSFolder;
CMyComPtr<IFolderFolder> subFolder = fsFolderSpec;
- RINOK(fsFolderSpec->Init(
- GetUnicodeString(resource.RemoteName, GetCurrentCodePage())
- + L'\\', this));
+ RINOK(fsFolderSpec->Init(resource.RemoteName + L'\\', this));
*resultFolder = subFolder.Detach();
}
else
{
CNetFolder *netFolder = new CNetFolder;
CMyComPtr<IFolderFolder> subFolder = netFolder;
- netFolder->Init(&resource, this, GetUnicodeString(resource.Name) + L'\\');
+ netFolder->Init(&resource, this, resource.Name + L'\\');
*resultFolder = subFolder.Detach();
}
return S_OK;
@@ -231,7 +228,7 @@ STDMETHODIMP CNetFolder::BindToParentFolder(IFolderFolder **resultFolder)
}
if (_netResourcePointer != 0)
{
- CResource resourceParent;
+ CResourceW resourceParent;
DWORD result = GetResourceParent(_netResource, resourceParent);
if (result != NO_ERROR)
return result;
@@ -257,13 +254,13 @@ STDMETHODIMP CNetFolder::GetName(BSTR *name)
*/
}
-STDMETHODIMP CNetFolder::GetNumberOfProperties(UINT32 *numProperties)
+STDMETHODIMP CNetFolder::GetNumberOfProperties(UInt32 *numProperties)
{
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
return S_OK;
}
-STDMETHODIMP CNetFolder::GetPropertyInfo(UINT32 index,
+STDMETHODIMP CNetFolder::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
@@ -289,12 +286,12 @@ STDMETHODIMP CNetFolder::GetPath(BSTR *path)
return S_OK;
}
-STDMETHODIMP CNetFolder::GetSystemIconIndex(UINT32 index, INT32 *iconIndex)
+STDMETHODIMP CNetFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
{
- if (index >= (UINT32)_items.Size())
+ if (index >= (UInt32)_items.Size())
return E_INVALIDARG;
*iconIndex = 0;
- const CResource &resource = _items[index];
+ const CResourceW &resource = _items[index];
int iconIndexTemp;
if (resource.DisplayType == RESOURCEDISPLAYTYPE_SERVER ||
resource.Usage == RESOURCEUSAGE_CONNECTABLE)
diff --git a/7zip/FileManager/NetFolder.h b/7zip/FileManager/NetFolder.h
index 0aedb5b8..f23c7e4e 100755
--- a/7zip/FileManager/NetFolder.h
+++ b/7zip/FileManager/NetFolder.h
@@ -11,7 +11,7 @@
#include "IFolder.h"
-struct CResourceEx: public NWindows::NNet::CResource
+struct CResourceEx: public NWindows::NNet::CResourceW
{
UString Name;
};
@@ -33,23 +33,23 @@ public:
)
STDMETHOD(LoadItems)();
- STDMETHOD(GetNumberOfItems)(UINT32 *numItems);
- STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value);
- STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder);
+ STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
+ STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value);
+ STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder);
STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder);
STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder);
STDMETHOD(GetName)(BSTR *name);
- STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties);
- STDMETHOD(GetPropertyInfo)(UINT32 index,
+ STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
+ STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetTypeID)(BSTR *name);
STDMETHOD(GetPath)(BSTR *path);
- STDMETHOD(GetSystemIconIndex)(UINT32 index, INT32 *iconIndex);
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
private:
- NWindows::NNet::CResource _netResource;
- NWindows::NNet::CResource *_netResourcePointer;
+ NWindows::NNet::CResourceW _netResource;
+ NWindows::NNet::CResourceW *_netResourcePointer;
CObjectVector<CResourceEx> _items;
@@ -58,7 +58,7 @@ private:
public:
void Init(const UString &path);
- void Init(const NWindows::NNet::CResource *netResource,
+ void Init(const NWindows::NNet::CResourceW *netResource,
IFolderFolder *parentFolder, const UString &path);
CNetFolder(): _netResourcePointer(0) {}
};
diff --git a/7zip/FileManager/OpenCallback.cpp b/7zip/FileManager/OpenCallback.cpp
index f12b9d04..9c9f842e 100755
--- a/7zip/FileManager/OpenCallback.cpp
+++ b/7zip/FileManager/OpenCallback.cpp
@@ -46,7 +46,7 @@ STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value
switch(propID)
{
case kpidName:
- propVariant = GetUnicodeString(_fileInfo.Name);
+ propVariant = _fileInfo.Name;
break;
case kpidIsFolder:
propVariant = _fileInfo.IsDirectory();
diff --git a/7zip/FileManager/OptionsDialog.cpp b/7zip/FileManager/OptionsDialog.cpp
index 350d5263..b6c07275 100755
--- a/7zip/FileManager/OptionsDialog.cpp
+++ b/7zip/FileManager/OptionsDialog.cpp
@@ -24,33 +24,7 @@
#include "MyLoadMenu.h"
#include "App.h"
-void FillInPropertyPage(PROPSHEETPAGE* page, HINSTANCE instance, int dialogID,
- NWindows::NControl::CPropertyPage *propertyPage, const CSysString &title)
-{
- page->dwSize = sizeof(PROPSHEETPAGE);
- // page->dwSize = sizeof(PROPSHEETPAGEW_V1_SIZE);
-
- page->dwFlags = PSP_HASHELP;
- page->hInstance = instance;
- page->pszTemplate = MAKEINTRESOURCE(dialogID);
- page->pszIcon = NULL;
- page->pfnDlgProc = NWindows::NControl::ProperyPageProcedure;
-
- if (title.IsEmpty())
- page->pszTitle = NULL;
- else
- {
- page->dwFlags |= PSP_USETITLE;
- page->pszTitle = title;
- }
-
- page->lParam = LPARAM(propertyPage);
- page->pfnCallback = NULL;
-
- // page->dwFlags = 0;
- // page->pszTitle = NULL;
- // page->lParam = 0;
-}
+using namespace NWindows;
void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance)
{
@@ -60,54 +34,32 @@ void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance)
CSettingsPage settingsPage;
CLangPage langPage;
- CSysStringVector titles;
+ CObjectVector<NControl::CPageInfo> pages;
UINT32 langIDs[] = { 0x03010300, 0x03010100, 0x03010200, 0x03010400, 0x01000400};
+ UINT pageIDs[] = { IDD_SYSTEM, IDD_PLUGINS, IDD_EDIT, IDD_SETTINGS, IDD_LANG};
+ NControl::CPropertyPage *pagePinters[] = { &systemPage, &pluginsPage, &editPage, &settingsPage, &langPage };
const int kNumPages = sizeof(langIDs) / sizeof(langIDs[0]);
for (int i = 0; i < kNumPages; i++)
- titles.Add(GetSystemString(LangLoadString(langIDs[i])));
-
- PROPSHEETPAGE pages[kNumPages];
-
- FillInPropertyPage(&pages[0], hInstance, IDD_SYSTEM, &systemPage, titles[0]);
- FillInPropertyPage(&pages[1], hInstance, IDD_PLUGINS, &pluginsPage, titles[1]);
- FillInPropertyPage(&pages[2], hInstance, IDD_EDIT, &editPage, titles[2]);
- FillInPropertyPage(&pages[3], hInstance, IDD_SETTINGS, &settingsPage, titles[3]);
- FillInPropertyPage(&pages[4], hInstance, IDD_LANG, &langPage, titles[4]);
-
- PROPSHEETHEADER sheet;
-
- // sheet.dwSize = sizeof(PROPSHEETHEADER_V1_SIZE);
-
- sheet.dwSize = sizeof(PROPSHEETHEADER);
- sheet.dwFlags = PSH_PROPSHEETPAGE;
- sheet.hwndParent = hwndOwner;
- sheet.hInstance = hInstance;
-
- CSysString title = LangLoadString(IDS_OPTIONS, 0x03010000);
-
- sheet.pszCaption = title;
- sheet.nPages = sizeof(pages) / sizeof(PROPSHEETPAGE);
- sheet.nStartPage = 0;
- sheet.ppsp = pages;
- sheet.pfnCallback = NULL;
+ {
+ NControl::CPageInfo page;
+ page.Title = LangString(langIDs[i]);
+ page.ID = pageIDs[i];
+ page.Page = pagePinters[i];
+ pages.Add(page);
+ }
- if (::PropertySheet(&sheet) != -1)
+ int res = NControl::MyPropertySheet(pages, hwndOwner, LangString(IDS_OPTIONS, 0x03010000));
+ if (res != -1 && res != 0)
{
if (langPage._langWasChanged)
{
- g_App._window.SetText(LangLoadStringW(IDS_APP_TITLE, 0x03000000));
+ g_App._window.SetText(LangString(IDS_APP_TITLE, 0x03000000));
MyLoadMenu();
}
g_App.SetListSettings();
g_App.SetShowSystemMenu();
g_App.RefreshAllPanels();
g_App.ReloadToolbars();
- // ::PostMessage(hwndOwner, kLangWasChangedMessage, 0 , 0);
+ // ::PostMessage(hwndOwner, kLangWasChangedMessage, 0 , 0);
}
- /*
- else
- MessageBox(0, NWindows::NError::MyFormatMessage(GetLastError()), TEXT("PropertySheet"), 0);
- */
-
}
-
diff --git a/7zip/FileManager/Panel.cpp b/7zip/FileManager/Panel.cpp
index 43905e0b..73a7f4ad 100755
--- a/7zip/FileManager/Panel.cpp
+++ b/7zip/FileManager/Panel.cpp
@@ -22,6 +22,10 @@
using namespace NWindows;
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
static const UINT_PTR kTimerID = 1;
static const UINT kTimerElapse = 1000;
@@ -49,7 +53,7 @@ CPanel::~CPanel()
CloseOpenFolders();
}
-static LPCTSTR kClassName = TEXT("7-Zip::Panel");
+static LPCWSTR kClassName = L"7-Zip::Panel";
LRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
@@ -196,7 +200,12 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
_panel->_lastFocusedIsList = true;
_panel->_panelCallback->PanelWasFocused();
}
- return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
+ else
+ #endif
+ return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
}
/*
@@ -278,7 +287,12 @@ LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
return 0;
}
}
- return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
+ else
+ #endif
+ return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
}
bool CPanel::OnCreate(CREATESTRUCT *createStruct)
@@ -318,11 +332,19 @@ bool CPanel::OnCreate(CREATESTRUCT *createStruct)
HWND(*this), (HMENU)_baseID + 1, g_hInstance, NULL))
return false;
+ _listView.SetUnicodeFormat(true);
_listView.SetUserDataLongPtr(LONG_PTR(&_listView));
_listView._panel = this;
- _listView._origWindowProc = (WNDPROC)_listView.SetLongPtr(GWLP_WNDPROC,
- LONG_PTR(ListViewSubclassProc));
+
+ #ifndef _UNICODE
+ if(g_IsNT)
+ _listView._origWindowProc =
+ (WNDPROC)_listView.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
+ else
+ #endif
+ _listView._origWindowProc =
+ (WNDPROC)_listView.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
SHFILEINFO shellInfo;
HIMAGELIST imageList = (HIMAGELIST)SHGetFileInfo(TEXT(""),
@@ -401,8 +423,6 @@ bool CPanel::OnCreate(CREATESTRUCT *createStruct)
;
}
-
-
_headerToolBar.Attach(::CreateToolbarEx ((*this), toolbarStyle,
_baseID + 2, 11,
(HINSTANCE)HINST_COMMCTRL,
@@ -414,12 +434,15 @@ bool CPanel::OnCreate(CREATESTRUCT *createStruct)
icex.dwICC = ICC_USEREX_CLASSES;
InitCommonControlsEx(&icex);
- _headerComboBox.CreateEx(0, WC_COMBOBOXEX, NULL,
+ _headerComboBox.CreateEx(0, WC_COMBOBOXEXW, NULL,
WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL,
0, 0, 100, 20,
((_headerReBar == 0) ? HWND(*this) : _headerToolBar),
(HMENU)(_comboBoxID),
g_hInstance, NULL);
+ // _headerComboBox.SendMessage(CBEM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
+
+
_headerComboBox.SetExtendedStyle(CBES_EX_PATHWORDBREAKPROC, CBES_EX_PATHWORDBREAKPROC);
/*
@@ -430,11 +453,20 @@ bool CPanel::OnCreate(CREATESTRUCT *createStruct)
LONG_PTR(ComboBoxSubclassProc));
*/
_comboBoxEdit.Attach(_headerComboBox.GetEditControl());
+
+ // _comboBoxEdit.SendMessage(CCM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
+
_comboBoxEdit.SetUserDataLongPtr(LONG_PTR(&_comboBoxEdit));
_comboBoxEdit._panel = this;
- _comboBoxEdit._origWindowProc =
- (WNDPROC)_comboBoxEdit.SetLongPtr(GWLP_WNDPROC,
- LONG_PTR(ComboBoxEditSubclassProc));
+ #ifndef _UNICODE
+ if(g_IsNT)
+ _comboBoxEdit._origWindowProc =
+ (WNDPROC)_comboBoxEdit.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
+ else
+ #endif
+ _comboBoxEdit._origWindowProc =
+ (WNDPROC)_comboBoxEdit.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
+
if (_headerReBar)
@@ -472,8 +504,8 @@ bool CPanel::OnCreate(CREATESTRUCT *createStruct)
// _headerReBar.MaximizeBand(1, false);
}
- _statusBar.Create(WS_CHILD | WS_VISIBLE, TEXT("Status"), (*this), _statusBarID);
- // _statusBar2.Create(WS_CHILD | WS_VISIBLE, TEXT("Status"), (*this), _statusBarID + 1);
+ _statusBar.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID);
+ // _statusBar2.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID + 1);
int sizes[] = {150, 200, 250, -1};
_statusBar.SetParts(4, sizes);
@@ -607,7 +639,7 @@ void CPanel::MessageBox(LPCWSTR message)
void CPanel::MessageBoxMyError(LPCWSTR message)
{ MessageBox(message, L"Error"); }
void CPanel::MessageBoxError(HRESULT errorCode, LPCWSTR caption)
- { MessageBox(GetUnicodeString(NError::MyFormatMessage(errorCode)), caption); }
+ { MessageBox(NError::MyFormatMessageW(errorCode), caption); }
void CPanel::MessageBoxError(HRESULT errorCode)
{ MessageBoxError(errorCode, L"7-Zip"); }
void CPanel::MessageBoxLastError(LPCWSTR caption)
@@ -629,11 +661,6 @@ void CPanel::SetFocusToLastRememberedItem()
_headerComboBox.SetFocus();
}
-CSysString CPanel::GetFileType(UINT32 index)
-{
- return TEXT("Test type");
-}
-
UString CPanel::GetFolderTypeID() const
{
CMyComPtr<IFolderGetTypeID> folderGetTypeID;
diff --git a/7zip/FileManager/Panel.h b/7zip/FileManager/Panel.h
index 95ab0d3c..dc0f1d62 100755
--- a/7zip/FileManager/Panel.h
+++ b/7zip/FileManager/Panel.h
@@ -159,15 +159,18 @@ class CPanel:public NWindows::NControl::CWindow2
virtual void OnDestroy();
virtual bool OnNotify(UINT controlID, LPNMHDR lParam, LRESULT &result);
void OnComboBoxCommand(UINT code, LPARAM &aParam);
+ bool OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result);
+ #ifndef _UNICODE
bool OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result);
+ #endif
bool OnNotifyReBar(LPNMHDR lParam, LRESULT &result);
bool OnNotifyComboBox(LPNMHDR lParam, LRESULT &result);
void OnItemChanged(NMLISTVIEW *item);
bool OnNotifyList(LPNMHDR lParam, LRESULT &result);
void OnDrag(LPNMLISTVIEW nmListView);
bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result);
- BOOL OnBeginLabelEdit(LV_DISPINFO * lpnmh);
- BOOL OnEndLabelEdit(LV_DISPINFO * lpnmh);
+ BOOL OnBeginLabelEdit(LV_DISPINFOW * lpnmh);
+ BOOL OnEndLabelEdit(LV_DISPINFOW * lpnmh);
void OnColumnClick(LPNMLISTVIEW info);
bool OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result);
@@ -204,8 +207,8 @@ public:
void InvertSelection();
private:
- CSysString GetFileType(UInt32 index);
- LRESULT SetItemText(LVITEM &item);
+ // UString GetFileType(UInt32 index);
+ LRESULT SetItemText(LVITEMW &item);
// CRecordVector<PROPID> m_ColumnsPropIDs;
@@ -231,7 +234,7 @@ public:
UString _focusedName;
- UInt32 GetRealIndex(const LVITEM &item) const
+ UInt32 GetRealIndex(const LVITEMW &item) const
{
/*
if (_virtualMode)
@@ -326,7 +329,7 @@ public:
bool _needSaveInfo;
- CSysString _typeIDString;
+ UString _typeIDString;
CListViewInfo _listViewInfo;
CItemProperties _properties;
CItemProperties _visibleProperties;
diff --git a/7zip/FileManager/PanelCopy.cpp b/7zip/FileManager/PanelCopy.cpp
index df0fd772..5aa19173 100755
--- a/7zip/FileManager/PanelCopy.cpp
+++ b/7zip/FileManager/PanelCopy.cpp
@@ -55,7 +55,7 @@ HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &fold
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- UString errorMessage = LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
if (showErrorMessages)
MessageBox(errorMessage);
else if (messages != 0)
@@ -71,9 +71,9 @@ HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &fold
extracter.ExtractCallbackSpec->ShowMessages = showErrorMessages;
UString title = moveMode ?
- LangLoadStringW(IDS_MOVING, 0x03020206):
- LangLoadStringW(IDS_COPYING, 0x03020205);
- UString progressWindowTitle = LangLoadStringW(IDS_APP_TITLE, 0x03000000);
+ LangString(IDS_MOVING, 0x03020206):
+ LangString(IDS_COPYING, 0x03020205);
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
extracter.ExtractCallbackSpec->ProgressDialog.MainWindow = GetParent();
extracter.ExtractCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle;
@@ -133,7 +133,7 @@ HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &fileP
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- UString errorMessage = LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
if (showErrorMessages)
MessageBox(errorMessage);
else if (messages != 0)
@@ -145,8 +145,8 @@ HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &fileP
updater.UpdateCallbackSpec = new CUpdateCallback100Imp;
updater.UpdateCallback = updater.UpdateCallbackSpec;
- UString title = LangLoadStringW(IDS_COPYING, 0x03020205);
- UString progressWindowTitle = LangLoadStringW(IDS_APP_TITLE, 0x03000000);
+ UString title = LangString(IDS_COPYING, 0x03020205);
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
updater.UpdateCallbackSpec->ProgressDialog.MainWindow = GetParent();
updater.UpdateCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle;
@@ -176,8 +176,8 @@ HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &fileP
void CPanel::CopyFrom(const UStringVector &filePaths)
{
- UString title = LangLoadStringW(IDS_CONFIRM_FILE_COPY, 0x03020222);
- UString message = LangLoadStringW(IDS_WANT_TO_COPY_FILES, 0x03020223);
+ UString title = LangString(IDS_CONFIRM_FILE_COPY, 0x03020222);
+ UString message = LangString(IDS_WANT_TO_COPY_FILES, 0x03020223);
message += L"\n\'";
message += _currentFolderPrefix;
message += L"\' ?";
diff --git a/7zip/FileManager/PanelDrag.cpp b/7zip/FileManager/PanelDrag.cpp
index 028be67b..4de6d95f 100755
--- a/7zip/FileManager/PanelDrag.cpp
+++ b/7zip/FileManager/PanelDrag.cpp
@@ -2,21 +2,26 @@
#include "StdAfx.h"
+#include "Common/StringConvert.h"
+
#include "Windows/Memory.h"
#include "Windows/FileDir.h"
#include "Windows/Shell.h"
-#include "Common/StringConvert.h"
#include "../UI/Common/ArchiveName.h"
#include "../UI/Common/CompressCall.h"
#include "Resource/MessagesDialog/MessagesDialog.h"
-using namespace NWindows;
-
#include "App.h"
#include "EnumFormatEtc.h"
+using namespace NWindows;
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
static wchar_t *kTempDirPrefix = L"7zE";
static LPCTSTR kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder");
@@ -212,39 +217,73 @@ STDMETHODIMP CDropSource::GiveFeedback(DWORD effect)
return DRAGDROP_S_USEDEFAULTCURSORS;
}
-static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const CSysStringVector &names)
+static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const UStringVector &names)
{
size_t totalLength = 1;
- int i;
- for (i = 0; i < names.Size(); i++)
- totalLength += names[i].Length() + 1;
-
- if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLength * sizeof(TCHAR) + sizeof(DROPFILES)))
- return false;
- NMemory::CGlobalLock dropLock(hgDrop);
- DROPFILES* dropFiles = (DROPFILES*)dropLock.GetPointer();
- if (dropFiles == 0)
- return false;
- dropFiles->fNC = FALSE;
- dropFiles->pt.x = 0;
- dropFiles->pt.y = 0;
- dropFiles->pFiles = sizeof(DROPFILES);
- #ifdef _UNICODE
- dropFiles->fWide = TRUE;
- #else
- dropFiles->fWide = FALSE;
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ AStringVector namesA;
+ int i;
+ for (i = 0; i < names.Size(); i++)
+ namesA.Add(GetSystemString(names[i]));
+ for (i = 0; i < names.Size(); i++)
+ totalLength += namesA[i].Length() + 1;
+
+ if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLength * sizeof(CHAR) + sizeof(DROPFILES)))
+ return false;
+
+ NMemory::CGlobalLock dropLock(hgDrop);
+ DROPFILES* dropFiles = (DROPFILES*)dropLock.GetPointer();
+ if (dropFiles == 0)
+ return false;
+ dropFiles->fNC = FALSE;
+ dropFiles->pt.x = 0;
+ dropFiles->pt.y = 0;
+ dropFiles->pFiles = sizeof(DROPFILES);
+ dropFiles->fWide = FALSE;
+ CHAR *p = (CHAR *)((BYTE *)dropFiles + sizeof(DROPFILES));
+ for (i = 0; i < names.Size(); i++)
+ {
+ const AString &s = namesA[i];
+ int fullLength = s.Length() + 1;
+ strcpy(p, s);
+ p += fullLength;
+ totalLength -= fullLength;
+ }
+ *p = 0;
+ }
+ else
#endif
- TCHAR *p = (TCHAR *)((BYTE *)dropFiles + sizeof(DROPFILES));
- for (i = 0; i < names.Size(); i++)
{
- const CSysString &s = names[i];
- int fullLength = s.Length() + 1;
- lstrcpy(p, s);
- p += fullLength;
- totalLength -= fullLength;
+ int i;
+ for (i = 0; i < names.Size(); i++)
+ totalLength += names[i].Length() + 1;
+
+ if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLength * sizeof(WCHAR) + sizeof(DROPFILES)))
+ return false;
+
+ NMemory::CGlobalLock dropLock(hgDrop);
+ DROPFILES* dropFiles = (DROPFILES*)dropLock.GetPointer();
+ if (dropFiles == 0)
+ return false;
+ dropFiles->fNC = FALSE;
+ dropFiles->pt.x = 0;
+ dropFiles->pt.y = 0;
+ dropFiles->pFiles = sizeof(DROPFILES);
+ dropFiles->fWide = TRUE;
+ WCHAR *p = (WCHAR *)((BYTE *)dropFiles + sizeof(DROPFILES));
+ for (i = 0; i < names.Size(); i++)
+ {
+ const UString &s = names[i];
+ int fullLength = s.Length() + 1;
+ wcscpy(p, s);
+ p += fullLength;
+ totalLength -= fullLength;
+ }
+ *p = 0;
}
- *p = 0;
return true;
}
@@ -278,9 +317,9 @@ void CPanel::OnDrag(LPNMLISTVIEW nmListView)
CMyComPtr<IDataObject> dataObject = dataObjectSpec;
{
- CSysStringVector names;
+ UStringVector names;
for (int i = 0; i < indices.Size(); i++)
- names.Add(GetSystemString(dirPrefix + GetItemName(indices[i])));
+ names.Add(dirPrefix + GetItemName(indices[i]));
if (!CopyNamesToHGlobal(dataObjectSpec->hGlobal, names))
return;
}
@@ -686,15 +725,12 @@ void CPanel::DropObject(IDataObject *dataObject, const UString &folderPath)
/*
void CPanel::CompressDropFiles(HDROP dr)
{
- CSysStringVector fileNames;
+ UStringVector fileNames;
{
NShell::CDrop drop(true);
drop.Attach(dr);
drop.QueryFileNames(fileNames);
}
- UStringVector fileNamesUnicode;
- for (int i = 0; i < fileNames.Size(); i++)
- fileNamesUnicode.Add(GetUnicodeString(fileNames[i]));
CompressDropFiles(fileNamesUnicode);
}
*/
diff --git a/7zip/FileManager/PanelFolderChange.cpp b/7zip/FileManager/PanelFolderChange.cpp
index e632c5f7..d8ae7d1b 100755
--- a/7zip/FileManager/PanelFolderChange.cpp
+++ b/7zip/FileManager/PanelFolderChange.cpp
@@ -141,12 +141,12 @@ void CPanel::LoadFullPathAndShow()
_appState->FolderHistory.AddString(_currentFolderPrefix);
// _headerComboBox.SendMessage(CB_RESETCONTENT, 0, 0);
- _headerComboBox.SetText(GetSystemString(_currentFolderPrefix));
+ _headerComboBox.SetText(_currentFolderPrefix);
/*
for (int i = 0; i < g_Folders.m_Strings.Size(); i++)
{
- CSysString string = GetSystemString(g_Folders.m_Strings[i]);
+ UString string = g_Folders.m_Strings[i];
COMBOBOXEXITEM item;
item.mask = CBEIF_TEXT;
item.iItem = i;
@@ -156,11 +156,41 @@ void CPanel::LoadFullPathAndShow()
*/
}
+bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result)
+{
+ if (info->iWhy == CBENF_ESCAPE)
+ {
+ _headerComboBox.SetText(_currentFolderPrefix);
+ PostMessage(kSetFocusToListView);
+ result = FALSE;
+ return true;
+ }
+ if (info->iWhy == CBENF_DROPDOWN)
+ {
+ result = FALSE;
+ return true;
+ }
+
+ if (info->iWhy == CBENF_RETURN)
+ {
+ if (BindToPathAndRefresh(info->szText) != S_OK)
+ {
+ result = TRUE;
+ return true;
+ }
+ result = FALSE;
+ PostMessage(kSetFocusToListView);
+ return true;
+ }
+ return false;
+}
+
+#ifndef _UNICODE
bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result)
{
if (info->iWhy == CBENF_ESCAPE)
{
- _headerComboBox.SetText(GetSystemString(_currentFolderPrefix));
+ _headerComboBox.SetText(_currentFolderPrefix);
PostMessage(kSetFocusToListView);
result = FALSE;
return true;
@@ -175,7 +205,6 @@ bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result)
{
if (BindToPathAndRefresh(GetUnicodeString(info->szText)) != S_OK)
{
- // MessageBeep((UINT)-1);
result = TRUE;
return true;
}
@@ -185,24 +214,22 @@ bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result)
}
return false;
}
+#endif
void CPanel::OnComboBoxCommand(UINT code, LPARAM &param)
{
/*
if (code == CBN_SELENDOK)
{
- CSysString path;
+ UString path;
if (!_headerComboBox.GetText(path))
return;
CRootFolder *rootFolderSpec = new CRootFolder;
CMyComPtr<IFolderFolder> rootFolder = rootFolderSpec;
rootFolderSpec->Init();
CMyComPtr<IFolderFolder> newFolder;
- if (rootFolder->BindToFolder(GetUnicodeString(path),
- &newFolder) != S_OK)
- {
+ if (rootFolder->BindToFolder(path, &newFolder) != S_OK)
return;
- }
_folder = newFolder;
SetCurrentPathText();
RefreshListCtrl(UString(), -1, UStringVector());
@@ -220,10 +247,16 @@ bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result)
_lastFocusedIsList = false;
_panelCallback->PanelWasFocused();
}
+ #ifndef _UNICODE
case CBEN_ENDEDIT:
{
return OnNotifyComboBoxEndEdit((PNMCBEENDEDIT)header, result);
}
+ #endif
+ case CBEN_ENDEDITW:
+ {
+ return OnNotifyComboBoxEndEdit((PNMCBEENDEDITW)header, result);
+ }
}
return false;
}
@@ -233,28 +266,23 @@ void CPanel::FoldersHistory()
{
CListViewDialog listViewDialog;
listViewDialog.DeleteIsAllowed = true;
- // listViewDialog.m_Value = TEXT("*");
- listViewDialog.Title = LangLoadStringW(IDS_FOLDERS_HISTORY, 0x03020260);
- UStringVector strings;
- _appState->FolderHistory.GetList(strings);
- int i;
- for(i = 0; i < strings.Size(); i++)
- listViewDialog.Strings.Add(GetSystemString(strings[i]));
+ listViewDialog.Title = LangString(IDS_FOLDERS_HISTORY, 0x03020260);
+ _appState->FolderHistory.GetList(listViewDialog.Strings);
if (listViewDialog.Create(GetParent()) == IDCANCEL)
return;
UString selectString;
if (listViewDialog.StringsWereChanged)
{
_appState->FolderHistory.RemoveAll();
- for (i = listViewDialog.Strings.Size() - 1; i >= 0; i--)
- _appState->FolderHistory.AddString(GetUnicodeString(listViewDialog.Strings[i]));
+ for (int i = listViewDialog.Strings.Size() - 1; i >= 0; i--)
+ _appState->FolderHistory.AddString(listViewDialog.Strings[i]);
if (listViewDialog.FocusedItemIndex >= 0)
- selectString = GetUnicodeString(listViewDialog.Strings[listViewDialog.FocusedItemIndex]);
+ selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex];
}
else
{
if (listViewDialog.FocusedItemIndex >= 0)
- selectString = strings[listViewDialog.FocusedItemIndex];
+ selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex];
}
if (listViewDialog.FocusedItemIndex >= 0)
BindToPathAndRefresh(selectString);
@@ -273,7 +301,7 @@ void CPanel::OpenParentFolder()
pos = 0;
else
pos++;
- focucedName = GetUnicodeString(string.Mid(pos));
+ focucedName = string.Mid(pos);
}
CDisableTimerProcessing disableTimerProcessing1(*this);
@@ -309,7 +337,7 @@ void CPanel::OpenParentFolder()
selectedItems.Add(focucedName);
*/
LoadFullPath();
- ::SetCurrentDirectory(::GetSystemString(_currentFolderPrefix));
+ // ::SetCurrentDirectory(::_currentFolderPrefix);
RefreshListCtrl(focucedName, -1, true, selectedItems);
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
RefreshStatusBar();
@@ -337,13 +365,13 @@ void CPanel::OpenRootFolder()
_parentFolders.Clear();
SetToRootFolder();
RefreshListCtrl(UString(), -1, true, UStringVector());
- // ::SetCurrentDirectory(::GetSystemString(_currentFolderPrefix));
+ // ::SetCurrentDirectory(::_currentFolderPrefix);
/*
BeforeChangeFolder();
_currentFolderPrefix.Empty();
AfterChangeFolder();
SetCurrentPathText();
- RefreshListCtrl(CSysString(), 0, CSysStringVector());
+ RefreshListCtrl(UString(), 0, UStringVector());
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
*/
}
@@ -370,7 +398,7 @@ void CPanel::OpenFolder(int index)
return;
_folder = newFolder;
LoadFullPath();
- ::SetCurrentDirectory(::GetSystemString(_currentFolderPrefix));
+ // ::SetCurrentDirectory(::_currentFolderPrefix);
RefreshListCtrl();
UINT state = LVIS_SELECTED;
_listView.SetItemState(_listView.GetFocusedItem(), state, state);
diff --git a/7zip/FileManager/PanelItemOpen.cpp b/7zip/FileManager/PanelItemOpen.cpp
index 5cf77b7c..25a25c8f 100755
--- a/7zip/FileManager/PanelItemOpen.cpp
+++ b/7zip/FileManager/PanelItemOpen.cpp
@@ -29,9 +29,9 @@ using namespace NFile;
using namespace NDirectory;
extern HWND g_HWND;
-
-static inline UINT GetCurrentFileCodePage()
- { return AreFileApisANSI() ? CP_ACP : CP_OEMCP;}
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
static wchar_t *kTempDirPrefix = L"7zO";
@@ -81,8 +81,7 @@ HRESULT CPanel::OpenItemAsArchive(const UString &name,
// _password.Empty();
NDLL::CLibrary library;
- RINOK(OpenFileFolderPlugin(GetUnicodeString(filePath),
- &library, &newFolder, GetParent()));
+ RINOK(OpenFileFolderPlugin(filePath, &library, &newFolder, GetParent()));
folderLink.ParentFolder = _folder;
folderLink.ItemName = name;
@@ -130,7 +129,7 @@ HRESULT CPanel::OpenParentArchiveFolder()
if (OnOpenItemChanged(folderLink.FolderPath, folderLink.ItemName) != S_OK)
{
::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE,
- 0x03020281, GetUnicodeString(folderLink.FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP);
+ 0x03020281, folderLink.FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
return S_OK;
}
}
@@ -151,69 +150,114 @@ static bool DoItemAlwaysStart(const UString &name)
static HANDLE StartEditApplication(const UString &path, HWND window)
{
- CSysString command;
+ UString command;
ReadRegEditor(command);
if (command.IsEmpty())
{
if (!MyGetWindowsDirectory(command))
return 0;
NFile::NName::NormalizeDirPathPrefix(command);
- command += TEXT("notepad.exe");
+ command += L"notepad.exe";
}
- command = CSysString(TEXT("\"")) + command + CSysString(TEXT("\""));
- command += TEXT(" \"");
- command += GetSystemString(path);
- command += TEXT("\"");
-
- STARTUPINFO startupInfo;
- startupInfo.cb = sizeof(startupInfo);
- startupInfo.lpReserved = 0;
- startupInfo.lpDesktop = 0;
- startupInfo.lpTitle = 0;
- startupInfo.dwFlags = 0;
- startupInfo.cbReserved2 = 0;
- startupInfo.lpReserved2 = 0;
-
+ command = UString(L"\"") + command + UString(L"\"");
+ command += L" \"";
+ command += UString(path);
+ command += L"\"";
+
PROCESS_INFORMATION processInformation;
- BOOL result = ::CreateProcess(NULL, (TCHAR *)(const TCHAR *)command,
+ BOOL result;
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ STARTUPINFOA startupInfo;
+ startupInfo.cb = sizeof(startupInfo);
+ startupInfo.lpReserved = 0;
+ startupInfo.lpDesktop = 0;
+ startupInfo.lpTitle = 0;
+ startupInfo.dwFlags = 0;
+ startupInfo.cbReserved2 = 0;
+ startupInfo.lpReserved2 = 0;
+
+ result = ::CreateProcessA(NULL, (CHAR *)(const CHAR *)GetSystemString(command),
+ NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
+ }
+ else
+ #endif
+ {
+ STARTUPINFOW startupInfo;
+ startupInfo.cb = sizeof(startupInfo);
+ startupInfo.lpReserved = 0;
+ startupInfo.lpDesktop = 0;
+ startupInfo.lpTitle = 0;
+ startupInfo.dwFlags = 0;
+ startupInfo.cbReserved2 = 0;
+ startupInfo.lpReserved2 = 0;
+
+ result = ::CreateProcessW(NULL, (WCHAR *)(const WCHAR *)command,
NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
+ }
+
if (result != FALSE)
{
::CloseHandle(processInformation.hThread);
return processInformation.hProcess;
}
- ::MessageBoxW(window, LangLoadStringW(IDS_CANNOT_START_EDITOR, 0x03020282),
+ ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282),
L"7-Zip", MB_OK | MB_ICONSTOP);
return 0;
}
static HANDLE StartApplication(const UString &path, HWND window)
{
- SHELLEXECUTEINFO execInfo;
- execInfo.cbSize = sizeof(execInfo);
- execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
- execInfo.hwnd = NULL;
- execInfo.lpVerb = NULL;
- const CSysString sysPath = GetSystemString(path);
- execInfo.lpFile = sysPath;
- execInfo.lpParameters = NULL;
- execInfo.lpDirectory = NULL;
- execInfo.nShow = SW_SHOWNORMAL;
- execInfo.hProcess = 0;
- bool success = BOOLToBool(::ShellExecuteEx(&execInfo));
- UINT32 result = (UINT32)execInfo.hInstApp;
+ UINT32 result;
+ HANDLE hProcess;
+ #ifndef _UNICODE
+ if (g_IsNT)
+ {
+ SHELLEXECUTEINFOW execInfo;
+ execInfo.cbSize = sizeof(execInfo);
+ execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
+ execInfo.hwnd = NULL;
+ execInfo.lpVerb = NULL;
+ execInfo.lpFile = path;
+ execInfo.lpParameters = NULL;
+ execInfo.lpDirectory = NULL;
+ execInfo.nShow = SW_SHOWNORMAL;
+ execInfo.hProcess = 0;
+ ::ShellExecuteExW(&execInfo);
+ result = (UINT32)execInfo.hInstApp;
+ hProcess = execInfo.hProcess;
+ }
+ else
+ #endif
+ {
+ SHELLEXECUTEINFO execInfo;
+ execInfo.cbSize = sizeof(execInfo);
+ execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
+ execInfo.hwnd = NULL;
+ execInfo.lpVerb = NULL;
+ const CSysString sysPath = GetSystemString(path);
+ execInfo.lpFile = sysPath;
+ execInfo.lpParameters = NULL;
+ execInfo.lpDirectory = NULL;
+ execInfo.nShow = SW_SHOWNORMAL;
+ execInfo.hProcess = 0;
+ ::ShellExecuteEx(&execInfo);
+ result = (UINT32)execInfo.hInstApp;
+ hProcess = execInfo.hProcess;
+ }
if(result <= 32)
{
switch(result)
{
case SE_ERR_NOASSOC:
- ::MessageBox(window,
- NError::MyFormatMessage(::GetLastError()),
- // TEXT("There is no application associated with the given file name extension"),
- TEXT("7-Zip"), MB_OK | MB_ICONSTOP);
+ ::MessageBoxW(window,
+ NError::MyFormatMessageW(::GetLastError()),
+ // L"There is no application associated with the given file name extension",
+ L"7-Zip", MB_OK | MB_ICONSTOP);
}
}
- return execInfo.hProcess;
+ return hProcess;
}
void CPanel::EditItem(int index)
@@ -268,7 +312,7 @@ LRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &item
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return E_FAIL;
}
UStringVector fileNames;
@@ -342,7 +386,7 @@ static DWORD WINAPI MyThreadFunction(void *param)
if (SendMessage(tmpProcessInfo->Window, kOpenItemChanged, 0, (LONG_PTR)tmpProcessInfo) != 1)
{
::MessageBoxW(g_HWND, MyFormatNew(IDS_CANNOT_UPDATE_FILE,
- 0x03020281, GetUnicodeString(tmpProcessInfo->FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP);
+ 0x03020281, tmpProcessInfo->FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
return 0;
}
}
@@ -365,7 +409,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
@@ -443,7 +487,7 @@ static bool CheckDeleteItem(UINT64 currentFileTime, UINT64 folderFileTime)
void DeleteOldTempFiles()
{
- CSysString tempPath;
+ UString tempPath;
if(!NFile::NDirectory::MyGetTempPath(tempPath))
throw 1;
@@ -452,10 +496,10 @@ void DeleteOldTempFiles()
UINT64 currentFileTime;
if(!::SystemTimeToFileTime(&systemTime, (FILETIME *)&currentFileTime))
throw 2;
- CSysString searchWildCard = tempPath + kTempDirPrefix + TEXT("*.tmp");
- searchWildCard += TCHAR(NName::kAnyStringWildcard);
- NFind::CEnumerator enumerator(searchWildCard);
- NFind::CFileInfo fileInfo;
+ UString searchWildCard = tempPath + kTempDirPrefix + L"*.tmp";
+ searchWildCard += WCHAR(NName::kAnyStringWildcard);
+ NFind::CEnumeratorW enumerator(searchWildCard);
+ NFind::CFileInfoW fileInfo;
while(enumerator.Next(fileInfo))
{
if (!fileInfo.IsDirectory())
diff --git a/7zip/FileManager/PanelItems.cpp b/7zip/FileManager/PanelItems.cpp
index b839cc8f..7e926226 100755
--- a/7zip/FileManager/PanelItems.cpp
+++ b/7zip/FileManager/PanelItems.cpp
@@ -186,10 +186,8 @@ void CPanel::InitColumns()
void CPanel::InsertColumn(int index)
{
const CItemProperty &property = _visibleProperties[index];
- LV_COLUMN column;
+ LV_COLUMNW column;
column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_ORDER;
- TCHAR string[1024];
- column.pszText = string;
column.cx = property.Width;
column.fmt = GetColumnAlign(property.ID, property.Type);
column.iOrder = property.Order;
@@ -197,7 +195,7 @@ void CPanel::InsertColumn(int index)
UString propertyName = GetNameOfProperty(property.ID);
if (propertyName.IsEmpty())
propertyName = property.Name;
- lstrcpy(string, GetSystemString(propertyName));
+ column.pszText = (wchar_t *)(const wchar_t *)propertyName;
_listView.InsertColumn(index, &column);
}
@@ -223,8 +221,8 @@ void CPanel::GetSelectedNames(UStringVector &selectedNames)
for (int i = 0; i < _listView.GetItemCount(); i++)
{
const int kSize = 1024;
- TCHAR name[kSize + 1];
- LVITEM item;
+ WCHAR name[kSize + 1];
+ LVITEMW item;
item.iItem = i;
item.pszText = name;
item.cchTextMax = kSize;
@@ -236,7 +234,7 @@ void CPanel::GetSelectedNames(UStringVector &selectedNames)
if (realIndex == kParentIndex)
continue;
if (_selectedStatusVector[realIndex])
- selectedNames.Add(GetUnicodeString(item.pszText));
+ selectedNames.Add(item.pszText);
}
*/
selectedNames.Sort();
@@ -262,15 +260,15 @@ void CPanel::SaveSelectedState(CSelectedState &s)
s.FocusedName = GetItemName(realIndex);
/*
const int kSize = 1024;
- TCHAR name[kSize + 1];
- LVITEM item;
+ WCHAR name[kSize + 1];
+ LVITEMW item;
item.iItem = focusedItem;
item.pszText = name;
item.cchTextMax = kSize;
item.iSubItem = 0;
item.mask = LVIF_TEXT;
if (_listView.GetItem(&item))
- focusedName = GetUnicodeString(item.pszText);
+ focusedName = item.pszText;
*/
}
}
@@ -320,7 +318,7 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
_listView.SetRedraw(false);
// m_RedrawEnabled = false;
- LVITEM item;
+ LVITEMW item;
ZeroMemory(&item, sizeof(item));
_listView.DeleteAllItems();
@@ -373,13 +371,9 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
int subItem = 0;
item.iSubItem = subItem++;
item.lParam = kParentIndex;
- const int kMaxNameSize = MAX_PATH * 2;
- TCHAR string[kMaxNameSize];
- lstrcpyn(string, GetSystemString(itemName), kMaxNameSize);
- item.pszText = string;
+ item.pszText = (wchar_t *)(const wchar_t *)itemName;
UINT32 attributes = FILE_ATTRIBUTE_DIRECTORY;
- item.iImage = _extToIconMap.GetIconIndex(attributes,
- GetSystemString(itemName));
+ item.iImage = _extToIconMap.GetIconIndex(attributes, itemName);
if (item.iImage < 0)
item.iImage = 0;
if(_listView.InsertItem(&item) == -1)
@@ -413,11 +407,9 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
item.iSubItem = subItem++;
item.lParam = i;
- const int kMaxNameSize = MAX_PATH * 2;
- TCHAR string[kMaxNameSize + 1];
+ UString correctedName;
if (itemName.Find(L" ") >= 0)
{
- UString correctedName;
int pos = 0;
while (true)
{
@@ -432,11 +424,10 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
pos = posNew;
while (itemName[++pos] == ' ');
}
- lstrcpyn(string, GetSystemString(correctedName), kMaxNameSize);
+ item.pszText = (wchar_t *)(const wchar_t *)correctedName;
}
else
- lstrcpyn(string, GetSystemString(itemName), kMaxNameSize);
- item.pszText = string;
+ item.pszText = (wchar_t *)(const wchar_t *)itemName;
NCOM::CPropVariant propVariant;
_folder->GetProperty(i, kpidAttributes, &propVariant);
@@ -461,13 +452,12 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
if (_currentFolderPrefix.IsEmpty())
{
int iconIndexTemp;
- GetRealIconIndex(GetSystemString(itemName + L"\\"), attributes, iconIndexTemp);
+ GetRealIconIndex(itemName + L"\\", attributes, iconIndexTemp);
item.iImage = iconIndexTemp;
}
else
{
- item.iImage = _extToIconMap.GetIconIndex(attributes,
- GetSystemString(itemName));
+ item.iImage = _extToIconMap.GetIconIndex(attributes, itemName);
}
}
if (item.iImage < 0)
@@ -585,7 +575,7 @@ void CPanel::OpenSelectedItems(bool tryInternal)
GetOperatedItemIndices(indices);
if (indices.Size() > 20)
{
- MessageBox(LangLoadStringW(IDS_TOO_MANY_ITEMS, 0x02000606));
+ MessageBox(LangString(IDS_TOO_MANY_ITEMS, 0x02000606));
return;
}
@@ -667,7 +657,7 @@ void CPanel::ReadListViewInfo()
return;
CMyComBSTR typeID;
folderGetTypeID->GetTypeID(&typeID);
- _typeIDString = GetSystemString((const wchar_t *)typeID);
+ _typeIDString = typeID;
::ReadListViewInfo(_typeIDString, _listViewInfo);
}
diff --git a/7zip/FileManager/PanelKey.cpp b/7zip/FileManager/PanelKey.cpp
index f623332a..493bcb1e 100755
--- a/7zip/FileManager/PanelKey.cpp
+++ b/7zip/FileManager/PanelKey.cpp
@@ -8,7 +8,7 @@
#include "../PropID.h"
#include "App.h"
-// static LPCTSTR kHelpTopic = _T("FM/index.htm");
+// static LPCWSTR kHelpTopic = L"FM/index.htm";
struct CVKeyPropIDPair
{
diff --git a/7zip/FileManager/PanelListNotify.cpp b/7zip/FileManager/PanelListNotify.cpp
index ac8c069d..831a7d3e 100755
--- a/7zip/FileManager/PanelListNotify.cpp
+++ b/7zip/FileManager/PanelListNotify.cpp
@@ -41,7 +41,7 @@ static UString ConvertSizeToString(UINT64 value)
return UString(s) + L" G";
}
-LRESULT CPanel::SetItemText(LVITEM &item)
+LRESULT CPanel::SetItemText(LVITEMW &item)
{
UINT32 realIndex = GetRealIndex(item);
/*
@@ -84,7 +84,7 @@ LRESULT CPanel::SetItemText(LVITEM &item)
if (realIndex == kParentIndex)
return 0;
- UString string;
+ UString s;
UINT32 subItemIndex = item.iSubItem;
PROPID propID = _visibleProperties[subItemIndex].ID;
/*
@@ -120,6 +120,7 @@ LRESULT CPanel::SetItemText(LVITEM &item)
}
if (needRead)
*/
+
if (_folder->GetProperty(realIndex, propID, &propVariant) != S_OK)
throw 2723407;
@@ -128,20 +129,16 @@ LRESULT CPanel::SetItemText(LVITEM &item)
propID == kpidClusterSize)
&&
(propVariant.vt == VT_UI8 || propVariant.vt == VT_UI4))
- {
- string = ConvertSizeToString(ConvertPropVariantToUInt64(propVariant));
- }
+ s = ConvertSizeToString(ConvertPropVariantToUInt64(propVariant));
else
- {
- string = ConvertPropertyToString(propVariant, propID, false);
- }
+ s = ConvertPropertyToString(propVariant, propID, false);
int size = item.cchTextMax;
if(size > 0)
{
- if(string.Length() + 1 > size)
- string = string.Left(size - 1);
- lstrcpy(item.pszText, GetSystemString(string));
+ if(s.Length() + 1 > size)
+ s = s.Left(size - 1);
+ wcscpy(item.pszText, s);
}
return 0;
}
@@ -185,9 +182,9 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
}
*/
- case LVN_GETDISPINFO:
+ case LVN_GETDISPINFOW:
{
- LV_DISPINFO *dispInfo = (LV_DISPINFO *)header;
+ LV_DISPINFOW *dispInfo = (LV_DISPINFOW *)header;
//is the sub-item information being requested?
@@ -268,11 +265,11 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
OnLeftClick((LPNMITEMACTIVATE)header);
return false;
}
- case LVN_BEGINLABELEDIT:
- result = OnBeginLabelEdit((LV_DISPINFO *)header);
+ case LVN_BEGINLABELEDITW:
+ result = OnBeginLabelEdit((LV_DISPINFOW *)header);
return true;
- case LVN_ENDLABELEDIT:
- result = OnEndLabelEdit((LV_DISPINFO *)header);
+ case LVN_ENDLABELEDITW:
+ result = OnEndLabelEdit((LV_DISPINFOW *)header);
return true;
case NM_CUSTOMDRAW:
@@ -354,8 +351,7 @@ void CPanel::OnRefreshStatusBar()
CRecordVector<UINT32> indices;
GetOperatedItemIndices(indices);
- _statusBar.SetText(0, GetSystemString(MyFormatNew(IDS_N_SELECTED_ITEMS,
- 0x02000301, NumberToStringW(indices.Size()))));
+ _statusBar.SetText(0, MyFormatNew(IDS_N_SELECTED_ITEMS, 0x02000301, NumberToString(indices.Size())));
UString selectSizeString;
@@ -366,12 +362,11 @@ void CPanel::OnRefreshStatusBar()
totalSize += GetItemSize(indices[i]);
selectSizeString = ConvertSizeToString(totalSize);
}
- _statusBar.SetText(1, GetSystemString(selectSizeString));
+ _statusBar.SetText(1, selectSizeString);
int focusedItem = _listView.GetFocusedItem();
UString sizeString;
UString dateString;
- // CSysString nameString;
if (focusedItem >= 0 && _listView.GetSelectedCount() > 0)
{
int realIndex = GetRealItemIndex(focusedItem);
@@ -382,16 +377,9 @@ void CPanel::OnRefreshStatusBar()
if (_folder->GetProperty(realIndex, kpidLastWriteTime, &propVariant) == S_OK)
dateString = ConvertPropertyToString(propVariant, kpidLastWriteTime, false);
}
- // nameString = GetSystemString(GetItemName(realIndex));
}
- _statusBar.SetText(2, GetSystemString(sizeString));
- _statusBar.SetText(3, GetSystemString(dateString));
+ _statusBar.SetText(2, sizeString);
+ _statusBar.SetText(3, dateString);
// _statusBar.SetText(4, nameString);
-
-
- /*
- _statusBar2.SetText(1, GetSystemString(MyFormatNew(L"{0} bytes",
- NumberToStringW(totalSize))));
- */
- // _statusBar.SetText(L"yyy"));
+ // _statusBar2.SetText(1, MyFormatNew(L"{0} bytes", NumberToStringW(totalSize)));
}
diff --git a/7zip/FileManager/PanelMenu.cpp b/7zip/FileManager/PanelMenu.cpp
index f10fa1aa..3766a7ea 100755
--- a/7zip/FileManager/PanelMenu.cpp
+++ b/7zip/FileManager/PanelMenu.cpp
@@ -198,17 +198,17 @@ void CPanel::CreateSystemMenu(HMENU menuSpec,
systemContextMenu->QueryContextMenu(hMenu, 0, kSystemStartMenuID, 0x7FFF, Flags);
- MENUITEMINFO menuItem;
- menuItem.cbSize = sizeof(menuItem);
- menuItem.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_ID;
- menuItem.fType = MFT_STRING;
- menuItem.hSubMenu = popupMenu.Detach();
- // menuDestroyer.Disable();
- CSysString popupMenuCaption = LangLoadString(IDS_SYSTEM, 0x030202A0);
- menuItem.dwTypeData = (LPTSTR)(LPCTSTR)popupMenuCaption;
-
- InsertMenuItem(menuSpec, 0, TRUE, &menuItem);
-
+ {
+ CMenu menu;
+ menu.Attach(menuSpec);
+ CMenuItem menuItem;
+ menuItem.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_ID;
+ menuItem.fType = MFT_STRING;
+ menuItem.hSubMenu = popupMenu.Detach();
+ // menuDestroyer.Disable();
+ menuItem.StringValue = LangString(IDS_SYSTEM, 0x030202A0);
+ menu.InsertItem(0, true, menuItem);
+ }
/*
if (Cmd < 100 && Cmd != 0)
{
@@ -302,7 +302,7 @@ void CPanel::CreateFileMenu(HMENU menuSpec,
CreateSystemMenu(menu, operatedIndices, systemContextMenu);
if (menu.GetItemCount() > 0)
- menu.AppendItem(MF_SEPARATOR, 0, 0);
+ menu.AppendItem(MF_SEPARATOR, 0, (LPCTSTR)0);
LoadFileMenu(menu, menu.GetItemCount(), !operatedIndices.IsEmpty(), programMenu);
}
diff --git a/7zip/FileManager/PanelOperations.cpp b/7zip/FileManager/PanelOperations.cpp
index 5efbc2d7..3e5c85f6 100755
--- a/7zip/FileManager/PanelOperations.cpp
+++ b/7zip/FileManager/PanelOperations.cpp
@@ -24,6 +24,10 @@
using namespace NWindows;
using namespace NFile;
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
struct CThreadDelete
{
CMyComPtr<IFolderOperations> FolderOperations;
@@ -58,37 +62,68 @@ void CPanel::DeleteItems(bool toRecycleBin)
SaveSelectedState(state);
if (IsFSFolder())
{
- CDynamicBuffer<TCHAR> buffer;
- size_t size = 0;
- for (int i = 0; i < indices.Size(); i++)
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ CDynamicBuffer<CHAR> buffer;
+ size_t size = 0;
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ const AString path = GetSystemString(GetFsPath() + GetItemName(indices[i]));
+ buffer.EnsureCapacity(size + path.Length() + 1);
+ memmove(((CHAR *)buffer) + size, (const CHAR *)path, (path.Length() + 1) * sizeof(CHAR));
+ size += path.Length() + 1;
+ }
+ buffer.EnsureCapacity(size + 1);
+ ((CHAR *)buffer)[size] = 0;
+ SHFILEOPSTRUCTA fo;
+ fo.hwnd = GetParent();
+ fo.wFunc = FO_DELETE;
+ fo.pFrom = (const CHAR *)buffer;
+ fo.pTo = 0;
+ fo.fFlags = 0;
+ if (toRecycleBin)
+ fo.fFlags |= FOF_ALLOWUNDO;
+ // fo.fFlags |= FOF_NOCONFIRMATION;
+ // fo.fFlags |= FOF_NOERRORUI;
+ // fo.fFlags |= FOF_SILENT;
+ // fo.fFlags |= FOF_WANTNUKEWARNING;
+ fo.fAnyOperationsAborted = FALSE;
+ fo.hNameMappings = 0;
+ fo.lpszProgressTitle = 0;
+ int res = ::SHFileOperationA(&fo);
+ }
+ else
+ #endif
{
- const CSysString path = GetSystemString(GetFsPath() + GetItemName(indices[i]));
- buffer.EnsureCapacity(size + path.Length() + 1);
- memmove(((TCHAR *)buffer) + size, (const TCHAR *)path, (path.Length() + 1) * sizeof(TCHAR));
- size += path.Length() + 1;
+ CDynamicBuffer<WCHAR> buffer;
+ size_t size = 0;
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ const UString path = GetFsPath() + GetItemName(indices[i]);
+ buffer.EnsureCapacity(size + path.Length() + 1);
+ memmove(((WCHAR *)buffer) + size, (const WCHAR *)path, (path.Length() + 1) * sizeof(WCHAR));
+ size += path.Length() + 1;
+ }
+ buffer.EnsureCapacity(size + 1);
+ ((WCHAR *)buffer)[size] = 0;
+ SHFILEOPSTRUCTW fo;
+ fo.hwnd = GetParent();
+ fo.wFunc = FO_DELETE;
+ fo.pFrom = (const WCHAR *)buffer;
+ fo.pTo = 0;
+ fo.fFlags = 0;
+ if (toRecycleBin)
+ fo.fFlags |= FOF_ALLOWUNDO;
+ fo.fAnyOperationsAborted = FALSE;
+ fo.hNameMappings = 0;
+ fo.lpszProgressTitle = 0;
+ int res = ::SHFileOperationW(&fo);
}
- buffer.EnsureCapacity(size + 1);
- ((TCHAR *)buffer)[size] = 0;
- SHFILEOPSTRUCT fo;
- fo.hwnd = GetParent();
- fo.wFunc = FO_DELETE;
- fo.pFrom = (const TCHAR *)buffer;
- fo.pTo = 0;
- fo.fFlags = 0;
- if (toRecycleBin)
- fo.fFlags |= FOF_ALLOWUNDO;
- // fo.fFlags |= FOF_NOCONFIRMATION;
- // fo.fFlags |= FOF_NOERRORUI;
- // fo.fFlags |= FOF_SILENT;
- // fo.fFlags |= FOF_WANTNUKEWARNING;
- fo.fAnyOperationsAborted = FALSE;
- fo.hNameMappings = 0;
- fo.lpszProgressTitle = 0;
- int res = SHFileOperation(&fo);
/*
if (fo.fAnyOperationsAborted)
{
- MessageBoxError(result, LangLoadStringW(IDS_ERROR_DELETING, 0x03020217));
+ MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217));
}
*/
/*
@@ -102,7 +137,7 @@ void CPanel::DeleteItems(bool toRecycleBin)
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
@@ -114,20 +149,20 @@ void CPanel::DeleteItems(bool toRecycleBin)
const UString itemName = GetItemName(index);
if (IsItemFolder(index))
{
- title = LangLoadStringW(IDS_CONFIRM_FOLDER_DELETE, 0x03020211);
+ title = LangString(IDS_CONFIRM_FOLDER_DELETE, 0x03020211);
message = MyFormatNew(IDS_WANT_TO_DELETE_FOLDER, 0x03020214, itemName);
}
else
{
- title = LangLoadStringW(IDS_CONFIRM_FILE_DELETE, 0x03020210);
+ title = LangString(IDS_CONFIRM_FILE_DELETE, 0x03020210);
message = MyFormatNew(IDS_WANT_TO_DELETE_FILE, 0x03020213, itemName);
}
}
else
{
- title = LangLoadStringW(IDS_CONFIRM_ITEMS_DELETE, 0x03020212);
+ title = LangString(IDS_CONFIRM_ITEMS_DELETE, 0x03020212);
message = MyFormatNew(IDS_WANT_TO_DELETE_ITEMS, 0x03020215,
- NumberToStringW(indices.Size()));
+ NumberToString(indices.Size()));
}
if (::MessageBoxW(GetParent(), message, title, MB_OKCANCEL | MB_ICONQUESTION) != IDOK)
return;
@@ -137,10 +172,10 @@ void CPanel::DeleteItems(bool toRecycleBin)
deleter.UpdateCallback = deleter.UpdateCallbackSpec;
deleter.UpdateCallbackSpec->Init(GetParent(), false, L"");
- UString progressTitle = LangLoadStringW(IDS_DELETING, 0x03020216);
+ UString progressTitle = LangString(IDS_DELETING, 0x03020216);
deleter.UpdateCallbackSpec->ProgressDialog.MainWindow = _mainWindow;
- deleter.UpdateCallbackSpec->ProgressDialog.MainTitle = LangLoadStringW(IDS_APP_TITLE, 0x03000000);
+ deleter.UpdateCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000);
deleter.UpdateCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" ");
deleter.FolderOperations = folderOperations;
@@ -153,13 +188,13 @@ void CPanel::DeleteItems(bool toRecycleBin)
HRESULT result = deleter.Result;
if (result != S_OK)
- MessageBoxError(result, LangLoadStringW(IDS_ERROR_DELETING, 0x03020217));
+ MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217));
}
RefreshListCtrl(state);
}
-BOOL CPanel::OnBeginLabelEdit(LV_DISPINFO * lpnmh)
+BOOL CPanel::OnBeginLabelEdit(LV_DISPINFOW * lpnmh)
{
int realIndex = GetRealIndex(lpnmh->item);
if (realIndex == kParentIndex)
@@ -170,7 +205,7 @@ BOOL CPanel::OnBeginLabelEdit(LV_DISPINFO * lpnmh)
return FALSE;
}
-BOOL CPanel::OnEndLabelEdit(LV_DISPINFO * lpnmh)
+BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
{
if (lpnmh->item.pszText == NULL)
return FALSE;
@@ -180,7 +215,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFO * lpnmh)
MessageBoxMyError(L"Renaming is not supported");
return FALSE;
}
- UString newName = GetUnicodeString(lpnmh->item.pszText);
+ UString newName = lpnmh->item.pszText;
CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
int realIndex = GetRealIndex(lpnmh->item);
@@ -189,7 +224,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFO * lpnmh)
HRESULT result = folderOperations->Rename(realIndex, newName, 0);
if (result != S_OK)
{
- MessageBoxError(result, LangLoadStringW(IDS_ERROR_RENAMING, 0x03020221));
+ MessageBoxError(result, LangString(IDS_ERROR_RENAMING, 0x03020221));
return FALSE;
}
// Can't use RefreshListCtrl here.
@@ -209,26 +244,26 @@ void CPanel::CreateFolder()
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
CSelectedState state;
SaveSelectedState(state);
CComboDialog comboDialog;
- comboDialog.Title = LangLoadStringW(IDS_CREATE_FOLDER, 0x03020230);
- comboDialog.Static = LangLoadStringW(IDS_CREATE_FOLDER_NAME, 0x03020231);
- comboDialog.Value = LangLoadStringW(IDS_CREATE_FOLDER_DEFAULT_NAME, /*0x03020232*/ (UInt32)-1);
+ comboDialog.Title = LangString(IDS_CREATE_FOLDER, 0x03020230);
+ comboDialog.Static = LangString(IDS_CREATE_FOLDER_NAME, 0x03020231);
+ comboDialog.Value = LangString(IDS_CREATE_FOLDER_DEFAULT_NAME, /*0x03020232*/ (UInt32)-1);
if (comboDialog.Create(GetParent()) == IDCANCEL)
return;
- UString newName = GetUnicodeString(comboDialog.Value);
+ UString newName = comboDialog.Value;
HRESULT result = folderOperations->CreateFolder(newName, 0);
if (result != S_OK)
{
- MessageBoxError(result, LangLoadStringW(IDS_CREATE_FOLDER_ERROR, 0x03020233));
+ MessageBoxError(result, LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233));
return;
}
- int pos = newName.Find(TEXT('\\'));
+ int pos = newName.Find(L'\\');
if (pos >= 0)
newName = newName.Left(pos);
if (!_mySelectMode)
@@ -243,26 +278,26 @@ void CPanel::CreateFile()
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
CSelectedState state;
SaveSelectedState(state);
CComboDialog comboDialog;
- comboDialog.Title = LangLoadStringW(IDS_CREATE_FILE, 0x03020240);
- comboDialog.Static = LangLoadStringW(IDS_CREATE_FILE_NAME, 0x03020241);
- comboDialog.Value = LangLoadStringW(IDS_CREATE_FILE_DEFAULT_NAME, /*0x03020242*/ (UInt32)-1);
+ comboDialog.Title = LangString(IDS_CREATE_FILE, 0x03020240);
+ comboDialog.Static = LangString(IDS_CREATE_FILE_NAME, 0x03020241);
+ comboDialog.Value = LangString(IDS_CREATE_FILE_DEFAULT_NAME, /*0x03020242*/ (UInt32)-1);
if (comboDialog.Create(GetParent()) == IDCANCEL)
return;
- UString newName = GetUnicodeString(comboDialog.Value);
+ UString newName = comboDialog.Value;
HRESULT result = folderOperations->CreateFile(newName, 0);
if (result != S_OK)
{
- MessageBoxError(result, LangLoadStringW(IDS_CREATE_FILE_ERROR, 0x03020243));
+ MessageBoxError(result, LangString(IDS_CREATE_FILE_ERROR, 0x03020243));
return;
}
- int pos = newName.Find(TEXT('\\'));
+ int pos = newName.Find(L'\\');
if (pos >= 0)
newName = newName.Left(pos);
if (!_mySelectMode)
@@ -293,7 +328,7 @@ void CPanel::ChangeComment()
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
@@ -309,12 +344,12 @@ void CPanel::ChangeComment()
}
UString name = GetItemName(realIndex);
CComboDialog comboDialog;
- comboDialog.Title = name + L" " + LangLoadStringW(IDS_COMMENT, 0x03020290);
+ comboDialog.Title = name + L" " + LangString(IDS_COMMENT, 0x03020290);
comboDialog.Value = comment;
- comboDialog.Static = LangLoadStringW(IDS_COMMENT2, 0x03020291);
+ comboDialog.Static = LangString(IDS_COMMENT2, 0x03020291);
if (comboDialog.Create(GetParent()) == IDCANCEL)
return;
- NCOM::CPropVariant propVariant = GetUnicodeString(comboDialog.Value);
+ NCOM::CPropVariant propVariant = comboDialog.Value;
HRESULT result = folderOperations->SetProperty(realIndex, kpidComment, &propVariant, NULL);
if (result != S_OK)
diff --git a/7zip/FileManager/PanelSelect.cpp b/7zip/FileManager/PanelSelect.cpp
index cbbc13b6..e769195f 100755
--- a/7zip/FileManager/PanelSelect.cpp
+++ b/7zip/FileManager/PanelSelect.cpp
@@ -152,9 +152,9 @@ void CPanel::SelectSpec(bool selectMode)
{
CComboDialog comboDialog;
comboDialog.Title = selectMode ?
- LangLoadStringW(IDS_SELECT, 0x03020250):
- LangLoadStringW(IDS_DESELECT, 0x03020251);
- comboDialog.Static = LangLoadStringW(IDS_SELECT_MASK, 0x03020252);
+ LangString(IDS_SELECT, 0x03020250):
+ LangString(IDS_DESELECT, 0x03020251);
+ comboDialog.Static = LangString(IDS_SELECT_MASK, 0x03020252);
comboDialog.Value = L"*";
if (comboDialog.Create(GetParent()) == IDCANCEL)
return;
diff --git a/7zip/FileManager/PanelSplitFile.cpp b/7zip/FileManager/PanelSplitFile.cpp
index d9ae5c11..be732a85 100755
--- a/7zip/FileManager/PanelSplitFile.cpp
+++ b/7zip/FileManager/PanelSplitFile.cpp
@@ -31,10 +31,10 @@ public:
{
if (_data != 0)
return false;
- _data = BigAlloc(size);
+ _data = ::MidAlloc(size);
return _data != 0;
}
- ~CMyBuffer() { BigFree(_data); }
+ ~CMyBuffer() { ::MidFree(_data); }
};
struct CVolSeqName
@@ -184,7 +184,7 @@ void CApp::Split()
CPanel &srcPanel = Panels[srcPanelIndex];
if (!srcPanel.IsFSFolder())
{
- srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
CRecordVector<UInt32> indices;
@@ -223,8 +223,8 @@ void CApp::Split()
CProgressDialog progressDialog;
spliter.ProgressDialog = &progressDialog;
- UString progressWindowTitle = LangLoadStringW(IDS_APP_TITLE, 0x03000000);
- UString title = LangLoadStringW(IDS_SPLITTING, 0x03020510);
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ UString title = LangString(IDS_SPLITTING, 0x03020510);
progressDialog.MainWindow = _window;
progressDialog.MainTitle = progressWindowTitle;
@@ -392,7 +392,7 @@ void CApp::Combine()
CPanel &srcPanel = Panels[srcPanelIndex];
if (!srcPanel.IsFSFolder())
{
- srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
CRecordVector<UInt32> indices;
@@ -421,11 +421,11 @@ void CApp::Combine()
path = destPanel._currentFolderPrefix;
CCopyDialog copyDialog;
copyDialog.Value = path;
- copyDialog.Title = LangLoadStringW(IDS_COMBINE, 0x03020600);
+ copyDialog.Title = LangString(IDS_COMBINE, 0x03020600);
copyDialog.Title += ' ';
copyDialog.Title += itemName;
- copyDialog.Static = LangLoadStringW(IDS_COMBINE_TO, 0x03020601);;
+ copyDialog.Static = LangString(IDS_COMBINE_TO, 0x03020601);;
if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
return;
@@ -435,8 +435,8 @@ void CApp::Combine()
CProgressDialog progressDialog;
combiner.ProgressDialog = &progressDialog;
- UString progressWindowTitle = LangLoadStringW(IDS_APP_TITLE, 0x03000000);
- UString title = LangLoadStringW(IDS_COMBINING, 0x03020610);
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ UString title = LangString(IDS_COMBINING, 0x03020610);
progressDialog.MainWindow = _window;
progressDialog.MainTitle = progressWindowTitle;
diff --git a/7zip/FileManager/PhysDriveFolder.cpp b/7zip/FileManager/PhysDriveFolder.cpp
new file mode 100755
index 00000000..35e829f7
--- /dev/null
+++ b/7zip/FileManager/PhysDriveFolder.cpp
@@ -0,0 +1,274 @@
+// PhysDriveFolder.cpp
+
+#include "StdAfx.h"
+
+#include "PhysDriveFolder.h"
+
+#include "Common/Alloc.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/FileDevice.h"
+#include "Windows/FileSystem.h"
+
+#include "../PropID.h"
+
+using namespace NWindows;
+
+static const UInt32 kBufferSize = (4 << 20);
+
+static STATPROPSTG kProperties[] =
+{
+ { NULL, kpidName, VT_BSTR},
+ { NULL, kpidSize, VT_UI8}
+};
+
+CPhysDriveFolder::~CPhysDriveFolder()
+{
+ if (_buffer != 0)
+ MyFree(_buffer);
+}
+
+HRESULT CPhysDriveFolder::Init(const UString &path)
+{
+ _prefix = L"\\\\.\\";
+ _path = path;
+ NFile::NDevice::CInFile inFile;
+ if (!inFile.Open(GetFullPath()))
+ return GetLastError();
+ return S_OK;
+}
+
+STDMETHODIMP CPhysDriveFolder::LoadItems()
+{
+ _driveType = NFile::NSystem::MyGetDriveType(_path + L"\\");
+ _name = _path.Left(1);
+ _name += L'.';
+ if (_driveType == DRIVE_CDROM)
+ _name += L"iso";
+ else
+ _name += L"img";
+ Int32 dummy;
+ WasChanged(&dummy);
+ return GetLength(_length);
+}
+
+STDMETHODIMP CPhysDriveFolder::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = 1;
+ return S_OK;
+}
+
+STDMETHODIMP CPhysDriveFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant propVariant;
+ if (itemIndex >= 1)
+ return E_INVALIDARG;
+ switch(propID)
+ {
+ case kpidIsFolder:
+ propVariant = false;
+ break;
+ case kpidName:
+ propVariant = _name;
+ break;
+ case kpidSize:
+ propVariant = _length;
+ break;
+ }
+ propVariant.Detach(value);
+ return S_OK;
+}
+
+STDMETHODIMP CPhysDriveFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
+ { return E_NOTIMPL; }
+
+STDMETHODIMP CPhysDriveFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
+ { return E_NOTIMPL; }
+
+STDMETHODIMP CPhysDriveFolder::BindToParentFolder(IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CPhysDriveFolder::GetName(BSTR *name)
+ { return E_NOTIMPL; }
+
+STDMETHODIMP CPhysDriveFolder::GetNumberOfProperties(UInt32 *numProperties)
+{
+ *numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
+ return S_OK;
+}
+
+STDMETHODIMP CPhysDriveFolder::GetPropertyInfo(UInt32 index,
+ BSTR *name, PROPID *propID, VARTYPE *varType)
+{
+ if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
+ return E_INVALIDARG;
+ const STATPROPSTG &prop = kProperties[index];
+ *propID = prop.propid;
+ *varType = prop.vt;
+ *name = 0;
+ return S_OK;
+}
+
+
+STDMETHODIMP CPhysDriveFolder::GetTypeID(BSTR *name)
+{
+ CMyComBSTR temp = L"PhysDrive";
+ *name = temp.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CPhysDriveFolder::GetPath(BSTR *path)
+{
+ UString tempPath = GetFullPath() + L"\\";
+ CMyComBSTR temp = tempPath;
+ *path = temp.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CPhysDriveFolder::WasChanged(Int32 *wasChanged)
+{
+ bool wasChangedMain = false;
+ *wasChanged = BoolToInt(wasChangedMain);
+ return S_OK;
+}
+
+STDMETHODIMP CPhysDriveFolder::Clone(IFolderFolder **resultFolder)
+{
+ CPhysDriveFolder *folderSpec = new CPhysDriveFolder;
+ CMyComPtr<IFolderFolder> folderNew = folderSpec;
+ folderSpec->Init(_path);
+ *resultFolder = folderNew.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CPhysDriveFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress)
+{
+ NCOM::CPropVariant propVariant;
+ if (index >= 1)
+ return E_INVALIDARG;
+ UInt64 size = 0;
+ HRESULT result = GetLength(size);
+ propVariant = size;
+ propVariant.Detach(value);
+ return result;
+}
+
+STDMETHODIMP CPhysDriveFolder::CreateFolder(const wchar_t *name, IProgress *progress)
+ { return E_NOTIMPL; }
+
+STDMETHODIMP CPhysDriveFolder::CreateFile(const wchar_t *name, IProgress *progress)
+ { return E_NOTIMPL; }
+
+STDMETHODIMP CPhysDriveFolder::Rename(UInt32 index, const wchar_t *newName, IProgress *progress)
+ { return E_NOTIMPL; }
+
+STDMETHODIMP CPhysDriveFolder::Delete(const UInt32 *indices, UInt32 numItems, IProgress *progress)
+ { return E_NOTIMPL; }
+
+STDMETHODIMP CPhysDriveFolder::SetProperty(UInt32 index, PROPID propID,
+ const PROPVARIANT *value, IProgress *progress)
+{
+ if (index >= 1)
+ return E_INVALIDARG;
+ return E_NOTIMPL;
+}
+
+HRESULT CPhysDriveFolder::GetLength(UInt64 &length) const
+{
+ NFile::NDevice::CInFile inFile;
+ if (!inFile.Open(GetFullPath()))
+ return GetLastError();
+ if (!inFile.GetLengthSmart(length))
+ return GetLastError();
+ return S_OK;
+}
+
+STDMETHODIMP CPhysDriveFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
+ const wchar_t *path, IFolderOperationsExtractCallback *callback)
+{
+ if (numItems == 0)
+ return S_OK;
+ UString destPath = path;
+ if (destPath.IsEmpty())
+ return E_INVALIDARG;
+ bool directName = (destPath[destPath.Length() - 1] != L'\\');
+ if (directName)
+ {
+ if (numItems > 1)
+ return E_INVALIDARG;
+ }
+ else
+ destPath += _name;
+
+ UInt64 fileSize;
+ if (GetLength(fileSize) == S_OK)
+ {
+ RINOK(callback->SetTotal(fileSize));
+ }
+
+ Int32 writeAskResult;
+ CMyComBSTR destPathResult;
+ RINOK(callback->AskWrite(GetFullPath(), BoolToInt(false), NULL, &fileSize,
+ destPath, &destPathResult, &writeAskResult));
+ if (!IntToBool(writeAskResult))
+ return S_OK;
+
+ RINOK(callback->SetCurrentFilePath(GetFullPathWithName()));
+
+ NFile::NDevice::CInFile inFile;
+ if (!inFile.Open(GetFullPath()))
+ return GetLastError();
+ NFile::NIO::COutFile outFile;
+ if (!outFile.Create(destPathResult, true))
+ return GetLastError();
+ if (_buffer == 0)
+ {
+ _buffer = MyAlloc(kBufferSize);
+ if (_buffer == 0)
+ return E_OUTOFMEMORY;
+ }
+ UInt64 pos = 0;
+ UInt32 bufferSize = kBufferSize;
+ if (_driveType == DRIVE_REMOVABLE)
+ bufferSize = (18 << 10) * 4;
+ pos = 0;
+ while(pos < fileSize)
+ {
+ RINOK(callback->SetCompleted(&pos));
+ UInt32 curSize = (UInt32)MyMin(fileSize - pos, (UInt64)bufferSize);
+ UInt32 processedSize;
+ if (!inFile.Read(_buffer, curSize, processedSize))
+ return GetLastError();
+ if (processedSize == 0)
+ break;
+ curSize = processedSize;
+ if (!outFile.Write(_buffer, curSize, processedSize))
+ return GetLastError();
+ if (curSize != processedSize)
+ return E_FAIL;
+ pos += curSize;
+ }
+ return S_OK;
+}
+
+/////////////////////////////////////////////////
+// Move Operations
+
+STDMETHODIMP CPhysDriveFolder::MoveTo(
+ const UInt32 *indices,
+ UInt32 numItems,
+ const wchar_t *path,
+ IFolderOperationsExtractCallback *callback)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CPhysDriveFolder::CopyFrom(
+ const wchar_t *fromFolderPath,
+ const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress)
+{
+ return E_NOTIMPL;
+}
diff --git a/7zip/FileManager/PhysDriveFolder.h b/7zip/FileManager/PhysDriveFolder.h
new file mode 100755
index 00000000..076b0718
--- /dev/null
+++ b/7zip/FileManager/PhysDriveFolder.h
@@ -0,0 +1,89 @@
+// PhysDriveFolder.h
+
+#ifndef __PHYSDRIVEFOLDER_H
+#define __PHYSDRIVEFOLDER_H
+
+#include "Common/String.h"
+#include "Common/MyCom.h"
+
+#include "IFolder.h"
+
+class CPhysDriveFolder:
+ public IFolderFolder,
+ public IEnumProperties,
+ public IFolderGetTypeID,
+ public IFolderGetPath,
+ public IFolderWasChanged,
+ public IFolderOperations,
+ public IFolderGetItemFullSize,
+ public IFolderClone,
+ // public IFolderGetSystemIconIndex,
+ public CMyUnknownImp
+{
+ UInt64 GetSizeOfItem(int anIndex) const;
+public:
+ MY_QUERYINTERFACE_BEGIN
+ MY_QUERYINTERFACE_ENTRY(IEnumProperties)
+ MY_QUERYINTERFACE_ENTRY(IFolderGetTypeID)
+ MY_QUERYINTERFACE_ENTRY(IFolderGetPath)
+ MY_QUERYINTERFACE_ENTRY(IFolderWasChanged)
+ MY_QUERYINTERFACE_ENTRY(IFolderOperations)
+ MY_QUERYINTERFACE_ENTRY(IFolderGetItemFullSize)
+ MY_QUERYINTERFACE_ENTRY(IFolderClone)
+ // MY_QUERYINTERFACE_ENTRY(IFolderGetSystemIconIndex)
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+
+ STDMETHOD(LoadItems)();
+ STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
+ STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value);
+ STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder);
+ STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder);
+ STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder);
+ STDMETHOD(GetName)(BSTR *name);
+
+ STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
+ STDMETHOD(GetPropertyInfo)(UInt32 index,
+ BSTR *name, PROPID *propID, VARTYPE *varType);
+ STDMETHOD(GetTypeID)(BSTR *name);
+ STDMETHOD(GetPath)(BSTR *path);
+ STDMETHOD(WasChanged)(INT32 *wasChanged);
+ STDMETHOD(Clone)(IFolderFolder **resultFolder);
+ STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress);
+
+ // IFolderOperations
+ STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress);
+ STDMETHOD(CreateFile)(const wchar_t *name, IProgress *progress);
+ STDMETHOD(Rename)(UInt32 index, const wchar_t *newName, IProgress *progress);
+ STDMETHOD(Delete)(const UInt32 *indices, UInt32 numItems, IProgress *progress);
+ STDMETHOD(CopyTo)(const UInt32 *indices, UInt32 numItems,
+ const wchar_t *path, IFolderOperationsExtractCallback *callback);
+ STDMETHOD(MoveTo)(const UInt32 *indices, UInt32 numItems,
+ const wchar_t *path, IFolderOperationsExtractCallback *callback);
+ STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath,
+ const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress);
+ STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress);
+ // STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
+
+private:
+ UString _name;
+ UString _prefix;
+ UString _path;
+ UString GetFullPath() const { return _prefix + _path; }
+ UString GetFullPathWithName() const { return GetFullPath() + L'\\' + _name; }
+ CMyComPtr<IFolderFolder> _parentFolder;
+ void *_buffer;
+
+ UINT _driveType;
+ DISK_GEOMETRY geom;
+ UInt64 _length;
+
+public:
+ HRESULT Init(const UString &path);
+ HRESULT GetLength(UInt64 &size) const;
+ CPhysDriveFolder(): _buffer(0) {}
+ ~CPhysDriveFolder();
+};
+
+#endif
diff --git a/7zip/FileManager/PluginLoader.h b/7zip/FileManager/PluginLoader.h
index 88329bbf..598a874b 100755
--- a/7zip/FileManager/PluginLoader.h
+++ b/7zip/FileManager/PluginLoader.h
@@ -21,7 +21,7 @@ public:
return GetLastError();
return createObject(&clsID, &IID_IFolderManager, (void **)manager);
}
- HRESULT LoadAndCreateManager(LPCTSTR filePath, REFGUID clsID, IFolderManager **manager)
+ HRESULT LoadAndCreateManager(LPCWSTR filePath, REFGUID clsID, IFolderManager **manager)
{
if (!Load(filePath))
return GetLastError();
diff --git a/7zip/FileManager/PropertyName.cpp b/7zip/FileManager/PropertyName.cpp
index 5619273c..d6c5bac4 100755
--- a/7zip/FileManager/PropertyName.cpp
+++ b/7zip/FileManager/PropertyName.cpp
@@ -69,5 +69,5 @@ UString GetNameOfProperty(PROPID propID)
if (index < 0)
return UString();
const CPropertyIDNamePair &pair = kPropertyIDNamePairs[index];
- return LangLoadStringW(pair.ResourceID, pair.LangID);
+ return LangString(pair.ResourceID, pair.LangID);
}
diff --git a/7zip/FileManager/RegistryAssociations.cpp b/7zip/FileManager/RegistryAssociations.cpp
index 40490d55..b4b35c67 100755
--- a/7zip/FileManager/RegistryAssociations.cpp
+++ b/7zip/FileManager/RegistryAssociations.cpp
@@ -25,21 +25,24 @@ static NSynchronization::CCriticalSection g_CriticalSection;
static const TCHAR *kCUKeyPath = TEXT("Software\\7-ZIP\\FM");
static const TCHAR *kAssociations = TEXT("Associations");
-static const TCHAR *kExtPlugins = TEXT("Plugins");
+static const WCHAR *kExtPlugins = L"Plugins";
static const TCHAR *kExtEnabled = TEXT("Enabled");
+static CSysString GetAssociationsPath()
+{
+ return CSysString(kCUKeyPath) + CSysString('\\') + CSysString(kAssociations);
+}
+
bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo)
{
NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
CKey key;
- if(key.Open(HKEY_CURRENT_USER, CSysString(kCUKeyPath)
- + CSysString('\\') + CSysString(kAssociations)
- + CSysString('\\') + CSysString(GetSystemString(ext)),
- KEY_READ) != ERROR_SUCCESS)
+ if(key.Open(HKEY_CURRENT_USER, GetAssociationsPath() + CSysString('\\') +
+ CSysString(GetSystemString(ext)), KEY_READ) != ERROR_SUCCESS)
return false;
- CSysString pluginsString;
+ UString pluginsString;
key.QueryValue(kExtPlugins, pluginsString);
- SplitString(GetUnicodeString(pluginsString), extInfo.Plugins);
+ SplitString(pluginsString, extInfo.Plugins);
return true;
}
@@ -48,8 +51,7 @@ void ReadInternalAssociations(CObjectVector<CExtInfo> &items)
items.Clear();
NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
CKey associationsKey;
- if(associationsKey.Open(HKEY_CURRENT_USER, CSysString(kCUKeyPath)
- + CSysString('\\') + CSysString(kAssociations), KEY_READ) != ERROR_SUCCESS)
+ if(associationsKey.Open(HKEY_CURRENT_USER, GetAssociationsPath(), KEY_READ) != ERROR_SUCCESS)
return;
CSysStringVector extNames;
associationsKey.EnumKeys(extNames);
@@ -62,9 +64,9 @@ void ReadInternalAssociations(CObjectVector<CExtInfo> &items)
CKey key;
if(key.Open(associationsKey, extName, KEY_READ) != ERROR_SUCCESS)
return;
- CSysString pluginsString;
+ UString pluginsString;
key.QueryValue(kExtPlugins, pluginsString);
- SplitString(GetUnicodeString(pluginsString), extInfo.Plugins);
+ SplitString(pluginsString, extInfo.Plugins);
/*
if (key.QueryValue(kExtEnabled, extInfo.Enabled) != ERROR_SUCCESS)
extInfo.Enabled = false;
@@ -86,7 +88,7 @@ void WriteInternalAssociations(const CObjectVector<CExtInfo> &items)
const CExtInfo &extInfo = items[i];
CKey key;
key.Create(associationsKey, GetSystemString(extInfo.Ext));
- key.SetValue(kExtPlugins, GetSystemString(JoinStrings(extInfo.Plugins)));
+ key.SetValue(kExtPlugins, JoinStrings(extInfo.Plugins));
// key.SetValue(kExtEnabled, extInfo.Enabled);
}
}
@@ -160,9 +162,9 @@ void DeleteShellExtensionInfo(const CSysString &extension)
}
void AddShellExtensionInfo(const CSysString &extension,
- const CSysString &programTitle,
- const CSysString &programOpenCommand,
- const CSysString &iconPath,
+ const UString &programTitle,
+ const UString &programOpenCommand,
+ const UString &iconPath,
const void *shellNewData, int shellNewDataSize)
{
DeleteShellExtensionKey(extension);
@@ -200,18 +202,7 @@ void AddShellExtensionInfo(const CSysString &extension,
CKey commandKey;
commandKey.Create(openKey, kCommandKeyName);
- CSysString params;
- /*
- if (!NSystem::MyGetWindowsDirectory(aParams))
- {
- aParams.Empty();
- // return;
- }
- else
- NFile::NName::NormalizeDirPathPrefix(aParams);
- */
- // aParams += kOpenCommandValue;
- HRESULT result = commandKey.SetValue(NULL, programOpenCommand);
+ commandKey.SetValue(NULL, programOpenCommand);
}
///////////////////////////
diff --git a/7zip/FileManager/RegistryAssociations.h b/7zip/FileManager/RegistryAssociations.h
index 75a25e34..c225aca4 100755
--- a/7zip/FileManager/RegistryAssociations.h
+++ b/7zip/FileManager/RegistryAssociations.h
@@ -24,9 +24,9 @@ namespace NRegistryAssociations {
void DeleteShellExtensionInfo(const CSysString &extension);
void AddShellExtensionInfo(const CSysString &extension,
- const CSysString &programTitle,
- const CSysString &programOpenCommand,
- const CSysString &iconPath,
+ const UString &programTitle,
+ const UString &programOpenCommand,
+ const UString &iconPath,
const void *shellNewData, int shellNewDataSize);
diff --git a/7zip/FileManager/RegistryPlugins.cpp b/7zip/FileManager/RegistryPlugins.cpp
index 2f9dc777..cad3b43d 100755
--- a/7zip/FileManager/RegistryPlugins.cpp
+++ b/7zip/FileManager/RegistryPlugins.cpp
@@ -92,40 +92,22 @@ static bool ReadPluginInfo(CPluginInfo &pluginInfo)
return true;
}
-CSysString GetProgramFolderPrefix();
-
-#ifndef _WIN64
-static bool IsItWindowsNT()
-{
- OSVERSIONINFO versionInfo;
- versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
- return false;
- return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
-}
-#endif
+UString GetProgramFolderPrefix();
void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins)
{
plugins.Clear();
- CSysString baseFolderPrefix = GetProgramFolderPrefix();
+ UString baseFolderPrefix = GetProgramFolderPrefix();
{
- CSysString path = baseFolderPrefix + TEXT("7-zip");
- #ifndef _WIN64
- if (IsItWindowsNT())
- path += TEXT("n");
- #endif
- path += TEXT(".dll");
CPluginInfo pluginInfo;
- pluginInfo.FilePath = path;
-
+ pluginInfo.FilePath = baseFolderPrefix + L"7-zip.dll";
if (::ReadPluginInfo(pluginInfo))
plugins.Add(pluginInfo);
}
- CSysString folderPath = baseFolderPrefix + TEXT("Plugins\\");
- NFind::CEnumerator enumerator(folderPath + TEXT("*"));
- NFind::CFileInfo fileInfo;
+ UString folderPath = baseFolderPrefix + L"Plugins\\";
+ NFind::CEnumeratorW enumerator(folderPath + L"*");
+ NFind::CFileInfoW fileInfo;
while (enumerator.Next(fileInfo))
{
if (fileInfo.IsDirectory())
diff --git a/7zip/FileManager/RegistryPlugins.h b/7zip/FileManager/RegistryPlugins.h
index a3e0b493..4a30857c 100755
--- a/7zip/FileManager/RegistryPlugins.h
+++ b/7zip/FileManager/RegistryPlugins.h
@@ -13,7 +13,7 @@ enum EPluginType
struct CPluginInfo
{
- CSysString FilePath;
+ UString FilePath;
EPluginType Type;
UString Name;
CLSID ClassID;
diff --git a/7zip/FileManager/RegistryUtils.cpp b/7zip/FileManager/RegistryUtils.cpp
index 99937bec..ea92aa73 100755
--- a/7zip/FileManager/RegistryUtils.cpp
+++ b/7zip/FileManager/RegistryUtils.cpp
@@ -10,9 +10,10 @@ using namespace NRegistry;
static const TCHAR *kCUBasePath = TEXT("Software\\7-ZIP");
static const TCHAR *kCU_FMPath = TEXT("Software\\7-ZIP\\FM");
+static const TCHAR *kLM_Path = TEXT("Software\\7-ZIP\\FM");
-static const TCHAR *kLangValueName = TEXT("Lang");
-static const TCHAR *kEditor = TEXT("Editor");
+static const WCHAR *kLangValueName = L"Lang";
+static const WCHAR *kEditor = L"Editor";
static const TCHAR *kShowDots = TEXT("ShowDots");
static const TCHAR *kShowRealFileIcons = TEXT("ShowRealFileIcons");
static const TCHAR *kShowSystemMenu = TEXT("ShowSystemMenu");
@@ -20,58 +21,96 @@ static const TCHAR *kShowSystemMenu = TEXT("ShowSystemMenu");
static const TCHAR *kFullRow = TEXT("FullRow");
static const TCHAR *kShowGrid = TEXT("ShowGrid");
static const TCHAR *kAlternativeSelection = TEXT("AlternativeSelection");
+static const TCHAR *kLockMemoryAdd = TEXT("LockMemoryAdd");
+static const TCHAR *kLargePagesEnable = TEXT("LargePages");
// static const TCHAR *kSingleClick = TEXT("SingleClick");
// static const TCHAR *kUnderline = TEXT("Underline");
-void SaveRegLang(const CSysString &langFile)
+void SaveRegLang(const UString &langFile)
{
- CKey cuKey;
- cuKey.Create(HKEY_CURRENT_USER, kCUBasePath);
- cuKey.SetValue(kLangValueName, langFile);
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCUBasePath);
+ key.SetValue(kLangValueName, langFile);
}
-void ReadRegLang(CSysString &langFile)
+void ReadRegLang(UString &langFile)
{
langFile.Empty();
- CKey cuKey;
- cuKey.Create(HKEY_CURRENT_USER, kCUBasePath);
- cuKey.QueryValue(kLangValueName, langFile);
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS)
+ key.QueryValue(kLangValueName, langFile);
}
-void SaveRegEditor(const CSysString &editorPath)
+void SaveRegEditor(const UString &editorPath)
{
- CKey cuKey;
- cuKey.Create(HKEY_CURRENT_USER, kCU_FMPath);
- cuKey.SetValue(kEditor, editorPath);
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCU_FMPath);
+ key.SetValue(kEditor, editorPath);
}
-void ReadRegEditor(CSysString &editorPath)
+void ReadRegEditor(UString &editorPath)
{
editorPath.Empty();
- CKey cuKey;
- cuKey.Create(HKEY_CURRENT_USER, kCU_FMPath);
- cuKey.QueryValue(kEditor, editorPath);
- /*
- if (editorPath.IsEmpty())
- editorPath = TEXT("notepad.exe");
- */
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCU_FMPath, KEY_READ) == ERROR_SUCCESS)
+ key.QueryValue(kEditor, editorPath);
+}
+
+static void Save7ZipOption(const TCHAR *value, bool enabled)
+{
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCUBasePath);
+ key.SetValue(value, enabled);
}
static void SaveOption(const TCHAR *value, bool enabled)
{
- CKey cuKey;
- cuKey.Create(HKEY_CURRENT_USER, kCU_FMPath);
- cuKey.SetValue(value, enabled);
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCU_FMPath);
+ key.SetValue(value, enabled);
+}
+
+static bool Read7ZipOption(const TCHAR *value, bool defaultValue)
+{
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS)
+ {
+ bool enabled;
+ if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
+ return enabled;
+ }
+ return defaultValue;
}
static bool ReadOption(const TCHAR *value, bool defaultValue)
{
- CKey cuKey;
- cuKey.Create(HKEY_CURRENT_USER, kCU_FMPath);
- bool enabled;
- if (cuKey.QueryValue(value, enabled) != ERROR_SUCCESS)
- return defaultValue;
- return enabled;
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCU_FMPath, KEY_READ) == ERROR_SUCCESS)
+ {
+ bool enabled;
+ if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
+ return enabled;
+ }
+ return defaultValue;
+}
+
+static void SaveLmOption(const TCHAR *value, bool enabled)
+{
+ CKey key;
+ key.Create(HKEY_LOCAL_MACHINE, kLM_Path);
+ key.SetValue(value, enabled);
+}
+
+static bool ReadLmOption(const TCHAR *value, bool defaultValue)
+{
+ CKey key;
+ if (key.Open(HKEY_LOCAL_MACHINE, kLM_Path, KEY_READ) == ERROR_SUCCESS)
+ {
+ bool enabled;
+ if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
+ return enabled;
+ }
+ return defaultValue;
}
void SaveShowDots(bool showDots) { SaveOption(kShowDots, showDots); }
@@ -98,4 +137,12 @@ bool ReadSingleClick(){ return ReadOption(kSingleClick, false); }
void SaveUnderline(bool enable) { SaveOption(kUnderline, enable); }
bool ReadUnderline(){ return ReadOption(kUnderline, false); }
-*/ \ No newline at end of file
+*/
+
+// void SaveLockMemoryAdd(bool enable) { SaveLmOption(kLockMemoryAdd, enable); }
+// bool ReadLockMemoryAdd() { return ReadLmOption(kLockMemoryAdd, true); }
+
+void SaveLockMemoryEnable(bool enable) { Save7ZipOption(kLargePagesEnable, enable); }
+bool ReadLockMemoryEnable() { return Read7ZipOption(kLargePagesEnable, false); }
+
+
diff --git a/7zip/FileManager/RegistryUtils.h b/7zip/FileManager/RegistryUtils.h
index 2799061e..0fec6f80 100755
--- a/7zip/FileManager/RegistryUtils.h
+++ b/7zip/FileManager/RegistryUtils.h
@@ -5,11 +5,11 @@
#ifndef __REGISTRYUTILS_H
#define __REGISTRYUTILS_H
-void SaveRegLang(const CSysString &langFile);
-void ReadRegLang(CSysString &langFile);
+void SaveRegLang(const UString &langFile);
+void ReadRegLang(UString &langFile);
-void SaveRegEditor(const CSysString &langFile);
-void ReadRegEditor(CSysString &langFile);
+void SaveRegEditor(const UString &editorPath);
+void ReadRegEditor(UString &editorPath);
void SaveShowDots(bool showDots);
bool ReadShowDots();
@@ -29,6 +29,12 @@ bool ReadShowGrid();
void SaveAlternativeSelection(bool enable);
bool ReadAlternativeSelection();
+// void SaveLockMemoryAdd(bool enable);
+// bool ReadLockMemoryAdd();
+
+bool ReadLockMemoryEnable();
+void SaveLockMemoryEnable(bool enable);
+
/*
void SaveSingleClick(bool enable);
bool ReadSingleClick();
diff --git a/7zip/FileManager/Resource/AboutDialog/AboutDialog.h b/7zip/FileManager/Resource/AboutDialog/AboutDialog.h
index ccd50c1a..278d7c82 100755
--- a/7zip/FileManager/Resource/AboutDialog/AboutDialog.h
+++ b/7zip/FileManager/Resource/AboutDialog/AboutDialog.h
@@ -12,8 +12,7 @@ public:
virtual bool OnInit();
virtual void OnHelp();
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
- INT_PTR Create(HWND aWndParent = 0)
- { return CModalDialog::Create(MAKEINTRESOURCE(IDD_ABOUT), aWndParent); }
+ INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_ABOUT, wndParent); }
};
#endif
diff --git a/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp b/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp
index 8ea16ea8..e745ee90 100755
--- a/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp
+++ b/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp
@@ -5,6 +5,7 @@
#include "Common/IntToString.h"
#include "Common/StringToInt.h"
#include "Common/Exception.h"
+#include "Common/Alloc.h"
#include "Windows/Thread.h"
#include "Windows/PropVariant.h"
#include "Windows/Error.h"
@@ -140,15 +141,22 @@ public:
UInt32 BufferSize;
Byte *Buffer;
CBenchRandomGenerator(): Buffer(0) {}
- ~CBenchRandomGenerator() { delete []Buffer; }
+ ~CBenchRandomGenerator() { Free(); }
+ void Free()
+ {
+ ::MidFree(Buffer);
+ Buffer = 0;
+ }
void Init() { RG.Init(); }
- void Set(UInt32 bufferSize)
+ bool Alloc(UInt32 bufferSize)
{
- delete []Buffer;
- Buffer = 0;
- Buffer = new Byte[bufferSize];
+ if (Buffer != 0 && BufferSize == bufferSize)
+ return true;
+ Free();
+ Buffer = (Byte *)::MidAlloc(bufferSize);
Pos = 0;
BufferSize = bufferSize;
+ return (Buffer != 0);
}
UInt32 GetRndBit() { return RG.GetRnd(1); }
/*
@@ -525,15 +533,29 @@ public:
UInt32 Pos;
Byte *Buffer;
CBenchmarkOutStream(): Buffer(0) {}
- ~CBenchmarkOutStream() { delete []Buffer; }
- void Init(UInt32 bufferSize)
- {
- delete []Buffer;
+ ~CBenchmarkOutStream() { Free(); }
+ void Free()
+ {
+ ::MidFree(Buffer);
Buffer = 0;
- Buffer = new Byte[bufferSize];
- Pos = 0;
+ }
+
+ bool Alloc(UInt32 bufferSize)
+ {
+ if (Buffer != 0 && BufferSize == bufferSize)
+ return true;
+ Free();
+ Buffer = (Byte *)::MidAlloc(bufferSize);
+ Init();
BufferSize = bufferSize;
+ return (Buffer != 0);
}
+
+ void Init()
+ {
+ Pos = 0;
+ }
+
MY_UNKNOWN_IMP
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
};
@@ -691,7 +713,9 @@ DWORD CThreadBenchmark::Process()
writeCoderProperties->WriteCoderProperties(propStream);
}
- randomGenerator.Set(kBufferSize);
+ if (!randomGenerator.Alloc(kBufferSize))
+ return E_OUTOFMEMORY;
+
randomGenerator.Generate();
CCRC crc;
@@ -705,11 +729,22 @@ DWORD CThreadBenchmark::Process()
}
CBenchmarkInStream *inStreamSpec = new CBenchmarkInStream;
- inStreamSpec->Init(randomGenerator.Buffer, randomGenerator.BufferSize);
CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
CBenchmarkOutStream *outStreamSpec = new CBenchmarkOutStream;
- outStreamSpec->Init(kCompressedBufferSize);
CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
+ if (!outStreamSpec->Alloc(kCompressedBufferSize))
+ return E_OUTOFMEMORY;
+
+ {
+ // this code is for reducing time of memory allocationg
+ inStreamSpec->Init(randomGenerator.Buffer, MyMin((UInt32)1, randomGenerator.BufferSize));
+ outStreamSpec->Init();
+ HRESULT result = Encoder->Code(inStream, outStream, 0, 0, NULL);
+ }
+
+ inStreamSpec->Init(randomGenerator.Buffer, randomGenerator.BufferSize);
+ outStreamSpec->Init();
+
_approvedStart = dictionarySize;
_startTime = ::GetTimeCount();
HRESULT result = Encoder->Code(inStream, outStream, 0, 0, this);
diff --git a/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h b/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h
index e26e4a2b..16bb113b 100755
--- a/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h
+++ b/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h
@@ -128,11 +128,7 @@ public:
CProgressSyncInfo _syncInfo;
CBenchmarkDialog(): _timer(0) {}
-
- INT_PTR Create(HWND wndParent = 0)
- {
- return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_BENCHMARK), wndParent);
- }
+ INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_BENCHMARK, wndParent); }
};
void Benchmark(HWND hwnd);
diff --git a/7zip/FileManager/Resource/ComboDialog/ComboDialog.h b/7zip/FileManager/Resource/ComboDialog/ComboDialog.h
index 438b9998..1838783d 100755
--- a/7zip/FileManager/Resource/ComboDialog/ComboDialog.h
+++ b/7zip/FileManager/Resource/ComboDialog/ComboDialog.h
@@ -17,10 +17,9 @@ public:
UString Title;
UString Static;
UString Value;
- CSysStringVector Strings;
+ UStringVector Strings;
// CComboDialog(): Sorted(false) {};
- INT_PTR Create(HWND parentWindow = 0)
- { return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_COMBO), parentWindow); }
+ INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COMBO, parentWindow); }
};
#endif
diff --git a/7zip/FileManager/Resource/CopyDialog/CopyDialog.cpp b/7zip/FileManager/Resource/CopyDialog/CopyDialog.cpp
index 1ef12716..9272b3b4 100755
--- a/7zip/FileManager/Resource/CopyDialog/CopyDialog.cpp
+++ b/7zip/FileManager/Resource/CopyDialog/CopyDialog.cpp
@@ -35,7 +35,7 @@ bool CCopyDialog::OnInit()
staticContol.Attach(GetItem(IDC_COPY_STATIC));
staticContol.SetText(Static);
for(int i = 0; i < Strings.Size(); i++)
- _path.AddString(GetSystemString(Strings[i]));
+ _path.AddString(Strings[i]);
_path.SetText(Value);
return CModalDialog::OnInit();
}
@@ -53,19 +53,19 @@ bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
void CCopyDialog::OnButtonSetPath()
{
- CSysString currentPath;
+ UString currentPath;
_path.GetText(currentPath);
/*
#ifdef LANG
- CSysString title = LangLoadString(IDS_EXTRACT_SET_FOLDER, 0x02000881);
+ UString title = LangLoadString(IDS_EXTRACT_SET_FOLDER, 0x02000881);
#else
- CSysString title = MyLoadString(IDS_EXTRACT_SET_FOLDER);
+ UString title = MyLoadString(IDS_EXTRACT_SET_FOLDER);
#endif
*/
- CSysString title = TEXT("Specify a location for output folder");
+ UString title = L"Specify a location for output folder";
- CSysString resultPath;
+ UString resultPath;
if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
return;
NFile::NName::NormalizeDirPathPrefix(resultPath);
diff --git a/7zip/FileManager/Resource/CopyDialog/CopyDialog.h b/7zip/FileManager/Resource/CopyDialog/CopyDialog.h
index 483b1779..353f6807 100755
--- a/7zip/FileManager/Resource/CopyDialog/CopyDialog.h
+++ b/7zip/FileManager/Resource/CopyDialog/CopyDialog.h
@@ -20,8 +20,7 @@ public:
UString Value;
UStringVector Strings;
- INT_PTR Create(HWND parentWindow = 0)
- { return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_COPY), parentWindow); }
+ INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COPY, parentWindow); }
};
#endif
diff --git a/7zip/FileManager/Resource/EditPage/EditPage.cpp b/7zip/FileManager/Resource/EditPage/EditPage.cpp
index 812515f2..0e6e1d71 100755
--- a/7zip/FileManager/Resource/EditPage/EditPage.cpp
+++ b/7zip/FileManager/Resource/EditPage/EditPage.cpp
@@ -7,6 +7,7 @@
#include "Common/StringConvert.h"
#include "Windows/Defs.h"
+#include "Windows/CommonDialog.h"
// #include "Windows/FileFind.h"
// #include "Windows/FileDir.h"
@@ -29,7 +30,7 @@ bool CEditPage::OnInit()
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
_editorEdit.Attach(GetItem(IDC_EDIT_EDIT_EDITOR));
- CSysString editorPath;
+ UString editorPath;
ReadRegEditor(editorPath);
_editorEdit.SetText(editorPath);
return CPropertyPage::OnInit();
@@ -40,7 +41,7 @@ LONG CEditPage::OnApply()
// int selectedIndex = _langCombo.GetCurSel();
// int pathIndex = _langCombo.GetItemData(selectedIndex);
// ReloadLang();
- CSysString editorPath;
+ UString editorPath;
_editorEdit.GetText(editorPath);
SaveRegEditor(editorPath);
return PSNRET_NOERROR;
@@ -66,85 +67,14 @@ bool CEditPage::OnButtonClicked(int aButtonID, HWND aButtonHWND)
return CPropertyPage::OnButtonClicked(aButtonID, aButtonHWND);
}
-class CDoubleZeroStringList
-{
- CRecordVector<int> _indexes;
- CSysString _string;
-public:
- void Add(LPCTSTR string);
- void SetForBuffer(LPTSTR buffer);
-};
-
-const TCHAR kDelimiterSymbol = TEXT(' ');
-void CDoubleZeroStringList::Add(LPCTSTR string)
-{
- _string += string;
- _indexes.Add(_string.Length());
- _string += kDelimiterSymbol;
-}
-
-void CDoubleZeroStringList::SetForBuffer(LPTSTR buffer)
-{
- lstrcpy(buffer, _string);
- for (int i = 0; i < _indexes.Size(); i++)
- buffer[_indexes[i]] = TEXT('\0');
-}
-
void CEditPage::OnSetEditorButton()
{
- OPENFILENAME info;
- info.lStructSize = sizeof(info);
- info.hwndOwner = HWND(*this);
- info.hInstance = 0;
-
- const int kBufferSize = MAX_PATH * 2;
- TCHAR buffer[kBufferSize + 1];
- CSysString editorPath;
+ UString editorPath;
_editorEdit.GetText(editorPath);
-
- lstrcpy(buffer, editorPath);
-
- const int kFilterBufferSize = MAX_PATH;
- TCHAR filterBuffer[kFilterBufferSize];
- CDoubleZeroStringList doubleZeroStringList;
- CSysString string = TEXT("*.exe");
- doubleZeroStringList.Add(string);
- doubleZeroStringList.Add(string);
- doubleZeroStringList.SetForBuffer(filterBuffer);
- info.lpstrFilter = filterBuffer;
-
- info.lpstrCustomFilter = NULL;
- info.nMaxCustFilter = 0;
- info.nFilterIndex = 0;
-
- info.lpstrFile = buffer;
- info.nMaxFile = kBufferSize;
-
- info.lpstrFileTitle = NULL;
- info.nMaxFileTitle = 0;
-
- info.lpstrInitialDir= NULL;
-
- /*
- CSysString title = "Open";
- LangLoadString(IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE, 0x02000D90);
- info.lpstrTitle = title;
- */
- info.lpstrTitle = 0;
-
-
- info.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
- info.nFileOffset = 0;
- info.nFileExtension = 0;
- info.lpstrDefExt = NULL;
-
- info.lCustData = 0;
- info.lpfnHook = NULL;
- info.lpTemplateName = NULL;
-
- if(!GetOpenFileName(&info))
+ UString resPath;
+ if(!MyGetOpenFileName(HWND(*this), 0, editorPath, L"*.exe", resPath))
return;
- _editorEdit.SetText(buffer);
+ _editorEdit.SetText(resPath);
// Changed();
}
diff --git a/7zip/FileManager/Resource/LangPage/LangPage.cpp b/7zip/FileManager/Resource/LangPage/LangPage.cpp
index 929bc9bf..f3d9c1d4 100755
--- a/7zip/FileManager/Resource/LangPage/LangPage.cpp
+++ b/7zip/FileManager/Resource/LangPage/LangPage.cpp
@@ -26,13 +26,13 @@ bool CLangPage::OnInit()
_langCombo.Attach(GetItem(IDC_LANG_COMBO_LANG));
- CSysString s = NWindows::MyLoadString(IDS_LANG_ENGLISH);
- s += TEXT(" (");
- s += NWindows::MyLoadString(IDS_LANG_NATIVE);
- s += TEXT(")");
+ UString s = NWindows::MyLoadStringW(IDS_LANG_ENGLISH);
+ s += L" (";
+ s += NWindows::MyLoadStringW(IDS_LANG_NATIVE);
+ s += L")";
int index = _langCombo.AddString(s);
_langCombo.SetItemData(index, _paths.Size());
- _paths.Add(TEXT("-"));
+ _paths.Add(L"-");
_langCombo.SetCurSel(0);
CObjectVector<CLangEx> langs;
@@ -55,10 +55,10 @@ bool CLangPage::OnInit()
name += L")";
}
}
- index = _langCombo.AddString(GetSystemString(name));
+ index = _langCombo.AddString(name);
_langCombo.SetItemData(index, _paths.Size());
- _paths.Add(GetSystemString(lang.ShortName));
- if (g_LangID.CompareNoCase(GetSystemString(lang.ShortName)) == 0)
+ _paths.Add(lang.ShortName);
+ if (g_LangID.CompareNoCase(lang.ShortName) == 0)
_langCombo.SetCurSel(index);
}
return CPropertyPage::OnInit();
diff --git a/7zip/FileManager/Resource/LangPage/LangPage.h b/7zip/FileManager/Resource/LangPage/LangPage.h
index d30cbe49..b28d6984 100755
--- a/7zip/FileManager/Resource/LangPage/LangPage.h
+++ b/7zip/FileManager/Resource/LangPage/LangPage.h
@@ -9,7 +9,7 @@
class CLangPage: public NWindows::NControl::CPropertyPage
{
NWindows::NControl::CComboBox _langCombo;
- CSysStringVector _paths;
+ UStringVector _paths;
public:
bool _langWasChanged;
virtual bool OnInit();
diff --git a/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.cpp b/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.cpp
index a43f2626..750a4085 100755
--- a/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.cpp
+++ b/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.cpp
@@ -32,10 +32,10 @@ bool CListViewDialog::OnInit()
for(int i = 0; i < Strings.Size(); i++)
{
- LVITEM item;
+ LVITEMW item;
item.mask = LVIF_TEXT;
item.iItem = i;
- item.pszText = (LPTSTR)(LPCTSTR)Strings[i];
+ item.pszText = (LPWSTR)(LPCWSTR)Strings[i];
item.iSubItem = 0;
_listView.InsertItem(&item);
}
diff --git a/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.h b/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.h
index 5c93e07d..ad107eba 100755
--- a/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.h
+++ b/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.h
@@ -17,12 +17,11 @@ class CListViewDialog: public NWindows::NControl::CModalDialog
public:
UString Title;
bool DeleteIsAllowed;
- CSysStringVector Strings;
+ UStringVector Strings;
bool StringsWereChanged;
int FocusedItemIndex;
- INT_PTR Create(HWND wndParent = 0)
- { return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_LISTVIEW), wndParent); }
+ INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_LISTVIEW, wndParent); }
CListViewDialog(): DeleteIsAllowed(false) {}
diff --git a/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.cpp b/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.cpp
index 2a8d46a7..ed39508e 100755
--- a/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.cpp
+++ b/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.cpp
@@ -3,6 +3,7 @@
#include "StdAfx.h"
#include "MessagesDialog.h"
#include "Common/StringConvert.h"
+#include "Common/IntToString.h"
#include "Windows/ResourceString.h"
#ifdef LANG
@@ -18,24 +19,21 @@ static CIDLangPair kIDLangPairs[] =
};
#endif
-void CMessagesDialog::AddMessageDirect(LPCTSTR message)
+void CMessagesDialog::AddMessageDirect(LPCWSTR message)
{
int itemIndex = _messageList.GetItemCount();
- LVITEM item;
+ LVITEMW item;
item.mask = LVIF_TEXT;
item.iItem = itemIndex;
- CSysString stringNumber;
- TCHAR sz[32];
- wsprintf(sz, TEXT("%d"), itemIndex);
- stringNumber = sz;
+ wchar_t sz[32];
+ ConvertInt64ToString(itemIndex, sz);
- item.pszText = (LPTSTR)(LPCTSTR)stringNumber;
+ item.pszText = sz;
item.iSubItem = 0;
_messageList.InsertItem(&item);
- item.mask = LVIF_TEXT;
- item.pszText = (LPTSTR)message;
+ item.pszText = (LPWSTR)message;
item.iSubItem = 1;
_messageList.SetItem(&item);
}
@@ -48,10 +46,10 @@ void CMessagesDialog::AddMessage(LPCWSTR message)
int pos = s.Find(L'\n');
if (pos < 0)
break;
- AddMessageDirect(GetSystemString(s.Left(pos)));
+ AddMessageDirect(s.Left(pos));
s.Delete(0, pos + 1);
}
- AddMessageDirect(GetSystemString(s));
+ AddMessageDirect(s);
}
bool CMessagesDialog::OnInit()
@@ -61,11 +59,12 @@ bool CMessagesDialog::OnInit()
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
_messageList.Attach(GetItem(IDC_MESSAGE_LIST));
+ _messageList.SetUnicodeFormat(true);
- LVCOLUMN columnInfo;
+ LVCOLUMNW columnInfo;
columnInfo.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
columnInfo.fmt = LVCFMT_LEFT;
- columnInfo.pszText = TEXT("#");
+ columnInfo.pszText = L"#";
columnInfo.iSubItem = 0;
columnInfo.cx = 30;
@@ -74,13 +73,14 @@ bool CMessagesDialog::OnInit()
columnInfo.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
columnInfo.fmt = LVCFMT_LEFT;
- #ifdef LANG
- CSysString s = LangLoadString(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, 0x02000A80);
+ UString s =
+ #ifdef LANG
+ LangString(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, 0x02000A80);
#else
- CSysString s = MyLoadString(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN);
+ MyLoadStringW(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN);
#endif
- columnInfo.pszText = (LPTSTR)(LPCTSTR)s;
+ columnInfo.pszText = (LPWSTR)(LPCWSTR)s;
columnInfo.iSubItem = 1;
columnInfo.cx = 450;
diff --git a/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.h b/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.h
index db4d5180..aa7c788a 100755
--- a/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.h
+++ b/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.h
@@ -11,13 +11,12 @@
class CMessagesDialog: public NWindows::NControl::CModalDialog
{
NWindows::NControl::CListView _messageList;
- void AddMessageDirect(LPCTSTR message);
+ void AddMessageDirect(LPCWSTR message);
void AddMessage(LPCWSTR message);
virtual bool OnInit();
public:
const UStringVector *Messages;
- INT_PTR Create(HWND parentWindow = 0)
- { return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_MESSAGES), parentWindow); }
+ INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_MESSAGES, parent); }
};
#endif
diff --git a/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.cpp b/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.cpp
index 1232b0db..4e85306c 100755
--- a/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.cpp
+++ b/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.cpp
@@ -45,7 +45,7 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
#ifdef LANG
0x02000982,
#endif
- NumberToStringW(fileInfo.Size));
+ NumberToString(fileInfo.Size));
UString reducedName;
const int kLineSize = 88;
@@ -70,11 +70,12 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
timeString = ConvertFileTimeToString(localFileTime);
fullString +=
- #ifdef LANG
- LangLoadStringW(IDS_FILE_MODIFIED, 0x02000983);
+ #ifdef LANG
+ LangString(IDS_FILE_MODIFIED, 0x02000983);
#else
MyLoadStringW(IDS_FILE_MODIFIED);
#endif
+
fullString += L" ";
fullString += timeString;
}
diff --git a/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.h b/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.h
index 329d85ea..0bfbe059 100755
--- a/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.h
+++ b/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.h
@@ -25,8 +25,7 @@ class COverwriteDialog: public NWindows::NControl::CModalDialog
virtual bool OnInit();
bool OnButtonClicked(int buttonID, HWND buttonHWND);
public:
- INT_PTR Create(HWND parent = 0)
- { return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_OVERWRITE), parent); }
+ INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_OVERWRITE, parent); }
NOverwriteDialog::CFileInfo OldFileInfo;
NOverwriteDialog::CFileInfo NewFileInfo;
diff --git a/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.cpp b/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.cpp
index 2a6a2727..4f09f7f7 100755
--- a/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.cpp
+++ b/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.cpp
@@ -35,7 +35,7 @@ bool CPasswordDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
{
_passwordControl.SetPasswordChar((IsButtonChecked(
IDC_CHECK_PASSWORD_SHOW) == BST_CHECKED) ? 0: TEXT('*'));
- CSysString password;
+ UString password;
_passwordControl.GetText(password);
_passwordControl.SetText(password);
return true;
diff --git a/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.h b/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.h
index 481050a0..f77cd2be 100755
--- a/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.h
+++ b/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.h
@@ -15,8 +15,7 @@ class CPasswordDialog: public NWindows::NControl::CModalDialog
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
public:
UString Password;
- INT_PTR Create(HWND parentWindow = 0)
- { return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_PASSWORD), parentWindow); }
+ INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_PASSWORD, parentWindow); }
};
#endif
diff --git a/7zip/FileManager/Resource/PluginsPage/PluginsPage.cpp b/7zip/FileManager/Resource/PluginsPage/PluginsPage.cpp
index 3ca43916..0ccdf07e 100755
--- a/7zip/FileManager/Resource/PluginsPage/PluginsPage.cpp
+++ b/7zip/FileManager/Resource/PluginsPage/PluginsPage.cpp
@@ -33,18 +33,17 @@ bool CPluginsPage::OnInit()
_listView.Attach(GetItem(IDC_PLUGINS_LIST));
- UINT32 aNewFlags = /*LVS_EX_CHECKBOXES | */ LVS_EX_FULLROWSELECT;
- _listView.SetExtendedListViewStyle(aNewFlags, aNewFlags);
-
- // CSysString aString = LangLoadString(IDS_COLUMN_TITLE, 0x02000E81);
- CSysString aString = TEXT("Plugins");
- LVCOLUMN aColumn;
- aColumn.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT | LVCF_SUBITEM;
- aColumn.cx = 160;
- aColumn.fmt = LVCFMT_LEFT;
- aColumn.pszText = (LPTSTR)(LPCTSTR)aString;
- aColumn.iSubItem = 0;
- _listView.InsertColumn(0, &aColumn);
+ UINT32 newFlags = /*LVS_EX_CHECKBOXES | */ LVS_EX_FULLROWSELECT;
+ _listView.SetExtendedListViewStyle(newFlags, newFlags);
+
+ UString title = L"Plugins";
+ LVCOLUMNW column;
+ column.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT | LVCF_SUBITEM;
+ column.cx = 160;
+ column.fmt = LVCFMT_LEFT;
+ column.pszText = (LPWSTR)(LPCWSTR)title;
+ column.iSubItem = 0;
+ _listView.InsertColumn(0, &column);
ReadFileFolderPluginInfoList(_plugins);
@@ -52,22 +51,22 @@ bool CPluginsPage::OnInit()
// _listView.DeleteAllItems();
for(int i = 0; i < _plugins.Size(); i++)
{
- LVITEM anItem;
- anItem.iItem = i;
- anItem.mask = LVIF_TEXT | LVIF_STATE;
- CSysString pluginName = GetSystemString(_plugins[i].Name);
- anItem.pszText = (TCHAR *)(const TCHAR *)pluginName;
- anItem.state = 0;
- anItem.stateMask = UINT(-1);
- anItem.iSubItem = 0;
- _listView.InsertItem(&anItem);
+ LVITEMW item;
+ item.iItem = i;
+ item.mask = LVIF_TEXT | LVIF_STATE;
+ UString pluginName = _plugins[i].Name;
+ item.pszText = (WCHAR *)(const WCHAR *)pluginName;
+ item.state = 0;
+ item.stateMask = UINT(-1);
+ item.iSubItem = 0;
+ _listView.InsertItem(&item);
_listView.SetCheckState(i, true);
}
_listView.SetRedraw(true);
if(_listView.GetItemCount() > 0)
{
- UINT aState = LVIS_SELECTED | LVIS_FOCUSED;
- _listView.SetItemState(0, aState, aState);
+ UINT state = LVIS_SELECTED | LVIS_FOCUSED;
+ _listView.SetItemState(0, state, state);
}
return CPropertyPage::OnInit();
@@ -76,8 +75,8 @@ bool CPluginsPage::OnInit()
LONG CPluginsPage::OnApply()
{
/*
- int aSelectedIndex = m_Lang.GetCurSel();
- int aPathIndex = m_Lang.GetItemData(aSelectedIndex);
+ int selectedIndex = m_Lang.GetCurSel();
+ int aPathIndex = m_Lang.GetItemData(selectedIndex);
SaveRegLang(m_Paths[aPathIndex]);
ReloadLang();
*/
@@ -123,31 +122,14 @@ STDMETHODIMP CPluginOptionsCallback::GetProgramFolderPath(BSTR *value)
UString folder;
if (!::GetProgramFolderPath(folder))
return E_FAIL;
- CMyComBSTR valueTemp = GetUnicodeString(folder);
+ CMyComBSTR valueTemp = folder;
*value = valueTemp.Detach();
return S_OK;
}
-#ifndef _WIN64
-static bool IsItWindowsNT()
-{
- OSVERSIONINFO aVersionInfo;
- aVersionInfo.dwOSVersionInfoSize = sizeof(aVersionInfo);
- if (!::GetVersionEx(&aVersionInfo))
- return false;
- return (aVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
-}
-#endif
-
static UString GetDefaultProgramName()
{
- UString name;
- name += L"7zFM";
- #ifndef _WIN64
- if (IsItWindowsNT())
- name += L"n";
- #endif
- return name + L".exe";
+ return L"7zFM.exe";
}
STDMETHODIMP CPluginOptionsCallback::GetProgramPath(BSTR *value)
@@ -214,9 +196,9 @@ bool CPluginsPage::OnNotify(UINT controlID, LPNMHDR lParam)
const NMLISTVIEW *aNMListView = (const NMLISTVIEW *)lParam;
if ((aNMListView->uChanged & LVIF_STATE) != 0)
{
- UINT anOldState = aNMListView->uOldState & LVIS_STATEIMAGEMASK;
- UINT aNewState = aNMListView->uNewState & LVIS_STATEIMAGEMASK;
- if (anOldState != aNewState)
+ UINT oldState = aNMListView->uOldState & LVIS_STATEIMAGEMASK;
+ UINT newState = aNMListView->uNewState & LVIS_STATEIMAGEMASK;
+ if (oldState != newState)
Changed();
}
return true;
@@ -225,14 +207,14 @@ bool CPluginsPage::OnNotify(UINT controlID, LPNMHDR lParam)
}
/*
-bool CPluginsPage::OnCommand(int aCode, int anItemID, LPARAM lParam)
+bool CPluginsPage::OnCommand(int code, int itemID, LPARAM lParam)
{
- if (aCode == CBN_SELCHANGE && anItemID == IDC_LANG_COMBO_LANG)
+ if (code == CBN_SELCHANGE && itemID == IDC_LANG_COMBO_LANG)
{
Changed();
return true;
}
- return CPropertyPage::OnCommand(aCode, anItemID, lParam);
+ return CPropertyPage::OnCommand(code, itemID, lParam);
}
*/ \ No newline at end of file
diff --git a/7zip/FileManager/Resource/PluginsPage/PluginsPage.h b/7zip/FileManager/Resource/PluginsPage/PluginsPage.h
index 3c31bbc4..78e81dbb 100755
--- a/7zip/FileManager/Resource/PluginsPage/PluginsPage.h
+++ b/7zip/FileManager/Resource/PluginsPage/PluginsPage.h
@@ -17,7 +17,6 @@ class CPluginsPage: public NWindows::NControl::CPropertyPage
public:
virtual bool OnInit();
virtual void OnNotifyHelp();
- // virtual bool OnCommand(int aCode, int anItemID, LPARAM lParam);
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
virtual void OnButtonOptions();
virtual LONG OnApply();
diff --git a/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp b/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp
index 1e0fd392..85fcd806 100755
--- a/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp
+++ b/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp
@@ -27,10 +27,10 @@ CProgressDialog::~CProgressDialog()
{
AddToTitle(TEXT(""));
}
-void CProgressDialog::AddToTitle(LPCTSTR s)
+void CProgressDialog::AddToTitle(LPCWSTR s)
{
if (MainWindow != 0)
- ::SetWindowText(MainWindow, s + UString(MainTitle));
+ ::MySetWindowText(MainWindow, UString(s) + MainTitle);
}
#endif
diff --git a/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h b/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h
index 4ed48519..81a0f9a6 100755
--- a/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h
+++ b/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h
@@ -88,7 +88,7 @@ private:
virtual void OnCancel();
NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent;
#ifndef _SFX
- void AddToTitle(LPCTSTR string);
+ void AddToTitle(LPCWSTR string);
#endif
bool OnButtonClicked(int buttonID, HWND buttonHWND);
public:
@@ -110,10 +110,10 @@ public:
void WaitCreating() { _dialogCreatedEvent.Lock(); }
- INT_PTR Create(const UString &title, HWND aWndParent = 0)
+ INT_PTR Create(const UString &title, HWND wndParent = 0)
{
_title = title;
- return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_PROGRESS), aWndParent);
+ return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent);
}
static const UINT kCloseMessage;
diff --git a/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.cpp b/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.cpp
index 589f845e..49961874 100755
--- a/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.cpp
+++ b/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.cpp
@@ -69,7 +69,7 @@ static void ReduceString(UString &s, int size)
bool CProgressDialog::OnInit()
{
- _range = UInt64(-1);
+ _range = (UInt64)(Int64)(-1);
_prevPercentValue = UInt32(-1);
_prevElapsedSec = UInt32(-1);
_prevRemainingSec = UInt32(-1);
@@ -93,9 +93,9 @@ bool CProgressDialog::OnInit()
window = GetItem(IDC_BUTTON_PAUSE);
window.GetText(pauseString);
- foregroundString = LangLoadStringW(IDS_PROGRESS_FOREGROUND, 0x02000C11);
- continueString = LangLoadStringW(IDS_PROGRESS_CONTINUE, 0x02000C13);
- pausedString = LangLoadStringW(IDS_PROGRESS_PAUSED, 0x02000C20);
+ foregroundString = LangString(IDS_PROGRESS_FOREGROUND, 0x02000C11);
+ continueString = LangString(IDS_PROGRESS_CONTINUE, 0x02000C13);
+ pausedString = LangString(IDS_PROGRESS_PAUSED, 0x02000C20);
m_ProgressBar.Attach(GetItem(IDC_PROGRESS1));
_timer = SetTimer(kTimerID, kTimerElapse);
@@ -113,27 +113,19 @@ void CProgressDialog::OnCancel()
static void ConvertSizeToString(UInt64 value, wchar_t *s)
{
- if (value < (UInt64(10000) << 0))
- {
- ConvertUInt64ToString(value, s);
- lstrcatW(s, L" B");
- return;
- }
- if (value < (UInt64(10000) << 10))
- {
- ConvertUInt64ToString((value >> 10), s);
- lstrcatW(s, L" KB");
- return;
- }
- if (value < (UInt64(10000) << 20))
- {
- ConvertUInt64ToString((value >> 20), s);
- lstrcatW(s, L" MB");
- return;
- }
- ConvertUInt64ToString((value >> 30), s);
- lstrcatW(s, L" GB");
- return;
+ const wchar_t *kModif = L" KMGTP";
+ for (int i = 0; true; i++)
+ if (i == 5 || value < (UInt64(10000) << (i * 10)))
+ {
+ ConvertUInt64ToString(value >> (i * 10), s);
+ s += wcslen(s);
+ *s++ = ' ';
+ if (i != 0)
+ *s++ = kModif[i];
+ *s++ = L'B';
+ *s++ = L'\0';
+ return;
+ }
}
void CProgressDialog::SetRange(UInt64 range)
@@ -182,7 +174,13 @@ bool CProgressDialog::OnTimer(WPARAM timerID, LPARAM callback)
if (total != _range)
SetRange(total);
- SetPos(completed);
+ if (total == (UInt64)(Int64)-1)
+ {
+ SetPos(0);
+ SetRange(completed);
+ }
+ else
+ SetPos(completed);
_elapsedTime += (curTime - _prevTime);
_prevTime = curTime;
@@ -201,16 +199,23 @@ bool CProgressDialog::OnTimer(WPARAM timerID, LPARAM callback)
if (completed != 0 && elapsedChanged)
{
- UInt64 remainingTime = 0;
- if (completed < total)
- remainingTime = _elapsedTime * (total - completed) / completed;
- UInt64 remainingSec = remainingTime / 1000;
- if (remainingSec != _prevRemainingSec)
+ if (total == (UInt64)(Int64)-1)
{
- TCHAR s[40];
- GetTimeString(remainingSec, s);
- SetItemText(IDC_PROGRESS_REMAINING_VALUE, s);
- _prevRemainingSec = remainingSec;
+ SetItemText(IDC_PROGRESS_REMAINING_VALUE, L"");
+ }
+ else
+ {
+ UInt64 remainingTime = 0;
+ if (completed < total)
+ remainingTime = _elapsedTime * (total - completed) / completed;
+ UInt64 remainingSec = remainingTime / 1000;
+ if (remainingSec != _prevRemainingSec)
+ {
+ TCHAR s[40];
+ GetTimeString(remainingSec, s);
+ SetItemText(IDC_PROGRESS_REMAINING_VALUE, s);
+ _prevRemainingSec = remainingSec;
+ }
}
// if (elapsedChanged)
{
@@ -405,7 +410,7 @@ bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
if (!paused)
OnPauseButton();
int res = ::MessageBoxW(HWND(*this),
- LangLoadStringW(IDS_PROGRESS_ASK_CANCEL, 0x02000C30),
+ LangString(IDS_PROGRESS_ASK_CANCEL, 0x02000C30),
_title, MB_YESNOCANCEL);
// ProgressSynch.SetPaused(paused);
if (!paused)
diff --git a/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.h b/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.h
index 713e0f29..1803ce8b 100755
--- a/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.h
+++ b/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.h
@@ -21,7 +21,7 @@ class CProgressSynch
UString TitleFileName;
UString CurrentFileName;
public:
- CProgressSynch(): _stopped(false), _paused(false), _total(1), _completed(0) {}
+ CProgressSynch(): _stopped(false), _paused(false), _total((UInt64)(Int64)-1), _completed(0) {}
bool GetStopped()
{
@@ -168,10 +168,10 @@ public:
void WaitCreating() { _dialogCreatedEvent.Lock(); }
- INT_PTR Create(const UString &title, HWND aWndParent = 0)
+ INT_PTR Create(const UString &title, HWND wndParent = 0)
{
_title = title;
- return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_PROGRESS), aWndParent);
+ return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent);
}
static const UINT kCloseMessage;
diff --git a/7zip/FileManager/Resource/SettingsPage/SettingsPage.cpp b/7zip/FileManager/Resource/SettingsPage/SettingsPage.cpp
index 3150d3f1..6a681fbc 100755
--- a/7zip/FileManager/Resource/SettingsPage/SettingsPage.cpp
+++ b/7zip/FileManager/Resource/SettingsPage/SettingsPage.cpp
@@ -7,6 +7,7 @@
#include "Common/StringConvert.h"
#include "Windows/Defs.h"
+#include "Windows/MemoryLock.h"
#include "../../RegistryUtils.h"
#include "../../HelpUtils.h"
@@ -23,12 +24,15 @@ static CIDLangPair kIDLangPairs[] =
{ IDC_SETTINGS_FULL_ROW, 0x03010420},
{ IDC_SETTINGS_SHOW_GRID, 0x03010421},
{ IDC_SETTINGS_ALTERNATIVE_SELECTION, 0x03010430},
+ { IDC_SETTINGS_LARGE_PAGES, 0x03010440}
// { IDC_SETTINGS_SINGLE_CLICK, 0x03010422},
// { IDC_SETTINGS_UNDERLINE, 0x03010423}
};
static LPCWSTR kEditTopic = L"FM/options.htm#settings";
+extern bool IsLargePageSupported();
+
bool CSettingsPage::OnInit()
{
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
@@ -40,6 +44,10 @@ bool CSettingsPage::OnInit()
CheckButton(IDC_SETTINGS_FULL_ROW, ReadFullRow());
CheckButton(IDC_SETTINGS_SHOW_GRID, ReadShowGrid());
CheckButton(IDC_SETTINGS_ALTERNATIVE_SELECTION, ReadAlternativeSelection());
+ if (IsLargePageSupported())
+ CheckButton(IDC_SETTINGS_LARGE_PAGES, ReadLockMemoryEnable());
+ else
+ EnableItem(IDC_SETTINGS_LARGE_PAGES, false);
// CheckButton(IDC_SETTINGS_SINGLE_CLICK, ReadSingleClick());
// CheckButton(IDC_SETTINGS_UNDERLINE, ReadUnderline());
@@ -64,6 +72,12 @@ LONG CSettingsPage::OnApply()
SaveFullRow(IsButtonCheckedBool(IDC_SETTINGS_FULL_ROW));
SaveShowGrid(IsButtonCheckedBool(IDC_SETTINGS_SHOW_GRID));
SaveAlternativeSelection(IsButtonCheckedBool(IDC_SETTINGS_ALTERNATIVE_SELECTION));
+ if (IsLargePageSupported())
+ {
+ bool enable = IsButtonCheckedBool(IDC_SETTINGS_LARGE_PAGES);
+ NSecurity::EnableLockMemoryPrivilege(enable);
+ SaveLockMemoryEnable(enable);
+ }
// SaveSingleClick(IsButtonCheckedBool(IDC_SETTINGS_SINGLE_CLICK));
// SaveUnderline(IsButtonCheckedBool(IDC_SETTINGS_UNDERLINE));
@@ -91,6 +105,7 @@ bool CSettingsPage::OnButtonClicked(int buttonID, HWND buttonHWND)
case IDC_SETTINGS_FULL_ROW:
case IDC_SETTINGS_SHOW_GRID:
case IDC_SETTINGS_ALTERNATIVE_SELECTION:
+ case IDC_SETTINGS_LARGE_PAGES:
Changed();
return true;
}
diff --git a/7zip/FileManager/Resource/SettingsPage/resource.h b/7zip/FileManager/Resource/SettingsPage/resource.h
index f74b00a7..8932dc0e 100755
--- a/7zip/FileManager/Resource/SettingsPage/resource.h
+++ b/7zip/FileManager/Resource/SettingsPage/resource.h
@@ -8,3 +8,4 @@
#define IDC_SETTINGS_SINGLE_CLICK 1014
#define IDC_SETTINGS_UNDERLINE 1015
#define IDC_SETTINGS_ALTERNATIVE_SELECTION 1016
+#define IDC_SETTINGS_LARGE_PAGES 1017
diff --git a/7zip/FileManager/Resource/SettingsPage/resource.rc b/7zip/FileManager/Resource/SettingsPage/resource.rc
index 20578774..69afeba7 100755
--- a/7zip/FileManager/Resource/SettingsPage/resource.rc
+++ b/7zip/FileManager/Resource/SettingsPage/resource.rc
@@ -29,4 +29,7 @@ BEGIN
CONTROL "&Alternative selection mode", IDC_SETTINGS_ALTERNATIVE_SELECTION, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
marg, 122, xSize2, 10
+ CONTROL "Use &large memory pages", IDC_SETTINGS_LARGE_PAGES, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+ marg, 142, xSize2, 10
+
END
diff --git a/7zip/FileManager/Resource/SplitDialog/SplitDialog.cpp b/7zip/FileManager/Resource/SplitDialog/SplitDialog.cpp
index 014ba7ec..a84dc0bd 100755
--- a/7zip/FileManager/Resource/SplitDialog/SplitDialog.cpp
+++ b/7zip/FileManager/Resource/SplitDialog/SplitDialog.cpp
@@ -36,7 +36,7 @@ bool CSplitDialog::OnInit()
{
UString title;
GetText(title);
- title += ' ';
+ title += L' ';
title += FilePath;
SetText(title);
}
@@ -59,10 +59,10 @@ bool CSplitDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
void CSplitDialog::OnButtonSetPath()
{
- CSysString currentPath;
+ UString currentPath;
_pathCombo.GetText(currentPath);
- CSysString title = TEXT("Specify a location for output folder");
- CSysString resultPath;
+ UString title = L"Specify a location for output folder";
+ UString resultPath;
if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
return;
NFile::NName::NormalizeDirPathPrefix(resultPath);
@@ -78,7 +78,7 @@ void CSplitDialog::OnOK()
volumeString.Trim();
if (!ParseVolumeSizes(volumeString, VolumeSizes))
{
- MessageBox((HWND)*this, TEXT("Incorrect volume size"), TEXT("7-Zip"), MB_ICONERROR);
+ MessageBoxW((HWND)*this, L"Incorrect volume size", L"7-Zip", MB_ICONERROR);
return;
}
CModalDialog::OnOK();
diff --git a/7zip/FileManager/Resource/SplitDialog/SplitDialog.h b/7zip/FileManager/Resource/SplitDialog/SplitDialog.h
index bc5ebecf..d73dcbca 100755
--- a/7zip/FileManager/Resource/SplitDialog/SplitDialog.h
+++ b/7zip/FileManager/Resource/SplitDialog/SplitDialog.h
@@ -21,7 +21,7 @@ public:
UString Path;
CRecordVector<UInt64> VolumeSizes;
INT_PTR Create(HWND parentWindow = 0)
- { return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_SPLIT), parentWindow); }
+ { return CModalDialog::Create(IDD_DIALOG_SPLIT, parentWindow); }
};
#endif
diff --git a/7zip/FileManager/Resource/SystemPage/SystemPage.cpp b/7zip/FileManager/Resource/SystemPage/SystemPage.cpp
index 133ba7d1..4c561b18 100755
--- a/7zip/FileManager/Resource/SystemPage/SystemPage.cpp
+++ b/7zip/FileManager/Resource/SystemPage/SystemPage.cpp
@@ -50,24 +50,24 @@ bool CSystemPage::OnInit()
_listViewExt.SetExtendedListViewStyle(newFlags, newFlags);
_listViewPlugins.SetExtendedListViewStyle(newFlags, newFlags);
- CSysString s = LangLoadString(IDS_PROPERTY_EXTENSION, 0x02000205);
- LVCOLUMN column;
+ UString s = LangString(IDS_PROPERTY_EXTENSION, 0x02000205);
+ LVCOLUMNW column;
column.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT | LVCF_SUBITEM;
column.cx = 70;
column.fmt = LVCFMT_LEFT;
- column.pszText = (LPTSTR)(LPCTSTR)s;
+ column.pszText = (LPWSTR)(LPCWSTR)s;
column.iSubItem = 0;
_listViewExt.InsertColumn(0, &column);
- s = LangLoadString(IDS_PLUGIN, 0x03010310);
+ s = LangString(IDS_PLUGIN, 0x03010310);
column.cx = 70;
- column.pszText = (LPTSTR)(LPCTSTR)s;
+ column.pszText = (LPWSTR)(LPCWSTR)s;
column.iSubItem = 1;
_listViewExt.InsertColumn(1, &column);
- s = LangLoadString(IDS_PLUGIN, 0x03010310);
+ s = LangString(IDS_PLUGIN, 0x03010310);
column.cx = 70;
- column.pszText = (LPTSTR)(LPCTSTR)s;
+ column.pszText = (LPWSTR)(LPCWSTR)s;
column.iSubItem = 0;
_listViewPlugins.InsertColumn(0, &column);
@@ -77,12 +77,11 @@ bool CSystemPage::OnInit()
{
CExtInfoBig &extInfo = _extDatabase.ExtBigItems[i];
- LVITEM item;
+ LVITEMW item;
item.iItem = i;
item.mask = LVIF_TEXT | LVIF_PARAM;
item.lParam = i;
- CSysString ext = GetSystemString(extInfo.Ext);
- item.pszText = (LPTSTR)(LPCTSTR)ext;
+ item.pszText = (LPWSTR)(LPCWSTR)extInfo.Ext;
item.iSubItem = 0;
int itemIndex = _listViewExt.InsertItem(&item);
@@ -106,53 +105,36 @@ bool CSystemPage::OnInit()
void CSystemPage::SetMainPluginText(int itemIndex, int indexInDatabase)
{
- LVITEM item;
+ LVITEMW item;
item.iItem = itemIndex;
item.mask = LVIF_TEXT;
- CSysString mainPlugin = GetSystemString(
- _extDatabase.GetMainPluginNameForExtItem(indexInDatabase));
- item.pszText = (TCHAR *)(const TCHAR *)mainPlugin;
+ UString mainPlugin = _extDatabase.GetMainPluginNameForExtItem(indexInDatabase);
+ item.pszText = (WCHAR *)(const WCHAR *)mainPlugin;
item.iSubItem = 1;
_listViewExt.SetItem(&item);
}
-#ifndef _WIN64
-static bool IsItWindowsNT()
-{
- OSVERSIONINFO versionInfo;
- versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
- return false;
- return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
-}
-#endif
-
static UString GetProgramCommand()
{
UString path = L"\"";
UString folder;
if (GetProgramFolderPath(folder))
path += folder;
- path += L"7zFM";
- #ifndef _WIN64
- if (IsItWindowsNT())
- path += L"n";
- #endif
- path += L".exe\" \"%1\"";
+ path += L"7zFM.exe\" \"%1\"";
return path;
}
-static CSysString GetIconPath(const CSysString &filePath,
+static UString GetIconPath(const UString &filePath,
const CLSID &clsID, const UString &extension)
{
CPluginLibrary library;
CMyComPtr<IFolderManager> folderManager;
CMyComPtr<IFolderFolder> folder;
if (library.LoadAndCreateManager(filePath, clsID, &folderManager) != S_OK)
- return CSysString();
+ return UString();
CMyComBSTR typesString;
if (folderManager->GetTypes(&typesString) != S_OK)
- return CSysString();
+ return UString();
UStringVector types;
SplitString((const wchar_t *)typesString, types);
for (int typeIndex = 0; typeIndex < types.Size(); typeIndex++)
@@ -164,16 +146,15 @@ static CSysString GetIconPath(const CSysString &filePath,
if (extension.CompareNoCase((const wchar_t *)extTemp) == 0)
{
CMyComPtr<IFolderManagerGetIconPath> getIconPath;
- if (folderManager.QueryInterface(
- IID_IFolderManagerGetIconPath, &getIconPath) != S_OK)
- return CSysString();
+ if (folderManager.QueryInterface(IID_IFolderManagerGetIconPath, &getIconPath) != S_OK)
+ break;
CMyComBSTR iconPathTemp;
if (getIconPath->GetIconPath(type, &iconPathTemp) != S_OK)
- return CSysString();
- return GetSystemString((const wchar_t *)iconPathTemp);
+ break;
+ return (const wchar_t *)iconPathTemp;
}
}
- return CSysString();
+ return UString();
}
LONG CSystemPage::OnApply()
@@ -189,7 +170,7 @@ LONG CSystemPage::OnApply()
{
UString title = extInfo.Ext + UString(L" Archive");
UString command = GetProgramCommand();
- CSysString iconPath;
+ UString iconPath;
if (!extInfo.PluginsPairs.IsEmpty())
{
const CPluginInfo &plugin = _extDatabase.Plugins[extInfo.PluginsPairs[0].Index];
@@ -197,8 +178,8 @@ LONG CSystemPage::OnApply()
}
NRegistryAssociations::AddShellExtensionInfo(
GetSystemString(extInfo.Ext),
- GetSystemString(title),
- GetSystemString(command),
+ title,
+ command,
iconPath, NULL, 0);
}
else
@@ -210,7 +191,7 @@ LONG CSystemPage::OnApply()
else
NRegistryAssociations::DeleteContextMenuHandler();
*/
-
+ SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
return PSNRET_NOERROR;
}
@@ -411,12 +392,12 @@ void CSystemPage::RefreshPluginsList(int selectIndex)
for (int i = 0; i < extInfo.PluginsPairs.Size(); i++)
{
CPluginEnabledPair pluginPair = extInfo.PluginsPairs[i];
- CSysString pluginName = GetSystemString(_extDatabase.Plugins[pluginPair.Index].Name);
- LVITEM item;
+ UString pluginName = _extDatabase.Plugins[pluginPair.Index].Name;
+ LVITEMW item;
item.iItem = i;
item.mask = LVIF_TEXT | LVIF_PARAM;
item.lParam = i;
- item.pszText = (LPTSTR)(LPCTSTR)pluginName;
+ item.pszText = (LPWSTR)(LPCWSTR)pluginName;
item.iSubItem = 0;
int itemIndex = _listViewPlugins.InsertItem(&item);
_listViewPlugins.SetCheckState(itemIndex, pluginPair.Enabled);
@@ -434,9 +415,6 @@ void CSystemPage::RefreshPluginsList(int selectIndex)
/*
-static LPCTSTR kZIPExtension = TEXT("zip");
-static LPCTSTR kRARExtension = TEXT("rar");
-
static BYTE kZipShellNewData[] =
{ 0x50-1, 0x4B, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0 };
diff --git a/7zip/FileManager/RootFolder.cpp b/7zip/FileManager/RootFolder.cpp
index ebff83c4..6eed3d1f 100755
--- a/7zip/FileManager/RootFolder.cpp
+++ b/7zip/FileManager/RootFolder.cpp
@@ -12,6 +12,7 @@
#include "Windows/PropVariant.h"
#include "FSDrives.h"
+#include "PhysDriveFolder.h"
#include "NetFolder.h"
#include "SysIconUtils.h"
#include "LangUtils.h"
@@ -29,8 +30,8 @@ static const STATPROPSTG kProperties[] =
void CRootFolder::Init()
{
- _computerName = LangLoadStringW(IDS_COMPUTER, 0x03020300);
- _networkName = LangLoadStringW(IDS_NETWORK, 0x03020301);
+ _computerName = LangString(IDS_COMPUTER, 0x03020300);
+ _networkName = LangString(IDS_NETWORK, 0x03020301);
};
STDMETHODIMP CRootFolder::LoadItems()
@@ -39,13 +40,13 @@ STDMETHODIMP CRootFolder::LoadItems()
return S_OK;
}
-STDMETHODIMP CRootFolder::GetNumberOfItems(UINT32 *numItems)
+STDMETHODIMP CRootFolder::GetNumberOfItems(UInt32 *numItems)
{
*numItems = 2;
return S_OK;
}
-STDMETHODIMP CRootFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT *value)
+STDMETHODIMP CRootFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
{
NCOM::CPropVariant propVariant;
switch(propID)
@@ -56,7 +57,7 @@ STDMETHODIMP CRootFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIA
case kpidName:
if (itemIndex == 0)
propVariant = _computerName;
- else
+ else if (itemIndex == 1)
propVariant = _networkName;
break;
}
@@ -64,7 +65,7 @@ STDMETHODIMP CRootFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIA
return S_OK;
}
-STDMETHODIMP CRootFolder::BindToFolder(UINT32 index, IFolderFolder **resultFolder)
+STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
{
if (index == 0)
{
@@ -73,13 +74,15 @@ STDMETHODIMP CRootFolder::BindToFolder(UINT32 index, IFolderFolder **resultFolde
fsDrivesSpec->Init();
*resultFolder = subFolder.Detach();
}
- else
+ else if (index == 1)
{
CNetFolder *netFolderSpec = new CNetFolder;
CMyComPtr<IFolderFolder> subFolder = netFolderSpec;
netFolderSpec->Init(0, 0, _networkName + L'\\');
*resultFolder = subFolder.Detach();
}
+ else
+ return E_INVALIDARG;
return S_OK;
}
@@ -98,10 +101,10 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu
}
if (name2 == _computerName ||
name2 == (_computerName + UString(L'\\')))
- return BindToFolder(UINT32(0), resultFolder);
+ return BindToFolder(UInt32(0), resultFolder);
if (name2 == _networkName ||
name2 == (_networkName + UString(L'\\')))
- return BindToFolder(UINT32(1), resultFolder);
+ return BindToFolder(UInt32(1), resultFolder);
if (name2 == UString(L'\\'))
{
CMyComPtr<IFolderFolder> subFolder = this;
@@ -112,24 +115,34 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu
if (name2.Length () < 2)
return E_INVALIDARG;
- if (name2[name2.Length () - 1] != L'\\')
- name2 += L'\\';
- CFSFolder *fsFolderSpec = new CFSFolder;
- CMyComPtr<IFolderFolder> subFolder = fsFolderSpec;
- if (fsFolderSpec->Init(name2, 0) == S_OK)
+ CMyComPtr<IFolderFolder> subFolder;
+
+ if (name2.Left(4) == L"\\\\.\\")
{
- *resultFolder = subFolder.Detach();
- return S_OK;
+ CPhysDriveFolder *folderSpec = new CPhysDriveFolder;
+ subFolder = folderSpec;
+ RINOK(folderSpec->Init(name2.Mid(4, 2)));
}
- if (name2[0] == L'\\')
+ else
{
- CNetFolder *netFolderSpec = new CNetFolder;
- CMyComPtr<IFolderFolder> subFolder = netFolderSpec;
- netFolderSpec->Init(name2);
- *resultFolder = subFolder.Detach();
- return S_OK;
+ if (name2[name2.Length () - 1] != L'\\')
+ name2 += L'\\';
+ CFSFolder *fsFolderSpec = new CFSFolder;
+ subFolder = fsFolderSpec;
+ if (fsFolderSpec->Init(name2, 0) != S_OK)
+ {
+ if (name2[0] == L'\\')
+ {
+ CNetFolder *netFolderSpec = new CNetFolder;
+ subFolder = netFolderSpec;
+ netFolderSpec->Init(name2);
+ }
+ else
+ return E_INVALIDARG;
+ }
}
- return E_INVALIDARG;
+ *resultFolder = subFolder.Detach();
+ return S_OK;
}
STDMETHODIMP CRootFolder::BindToParentFolder(IFolderFolder **resultFolder)
@@ -143,13 +156,13 @@ STDMETHODIMP CRootFolder::GetName(BSTR *name)
return E_NOTIMPL;
}
-STDMETHODIMP CRootFolder::GetNumberOfProperties(UINT32 *numProperties)
+STDMETHODIMP CRootFolder::GetNumberOfProperties(UInt32 *numProperties)
{
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
return S_OK;
}
-STDMETHODIMP CRootFolder::GetPropertyInfo(UINT32 index,
+STDMETHODIMP CRootFolder::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
@@ -175,7 +188,7 @@ STDMETHODIMP CRootFolder::GetPath(BSTR *path)
return S_OK;
}
-STDMETHODIMP CRootFolder::GetSystemIconIndex(UINT32 index, INT32 *iconIndex)
+STDMETHODIMP CRootFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
{
int aCSIDL;
if (index == 0)
diff --git a/7zip/FileManager/RootFolder.h b/7zip/FileManager/RootFolder.h
index 6dd08bc0..16bac250 100755
--- a/7zip/FileManager/RootFolder.h
+++ b/7zip/FileManager/RootFolder.h
@@ -26,19 +26,19 @@ public:
)
STDMETHOD(LoadItems)();
- STDMETHOD(GetNumberOfItems)(UINT32 *numItems);
- STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value);
- STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder);
+ STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
+ STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value);
+ STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder);
STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder);
STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder);
STDMETHOD(GetName)(BSTR *name);
- STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties);
- STDMETHOD(GetPropertyInfo)(UINT32 index,
+ STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
+ STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetTypeID)(BSTR *name);
STDMETHOD(GetPath)(BSTR *path);
- STDMETHOD(GetSystemIconIndex)(UINT32 index, INT32 *iconIndex);
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
void Init();
private:
diff --git a/7zip/FileManager/StringUtils.cpp b/7zip/FileManager/StringUtils.cpp
index 47560b05..63eebdba 100755
--- a/7zip/FileManager/StringUtils.cpp
+++ b/7zip/FileManager/StringUtils.cpp
@@ -66,13 +66,3 @@ UString JoinStrings(const UStringVector &srcStrings)
return destString;
}
-/*
-void SplitString(const CSysString &srcString, CSysStringVector &destStrings)
-{
- destStrings.Clear();
- UStringVector destStringsTemp;
- SplitString(GetUnicodeString(srcString), destStringsTemp);
- for (int i = 0; i < destStringsTemp.Size(); i++);
- destStrings.Add(GetSysUnicodeString
-}
-*/
diff --git a/7zip/FileManager/SysIconUtils.cpp b/7zip/FileManager/SysIconUtils.cpp
index e2577b45..36230610 100755
--- a/7zip/FileManager/SysIconUtils.cpp
+++ b/7zip/FileManager/SysIconUtils.cpp
@@ -7,6 +7,10 @@
#include "Common/StringConvert.h"
#endif
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
int GetIconIndexForCSIDL(int aCSIDL)
{
LPITEMIDLIST pidlMyComputer = 0;
@@ -39,39 +43,57 @@ DWORD_PTR GetRealIconIndex(LPCTSTR path, UINT32 attributes, int &iconIndex)
}
#ifndef _UNICODE
-static inline UINT GetCurrentCodePage()
- { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+// static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
DWORD_PTR GetRealIconIndex(LPCWSTR path, UINT32 attributes, int &iconIndex)
{
- SHFILEINFOW shellInfo;
- DWORD_PTR res = ::SHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
+ if(g_IsNT)
+ {
+ SHFILEINFOW shellInfo;
+ DWORD_PTR res = ::SHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
- if (res == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
- return GetRealIconIndex(UnicodeStringToMultiByte(path, GetCurrentCodePage()), attributes, iconIndex);
- iconIndex = shellInfo.iIcon;
- return res;
+ iconIndex = shellInfo.iIcon;
+ return res;
+ }
+ else
+ return GetRealIconIndex(UnicodeStringToMultiByte(path), attributes, iconIndex);
}
#endif
-DWORD_PTR GetRealIconIndex(const CSysString &fileName, UINT32 attributes,
- int &iconIndex, CSysString &typeName)
+DWORD_PTR GetRealIconIndex(const UString &fileName, UINT32 attributes,
+ int &iconIndex, UString &typeName)
{
- SHFILEINFO shellInfo;
- DWORD_PTR res = ::SHGetFileInfo(fileName, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
+ #ifndef _UNICODE
+ if(!g_IsNT)
+ {
+ SHFILEINFO shellInfo;
+ shellInfo.szTypeName[0] = 0;
+ DWORD_PTR res = ::SHGetFileInfoA(GetSystemString(fileName), FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX
| SHGFI_TYPENAME);
- typeName = shellInfo.szTypeName;
- iconIndex = shellInfo.iIcon;
- return res;
+ typeName = GetUnicodeString(shellInfo.szTypeName);
+ iconIndex = shellInfo.iIcon;
+ return res;
+ }
+ else
+ #endif
+ {
+ SHFILEINFOW shellInfo;
+ shellInfo.szTypeName[0] = 0;
+ DWORD_PTR res = ::SHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
+ sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX
+ | SHGFI_TYPENAME);
+ typeName = shellInfo.szTypeName;
+ iconIndex = shellInfo.iIcon;
+ return res;
+ }
}
-int CExtToIconMap::GetIconIndex(UINT32 attributes, const CSysString &fileNameSpec,
- CSysString &typeName)
+int CExtToIconMap::GetIconIndex(UINT32 attributes, const UString &fileNameSpec, UString &typeName)
{
- CSysString fileName = fileNameSpec;
+ UString fileName = fileNameSpec;
if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
{
- fileName = TEXT("__Fldr__");
+ fileName = L"__Fldr__";
if (_dirIconIndex < 0)
GetRealIconIndex(fileName, attributes, _dirIconIndex, _dirTypeName);
typeName = _dirTypeName;
@@ -80,7 +102,7 @@ int CExtToIconMap::GetIconIndex(UINT32 attributes, const CSysString &fileNameSpe
int dotPos = fileName.ReverseFind('.');
if (dotPos < 0)
{
- fileName = TEXT("__File__");
+ fileName = L"__File__";
if (_noExtIconIndex < 0)
{
int iconIndexTemp;
@@ -101,8 +123,8 @@ int CExtToIconMap::GetIconIndex(UINT32 attributes, const CSysString &fileNameSpe
return extIconPair.IconIndex;
}
-int CExtToIconMap::GetIconIndex(UINT32 attributes, const CSysString &fileName)
+int CExtToIconMap::GetIconIndex(UINT32 attributes, const UString &fileName)
{
- CSysString typeName;
+ UString typeName;
return GetIconIndex(attributes, fileName, typeName);
}
diff --git a/7zip/FileManager/SysIconUtils.h b/7zip/FileManager/SysIconUtils.h
index cf8f79e5..51294751 100755
--- a/7zip/FileManager/SysIconUtils.h
+++ b/7zip/FileManager/SysIconUtils.h
@@ -7,9 +7,9 @@
struct CExtIconPair
{
- CSysString Ext;
+ UString Ext;
int IconIndex;
- CSysString TypeName;
+ UString TypeName;
};
@@ -26,9 +26,9 @@ inline bool operator<(const CExtIconPair &a1, const CExtIconPair &a2)
class CExtToIconMap
{
int _dirIconIndex;
- CSysString _dirTypeName;
+ UString _dirTypeName;
int _noExtIconIndex;
- CSysString _noExtTypeName;
+ UString _noExtTypeName;
CObjectVector<CExtIconPair> _map;
public:
CExtToIconMap(): _dirIconIndex(-1), _noExtIconIndex(-1) {}
@@ -38,16 +38,14 @@ public:
_noExtIconIndex = -1;
_map.Clear();
}
- int GetIconIndex(UINT32 attributes, const CSysString &fileName,
- CSysString &typeName);
- int GetIconIndex(UINT32 attributes, const CSysString &fileName);
+ int GetIconIndex(UINT32 attributes, const UString &fileName, UString &typeName);
+ int GetIconIndex(UINT32 attributes, const UString &fileName);
};
DWORD_PTR GetRealIconIndex(LPCTSTR path, UINT32 attributes, int &iconIndex);
#ifndef _UNICODE
-// DWORD_PTR GetRealIconIndex(LPCWSTR path, UINT32 attributes, int &iconIndex);
+DWORD_PTR GetRealIconIndex(LPCWSTR path, UINT32 attributes, int &iconIndex);
#endif
-DWORD_PTR GetRealIconIndex(const CSysString &fileName, UINT32 attributes, int &iconIndex, CSysString &typeName);
int GetIconIndexForCSIDL(int aCSIDL);
#endif
diff --git a/7zip/FileManager/UpdateCallback100.cpp b/7zip/FileManager/UpdateCallback100.cpp
index 113e0d8f..c9931922 100755
--- a/7zip/FileManager/UpdateCallback100.cpp
+++ b/7zip/FileManager/UpdateCallback100.cpp
@@ -81,7 +81,7 @@ STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword2(INT32 *passwordIsDefi
CPasswordDialog dialog;
if (dialog.Create(_parentWindow) == IDCANCEL)
return E_ABORT;
- _password = GetUnicodeString((LPCTSTR)dialog._password);
+ _password = dialog._password;
_passwordIsDefined = true;
*/
}
diff --git a/7zip/FileManager/ViewSettings.cpp b/7zip/FileManager/ViewSettings.cpp
index 9b8d0765..61d422cc 100755
--- a/7zip/FileManager/ViewSettings.cpp
+++ b/7zip/FileManager/ViewSettings.cpp
@@ -3,6 +3,7 @@
#include "StdAfx.h"
#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
#include "ViewSettings.h"
#include "Windows/Registry.h"
@@ -19,7 +20,7 @@ static const TCHAR *kPositionValueName = TEXT("Position");
static const TCHAR *kPanelsInfoValueName = TEXT("Panels");
static const TCHAR *kToolbars = TEXT("Toolbars");
-static const TCHAR *kPanelPathValueName = TEXT("PanelPath");
+static const WCHAR *kPanelPathValueName = L"PanelPath";
static const TCHAR *kListMode = TEXT("ListMode");
static const TCHAR *kFolderHistoryValueName = TEXT("FolderHistory");
static const TCHAR *kFastFoldersValueName = TEXT("FolderShortcuts");
@@ -106,7 +107,7 @@ public:
}
};
-void SaveListViewInfo(const CSysString &id, const CListViewInfo &viewInfo)
+void SaveListViewInfo(const UString &id, const CListViewInfo &viewInfo)
{
const CObjectVector<CColumnInfo> &columns = viewInfo.Columns;
CTempOutBufferSpec buffer;
@@ -130,11 +131,11 @@ void SaveListViewInfo(const CSysString &id, const CListViewInfo &viewInfo)
keyName += kCulumnsKeyName;
CKey key;
key.Create(HKEY_CURRENT_USER, keyName);
- key.SetValue(id, (const Byte *)buffer, dataSize);
+ key.SetValue(GetSystemString(id), (const Byte *)buffer, dataSize);
}
}
-void ReadListViewInfo(const CSysString &id, CListViewInfo &viewInfo)
+void ReadListViewInfo(const UString &id, CListViewInfo &viewInfo)
{
viewInfo.Clear();
CObjectVector<CColumnInfo> &columns = viewInfo.Columns;
@@ -148,7 +149,7 @@ void ReadListViewInfo(const CSysString &id, CListViewInfo &viewInfo)
CKey key;
if(key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS)
return;
- if (key.QueryValue(id, buffer, size) != ERROR_SUCCESS)
+ if (key.QueryValue(GetSystemString(id), buffer, size) != ERROR_SUCCESS)
return;
}
if (size < kColumnHeaderSize)
@@ -299,15 +300,15 @@ UInt32 ReadToolbarsMask()
}
-static CSysString GetPanelPathName(UInt32 panelIndex)
+static UString GetPanelPathName(UInt32 panelIndex)
{
- TCHAR panelString[32];
+ WCHAR panelString[32];
ConvertUInt64ToString(panelIndex, panelString);
- return CSysString(kPanelPathValueName) + panelString;
+ return UString(kPanelPathValueName) + panelString;
}
-void SavePanelPath(UInt32 panel, const CSysString &path)
+void SavePanelPath(UInt32 panel, const UString &path)
{
CKey key;
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
@@ -315,7 +316,7 @@ void SavePanelPath(UInt32 panel, const CSysString &path)
key.SetValue(GetPanelPathName(panel), path);
}
-bool ReadPanelPath(UInt32 panel, CSysString &path)
+bool ReadPanelPath(UInt32 panel, UString &path)
{
CKey key;
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
diff --git a/7zip/FileManager/ViewSettings.h b/7zip/FileManager/ViewSettings.h
index b9da8bf2..4894a6f9 100755
--- a/7zip/FileManager/ViewSettings.h
+++ b/7zip/FileManager/ViewSettings.h
@@ -59,8 +59,8 @@ struct CListViewInfo
}
};
-void SaveListViewInfo(const CSysString &anID, const CListViewInfo &viewInfo);
-void ReadListViewInfo(const CSysString &anID, CListViewInfo &viewInfo);
+void SaveListViewInfo(const UString &id, const CListViewInfo &viewInfo);
+void ReadListViewInfo(const UString &id, CListViewInfo &viewInfo);
void SaveWindowSize(const RECT &rect, bool maximized);
bool ReadWindowSize(RECT &rect, bool &maximized);
@@ -71,8 +71,8 @@ bool ReadPanelsInfo(UInt32 &numPanels, UInt32 &currentPanel, UInt32 &splitterPos
void SaveToolbarsMask(UInt32 toolbarMask);
UInt32 ReadToolbarsMask();
-void SavePanelPath(UInt32 panel, const CSysString &path);
-bool ReadPanelPath(UInt32 panel, CSysString &path);
+void SavePanelPath(UInt32 panel, const UString &path);
+bool ReadPanelPath(UInt32 panel, UString &path);
struct CListMode
{
diff --git a/7zip/FileManager/makefile b/7zip/FileManager/makefile
index 63f1ead8..00f657b6 100755
--- a/7zip/FileManager/makefile
+++ b/7zip/FileManager/makefile
@@ -33,6 +33,7 @@ FM_OBJS = \
$O\PanelSelect.obj \
$O\PanelSort.obj \
$O\PanelSplitFile.obj \
+ $O\PhysDriveFolder.obj \
$O\ProgramLocation.obj \
$O\PropertyName.obj \
$O\RegistryAssociations.obj \
@@ -65,19 +66,24 @@ COMMON_OBJS = \
$O\Wildcard.obj \
WIN_OBJS = \
+ $O\CommonDialog.obj \
$O\DLL.obj \
$O\Error.obj \
+ $O\FileDevice.obj \
$O\FileDir.obj \
$O\FileFind.obj \
$O\FileIO.obj \
$O\FileName.obj \
$O\FileSystem.obj \
$O\Memory.obj \
+ $O\MemoryLock.obj \
+ $O\Menu.obj \
$O\Net.obj \
$O\PropVariant.obj \
$O\PropVariantConversions.obj \
$O\Registry.obj \
$O\ResourceString.obj \
+ $O\Security.obj \
$O\Shell.obj \
$O\Synchronization.obj \
$O\Window.obj \
diff --git a/7zip/Guid.txt b/7zip/Guid.txt
index 66d202e1..869b2b9e 100755
--- a/7zip/Guid.txt
+++ b/7zip/Guid.txt
@@ -114,6 +114,7 @@ Handler GUIDs:
07 7z
08 Cab
+E8 Bkf
E9 Chm
EA Split
EB Rpm
diff --git a/7zip/MyVersion.h b/7zip/MyVersion.h
index ed14a2fb..24c1418e 100755
--- a/7zip/MyVersion.h
+++ b/7zip/MyVersion.h
@@ -1,7 +1,7 @@
#define MY_VER_MAJOR 4
-#define MY_VER_MINOR 29
-#define MY_VERSION "4.29 beta"
-#define MY_7ZIP_VERSION "7-Zip 4.29 beta"
-#define MY_DATE "2005-09-28"
+#define MY_VER_MINOR 30
+#define MY_VERSION "4.30 beta"
+#define MY_7ZIP_VERSION "7-Zip 4.30 beta"
+#define MY_DATE "2005-11-18"
#define MY_COPYRIGHT "Copyright (c) 1999-2005 Igor Pavlov"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE
diff --git a/7zip/UI/Common/ArchiveCommandLine.cpp b/7zip/UI/Common/ArchiveCommandLine.cpp
index 664f4972..f41c8811 100755
--- a/7zip/UI/Common/ArchiveCommandLine.cpp
+++ b/7zip/UI/Common/ArchiveCommandLine.cpp
@@ -27,7 +27,7 @@ using namespace NCommandLineParser;
using namespace NWindows;
using namespace NFile;
-static const int kNumSwitches = 24;
+static const int kNumSwitches = 25;
namespace NKey {
enum Enum
@@ -55,7 +55,8 @@ enum Enum
kStdOut,
kOverwrite,
kEmail,
- kShowDialog
+ kShowDialog,
+ kLargePages
};
}
@@ -117,7 +118,8 @@ static const CSwitchForm kSwitchForms[kNumSwitches] =
{ L"SO", NSwitchType::kSimple, false, 0 },
{ L"AO", NSwitchType::kPostChar, false, 1, 1, kOverwritePostCharSet},
{ L"SEML", NSwitchType::kUnLimitedPostString, false, 0},
- { L"AD", NSwitchType::kSimple, false }
+ { L"AD", NSwitchType::kSimple, false },
+ { L"SLP", NSwitchType::kUnLimitedPostString, false, 0}
};
static const int kNumCommandForms = 7;
@@ -709,6 +711,16 @@ void CArchiveCommandLineParser::Parse1(const UStringVector &commandStrings,
options.StdOutMode = parser[NKey::kStdOut].ThereIs;
options.EnableHeaders = !parser[NKey::kDisableHeaders].ThereIs;
options.HelpMode = parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs;
+
+ #ifdef _WIN32
+ options.LargePages = false;
+ if (parser[NKey::kLargePages].ThereIs)
+ {
+ const UString &postString = parser[NKey::kLargePages].PostStrings.Front();
+ if (postString.IsEmpty())
+ options.LargePages = true;
+ }
+ #endif
}
void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
diff --git a/7zip/UI/Common/ArchiveCommandLine.h b/7zip/UI/Common/ArchiveCommandLine.h
index 48bf026d..ddca3237 100755
--- a/7zip/UI/Common/ArchiveCommandLine.h
+++ b/7zip/UI/Common/ArchiveCommandLine.h
@@ -40,6 +40,10 @@ struct CArchiveCommandLineOptions
{
bool HelpMode;
+ #ifdef _WIN32
+ bool LargePages;
+ #endif
+
bool IsInTerminal;
bool IsStdOutTerminal;
bool IsStdErrTerminal;
diff --git a/7zip/UI/Common/ArchiveExtractCallback.cpp b/7zip/UI/Common/ArchiveExtractCallback.cpp
index 1495446a..739a03b5 100755
--- a/7zip/UI/Common/ArchiveExtractCallback.cpp
+++ b/7zip/UI/Common/ArchiveExtractCallback.cpp
@@ -340,11 +340,6 @@ STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode)
return _extractCallback2->PrepareOperation(_filePath, askExtractMode, _isSplit ? &_position: 0);
}
-void CArchiveExtractCallback::AddErrorMessage(LPCTSTR message)
-{
- _messages.Add(message);
-}
-
STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
{
switch(operationResult)
diff --git a/7zip/UI/Common/ArchiveExtractCallback.h b/7zip/UI/Common/ArchiveExtractCallback.h
index 2a7423c9..c0de2cc4 100755
--- a/7zip/UI/Common/ArchiveExtractCallback.h
+++ b/7zip/UI/Common/ArchiveExtractCallback.h
@@ -54,8 +54,6 @@ private:
UString _diskFilePath;
- CSysStringVector _messages;
-
bool _extractMode;
struct CProcessedFileInfo
{
@@ -75,7 +73,6 @@ private:
bool _stdOutMode;
void CreateComplexDirectory(const UStringVector &dirPathParts);
- void AddErrorMessage(LPCTSTR message);
public:
void Init(
IInArchive *archiveHandler,
diff --git a/7zip/UI/Common/ArchiverInfo.cpp b/7zip/UI/Common/ArchiverInfo.cpp
index 6c7178b3..428aa405 100755
--- a/7zip/UI/Common/ArchiverInfo.cpp
+++ b/7zip/UI/Common/ArchiverInfo.cpp
@@ -63,7 +63,21 @@ static UString GetModuleFolderPrefix()
static wchar_t *kFormatFolderName = L"Formats";
static LPCTSTR kRegistryPath = TEXT("Software\\7-zip");
-static LPCTSTR kProgramPathValue = TEXT("Path");
+static LPCWSTR kProgramPathValue = L"Path";
+
+#ifdef _WIN32
+static bool ReadPathFromRegistry(HKEY baseKey, UString &path)
+{
+ NRegistry::CKey key;
+ if(key.Open(baseKey, kRegistryPath, KEY_READ) == ERROR_SUCCESS)
+ if (key.QueryValue(kProgramPathValue, path) == ERROR_SUCCESS)
+ {
+ NName::NormalizeDirPathPrefix(path);
+ return true;
+ }
+ return false;
+}
+#endif
static UString GetBaseFolderPrefixFromRegistry()
{
@@ -72,28 +86,12 @@ static UString GetBaseFolderPrefixFromRegistry()
if (NFind::FindFile(moduleFolderPrefix + kFormatFolderName, fileInfo))
if (fileInfo.IsDirectory())
return moduleFolderPrefix;
- CSysString pathSys;
+ UString path;
#ifdef _WIN32
- {
- NRegistry::CKey key;
- if(key.Open(HKEY_CURRENT_USER, kRegistryPath, KEY_READ) == ERROR_SUCCESS)
- if (key.QueryValue(kProgramPathValue, pathSys) == ERROR_SUCCESS)
- {
- UString path = GetUnicodeString(pathSys);
- NName::NormalizeDirPathPrefix(path);
- return path;
- }
- }
- {
- NRegistry::CKey key;
- if(key.Open(HKEY_LOCAL_MACHINE, kRegistryPath, KEY_READ) == ERROR_SUCCESS)
- if (key.QueryValue(kProgramPathValue, pathSys) == ERROR_SUCCESS)
- {
- UString path = GetUnicodeString(pathSys);
- NName::NormalizeDirPathPrefix(path);
- return path;
- }
- }
+ if(ReadPathFromRegistry(HKEY_CURRENT_USER, path))
+ return path;
+ if(ReadPathFromRegistry(HKEY_LOCAL_MACHINE, path))
+ return path;
#endif
return moduleFolderPrefix;
}
diff --git a/7zip/UI/Common/CompressCall.cpp b/7zip/UI/Common/CompressCall.cpp
index 208d3a74..419a1843 100755
--- a/7zip/UI/Common/CompressCall.cpp
+++ b/7zip/UI/Common/CompressCall.cpp
@@ -14,6 +14,11 @@
#include "Windows/FileDir.h"
#include "../../FileManager/ProgramLocation.h"
+#include "../../FileManager/RegistryUtils.h"
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif _UNICODE
using namespace NWindows;
@@ -23,38 +28,58 @@ static LPCWSTR kMapSwitch = L" -i#";
static LPCWSTR kArchiveNoNameSwitch = L" -an";
static LPCWSTR kArchiveMapSwitch = L" -ai#";
static LPCWSTR kStopSwitchParsing = L" --";
+static LPCWSTR kLargePagesDisable = L" -slp-";
-
-#ifndef _WIN64
-static bool IsItWindowsNT()
+static void AddLagePagesSwitch(UString &params)
{
- OSVERSIONINFO versionInfo;
- versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
- return false;
- return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+ if (!ReadLockMemoryEnable())
+ params += kLargePagesDisable;
}
-#endif
HRESULT MyCreateProcess(const UString &params,
- LPCTSTR curDir, bool waitFinish,
+ LPCWSTR curDir, bool waitFinish,
NWindows::NSynchronization::CEvent *event)
{
- STARTUPINFO startupInfo;
- startupInfo.cb = sizeof(startupInfo);
- startupInfo.lpReserved = 0;
- startupInfo.lpDesktop = 0;
- startupInfo.lpTitle = 0;
- startupInfo.dwFlags = 0;
- startupInfo.cbReserved2 = 0;
- startupInfo.lpReserved2 = 0;
-
+ const UString params2 = params;
PROCESS_INFORMATION processInformation;
- BOOL result = ::CreateProcess(NULL, (TCHAR *)(const TCHAR *)
- GetSystemString(params),
- NULL, NULL, FALSE, 0, NULL,
- curDir,
- &startupInfo, &processInformation);
+ BOOL result;
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ STARTUPINFOA startupInfo;
+ startupInfo.cb = sizeof(startupInfo);
+ startupInfo.lpReserved = 0;
+ startupInfo.lpDesktop = 0;
+ startupInfo.lpTitle = 0;
+ startupInfo.dwFlags = 0;
+ startupInfo.cbReserved2 = 0;
+ startupInfo.lpReserved2 = 0;
+
+ CSysString curDirA;
+ if (curDir != 0)
+ curDirA = GetSystemString(curDir);
+ result = ::CreateProcessA(NULL, (LPSTR)(LPCSTR)GetSystemString(params),
+ NULL, NULL, FALSE, 0, NULL,
+ ((curDir != 0) ? (LPCSTR)curDirA: 0),
+ &startupInfo, &processInformation);
+ }
+ else
+ #endif
+ {
+ STARTUPINFOW startupInfo;
+ startupInfo.cb = sizeof(startupInfo);
+ startupInfo.lpReserved = 0;
+ startupInfo.lpDesktop = 0;
+ startupInfo.lpTitle = 0;
+ startupInfo.dwFlags = 0;
+ startupInfo.cbReserved2 = 0;
+ startupInfo.lpReserved2 = 0;
+
+ result = ::CreateProcessW(NULL, (LPWSTR)(LPCWSTR)params,
+ NULL, NULL, FALSE, 0, NULL,
+ curDir,
+ &startupInfo, &processInformation);
+ }
if (result == 0)
return ::GetLastError();
else
@@ -84,13 +109,7 @@ static UString Get7zGuiPath()
UString folder;
if (GetProgramFolderPath(folder))
path += folder;
- path += L"7zG";
- #ifndef _WIN64
- if (IsItWindowsNT())
- path += L"n";
- #endif
- path += L".exe";
- // path += L"7z.exe";
+ path += L"7zG.exe";
return GetQuotedString(path);
}
@@ -260,6 +279,8 @@ HRESULT CompressFiles(
if (showDialog)
params += kShowDialogSwitch;
+ AddLagePagesSwitch(params);
+
params += kStopSwitchParsing;
params += L" ";
@@ -285,9 +306,8 @@ HRESULT CompressFiles(
*curData++ = L'\0';
}
// MessageBox(0, params, 0, 0);
- CSysString sysCurDir = GetSystemString(curDir);
RINOK(MyCreateProcess(params,
- (sysCurDir.IsEmpty()? 0: (LPCTSTR)sysCurDir),
+ (curDir.IsEmpty()? 0: (LPCWSTR)curDir),
waitFinish, &event));
}
catch(...)
@@ -312,6 +332,7 @@ static HRESULT ExtractGroupCommand(const UStringVector &archivePaths,
const UString &params)
{
UString params2 = params;
+ AddLagePagesSwitch(params2);
params2 += kArchiveNoNameSwitch;
params2 += kArchiveMapSwitch;
CFileMapping fileMapping;
diff --git a/7zip/UI/Common/CompressCall.h b/7zip/UI/Common/CompressCall.h
index 083748f2..815a50ea 100755
--- a/7zip/UI/Common/CompressCall.h
+++ b/7zip/UI/Common/CompressCall.h
@@ -7,8 +7,9 @@
#include "Windows/Synchronization.h"
HRESULT MyCreateProcess(const UString &params,
- LPCTSTR lpCurrentDirectory, bool waitFinish,
+ LPCWSTR lpCurrentDirectory, bool waitFinish,
NWindows::NSynchronization::CEvent *event);
+
HRESULT CompressFiles(
const UString &curDir,
const UString &archiveName,
diff --git a/7zip/UI/Common/OpenArchive.h b/7zip/UI/Common/OpenArchive.h
index 5de18a71..f96b1ebf 100755
--- a/7zip/UI/Common/OpenArchive.h
+++ b/7zip/UI/Common/OpenArchive.h
@@ -14,6 +14,7 @@
#include "Windows/DLL.h"
#endif
+HRESULT GetArchiveItemPath(IInArchive *archive, UInt32 index, UString &result);
HRESULT GetArchiveItemPath(IInArchive *archive, UInt32 index, const UString &defaultName, UString &result);
HRESULT GetArchiveItemFileTime(IInArchive *archive, UInt32 index,
const FILETIME &defaultFileTime, FILETIME &fileTime);
diff --git a/7zip/UI/Common/Update.cpp b/7zip/UI/Common/Update.cpp
index a241c9c4..f8185bfe 100755
--- a/7zip/UI/Common/Update.cpp
+++ b/7zip/UI/Common/Update.cpp
@@ -523,9 +523,9 @@ HRESULT EnumerateInArchiveItems(const NWildcard::CCensor &censor,
{
CArchiveItem ai;
- RINOK(GetArchiveItemPath(archive, i, defaultItemName, ai.Name));
+ RINOK(GetArchiveItemPath(archive, i, ai.Name));
RINOK(IsArchiveItemFolder(archive, i, ai.IsDirectory));
- ai.Censored = censor.CheckPath(ai.Name, !ai.IsDirectory);
+ ai.Censored = censor.CheckPath(ai.Name.IsEmpty() ? defaultItemName : ai.Name, !ai.IsDirectory);
RINOK(GetArchiveItemFileTime(archive, i,
archiveFileInfo.LastWriteTime, ai.LastWriteTime));
@@ -583,14 +583,14 @@ static HRESULT UpdateWithItemLists(
#ifdef _WIN32
class CCurrentDirRestorer
{
- CSysString m_CurrentDirectory;
+ UString m_CurrentDirectory;
public:
CCurrentDirRestorer()
{ NFile::NDirectory::MyGetCurrentDirectory(m_CurrentDirectory); }
~CCurrentDirRestorer()
{ RestoreDirectory();}
bool RestoreDirectory()
- { return BOOLToBool(::SetCurrentDirectory(m_CurrentDirectory)); }
+ { return BOOLToBool(NFile::NDirectory::MySetCurrentDirectory(m_CurrentDirectory)); }
};
#endif
diff --git a/7zip/UI/Common/ZipRegistry.cpp b/7zip/UI/Common/ZipRegistry.cpp
index 80336da3..5a324dae 100755
--- a/7zip/UI/Common/ZipRegistry.cpp
+++ b/7zip/UI/Common/ZipRegistry.cpp
@@ -47,7 +47,7 @@ void SaveExtractionInfo(const NExtract::CInfo &info)
pathHistoryKey.Create(extractionKey, kExtractionPathHistoryKeyName);
for(int i = 0; i < info.Paths.Size(); i++)
{
- TCHAR numberString[16];
+ wchar_t numberString[16];
ConvertUInt64ToString(i, numberString);
pathHistoryKey.SetValue(numberString, info.Paths[i]);
}
@@ -76,9 +76,9 @@ void ReadExtractionInfo(NExtract::CInfo &info)
{
while(true)
{
- TCHAR numberString[16];
+ wchar_t numberString[16];
ConvertUInt64ToString(info.Paths.Size(), numberString);
- CSysString path;
+ UString path;
if (pathHistoryKey.QueryValue(numberString, path) != ERROR_SUCCESS)
break;
info.Paths.Add(path);
@@ -132,9 +132,9 @@ static const TCHAR *kCompressionOptionsKeyName = TEXT("Options");
static const TCHAR *kSolid = TEXT("Solid");
static const TCHAR *kMultiThread = TEXT("Multithread");
-static const TCHAR *kCompressionOptions = TEXT("Options");
+static const WCHAR *kCompressionOptions = L"Options";
static const TCHAR *kCompressionLevel = TEXT("Level");
-static const TCHAR *kCompressionMethod = TEXT("Method");
+static const WCHAR *kCompressionMethod = L"Method";
static const TCHAR *kCompressionDictionary = TEXT("Dictionary");
static const TCHAR *kCompressionOrder = TEXT("Order");
@@ -150,7 +150,7 @@ void SaveCompressionInfo(const NCompression::CInfo &info)
historyArchivesKey.Create(compressionKey, kCompressionHistoryArchivesKeyName);
for(int i = 0; i < info.HistoryArchives.Size(); i++)
{
- TCHAR numberString[16];
+ wchar_t numberString[16];
ConvertUInt64ToString(i, numberString);
historyArchivesKey.SetValue(numberString, info.HistoryArchives[i]);
}
@@ -234,9 +234,9 @@ void ReadCompressionInfo(NCompression::CInfo &info)
{
while(true)
{
- TCHAR numberString[16];
+ wchar_t numberString[16];
ConvertUInt64ToString(info.HistoryArchives.Size(), numberString);
- CSysString path;
+ UString path;
if (historyArchivesKey.QueryValue(numberString, path) != ERROR_SUCCESS)
break;
info.HistoryArchives.Add(path);
@@ -308,7 +308,7 @@ void ReadCompressionInfo(NCompression::CInfo &info)
static const TCHAR *kOptionsInfoKeyName = TEXT("Options");
static const TCHAR *kWorkDirTypeValueName = TEXT("WorkDirType");
-static const TCHAR *kWorkDirPathValueName = TEXT("WorkDirPath");
+static const WCHAR *kWorkDirPathValueName = L"WorkDirPath";
static const TCHAR *kTempRemovableOnlyValueName = TEXT("TempRemovableOnly");
static const TCHAR *kCascadedMenuValueName = TEXT("CascadedMenu");
static const TCHAR *kContextMenuValueName = TEXT("ContextMenu");
@@ -319,7 +319,7 @@ void SaveWorkDirInfo(const NWorkDir::CInfo &info)
CKey optionsKey;
optionsKey.Create(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName));
optionsKey.SetValue(kWorkDirTypeValueName, UInt32(info.Mode));
- optionsKey.SetValue(kWorkDirPathValueName, GetSystemString(info.Path));
+ optionsKey.SetValue(kWorkDirPathValueName, info.Path);
optionsKey.SetValue(kTempRemovableOnlyValueName, info.ForRemovableOnly);
}
@@ -342,7 +342,7 @@ void ReadWorkDirInfo(NWorkDir::CInfo &info)
case NWorkDir::NMode::kSpecified:
info.Mode = NWorkDir::NMode::EEnum(dirType);
}
- CSysString sysWorkDir;
+ UString sysWorkDir;
if (optionsKey.QueryValue(kWorkDirPathValueName, sysWorkDir) != ERROR_SUCCESS)
{
info.Path.Empty();
diff --git a/7zip/UI/Common/ZipRegistry.h b/7zip/UI/Common/ZipRegistry.h
index 74f87339..cda96f7b 100755
--- a/7zip/UI/Common/ZipRegistry.h
+++ b/7zip/UI/Common/ZipRegistry.h
@@ -13,7 +13,7 @@ namespace NExtract
{
NPathMode::EEnum PathMode;
NOverwriteMode::EEnum OverwriteMode;
- CSysStringVector Paths;
+ UStringVector Paths;
bool ShowPassword;
};
}
@@ -23,9 +23,9 @@ namespace NCompression {
struct CFormatOptions
{
CSysString FormatID;
- CSysString Options;
+ UString Options;
UInt32 Level;
- CSysString Method;
+ UString Method;
UInt32 Dictionary;
UInt32 Order;
void Init()
@@ -39,7 +39,7 @@ namespace NCompression {
struct CInfo
{
- CSysStringVector HistoryArchives;
+ UStringVector HistoryArchives;
// bool LevelIsDefined;
UInt32 Level;
UString ArchiveType;
diff --git a/7zip/UI/Console/Console.dsp b/7zip/UI/Console/Console.dsp
index 29f10b2f..2f4db36e 100755
--- a/7zip/UI/Console/Console.dsp
+++ b/7zip/UI/Console/Console.dsp
@@ -276,6 +276,14 @@ SOURCE=..\..\..\Windows\FileName.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Windows\MemoryLock.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\MemoryLock.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Windows\PropVariant.cpp
# End Source File
# Begin Source File
diff --git a/7zip/UI/Console/Main.cpp b/7zip/UI/Console/Main.cpp
index a72bfca7..8be5483a 100755
--- a/7zip/UI/Console/Main.cpp
+++ b/7zip/UI/Console/Main.cpp
@@ -18,6 +18,9 @@
#include "Windows/FileName.h"
#include "Windows/Defs.h"
#include "Windows/Error.h"
+#ifdef _WIN32
+#include "Windows/MemoryLock.h"
+#endif
#include "../../IPassword.h"
#include "../../ICoder.h"
@@ -69,7 +72,7 @@ static const char *kHelpString =
"<Commands>\n"
" a: Add files to archive\n"
" d: Delete files from archive\n"
- " e: Extract files from archive\n"
+ " e: Extract files from archive (without using directory names)\n"
" l: List contents of archive\n"
// " l[a|t][f]: List contents of archive\n"
// " a - with Additional fields\n"
@@ -77,7 +80,7 @@ static const char *kHelpString =
// " f - with Full pathnames\n"
" t: Test integrity of archive\n"
" u: Update files to archive\n"
- " x: eXtract files with full pathname\n"
+ " x: eXtract files with full paths\n"
"<Switches>\n"
" -ai[r[-|0]]{@listfile|!wildcard}: Include archives\n"
" -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives\n"
@@ -88,7 +91,7 @@ static const char *kHelpString =
" -p{Password}: set Password\n"
" -r[-|0]: Recurse subdirectories\n"
" -sfx[{name}]: Create SFX archive\n"
- " -si: read data from stdin\n"
+ " -si[{name}]: read data from stdin\n"
" -so: write data to stdout\n"
" -t{Type}: Set type of archive\n"
" -v{Size}[b|k|m|g]: Create volumes\n"
@@ -178,6 +181,11 @@ int Main2(
return 0;
}
+ #ifdef _WIN32
+ if (options.LargePages)
+ NSecurity::EnableLockMemoryPrivilege();
+ #endif
+
CStdOutStream &stdStream = options.StdOutMode ? g_StdErr : g_StdOut;
g_StdStream = &stdStream;
diff --git a/7zip/UI/Console/MainAr.cpp b/7zip/UI/Console/MainAr.cpp
index 3af8cb8b..a30298c1 100755
--- a/7zip/UI/Console/MainAr.cpp
+++ b/7zip/UI/Console/MainAr.cpp
@@ -10,6 +10,9 @@
#include "Common/NewHandler.h"
#include "Common/Exception.h"
#include "Common/StringConvert.h"
+#ifdef _WIN32
+#include "Common/Alloc.h"
+#endif
#include "../Common/ExitCode.h"
#include "ConsoleClose.h"
@@ -18,6 +21,10 @@ using namespace NWindows;
CStdOutStream *g_StdStream = 0;
+#ifndef _UNICODE
+bool g_IsNT = false;
+#endif
+
extern int Main2(
#ifndef _WIN32
int numArguments, const char *arguments[]
@@ -31,7 +38,6 @@ static const char *kMemoryExceptionMessage = "\n\nERROR: Can't allocate required
static const char *kUnknownExceptionMessage = "\n\nUnknown Error\n";
static const char *kInternalExceptionMessage = "\n\nInternal Error #";
-#ifdef UNICODE
static inline bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
@@ -40,7 +46,6 @@ static inline bool IsItWindowsNT()
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
-#endif
int
#ifdef _MSC_VER
@@ -54,13 +59,20 @@ int numArguments, const char *arguments[]
)
{
g_StdStream = &g_StdOut;
- #ifdef UNICODE
+ #ifdef _UNICODE
if (!IsItWindowsNT())
{
(*g_StdStream) << "This program requires Windows NT/2000/XP/2003";
return NExitCode::kFatalError;
}
+ #else
+ g_IsNT = IsItWindowsNT();
#endif
+
+ #ifdef _WIN32
+ SetLargePageSize();
+ #endif
+
// setlocale(LC_COLLATE, ".OCP");
NConsoleClose::CCtrlHandlerSetter ctrlHandlerSetter;
try
diff --git a/7zip/UI/Console/UpdateCallbackConsole.cpp b/7zip/UI/Console/UpdateCallbackConsole.cpp
index 30a5285f..74b685d7 100755
--- a/7zip/UI/Console/UpdateCallbackConsole.cpp
+++ b/7zip/UI/Console/UpdateCallbackConsole.cpp
@@ -11,6 +11,8 @@
using namespace NWindows;
+static const wchar_t *kEmptyFileAlias = L"[Content]";
+
static const char *kCreatingArchiveMessage = "Creating archive ";
static const char *kUpdatingArchiveMessage = "Updating archive ";
static const char *kScanningMessage = "Scanning";
@@ -129,6 +131,8 @@ HRESULT CUpdateCallbackConsole::GetStream(const wchar_t *name, bool isAnti)
m_PercentPrinter.PrintString("Anti item ");
else
m_PercentPrinter.PrintString("Compressing ");
+ if (wcslen(name) == 0)
+ name = kEmptyFileAlias;
m_PercentPrinter.PrintString(name);
if (EnablePercents)
{
diff --git a/7zip/UI/Console/makefile b/7zip/UI/Console/makefile
index b9a5ef0b..a79106d5 100755
--- a/7zip/UI/Console/makefile
+++ b/7zip/UI/Console/makefile
@@ -35,6 +35,7 @@ WIN_OBJS = \
$O\FileFind.obj \
$O\FileIO.obj \
$O\FileName.obj \
+ $O\MemoryLock.obj \
$O\PropVariant.obj \
$O\PropVariantConversions.obj \
$O\Registry.obj \
diff --git a/7zip/UI/Explorer/ContextMenu.cpp b/7zip/UI/Explorer/ContextMenu.cpp
index 94cf1bd4..ca3fd030 100755
--- a/7zip/UI/Explorer/ContextMenu.cpp
+++ b/7zip/UI/Explorer/ContextMenu.cpp
@@ -52,8 +52,7 @@ extern LONG g_DllRefCount;
CZipContextMenu::CZipContextMenu() { InterlockedIncrement(&g_DllRefCount); }
CZipContextMenu::~CZipContextMenu() { InterlockedDecrement(&g_DllRefCount); }
-HRESULT CZipContextMenu::GetFileNames(LPDATAOBJECT dataObject,
- CSysStringVector &fileNames)
+HRESULT CZipContextMenu::GetFileNames(LPDATAOBJECT dataObject, UStringVector &fileNames)
{
fileNames.Clear();
if(dataObject == NULL)
@@ -81,15 +80,15 @@ STDMETHODIMP CZipContextMenu::Initialize(LPCITEMIDLIST pidlFolder,
_dropPath.Empty();
if (pidlFolder != 0)
{
- CSysString path;
- if (NShell::GetPathFromIDList(pidlFolder, path))
+ if (NShell::GetPathFromIDList(pidlFolder, _dropPath))
{
- _dropPath = GetUnicodeString(path);
// OutputDebugString(path);
// OutputDebugString(TEXT("\r\n"));
NFile::NName::NormalizeDirPathPrefix(_dropPath);
_dropMode = !_dropPath.IsEmpty();
}
+ else
+ _dropPath.Empty();
}
/*
@@ -97,13 +96,7 @@ STDMETHODIMP CZipContextMenu::Initialize(LPCITEMIDLIST pidlFolder,
if (pidlFolder == 0)
*/
// pidlFolder is NULL :(
- CSysStringVector sysFileNames;
- RINOK(GetFileNames(dataObject, sysFileNames));
- _fileNames.Clear();
- _fileNames.Reserve(sysFileNames.Size());
- for (int i = 0; i < sysFileNames.Size(); i++)
- _fileNames.Add(GetUnicodeString(sysFileNames[i]));
- return S_OK;
+ return GetFileNames(dataObject, _fileNames);
}
STDMETHODIMP CZipContextMenu::InitContextMenu(const wchar_t *folder,
@@ -237,8 +230,8 @@ void CZipContextMenu::FillCommand(ECommandInternalID id,
const CContextMenuCommand &command = g_Commands[i];
commandMapItem.CommandInternalID = command.CommandInternalID;
commandMapItem.Verb = command.Verb;
- commandMapItem.HelpString = LangLoadStringW(command.ResourceHelpID, command.LangID + 1);
- mainString = LangLoadStringW(command.ResourceID, command.LangID);
+ commandMapItem.HelpString = LangString(command.ResourceHelpID, command.LangID + 1);
+ mainString = LangString(command.ResourceID, command.LangID);
}
void CZipContextMenu::FillCommand2(ECommandInternalID id,
@@ -250,31 +243,19 @@ void CZipContextMenu::FillCommand2(ECommandInternalID id,
const CContextMenuCommand &command = g_Commands[i];
commandMapItem.CommandInternalID = command.CommandInternalID;
commandMapItem.Verb = command.Verb;
- commandMapItem.HelpString = LangLoadStringW(command.ResourceHelpID, command.LangID + 1);
- mainString = LangLoadStringW(command.ResourceID, command.LangID);
+ commandMapItem.HelpString = LangString(command.ResourceHelpID, command.LangID + 1);
+ mainString = LangString(command.ResourceID, command.LangID);
}
-/*
-CSysString GetExtractPath(const CSysString &archiveName)
-{
- CSysString s;
- int dotPos = s.ReverseFind('.');
- if (dotPos < 0)
- return archiveName;
- return archiveName.Left(dotPos);
-}
-*/
-
-static BOOL MyInsertMenu(HMENU hMenu, int pos, UINT id, LPCTSTR s)
+static bool MyInsertMenu(CMenu &menu, int pos, UINT id, const UString &s)
{
- MENUITEMINFO menuItem;
- menuItem.cbSize = sizeof(menuItem);
+ CMenuItem menuItem;
menuItem.fType = MFT_STRING;
menuItem.fMask = MIIM_TYPE | MIIM_ID;
menuItem.wID = id;
- menuItem.dwTypeData = (LPTSTR)(LPCTSTR)s;
- return ::InsertMenuItem(hMenu, pos++, TRUE, &menuItem);
+ menuItem.StringValue = s;
+ return menu.InsertItem(pos, true, menuItem);
}
static UString GetSubFolderNameForExtract(const UString &archiveName)
@@ -326,7 +307,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
menuDestroyer.Attach(popupMenu);
commandMapItem.CommandInternalID = kCommandNULL;
commandMapItem.Verb = kMainVerb;
- commandMapItem.HelpString = LangLoadStringW(IDS_CONTEXT_CAPTION_HELP, 0x02000102);
+ commandMapItem.HelpString = LangString(IDS_CONTEXT_CAPTION_HELP, 0x02000102);
_commandMap.Add(commandMapItem);
menuItem.wID = currentCommandID++;
@@ -359,7 +340,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
{
CCommandMapItem commandMapItem;
FillCommand(kOpen, mainString, commandMapItem);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(mainString));
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem);
}
}
@@ -394,7 +375,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
else
commandMapItem.Folder = folderPrefix;
commandMapItem.Folder += GetSubFolderNameForExtract(fileInfo.Name) + UString(L'\\');
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(mainString));
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem);
}
@@ -403,7 +384,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
{
CCommandMapItem commandMapItem;
FillCommand(kExtractHere, mainString, commandMapItem);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(mainString));
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
if (_dropMode)
commandMapItem.Folder = _dropPath;
else
@@ -428,7 +409,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.Folder = folderPrefix;
commandMapItem.Folder += folder;
s = MyFormatNew(s, GetReducedString(UString(L"\"") + folder + UString(L"\\\"")));
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(s));
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem);
}
// Test
@@ -436,7 +417,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
{
CCommandMapItem commandMapItem;
FillCommand(kTest, mainString, commandMapItem);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(mainString));
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem);
}
}
@@ -455,7 +436,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.Folder = archivePathPrefix;
commandMapItem.Archive = archiveName;
FillCommand(kCompress, mainString, commandMapItem);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(mainString));
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem);
}
@@ -473,7 +454,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.Archive = archiveName7z;
UString t = UString(L"\"") + GetReducedString(archiveName7z) + UString(L"\"");
s = MyFormatNew(s, t);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(s));
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem);
}
@@ -483,7 +464,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
CCommandMapItem commandMapItem;
commandMapItem.Archive = archiveName;
FillCommand(kCompressEmail, mainString, commandMapItem);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(mainString));
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem);
}
@@ -496,29 +477,28 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.Archive = archiveName7z;
UString t = UString(L"\"") + GetReducedString(archiveName7z) + UString(L"\"");
s = MyFormatNew(s, t);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(s));
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem);
}
}
- CSysString popupMenuCaption = LangLoadString(IDS_CONTEXT_POPUP_CAPTION, 0x02000101);
-
// don't use InsertMenu: See MSDN:
// PRB: Duplicate Menu Items In the File Menu For a Shell Context Menu Extension
// ID: Q214477
if (cascadedMenu)
{
- MENUITEMINFO menuItem;
- menuItem.cbSize = sizeof(menuItem);
+ CMenuItem menuItem;
menuItem.fType = MFT_STRING;
menuItem.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_ID;
menuItem.wID = currentCommandID++;
menuItem.hSubMenu = popupMenu.Detach();
menuDestroyer.Disable();
- menuItem.dwTypeData = (LPTSTR)(LPCTSTR)popupMenuCaption;
- ::InsertMenuItem(hMenu, indexMenu++, TRUE, &menuItem);
+ menuItem.StringValue = LangString(IDS_CONTEXT_POPUP_CAPTION, 0x02000101);
+ CMenu menu;
+ menu.Attach(hMenu);
+ menu.InsertItem(indexMenu++, true, menuItem);
}
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, currentCommandID - commandIDFirst);
@@ -535,64 +515,6 @@ UINT CZipContextMenu::FindVerb(const UString &verb)
extern const char *kShellFolderClassIDString;
-/*
-class CWindowDisable
-{
- bool m_WasEnabled;
- CWindow m_Window;
-public:
- CWindowDisable(HWND aWindow): m_Window(aWindow)
- {
- m_WasEnabled = m_Window.IsEnabled();
- if (m_WasEnabled)
- m_Window.Enable(false);
- }
- ~CWindowDisable()
- {
- if (m_WasEnabled)
- m_Window.Enable(true);
- }
-};
-*/
-
-/*
-struct CThreadCompressMain
-{
- CSysStringVector FileNames;
-
- DWORD Process()
- {
- NCOM::CComInitializer comInitializer;
- try
- {
- HRESULT result = CompressArchive(FileNames);
- }
- catch(...)
- {
- MyMessageBox(IDS_ERROR, 0x02000605);
- }
- return 0;
- }
-
- static DWORD WINAPI MyThreadFunction(void *param)
- {
- CThreadCompressMain *compressor = (CThreadCompressMain *)param;
- return ((CThreadCompressMain *)param)->Process();
- delete compressor;
- }
-};
-*/
-
-#ifndef _WIN64
-static bool IsItWindowsNT()
-{
- OSVERSIONINFO versionInfo;
- versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
- return false;
- return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
-}
-#endif
static UString GetProgramCommand()
{
@@ -600,12 +522,7 @@ static UString GetProgramCommand()
UString folder;
if (GetProgramFolderPath(folder))
path += folder;
- path += L"7zFM";
- #ifndef _WIN64
- if (IsItWindowsNT())
- path += L"n";
- #endif
- path += L".exe\"";
+ path += L"7zFM.exe\"";
return path;
}
@@ -637,7 +554,7 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
if(HIWORD(commandInfo->lpVerb) == 0)
commandOffset = LOWORD(commandInfo->lpVerb);
else
- commandOffset = FindVerb(GetSystemString(commandInfo->lpVerb));
+ commandOffset = FindVerb(commandInfo->lpVerb);
}
// return E_FAIL;
}
@@ -646,7 +563,7 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
if(HIWORD(commandInfo->lpVerb) == 0)
commandOffset = LOWORD(commandInfo->lpVerb);
else
- commandOffset = FindVerb(GetSystemString(commandInfo->lpVerb));
+ commandOffset = FindVerb(commandInfo->lpVerb);
}
#else
@@ -668,8 +585,6 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
ECommandInternalID commandInternalID = commandMapItem.CommandInternalID;
HWND aHWND = commandInfo->hwnd;
- // CWindowDisable aWindowDisable(aHWND);
-
try
{
switch(commandInternalID)
diff --git a/7zip/UI/Explorer/ContextMenu.h b/7zip/UI/Explorer/ContextMenu.h
index cd2c1b3d..a5a96c07 100755
--- a/7zip/UI/Explorer/ContextMenu.h
+++ b/7zip/UI/Explorer/ContextMenu.h
@@ -70,7 +70,7 @@ private:
bool _dropMode;
UString _dropPath;
CObjectVector<CCommandMapItem> _commandMap;
- HRESULT GetFileNames(LPDATAOBJECT dataObject, CSysStringVector &fileNames);
+ HRESULT GetFileNames(LPDATAOBJECT dataObject, UStringVector &fileNames);
UINT FindVerb(const UString &verb);
void FillCommand(ECommandInternalID id, UString &mainString,
diff --git a/7zip/UI/Explorer/DllExports.cpp b/7zip/UI/Explorer/DllExports.cpp
index abb4680a..8c5f21c1 100755
--- a/7zip/UI/Explorer/DllExports.cpp
+++ b/7zip/UI/Explorer/DllExports.cpp
@@ -3,7 +3,7 @@
// Notes:
// Win2000:
// If I register at HKCR\Folder\ShellEx then DLL is locked.
-// otherwise it unloads after exlorer closing.
+// otherwise it unloads after explorer closing.
// but if I call menu for desktop items it's locked all the time
#include "StdAfx.h"
@@ -16,6 +16,9 @@
#include <OleCtl.h>
#include "Common/ComTry.h"
+#include "Common/StringConvert.h"
+#include "Windows/DLL.h"
+#include "Windows/Registry.h"
#include "../../IPassword.h"
#include "../../FileManager/LangUtils.h"
@@ -24,10 +27,16 @@
#include "ContextMenu.h"
#include "OptionsDialog.h"
+using namespace NWindows;
+
HINSTANCE g_hInstance;
+#ifndef _UNICODE
+bool g_IsNT = false;
+#endif
+
LONG g_DllRefCount = 0; // Reference count of this DLL.
-static LPCTSTR kShellExtName = TEXT("7-Zip Shell Extension");
+static LPCWSTR kShellExtName = L"7-Zip Shell Extension";
static LPCTSTR kClsidMask = TEXT("CLSID\\%s");
static LPCTSTR kClsidInprocMask = TEXT("CLSID\\%s\\InprocServer32");
static LPCTSTR kApprovedKeyPath = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved");
@@ -95,9 +104,11 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
{
g_hInstance = hInstance;
// ODS("In DLLMain, DLL_PROCESS_ATTACH\r\n");
- #ifdef UNICODE
+ #ifdef _UNICODE
if (!IsItWindowsNT())
return FALSE;
+ #else
+ g_IsNT = IsItWindowsNT();
#endif
}
else if (dwReason == DLL_PROCESS_DETACH)
@@ -160,53 +171,46 @@ typedef struct
{
HKEY hRootKey;
LPCTSTR SubKey;
- LPCTSTR ValueName;
- LPCTSTR Data;
+ LPCWSTR ValueName;
+ LPCWSTR Data;
} CRegItem;
-static BOOL RegisterServer(CLSID clsid, LPCTSTR title)
+static BOOL RegisterServer(CLSID clsid, LPCWSTR title)
{
TCHAR clsidString[MAX_PATH];
if (!GetStringFromIID(clsid, clsidString, MAX_PATH))
return FALSE;
- TCHAR modulePath[MAX_PATH + 1];
- if (GetModuleFileName(g_hInstance, modulePath, MAX_PATH) == 0)
+ UString modulePath;
+ if (!NDLL::MyGetModuleFileName(g_hInstance, modulePath))
return FALSE;
CRegItem clsidEntries[] =
{
- HKEY_CLASSES_ROOT, kClsidMask, NULL, title,
- HKEY_CLASSES_ROOT, kClsidInprocMask, NULL, modulePath,
- HKEY_CLASSES_ROOT, kClsidInprocMask, TEXT("ThreadingModel"), TEXT("Apartment"),
- NULL, NULL, NULL, NULL
+ HKEY_CLASSES_ROOT, kClsidMask, NULL, title,
+ HKEY_CLASSES_ROOT, kClsidInprocMask, NULL, modulePath,
+ HKEY_CLASSES_ROOT, kClsidInprocMask, L"ThreadingModel", L"Apartment",
+ NULL, NULL, NULL, NULL
};
- HKEY hKey;
- DWORD dwDisp;
//register the CLSID entries
for(int i = 0; clsidEntries[i].hRootKey; i++)
{
TCHAR subKey[MAX_PATH];
wsprintf(subKey, clsidEntries[i].SubKey, clsidString);
- if (RegCreateKeyEx(clsidEntries[i].hRootKey, subKey, 0, NULL,
- REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp) != NOERROR)
+ NRegistry::CKey key;
+ if (key.Create(clsidEntries[i].hRootKey, subKey, NULL,
+ REG_OPTION_NON_VOLATILE, KEY_WRITE) != NOERROR)
return FALSE;
- const TCHAR *data = clsidEntries[i].Data;
- RegSetValueEx(hKey, clsidEntries[i].ValueName, 0, REG_SZ,
- (LPBYTE)data, (lstrlen(data) + 1) * sizeof(TCHAR));
- RegCloseKey(hKey);
+ key.SetValue(clsidEntries[i].ValueName, clsidEntries[i].Data);
}
if(IsItWindowsNT())
{
- if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, kApprovedKeyPath, 0, NULL,
- REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp) == NOERROR)
- {
- RegSetValueEx(hKey, clsidString, 0, REG_SZ,
- (LPBYTE)title,(lstrlen(title) + 1) * sizeof(TCHAR));
- RegCloseKey(hKey);
- }
+ NRegistry::CKey key;
+ if (key.Create(HKEY_LOCAL_MACHINE, kApprovedKeyPath, NULL,
+ REG_OPTION_NON_VOLATILE, KEY_WRITE) == NOERROR)
+ key.SetValue(GetUnicodeString(clsidString), title);
}
return TRUE;
}
diff --git a/7zip/UI/Explorer/Explorer.dsp b/7zip/UI/Explorer/Explorer.dsp
index 34555372..c8ffe168 100755
--- a/7zip/UI/Explorer/Explorer.dsp
+++ b/7zip/UI/Explorer/Explorer.dsp
@@ -138,7 +138,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib htmlhelp.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7-Zip.dll" /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib htmlhelp.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7-Zipn.dll" /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib htmlhelp.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7-Zip.dll" /pdbtype:sept
!ENDIF
@@ -669,6 +669,14 @@ SOURCE=..\..\..\Windows\FileName.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Windows\Memory.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Menu.cpp
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Windows\Menu.h
# End Source File
# Begin Source File
diff --git a/7zip/UI/Explorer/FoldersPage/FoldersPage.cpp b/7zip/UI/Explorer/FoldersPage/FoldersPage.cpp
index db6bebdd..776813d8 100755
--- a/7zip/UI/Explorer/FoldersPage/FoldersPage.cpp
+++ b/7zip/UI/Explorer/FoldersPage/FoldersPage.cpp
@@ -38,7 +38,6 @@ static const int kNumWorkModeButtons = sizeof(kWorkModeButtons) / sizeof(kWorkMo
bool CFoldersPage::OnInit()
{
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
- // CZipRegistryManager aRegistryManager;
ReadWorkDirInfo(m_WorkDirInfo);
CheckButton(IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, m_WorkDirInfo.ForRemovableOnly);
@@ -66,26 +65,26 @@ int CFoldersPage::GetWorkMode() const
void CFoldersPage::MyEnableControls()
{
- bool anEnablePath = (GetWorkMode() == NWorkDir::NMode::kSpecified);
- m_WorkPath.Enable(anEnablePath);
- m_ButtonSetWorkPath.Enable(anEnablePath);
+ bool enablePath = (GetWorkMode() == NWorkDir::NMode::kSpecified);
+ m_WorkPath.Enable(enablePath);
+ m_ButtonSetWorkPath.Enable(enablePath);
}
-void CFoldersPage::GetWorkDir(NWorkDir::CInfo &aWorkDirInfo)
+void CFoldersPage::GetWorkDir(NWorkDir::CInfo &workDirInfo)
{
- m_WorkPath.GetText(aWorkDirInfo.Path);
- aWorkDirInfo.ForRemovableOnly = IsButtonCheckedBool(IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE);
- aWorkDirInfo.Mode = NWorkDir::NMode::EEnum(GetWorkMode());
+ m_WorkPath.GetText(workDirInfo.Path);
+ workDirInfo.ForRemovableOnly = IsButtonCheckedBool(IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE);
+ workDirInfo.Mode = NWorkDir::NMode::EEnum(GetWorkMode());
}
/*
bool CFoldersPage::WasChanged()
{
- NWorkDir::CInfo aWorkDirInfo;
- GetWorkDir(aWorkDirInfo);
- return (aWorkDirInfo.Mode != m_WorkDirInfo.Mode ||
- aWorkDirInfo.ForRemovableOnly != m_WorkDirInfo.ForRemovableOnly ||
- aWorkDirInfo.Path.Compare(m_WorkDirInfo.Path) != 0);
+ NWorkDir::CInfo workDirInfo;
+ GetWorkDir(workDirInfo);
+ return (workDirInfo.Mode != m_WorkDirInfo.Mode ||
+ workDirInfo.ForRemovableOnly != m_WorkDirInfo.ForRemovableOnly ||
+ workDirInfo.Path.Compare(m_WorkDirInfo.Path) != 0);
}
*/
@@ -100,16 +99,16 @@ void CFoldersPage::ModifiedEvent()
*/
}
-bool CFoldersPage::OnButtonClicked(int aButtonID, HWND aButtonHWND)
+bool CFoldersPage::OnButtonClicked(int buttonID, HWND buttonHWND)
{
for (int i = 0; i < kNumWorkModeButtons; i++)
- if (aButtonID == kWorkModeButtons[i])
+ if (buttonID == kWorkModeButtons[i])
{
MyEnableControls();
ModifiedEvent();
return true;
}
- switch(aButtonID)
+ switch(buttonID)
{
case IDC_FOLDERS_WORK_BUTTON_PATH:
OnFoldersWorkButtonPath();
@@ -117,32 +116,29 @@ bool CFoldersPage::OnButtonClicked(int aButtonID, HWND aButtonHWND)
case IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE:
break;
default:
- return CPropertyPage::OnButtonClicked(aButtonID, aButtonHWND);
+ return CPropertyPage::OnButtonClicked(buttonID, buttonHWND);
}
ModifiedEvent();
return true;
}
-bool CFoldersPage::OnCommand(int aCode, int anItemID, LPARAM lParam)
+bool CFoldersPage::OnCommand(int code, int itemID, LPARAM lParam)
{
- if (aCode == EN_CHANGE && anItemID == IDC_FOLDERS_WORK_EDIT_PATH)
+ if (code == EN_CHANGE && itemID == IDC_FOLDERS_WORK_EDIT_PATH)
{
ModifiedEvent();
return true;
}
- return CPropertyPage::OnCommand(aCode, anItemID, lParam);
+ return CPropertyPage::OnCommand(code, itemID, lParam);
}
void CFoldersPage::OnFoldersWorkButtonPath()
{
- CSysString currentPath;
+ UString currentPath;
m_WorkPath.GetText(currentPath);
-
- UString title = LangLoadStringW(IDS_FOLDERS_SET_WORK_PATH_TITLE, 0x01000281);
-
- CSysString resultPath;
- if (NShell::BrowseForFolder(HWND(*this), GetSystemString(title),
- currentPath, resultPath))
+ UString title = LangString(IDS_FOLDERS_SET_WORK_PATH_TITLE, 0x01000281);
+ UString resultPath;
+ if (NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
m_WorkPath.SetText(resultPath);
}
diff --git a/7zip/UI/Explorer/FoldersPage/FoldersPage.h b/7zip/UI/Explorer/FoldersPage/FoldersPage.h
index e3f3b124..97950fc6 100755
--- a/7zip/UI/Explorer/FoldersPage/FoldersPage.h
+++ b/7zip/UI/Explorer/FoldersPage/FoldersPage.h
@@ -15,17 +15,16 @@ class CFoldersPage : public NWindows::NControl::CPropertyPage
void ModifiedEvent();
NWindows::NControl::CDialogChildControl m_WorkPath;
NWindows::NControl::CDialogChildControl m_ButtonSetWorkPath;
- // int m_RadioWorkMode;
void OnFoldersWorkButtonPath();
int GetWorkMode() const;
- void GetWorkDir(NWorkDir::CInfo &aWorkDirInfo);
+ void GetWorkDir(NWorkDir::CInfo &workDirInfo);
// bool WasChanged();
public:
virtual bool OnInit();
- virtual bool OnCommand(int aCode, int anItemID, LPARAM lParam);
+ virtual bool OnCommand(int code, int itemID, LPARAM lParam);
virtual void OnNotifyHelp();
virtual LONG OnApply();
- virtual bool OnButtonClicked(int aButtonID, HWND aButtonHWND);
+ virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
};
#endif
diff --git a/7zip/UI/Explorer/MyMessages.cpp b/7zip/UI/Explorer/MyMessages.cpp
index d2cae72c..3ec59f99 100755
--- a/7zip/UI/Explorer/MyMessages.cpp
+++ b/7zip/UI/Explorer/MyMessages.cpp
@@ -27,7 +27,7 @@ void MyMessageBox(UINT32 id
)
{
#ifdef LANG
- MyMessageBox(LangLoadStringW(id, langID));
+ MyMessageBox(LangString(id, langID));
#else
MyMessageBox(MyLoadStringW(id));
#endif
diff --git a/7zip/UI/Explorer/OptionsDialog.cpp b/7zip/UI/Explorer/OptionsDialog.cpp
index 742adae7..1a2c91d1 100755
--- a/7zip/UI/Explorer/OptionsDialog.cpp
+++ b/7zip/UI/Explorer/OptionsDialog.cpp
@@ -15,63 +15,27 @@
#include "SystemPage/SystemPage.h"
#include "SystemPage/resource.h"
-extern HINSTANCE g_hInstance;
+using namespace NWindows;
-static void FillInPropertyPage(PROPSHEETPAGE* page,
- HINSTANCE instance,
- int dialogID,
- NWindows::NControl::CPropertyPage *propertyPage,
- CSysString &title)
+int OptionsDialog(HWND hwndOwner)
{
- page->dwSize = sizeof(PROPSHEETPAGE);
- page->dwFlags = PSP_HASHELP;
- page->hInstance = instance;
- page->pszTemplate = MAKEINTRESOURCE(dialogID);
- page->pszIcon = NULL;
- page->pfnDlgProc = NWindows::NControl::ProperyPageProcedure;
-
- if (title.IsEmpty())
- page->pszTitle = NULL;
- else
- {
- page->dwFlags |= PSP_USETITLE;
- page->pszTitle = title;
- }
- page->lParam = LPARAM(propertyPage);
-}
-
-int OptionsDialog(HWND hwndOwner, HINSTANCE hInstance)
-{
- const int kNumPages = 2;
-
- PROPSHEETPAGE pages[kNumPages];
-
CSystemPage systemPage;
CFoldersPage foldersPage;
-
- CSysStringVector titles;
UINT32 langIDs[] = { 0x01000300, 0x01000200};
- for (int i = 0; i < sizeof(langIDs) / sizeof(langIDs[0]); i++)
- titles.Add(GetSystemString(LangLoadString(langIDs[i])));
-
- FillInPropertyPage(&pages[0], hInstance, IDD_SYSTEM, &systemPage, titles[0]);
- FillInPropertyPage(&pages[1], hInstance, IDD_FOLDERS, &foldersPage, titles[1]);
-
- PROPSHEETHEADER sheet;
-
- sheet.dwSize = sizeof(PROPSHEETHEADER);
- sheet.dwFlags = PSH_PROPSHEETPAGE;
- sheet.hwndParent = hwndOwner;
- sheet.hInstance = hInstance;
-
- CSysString title = LangLoadString(IDS_CONFIG_DIALOG_CAPTION, 0x01000000);
-
- sheet.pszCaption = title;
- sheet.nPages = sizeof(pages) / sizeof(PROPSHEETPAGE);
- sheet.nStartPage = 0;
- sheet.ppsp = pages;
-
- return (PropertySheet(&sheet));
+ UINT pageIDs[] = { IDD_SYSTEM, IDD_FOLDERS};
+ NControl::CPropertyPage *pagePinters[] = { &systemPage, &foldersPage };
+ CObjectVector<NControl::CPageInfo> pages;
+ const int kNumPages = sizeof(langIDs) / sizeof(langIDs[0]);
+ for (int i = 0; i < kNumPages; i++)
+ {
+ NControl::CPageInfo page;
+ page.Title = LangString(langIDs[i]);
+ page.ID = pageIDs[i];
+ page.Page = pagePinters[i];
+ pages.Add(page);
+ }
+ return NControl::MyPropertySheet(pages, hwndOwner,
+ LangString(IDS_CONFIG_DIALOG_CAPTION, 0x01000000));
}
STDMETHODIMP CSevenZipOptions::PluginOptions(HWND hWnd,
@@ -81,7 +45,7 @@ STDMETHODIMP CSevenZipOptions::PluginOptions(HWND hWnd,
CComBSTR programPath;
RETUEN_IF_NOT_S_OK(callback->GetProgramPath(programName)));
*/
- OptionsDialog(hWnd, g_hInstance);
+ OptionsDialog(hWnd);
return S_OK;
}
diff --git a/7zip/UI/Explorer/RegistryContextMenu.h b/7zip/UI/Explorer/RegistryContextMenu.h
index 3c2fb1ab..52b053da 100755
--- a/7zip/UI/Explorer/RegistryContextMenu.h
+++ b/7zip/UI/Explorer/RegistryContextMenu.h
@@ -10,6 +10,4 @@ namespace NZipRootRegistry {
void DeleteContextMenuHandler();
}
-// bool GetProgramDirPrefix(CSysString &folder);
-
#endif
diff --git a/7zip/UI/Explorer/SystemPage/SystemPage.cpp b/7zip/UI/Explorer/SystemPage/SystemPage.cpp
index 4268fea3..7852791b 100755
--- a/7zip/UI/Explorer/SystemPage/SystemPage.cpp
+++ b/7zip/UI/Explorer/SystemPage/SystemPage.cpp
@@ -77,41 +77,39 @@ bool CSystemPage::OnInit()
UINT32 newFlags = LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT;
m_ListView.SetExtendedListViewStyle(newFlags, newFlags);
- CSysString s; // = TEXT("Items"); // LangLoadString(IDS_PROPERTY_EXTENSION, 0x02000205);
- LVCOLUMN column;
+ UString s; // = TEXT("Items"); // LangLoadString(IDS_PROPERTY_EXTENSION, 0x02000205);
+ LVCOLUMNW column;
column.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT | LVCF_SUBITEM;
column.cx = 270;
column.fmt = LVCFMT_LEFT;
- column.pszText = (LPTSTR)(LPCTSTR)s;
+ column.pszText = (LPWSTR)(LPCWSTR)s;
column.iSubItem = 0;
m_ListView.InsertColumn(0, &column);
for (int i = 0; i < kNumMenuItems; i++)
{
CContextMenuItem &menuItem = kMenuItems[i];
- LVITEM item;
+ LVITEMW item;
item.iItem = i;
item.mask = LVIF_TEXT | LVIF_PARAM;
item.lParam = i;
- UString s = LangLoadStringW(menuItem.ControlID, menuItem.LangID);
+ UString s = LangString(menuItem.ControlID, menuItem.LangID);
switch(menuItem.ControlID)
{
case IDS_CONTEXT_EXTRACT_TO:
- s = MyFormatNew(s, LangLoadStringW(IDS_CONTEXT_FOLDER, 0x02000140));
+ s = MyFormatNew(s, LangString(IDS_CONTEXT_FOLDER, 0x02000140));
break;
case IDS_CONTEXT_COMPRESS_TO:
case IDS_CONTEXT_COMPRESS_TO_EMAIL:
- s = MyFormatNew(s, LangLoadStringW(IDS_CONTEXT_ARCHIVE, 0x02000141));
+ s = MyFormatNew(s, LangString(IDS_CONTEXT_ARCHIVE, 0x02000141));
break;
}
- CSysString ext = GetSystemString(s);
-
// UString MyFormatNew(const UString &format, const UString &argument);
- item.pszText = (LPTSTR)(LPCTSTR)ext;
+ item.pszText = (LPWSTR)(LPCWSTR)s;
item.iSubItem = 0;
int itemIndex = m_ListView.InsertItem(&item);
m_ListView.SetCheckState(itemIndex, ((contextMenuFlags & menuItem.Flag) != 0));
diff --git a/7zip/UI/Explorer/makefile b/7zip/UI/Explorer/makefile
index d1938716..1539428d 100755
--- a/7zip/UI/Explorer/makefile
+++ b/7zip/UI/Explorer/makefile
@@ -35,6 +35,7 @@ WIN_OBJS = \
$O\FileFind.obj \
$O\FileIO.obj \
$O\FileName.obj \
+ $O\Menu.obj \
$O\PropVariant.obj \
$O\PropVariantConversions.obj \
$O\Registry.obj \
diff --git a/7zip/UI/Far/Main.cpp b/7zip/UI/Far/Main.cpp
index 3f13d882..d9e7d696 100755
--- a/7zip/UI/Far/Main.cpp
+++ b/7zip/UI/Far/Main.cpp
@@ -67,11 +67,26 @@ extern "C"
};
HINSTANCE g_hInstance;
+#ifndef _UNICODE
+bool g_IsNT = false;
+static bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
+
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
g_hInstance = hInstance;
+ #ifndef _UNICODE
+ g_IsNT = IsItWindowsNT();
+ #endif
}
return TRUE;
}
@@ -387,8 +402,6 @@ static HANDLE MyOpenFilePlugin(const char *name)
// ::OutputDebugString("before OpenArchive\n");
- // UString defaultName;
-
archiveHandler = new CAgent;
CMyComBSTR archiveType;
HRESULT result = archiveHandler->Open(
diff --git a/7zip/UI/GUI/CompressDialog.cpp b/7zip/UI/GUI/CompressDialog.cpp
index 12e1cd37..ee214eca 100755
--- a/7zip/UI/GUI/CompressDialog.cpp
+++ b/7zip/UI/GUI/CompressDialog.cpp
@@ -6,6 +6,7 @@
#include "Common/Defs.h"
#include "Common/StringConvert.h"
#include "Common/IntToString.h"
+#include "Windows/CommonDialog.h"
#include "Windows/FileDir.h"
#include "Windows/FileName.h"
#include "Windows/ResourceString.h"
@@ -17,6 +18,10 @@
#include "CompressDialog.h"
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
#ifdef LANG
#include "../../FileManager/LangUtils.h"
#endif
@@ -206,31 +211,6 @@ static bool IsMethodSupportedBySfx(int methodID)
return false;
};
-class CDoubleZeroStringList
-{
- CRecordVector<int> m_Indexes;
- CSysString m_String;
-public:
- void Add(LPCTSTR s);
- void SetForBuffer(LPTSTR buffer);
-};
-
-const TCHAR kDelimiterSymbol = TEXT(' ');
-void CDoubleZeroStringList::Add(LPCTSTR s)
-{
- m_String += s;
- m_Indexes.Add(m_String.Length());
- m_String += kDelimiterSymbol;
-}
-
-void CDoubleZeroStringList::SetForBuffer(LPTSTR buffer)
-{
- lstrcpy(buffer, m_String);
- for (int i = 0; i < m_Indexes.Size(); i++)
- buffer[m_Indexes[i]] = TEXT('\0');
-}
-
-
bool CCompressDialog::OnInit()
{
#ifdef LANG
@@ -264,7 +244,7 @@ bool CCompressDialog::OnInit()
for(i = 0; i < m_ArchiverInfoList.Size(); i++)
{
const CArchiverInfo &ai = m_ArchiverInfoList[i];
- m_Format.AddString(GetSystemString(ai.Name));
+ m_Format.AddString(ai.Name);
if (ai.Name.CompareNoCase(m_RegistryInfo.ArchiveType) == 0)
Info.ArchiverInfoIndex = i;
}
@@ -277,10 +257,10 @@ bool CCompressDialog::OnInit()
for(i = 0; i < m_RegistryInfo.HistoryArchives.Size() && i < kHistorySize; i++)
m_ArchivePath.AddString(m_RegistryInfo.HistoryArchives[i]);
- m_UpdateMode.AddString(LangLoadString(IDS_COMPRESS_UPDATE_MODE_ADD, 0x02000DA1));
- m_UpdateMode.AddString(LangLoadString(IDS_COMPRESS_UPDATE_MODE_UPDATE, 0x02000DA2));
- m_UpdateMode.AddString(LangLoadString(IDS_COMPRESS_UPDATE_MODE_FRESH, 0x02000DA3));
- m_UpdateMode.AddString(LangLoadString(IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE, 0x02000DA4));
+ m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_ADD, 0x02000DA1));
+ m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_UPDATE, 0x02000DA2));
+ m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_FRESH, 0x02000DA3));
+ m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE, 0x02000DA4));
m_UpdateMode.SetCurSel(0);
@@ -311,7 +291,7 @@ void CCompressDialog::UpdatePasswordControl()
{
_passwordControl.SetPasswordChar((IsButtonChecked(
IDC_COMPRESS_CHECK_SHOW_PASSWORD) == BST_CHECKED) ? 0: TEXT('*'));
- CSysString password;
+ UString password;
_passwordControl.GetText(password);
_passwordControl.SetText(password);
}
@@ -434,73 +414,27 @@ void CCompressDialog::OnButtonSFX()
void CCompressDialog::OnButtonSetArchive()
{
- const int kBufferSize = MAX_PATH * 2;
- TCHAR buffer[kBufferSize];
UString fileName;
m_ArchivePath.GetText(fileName);
- fileName.TrimLeft();
- fileName.TrimRight();
+ fileName.Trim();
Info.ArchiveName = fileName;
UString fullFileName;
if (!Info.GetFullPathName(fullFileName))
{
fullFileName = Info.ArchiveName;
- // throw "Incorrect archive path";
return;
}
- lstrcpy(buffer, GetSystemString(fullFileName));
-
- OPENFILENAME info;
- info.lStructSize = sizeof(info);
- info.hwndOwner = HWND(*this);
- info.hInstance = 0;
-
-
- const int kFilterBufferSize = MAX_PATH;
- TCHAR filterBuffer[kFilterBufferSize];
- CDoubleZeroStringList doubleZeroStringList;
- // doubleZeroStringList.Add(TEXT("Zip Files (*.zip)"));
- // doubleZeroStringList.Add(TEXT("*.zip"));
- UString s = LangLoadStringW(IDS_OPEN_TYPE_ALL_FILES, 0x02000DB1);
+ UString title = LangString(IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE, 0x02000D90);
+ UString s = LangString(IDS_OPEN_TYPE_ALL_FILES, 0x02000DB1);
s += L" (*.*)";
- doubleZeroStringList.Add(GetSystemString(s));
- doubleZeroStringList.Add(TEXT("*.*"));
- doubleZeroStringList.SetForBuffer(filterBuffer);
- info.lpstrFilter = filterBuffer;
-
-
- info.lpstrCustomFilter = NULL;
- info.nMaxCustFilter = 0;
- info.nFilterIndex = 0;
-
- info.lpstrFile = buffer;
- info.nMaxFile = kBufferSize;
-
- info.lpstrFileTitle = NULL;
- info.nMaxFileTitle = 0;
-
- info.lpstrInitialDir= NULL;
-
- CSysString title = LangLoadString(IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE, 0x02000D90);
-
- info.lpstrTitle = title;
-
- info.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
- info.nFileOffset = 0;
- info.nFileExtension = 0;
- info.lpstrDefExt = NULL;
-
- info.lCustData = 0;
- info.lpfnHook = NULL;
- info.lpTemplateName = NULL;
-
- if(!GetOpenFileName(&info))
+ UString resPath;
+ if (!MyGetOpenFileName(HWND(*this), title, fullFileName, s, resPath))
return;
- m_ArchivePath.SetText(buffer);
+ m_ArchivePath.SetText(resPath);
}
// in ExtractDialog.cpp
-extern void AddUniqueString(CSysStringVector &strings, const CSysString &srcString);
+extern void AddUniqueString(UStringVector &strings, const UString &srcString);
void CCompressDialog::OnOK()
@@ -512,7 +446,7 @@ void CCompressDialog::OnOK()
m_ArchivePath.GetText(s);
s.Trim();
m_RegistryInfo.HistoryArchives.Clear();
- AddUniqueString(m_RegistryInfo.HistoryArchives, GetSystemString(s));
+ AddUniqueString(m_RegistryInfo.HistoryArchives, s);
Info.ArchiveName = s;
Info.UpdateMode = NCompressDialog::NUpdateMode::EEnum(m_UpdateMode.GetCurSel());
@@ -520,7 +454,7 @@ void CCompressDialog::OnOK()
Info.Dictionary = GetDictionarySpec();
Info.Order = GetOrderSpec();
Info.OrderMode = GetOrderMode();
- Info.Method = GetUnicodeString(GetMethodSpec());
+ Info.Method = GetMethodSpec();
Info.ArchiverInfoIndex = m_Format.GetCurSel();
@@ -543,7 +477,7 @@ void CCompressDialog::OnOK()
for(int i = 0; i < m_ArchivePath.GetCount(); i++)
{
- CSysString sTemp;
+ UString sTemp;
m_ArchivePath.GetLBText(i, sTemp);
sTemp.Trim();
AddUniqueString(m_RegistryInfo.HistoryArchives, sTemp);
@@ -751,7 +685,7 @@ void CCompressDialog::SetLevel()
if ((fi.LevelsMask & (1 << i)) != 0)
{
const CLevelInfo &levelInfo = g_Levels[i];
- int index = m_Level.AddString(LangLoadString(levelInfo.ResourceID, levelInfo.LangID));
+ int index = m_Level.AddString(LangString(levelInfo.ResourceID, levelInfo.LangID));
m_Level.SetItemData(index, i);
}
}
@@ -817,20 +751,19 @@ void CCompressDialog::SetMethod()
int CCompressDialog::GetMethodID()
{
- CSysString methodSpec;
- m_Method.GetText(methodSpec);
- UString methodName = GetUnicodeString(methodSpec);
+ UString methodName;
+ m_Method.GetText(methodName);
for (int i = 0; i < MY_SIZE_OF_ARRAY(kMethodsNames); i++)
if (methodName.CompareNoCase(kMethodsNames[i]) == 0)
return i;
return -1;
}
-CSysString CCompressDialog::GetMethodSpec()
+UString CCompressDialog::GetMethodSpec()
{
if (m_Method.GetCount() <= 1)
- return CSysString();
- CSysString result;
+ return UString();
+ UString result;
m_Method.GetText(result);
return result;
}
@@ -932,7 +865,7 @@ void CCompressDialog::SetDictionary()
else if (level >= 7)
defaultDictionary = (64 << 20);
else if (level >= 5)
- defaultDictionary = (24 << 20);
+ defaultDictionary = (16 << 20);
else
defaultDictionary = (4 << 20);
}
@@ -1020,21 +953,15 @@ void CCompressDialog::SetOrder()
case kLZMA:
{
if (defaultOrder == UInt32(-1))
- {
- if (level >= 7)
- defaultOrder = 64;
- else
- defaultOrder = 32;
- }
- int i;
- for (i = 3; i < 8; i++)
+ defaultOrder = (level >= 7) ? 64 : 32;
+ for (int i = 3; i <= 8; i++)
for (int j = 0; j < 2; j++)
{
UInt32 order = (1 << i) + (j << (i - 1));
- if (order < 255)
+ if (order <= 256)
AddOrder(order);
}
- AddOrder(255);
+ AddOrder(273);
SetNearestSelectComboBox(m_Order, defaultOrder);
break;
}
@@ -1076,14 +1003,14 @@ void CCompressDialog::SetOrder()
defaultOrder = 32;
}
int i;
- for (i = 3; i < 8; i++)
+ for (i = 3; i <= 8; i++)
for (int j = 0; j < 2; j++)
{
UInt32 order = (1 << i) + (j << (i - 1));
- if (order < 255)
+ if (order <= 256)
AddOrder(order);
}
- AddOrder(255);
+ AddOrder(methodID == kDeflate64 ? 257 : 258);
SetNearestSelectComboBox(m_Order, defaultOrder);
break;
}
@@ -1218,7 +1145,7 @@ void CCompressDialog::SaveOptionsInMem()
m_Params.GetText(Info.Options);
Info.Options.Trim();
NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
- fo.Options = GetSystemString(Info.Options);
+ fo.Options = Info.Options;
fo.Level = GetLevelSpec();
fo.Dictionary = GetDictionarySpec();
fo.Order = GetOrderSpec();
diff --git a/7zip/UI/GUI/CompressDialog.h b/7zip/UI/GUI/CompressDialog.h
index a2812917..d4504329 100755
--- a/7zip/UI/GUI/CompressDialog.h
+++ b/7zip/UI/GUI/CompressDialog.h
@@ -107,7 +107,7 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
void SetMethod();
int GetMethodID();
- CSysString GetMethodSpec();
+ UString GetMethodSpec();
int AddDictionarySize(UInt32 size, bool kilo, bool maga);
int AddDictionarySize(UInt32 size);
@@ -136,7 +136,7 @@ public:
UString OriginalFileName; // for bzip2, gzip2
INT_PTR Create(HWND wndParent = 0)
- { return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_COMPRESS ), wndParent); }
+ { return CModalDialog::Create(IDD_DIALOG_COMPRESS, wndParent); }
protected:
diff --git a/7zip/UI/GUI/ExtractDialog.cpp b/7zip/UI/GUI/ExtractDialog.cpp
index 3d71f04d..55c871ad 100755
--- a/7zip/UI/GUI/ExtractDialog.cpp
+++ b/7zip/UI/GUI/ExtractDialog.cpp
@@ -18,9 +18,7 @@
#include "../Common/ZipRegistry.h"
-#ifdef LANG
#include "../../FileManager/LangUtils.h"
-#endif
#include "../Resource/Extract/resource.h"
#include "../Resource/ExtractDialog/resource.h"
@@ -200,12 +198,14 @@ bool CExtractDialog::OnInit()
#endif
_path.Attach(GetItem(IDC_EXTRACT_COMBO_PATH));
+
_path.SetText(DirectoryPath);
#ifndef NO_REGISTRY
for(int i = 0; i < extractionInfo.Paths.Size() && i < kHistorySize; i++)
_path.AddString(extractionInfo.Paths[i]);
#endif
+
/*
if(extractionInfo.Paths.Size() > 0)
_path.SetCurSel(0);
@@ -243,7 +243,7 @@ void CExtractDialog::UpdatePasswordControl()
{
_passwordControl.SetPasswordChar((IsButtonChecked(
IDC_EXTRACT_CHECK_SHOW_PASSWORD) == BST_CHECKED) ? 0: TEXT('*'));
- CSysString password;
+ UString password;
_passwordControl.GetText(password);
_passwordControl.SetText(password);
}
@@ -277,19 +277,11 @@ bool CExtractDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
void CExtractDialog::OnButtonSetPath()
{
- CSysString currentPath;
+ UString currentPath;
_path.GetText(currentPath);
-
- #ifdef LANG
- UString title = LangLoadStringW(IDS_EXTRACT_SET_FOLDER, 0x02000881);
- #else
- UString title = MyLoadStringW(IDS_EXTRACT_SET_FOLDER);
- #endif
-
-
- CSysString resultPath;
- if (!NShell::BrowseForFolder(HWND(*this), GetSystemString(title),
- currentPath, resultPath))
+ UString title = LangStringSpec(IDS_EXTRACT_SET_FOLDER, 0x02000881);
+ UString resultPath;
+ if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
return;
#ifndef NO_REGISTRY
_path.SetCurSel(-1);
@@ -297,7 +289,7 @@ void CExtractDialog::OnButtonSetPath()
_path.SetText(resultPath);
}
-void AddUniqueString(CSysStringVector &list, const CSysString &s)
+void AddUniqueString(UStringVector &list, const UString &s)
{
for(int i = 0; i < list.Size(); i++)
if (s.CompareNoCase(list[i]) == 0)
@@ -337,24 +329,20 @@ void CExtractDialog::OnOK()
currentItem = _path.GetCount() - 1;
}
else
- {
- CSysString sTemp;
- _path.GetLBText(currentItem, sTemp);
- s = GetUnicodeString(sTemp);
- }
+ _path.GetLBText(currentItem, s);
#endif
s.Trim();
#ifndef _SFX
- AddUniqueString(extractionInfo.Paths, GetSystemString(s));
+ AddUniqueString(extractionInfo.Paths, s);
#endif
DirectoryPath = s;
#ifndef NO_REGISTRY
for(int i = 0; i < _path.GetCount(); i++)
if(i != currentItem)
{
- CSysString sTemp;
+ UString sTemp;
_path.GetLBText(i, sTemp);
sTemp.Trim();
AddUniqueString(extractionInfo.Paths, sTemp);
diff --git a/7zip/UI/GUI/ExtractDialog.h b/7zip/UI/GUI/ExtractDialog.h
index 34f93f96..f52498d2 100755
--- a/7zip/UI/GUI/ExtractDialog.h
+++ b/7zip/UI/GUI/ExtractDialog.h
@@ -71,7 +71,7 @@ public:
NExtract::NOverwriteMode::EEnum OverwriteMode;
INT_PTR Create(HWND aWndParent = 0)
- { return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_EXTRACT), aWndParent); }
+ { return CModalDialog::Create(IDD_DIALOG_EXTRACT, aWndParent); }
};
#endif
diff --git a/7zip/UI/GUI/ExtractGUI.cpp b/7zip/UI/GUI/ExtractGUI.cpp
index de6d1b8a..a076f3d0 100755
--- a/7zip/UI/GUI/ExtractGUI.cpp
+++ b/7zip/UI/GUI/ExtractGUI.cpp
@@ -13,6 +13,7 @@
#include "../../FileManager/FormatUtils.h"
#include "../../FileManager/ExtractCallback.h"
+#include "../../FileManager/LangUtils.h"
#include "../Common/ArchiveExtractCallback.h"
#include "../Explorer/MyMessages.h"
@@ -136,13 +137,8 @@ HRESULT ExtractGUI(
*/
}
- UString title =
- #ifdef LANG
- LangLoadStringW(options.TestMode ? IDS_PROGRESS_TESTING : IDS_PROGRESS_EXTRACTING,
+ UString title = LangStringSpec(options.TestMode ? IDS_PROGRESS_TESTING : IDS_PROGRESS_EXTRACTING,
options.TestMode ? 0x02000F90: 0x02000890);
- #else
- NWindows::MyLoadStringW(options.TestMode ? IDS_PROGRESS_TESTING : IDS_PROGRESS_EXTRACTING);
- #endif
extracter.ExtractCallbackSpec = extractCallback;
extracter.ExtractCallback = extractCallback;
@@ -163,8 +159,8 @@ HRESULT ExtractGUI(
extracter.ExtractCallbackSpec->NumArchiveErrors == 0)
{
#ifndef _SFX
- MessageBoxW(0, LangLoadStringW(IDS_MESSAGE_NO_ERRORS, 0x02000608),
- LangLoadStringW(IDS_PROGRESS_TESTING, 0x02000F90), 0);
+ MessageBoxW(0, LangString(IDS_MESSAGE_NO_ERRORS, 0x02000608),
+ LangString(IDS_PROGRESS_TESTING, 0x02000F90), 0);
#endif
}
if (extracter.Result != S_OK)
diff --git a/7zip/UI/GUI/GUI.cpp b/7zip/UI/GUI/GUI.cpp
index 9f3ea7a4..f263601a 100755
--- a/7zip/UI/GUI/GUI.cpp
+++ b/7zip/UI/GUI/GUI.cpp
@@ -15,6 +15,9 @@
#include "Windows/Synchronization.h"
#include "Windows/Error.h"
#include "Windows/FileName.h"
+#ifdef _WIN32
+#include "Windows/MemoryLock.h"
+#endif
#include "../../IStream.h"
#include "../../IPassword.h"
@@ -33,6 +36,9 @@
using namespace NWindows;
HINSTANCE g_hInstance;
+#ifndef _UNICODE
+bool g_IsNT = false;
+#endif
static const wchar_t *kExceptionErrorMessage = L"Error:";
static const wchar_t *kUserBreak = L"Break signaled";
@@ -71,6 +77,11 @@ int Main2()
parser.Parse1(commandStrings, options);
parser.Parse2(options);
+
+ #ifdef _WIN32
+ if (options.LargePages)
+ NSecurity::EnableLockMemoryPrivilege();
+ #endif
bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
@@ -157,18 +168,20 @@ static bool inline IsItWindowsNT()
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
g_hInstance = hInstance;
- InitCommonControls();
-
- ReloadLang();
-
-
- #ifdef UNICODE
+ #ifdef _UNICODE
if (!IsItWindowsNT())
{
MyMessageBox(L"This program requires Windows NT/2000/XP/2003");
return NExitCode::kFatalError;
}
+ #else
+ g_IsNT = IsItWindowsNT();
#endif
+
+ InitCommonControls();
+
+ ReloadLang();
+
// setlocale(LC_COLLATE, ".ACP");
try
{
diff --git a/7zip/UI/GUI/GUI.dsp b/7zip/UI/GUI/GUI.dsp
index e8db155c..bf6eb541 100755
--- a/7zip/UI/GUI/GUI.dsp
+++ b/7zip/UI/GUI/GUI.dsp
@@ -332,6 +332,14 @@ SOURCE=..\..\..\Windows\Control\ListView.h
# End Group
# Begin Source File
+SOURCE=..\..\..\Windows\CommonDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\CommonDialog.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Windows\DLL.cpp
# End Source File
# Begin Source File
@@ -380,6 +388,14 @@ SOURCE=..\..\..\Windows\FileName.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Windows\MemoryLock.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\MemoryLock.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Windows\PropVariant.cpp
# End Source File
# Begin Source File
diff --git a/7zip/UI/GUI/UpdateGUI.cpp b/7zip/UI/GUI/UpdateGUI.cpp
index 5becefef..a3f6b449 100755
--- a/7zip/UI/GUI/UpdateGUI.cpp
+++ b/7zip/UI/GUI/UpdateGUI.cpp
@@ -30,7 +30,7 @@ using namespace NWindows;
using namespace NFile;
static const wchar_t *kIncorrectOutDir = L"Incorrect output directory path";
-static const wchar_t *kDefaultSfxModule = L"7zC.sfx";
+static const wchar_t *kDefaultSfxModule = L"7z.sfx";
static const wchar_t *kSFXExtension = L"exe";
struct CThreadUpdating
@@ -350,8 +350,7 @@ HRESULT UpdateGUI(
CThread thread;
if (!thread.Create(CThreadUpdating::MyThreadFunction, &tu))
throw 271824;
- const UString title = LangLoadStringW(IDS_PROGRESS_COMPRESSING, 0x02000DC0);
- tu.UpdateCallbackGUI->StartProgressDialog(title);
+ tu.UpdateCallbackGUI->StartProgressDialog(LangString(IDS_PROGRESS_COMPRESSING, 0x02000DC0));
return tu.Result;
}
diff --git a/7zip/UI/GUI/makefile b/7zip/UI/GUI/makefile
index 20c6caaa..85b98f81 100755
--- a/7zip/UI/GUI/makefile
+++ b/7zip/UI/GUI/makefile
@@ -28,12 +28,14 @@ COMMON_OBJS = \
$O\Wildcard.obj \
WIN_OBJS = \
+ $O\CommonDialog.obj \
$O\DLL.obj \
$O\Error.obj \
$O\FileDir.obj \
$O\FileFind.obj \
$O\FileIO.obj \
$O\FileName.obj \
+ $O\MemoryLock.obj \
$O\PropVariant.obj \
$O\PropVariantConversions.obj \
$O\Registry.obj \
diff --git a/Common/Alloc.cpp b/Common/Alloc.cpp
index 3ca49d1a..e2b8c3d2 100755
--- a/Common/Alloc.cpp
+++ b/Common/Alloc.cpp
@@ -15,6 +15,7 @@
#ifdef _SZ_ALLOC_DEBUG
#include <stdio.h>
int g_allocCount = 0;
+int g_allocCountMid = 0;
int g_allocCountBig = 0;
#endif
@@ -38,6 +39,52 @@ void MyFree(void *address) throw()
::free(address);
}
+#ifdef _WIN32
+
+void *MidAlloc(size_t size) throw()
+{
+ if (size == 0)
+ return 0;
+ #ifdef _SZ_ALLOC_DEBUG
+ fprintf(stderr, "\nAlloc_Mid %10d bytes; count = %10d", size, g_allocCountMid++);
+ #endif
+ return ::VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
+}
+
+void MidFree(void *address) throw()
+{
+ #ifdef _SZ_ALLOC_DEBUG
+ if (address != 0)
+ fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid);
+ #endif
+ if (address == 0)
+ return;
+ ::VirtualFree(address, 0, MEM_RELEASE);
+}
+
+static SIZE_T g_LargePageSize =
+ #ifdef _WIN64
+ (1 << 21);
+ #else
+ (1 << 22);
+ #endif
+
+typedef SIZE_T (WINAPI *GetLargePageMinimumP)();
+
+bool SetLargePageSize()
+{
+ GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)
+ ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");
+ if (largePageMinimum == 0)
+ return false;
+ SIZE_T size = largePageMinimum();
+ if (size == 0 || (size & (size - 1)) != 0)
+ return false;
+ g_LargePageSize = size;
+ return true;
+}
+
+
void *BigAlloc(size_t size) throw()
{
if (size == 0)
@@ -46,11 +93,14 @@ void *BigAlloc(size_t size) throw()
fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++);
#endif
- #ifdef _WIN32
+ if (size >= (1 << 18))
+ {
+ void *res = ::VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)),
+ MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);
+ if (res != 0)
+ return res;
+ }
return ::VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
- #else
- return ::malloc(size);
- #endif
}
void BigFree(void *address) throw()
@@ -62,21 +112,7 @@ void BigFree(void *address) throw()
if (address == 0)
return;
- #ifdef _WIN32
::VirtualFree(address, 0, MEM_RELEASE);
- #else
- ::free(address);
- #endif
}
-/*
-void *BigAllocE(size_t size)
-{
- void *res = BigAlloc(size);
- #ifndef _NO_EXCEPTIONS
- if (res == 0)
- throw CNewException();
- #endif
- return res;
-}
-*/
+#endif
diff --git a/Common/Alloc.h b/Common/Alloc.h
index 1a1caa8e..d444f631 100755
--- a/Common/Alloc.h
+++ b/Common/Alloc.h
@@ -7,8 +7,23 @@
void *MyAlloc(size_t size) throw();
void MyFree(void *address) throw();
+
+#ifdef _WIN32
+
+bool SetLargePageSize();
+
+void *MidAlloc(size_t size) throw();
+void MidFree(void *address) throw();
void *BigAlloc(size_t size) throw();
void BigFree(void *address) throw();
-// void *BigAllocE(size_t size);
+
+#else
+
+#define MidAlloc(size) MyAlloc(size)
+#define MidFree(address) MyFree(address)
+#define BigAlloc(size) MyAlloc(size)
+#define BigFree(address) MyFree(address)
+
+#endif
#endif
diff --git a/Common/ComTry.h b/Common/ComTry.h
index bef6ad54..5153362f 100755
--- a/Common/ComTry.h
+++ b/Common/ComTry.h
@@ -3,10 +3,15 @@
#ifndef __COM_TRY_H
#define __COM_TRY_H
-#include "Exception.h"
+#include "MyWindows.h"
+// #include "Exception.h"
+// #include "NewHandler.h"
#define COM_TRY_BEGIN try {
-#define COM_TRY_END } catch(const CSystemException &e) { return e.ErrorCode; }\
- catch(...) { return E_FAIL; }
+#define COM_TRY_END } catch(...) { return E_OUTOFMEMORY; }
+
+ // catch(const CNewException &) { return E_OUTOFMEMORY; }\
+ // catch(const CSystemException &e) { return e.ErrorCode; }\
+ // catch(...) { return E_FAIL; }
#endif
diff --git a/DOC/7zip.nsi b/DOC/7zip.nsi
index 7ba39abb..30963e82 100755
--- a/DOC/7zip.nsi
+++ b/DOC/7zip.nsi
@@ -2,7 +2,7 @@
;Defines
!define VERSION_MAJOR 4
-!define VERSION_MINOR 29
+!define VERSION_MINOR 30
!define VERSION_POSTFIX_FULL " beta"
!ifdef WIN64
!ifdef IA64
@@ -105,10 +105,17 @@
;Installer Sections
Section
+ !ifndef WIN64
+ DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\7zFMn.exe"
+ !endif
# delete old unwanted files
+ Delete $INSTDIR\7zFMn.exe
+ Delete $INSTDIR\7zgn.exe
Delete $INSTDIR\7zn.exe
Delete $INSTDIR\7zan.exe
+ Delete $INSTDIR\7zC.sfx
+ Delete $INSTDIR\7-zipn.dll
Delete $INSTDIR\7zipDoc.txt
Delete $INSTDIR\Codecs\Implode.dll
@@ -128,19 +135,14 @@ Section
# File 7-zip.dll
# File 7-zipn.dll
File 7zFM.exe
- !ifndef WIN64
- File 7zFMn.exe
- !endif
File 7z.exe
+ !ifdef WIN64
File 7za.exe
- File 7zg.exe
- !ifndef WIN64
- File 7zgn.exe
!endif
+ File 7zg.exe
File 7z.sfx
File 7zCon.sfx
- File 7zC.sfx
File 7-zip.chm
@@ -249,27 +251,7 @@ Section
SetShellVarContext all
- !ifdef WIN64
-
!insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED 7-zip.dll $INSTDIR\7-zip.dll $INSTDIR
- StrCpy "$MyDllPath" "7-zip.dll"
-
- !else
-
- StrCpy $0 0
- System::Call "kernel32::GetVersion() i .r0"
- IntCmpU $0 0x80000000 0 regNT 0
- !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED 7-zip.dll $INSTDIR\7-zip.dll $INSTDIR
- File 7-Zipn.dll
- StrCpy "$MyDllPath" "7-zip.dll"
- Goto doneReg
- regNT:
- !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED 7-zipn.dll $INSTDIR\7-zipn.dll $INSTDIR
- File 7-Zip.dll
- StrCpy "$MyDllPath" "7-zipn.dll"
- doneReg:
-
- !endif
ClearErrors
@@ -277,15 +259,7 @@ Section
SetOutPath $INSTDIR # working directory
CreateDirectory $SMPROGRAMS\7-Zip
- !ifdef WIN64
- StrCpy $1 ""
- !else
- StrCpy $1 "n"
- IntCmpU $0 0x80000000 0 +2 0
- StrCpy $1 ""
- !endif
-
- CreateShortcut "$SMPROGRAMS\7-Zip\${FM_LINK}" $INSTDIR\7zFM$1.exe
+ CreateShortcut "$SMPROGRAMS\7-Zip\${FM_LINK}" $INSTDIR\7zFM.exe
CreateShortcut "$SMPROGRAMS\7-Zip\${HELP_LINK}" $INSTDIR\7-zip.chm
IfErrors 0 noScErrors
@@ -293,7 +267,7 @@ Section
SetShellVarContext current
CreateDirectory $SMPROGRAMS\7-Zip
- CreateShortcut "$SMPROGRAMS\7-Zip\${FM_LINK}" $INSTDIR\7zFM$1.exe
+ CreateShortcut "$SMPROGRAMS\7-Zip\${FM_LINK}" $INSTDIR\7zFM.exe
CreateShortcut "$SMPROGRAMS\7-Zip\${HELP_LINK}" $INSTDIR\7-zip.chm
noScErrors:
@@ -304,7 +278,7 @@ Section
# write reg entries
WriteRegStr HKCR "CLSID\${CLSID_CONTEXT_MENU}" "" "7-Zip Shell Extension"
- WriteRegStr HKCR "CLSID\${CLSID_CONTEXT_MENU}\InprocServer32" "" "$INSTDIR\$MyDllPath"
+ WriteRegStr HKCR "CLSID\${CLSID_CONTEXT_MENU}\InprocServer32" "" "$INSTDIR\7-zip.dll"
WriteRegStr HKCR "CLSID\${CLSID_CONTEXT_MENU}\InprocServer32" "ThreadingModel" "Apartment"
@@ -319,10 +293,6 @@ Section
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\7zFM.exe" "" "$INSTDIR\7zFM.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\7zFM.exe" "Path" "$INSTDIR"
- !ifndef WIN64
- WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\7zFMn.exe" "" "$INSTDIR\7zFMn.exe"
- WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\7zFMn.exe" "Path" "$INSTDIR"
- !endif
# create uninstaller
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" "DisplayName" "${NAME_FULL}"
@@ -354,6 +324,8 @@ FunctionEnd
Section "Uninstall"
+ ExecWait 'regsvr32 /u /s "$INSTDIR\7-zip.dll"'
+
# delete files
Delete $INSTDIR\file_id.diz
@@ -365,19 +337,12 @@ Section "Uninstall"
Delete $INSTDIR\7zip_pad.xml
Delete /REBOOTOK $INSTDIR\7-zip.dll
- !ifndef WIN64
- Delete /REBOOTOK $INSTDIR\7-zipn.dll
- !endif
Delete $INSTDIR\7zFM.exe
- !ifndef WIN64
- Delete $INSTDIR\7zFMn.exe
- !endif
Delete $INSTDIR\7z.exe
+ !ifdef WIN64
Delete $INSTDIR\7za.exe
- Delete $INSTDIR\7zg.exe
- !ifndef WIN64
- Delete $INSTDIR\7zgn.exe
!endif
+ Delete $INSTDIR\7zg.exe
Delete $INSTDIR\7z.sfx
Delete $INSTDIR\7zCon.sfx
@@ -507,9 +472,6 @@ Section "Uninstall"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\7zFM.exe"
- !ifndef WIN64
- DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\7zFMn.exe"
- !endif
DeleteRegKey HKLM "Software\7-Zip"
DeleteRegKey HKCU "Software\7-Zip"
diff --git a/DOC/history.txt b/DOC/history.txt
index 3944a491..232a9ca8 100755
--- a/DOC/history.txt
+++ b/DOC/history.txt
@@ -1,6 +1,13 @@
Sources history of the 7-Zip
----------------------------
+ Version 4.30 beta 2005-11-18
+ --------------------------------------
+ - Security.h::AddLockMemoryPrivilege - installs "Large pages" fature
+ - MemoryLock.h::EnableLockMemoryPrivilege - enables "Large pages" fature
+ - Alloc.h::SetLargePageSize - sets optimal LargePageSize size;
+
+
Version 4.27 2005-09-21
--------------------------------------
- Some GUIDs/interfaces were changed.
diff --git a/DOC/readme.txt b/DOC/readme.txt
index 72de51d2..ae8c7108 100755
--- a/DOC/readme.txt
+++ b/DOC/readme.txt
@@ -1,4 +1,4 @@
-7-Zip 4.27 Sources
+7-Zip 4.30 Sources
------------------
7-Zip is a file archiver for Windows 95/98/ME/NT/2000/2003/XP.
diff --git a/Windows/CommonDialog.cpp b/Windows/CommonDialog.cpp
new file mode 100755
index 00000000..756026d7
--- /dev/null
+++ b/Windows/CommonDialog.cpp
@@ -0,0 +1,164 @@
+// Windows/CommonDialog.cpp
+
+#include "StdAfx.h"
+
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
+#include "Common/MyCom.h"
+#include "CommonDialog.h"
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+namespace NWindows{
+
+#ifndef _UNICODE
+class CDoubleZeroStringListA
+{
+ CRecordVector<int> m_Indexes;
+ AString m_String;
+public:
+ void Add(LPCSTR s);
+ void SetForBuffer(LPSTR buffer);
+};
+
+void CDoubleZeroStringListA::Add(LPCSTR s)
+{
+ m_String += s;
+ m_Indexes.Add(m_String.Length());
+ m_String += ' ';
+}
+
+void CDoubleZeroStringListA::SetForBuffer(LPSTR buffer)
+{
+ strcpy(buffer, m_String);
+ for (int i = 0; i < m_Indexes.Size(); i++)
+ buffer[m_Indexes[i]] = '\0';
+}
+#endif
+
+class CDoubleZeroStringListW
+{
+ CRecordVector<int> m_Indexes;
+ UString m_String;
+public:
+ void Add(LPCWSTR s);
+ void SetForBuffer(LPWSTR buffer);
+};
+
+void CDoubleZeroStringListW::Add(LPCWSTR s)
+{
+ m_String += s;
+ m_Indexes.Add(m_String.Length());
+ m_String += L' ';
+}
+
+void CDoubleZeroStringListW::SetForBuffer(LPWSTR buffer)
+{
+ wcscpy(buffer, m_String);
+ for (int i = 0; i < m_Indexes.Size(); i++)
+ buffer[m_Indexes[i]] = L'\0';
+}
+
+bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, LPCWSTR s, UString &resPath)
+{
+ const int kBufferSize = MAX_PATH * 2;
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ CHAR buffer[kBufferSize];
+ strcpy(buffer, GetSystemString(fullFileName));
+ OPENFILENAME info;
+ info.lStructSize = sizeof(info);
+ info.hwndOwner = hwnd;
+ info.hInstance = 0;
+ const int kFilterBufferSize = MAX_PATH;
+ CHAR filterBuffer[kFilterBufferSize];
+ CDoubleZeroStringListA doubleZeroStringList;
+ doubleZeroStringList.Add(GetSystemString(s));
+ doubleZeroStringList.Add("*.*");
+ doubleZeroStringList.SetForBuffer(filterBuffer);
+ info.lpstrFilter = filterBuffer;
+
+ info.lpstrCustomFilter = NULL;
+ info.nMaxCustFilter = 0;
+ info.nFilterIndex = 0;
+
+ info.lpstrFile = buffer;
+ info.nMaxFile = kBufferSize;
+
+ info.lpstrFileTitle = NULL;
+ info.nMaxFileTitle = 0;
+
+ info.lpstrInitialDir= NULL;
+
+ info.lpstrTitle = 0;
+ AString titleA;
+ if (title != 0)
+ {
+ titleA = GetSystemString(title);
+ info.lpstrTitle = titleA;
+ }
+
+ info.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
+ info.nFileOffset = 0;
+ info.nFileExtension = 0;
+ info.lpstrDefExt = NULL;
+
+ info.lCustData = 0;
+ info.lpfnHook = NULL;
+ info.lpTemplateName = NULL;
+
+ bool res = BOOLToBool(::GetOpenFileNameA(&info));
+ resPath = GetUnicodeString(buffer);
+ return res;
+ }
+ else
+ #endif
+ {
+ WCHAR buffer[kBufferSize];
+ wcscpy(buffer, fullFileName);
+ OPENFILENAMEW info;
+ info.lStructSize = sizeof(info);
+ info.hwndOwner = hwnd;
+ info.hInstance = 0;
+ const int kFilterBufferSize = MAX_PATH;
+ WCHAR filterBuffer[kFilterBufferSize];
+ CDoubleZeroStringListW doubleZeroStringList;
+ doubleZeroStringList.Add(s);
+ doubleZeroStringList.Add(L"*.*");
+ doubleZeroStringList.SetForBuffer(filterBuffer);
+ info.lpstrFilter = filterBuffer;
+
+ info.lpstrCustomFilter = NULL;
+ info.nMaxCustFilter = 0;
+ info.nFilterIndex = 0;
+
+ info.lpstrFile = buffer;
+ info.nMaxFile = kBufferSize;
+
+ info.lpstrFileTitle = NULL;
+ info.nMaxFileTitle = 0;
+
+ info.lpstrInitialDir= NULL;
+
+ info.lpstrTitle = title;
+
+ info.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
+ info.nFileOffset = 0;
+ info.nFileExtension = 0;
+ info.lpstrDefExt = NULL;
+
+ info.lCustData = 0;
+ info.lpfnHook = NULL;
+ info.lpTemplateName = NULL;
+
+ bool res = BOOLToBool(::GetOpenFileNameW(&info));
+ resPath = buffer;
+ return res;
+ }
+}
+
+}
diff --git a/Windows/CommonDialog.h b/Windows/CommonDialog.h
new file mode 100755
index 00000000..d0149aba
--- /dev/null
+++ b/Windows/CommonDialog.h
@@ -0,0 +1,17 @@
+// Windows/CommonDialog.h
+
+#ifndef __WINDOWS_COMMONDIALOG_H
+#define __WINDOWS_COMMONDIALOG_H
+
+#include <windows.h>
+
+#include "Common/String.h"
+#include "Windows/Defs.h"
+
+namespace NWindows{
+
+bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, LPCWSTR s, UString &resPath);
+
+}
+
+#endif
diff --git a/Windows/Control/ComboBox.cpp b/Windows/Control/ComboBox.cpp
index edef3a21..58c9b9c5 100755
--- a/Windows/Control/ComboBox.cpp
+++ b/Windows/Control/ComboBox.cpp
@@ -1,23 +1,63 @@
// Windows/Control/ComboBox.cpp
+// #define _UNICODE
+// #define UNICODE
+
#include "StdAfx.h"
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
+
#include "Windows/Control/ComboBox.h"
#include "Windows/Defs.h"
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
namespace NWindows {
namespace NControl {
-int CComboBox::GetLBText(int index, CSysString &string)
+LRESULT CComboBox::GetLBText(int index, CSysString &s)
+{
+ s.Empty();
+ LRESULT len = GetLBTextLen(index);
+ if (len == CB_ERR)
+ return len;
+ len = GetLBText(index, s.GetBuffer((int)len + 1));
+ s.ReleaseBuffer();
+ return len;
+}
+
+#ifndef _UNICODE
+LRESULT CComboBox::AddString(LPCWSTR s)
+{
+ if (g_IsNT)
+ return SendMessageW(CB_ADDSTRING, 0, (LPARAM)s);
+ return AddString(GetSystemString(s));
+}
+
+LRESULT CComboBox::GetLBText(int index, UString &s)
{
- string.Empty();
- int aLength = GetLBTextLen(index);
- if (aLength == CB_ERR)
- return aLength;
- aLength = GetLBText(index, string.GetBuffer(aLength));
- string.ReleaseBuffer();
- return aLength;
+ s.Empty();
+ if (g_IsNT)
+ {
+ LRESULT len = SendMessageW(CB_GETLBTEXTLEN, index, 0);
+ if (len == CB_ERR)
+ return len;
+ len = SendMessageW(CB_GETLBTEXT, index, (LPARAM)s.GetBuffer((int)len + 1));
+ s.ReleaseBuffer();
+ return len;
+ }
+ AString sa;
+ int len = GetLBText(index, sa);
+ if (len == CB_ERR)
+ return len;
+ s = GetUnicodeString(sa);
+ return s.Length();
}
+#endif
}}
diff --git a/Windows/Control/ComboBox.h b/Windows/Control/ComboBox.h
index d4ffd23e..b153e6ad 100755
--- a/Windows/Control/ComboBox.h
+++ b/Windows/Control/ComboBox.h
@@ -14,22 +14,21 @@ namespace NControl {
class CComboBox: public CWindow
{
public:
- void ResetContent()
- { SendMessage(CB_RESETCONTENT, 0, 0); }
- int AddString(LPCTSTR string)
- { return SendMessage(CB_ADDSTRING, 0, (LPARAM)string); }
- int SetCurSel(int index)
- { return SendMessage(CB_SETCURSEL, index, 0); }
- int GetCurSel()
- { return SendMessage(CB_GETCURSEL, 0, 0); }
- int GetCount()
- { return SendMessage(CB_GETCOUNT, 0, 0); }
+ void ResetContent() { SendMessage(CB_RESETCONTENT, 0, 0); }
+ LRESULT AddString(LPCTSTR string) { return SendMessage(CB_ADDSTRING, 0, (LPARAM)string); }
+ #ifndef _UNICODE
+ LRESULT AddString(LPCWSTR string);
+ #endif
+ int SetCurSel(int index) { return SendMessage(CB_SETCURSEL, index, 0); }
+ int GetCurSel() { return SendMessage(CB_GETCURSEL, 0, 0); }
+ int GetCount() { return SendMessage(CB_GETCOUNT, 0, 0); }
- int GetLBTextLen(int index)
- { return SendMessage(CB_GETLBTEXTLEN, index, 0); }
- int GetLBText(int index, LPTSTR string)
- { return SendMessage(CB_GETLBTEXT, index, (LPARAM)string); }
- int GetLBText(int index, CSysString &string);
+ LRESULT GetLBTextLen(int index) { return SendMessage(CB_GETLBTEXTLEN, index, 0); }
+ LRESULT GetLBText(int index, LPTSTR string) { return SendMessage(CB_GETLBTEXT, index, (LPARAM)string); }
+ LRESULT GetLBText(int index, CSysString &s);
+ #ifndef _UNICODE
+ LRESULT GetLBText(int index, UString &s);
+ #endif
int SetItemData(int index, LPARAM lParam)
{ return SendMessage(CB_SETITEMDATA, index, lParam); }
diff --git a/Windows/Control/Dialog.cpp b/Windows/Control/Dialog.cpp
index 4e026d49..5025f257 100755
--- a/Windows/Control/Dialog.cpp
+++ b/Windows/Control/Dialog.cpp
@@ -2,9 +2,15 @@
#include "StdAfx.h"
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
#include "Windows/Control/Dialog.h"
extern HINSTANCE g_hInstance;
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
namespace NWindows {
namespace NControl {
@@ -81,8 +87,7 @@ bool CDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
bool CModelessDialog::Create(LPCTSTR templateName, HWND parentWindow)
{
- HWND aHWND = CreateDialogParam(g_hInstance,
- templateName, parentWindow, DialogProcedure, LPARAM(this));
+ HWND aHWND = CreateDialogParam(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
if (aHWND == 0)
return false;
Attach(aHWND);
@@ -91,16 +96,50 @@ bool CModelessDialog::Create(LPCTSTR templateName, HWND parentWindow)
INT_PTR CModalDialog::Create(LPCTSTR templateName, HWND parentWindow)
{
- return DialogBoxParam(g_hInstance,
- templateName, parentWindow, DialogProcedure, LPARAM(this));
+ return DialogBoxParam(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
+}
+
+#ifndef _UNICODE
+
+bool CModelessDialog::Create(LPCWSTR templateName, HWND parentWindow)
+{
+ HWND aHWND;
+ if (g_IsNT)
+ aHWND = CreateDialogParamW(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
+ else
+ {
+ AString name;
+ LPCSTR templateNameA;
+ if (IS_INTRESOURCE(templateName))
+ templateNameA = (LPCSTR)templateName;
+ else
+ {
+ name = GetSystemString(templateName);
+ templateNameA = name;
+ }
+ aHWND = CreateDialogParamA(g_hInstance, templateNameA, parentWindow, DialogProcedure, (LPARAM)this);
+ }
+ if (aHWND == 0)
+ return false;
+ Attach(aHWND);
+ return true;
}
-/*
INT_PTR CModalDialog::Create(LPCWSTR templateName, HWND parentWindow)
{
- return DialogBoxParamW(g_hInstance,
- templateName, parentWindow, DialogProcedure, LPARAM(this));
+ if (g_IsNT)
+ return DialogBoxParamW(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
+ AString name;
+ LPCSTR templateNameA;
+ if (IS_INTRESOURCE(templateName))
+ templateNameA = (LPCSTR)templateName;
+ else
+ {
+ name = GetSystemString(templateName);
+ templateNameA = name;
+ }
+ return DialogBoxParamA(g_hInstance, templateNameA, parentWindow, DialogProcedure, (LPARAM)this);
}
-*/
+#endif
}}
diff --git a/Windows/Control/Dialog.h b/Windows/Control/Dialog.h
index de42a656..4d978790 100755
--- a/Windows/Control/Dialog.h
+++ b/Windows/Control/Dialog.h
@@ -102,6 +102,9 @@ class CModelessDialog: public CDialog
{
public:
bool Create(LPCTSTR templateName, HWND parentWindow);
+ #ifndef _UNICODE
+ bool Create(LPCWSTR templateName, HWND parentWindow);
+ #endif
virtual void OnOK() { Destroy(); }
virtual void OnCancel() { Destroy(); }
};
@@ -110,7 +113,12 @@ class CModalDialog: public CDialog
{
public:
INT_PTR Create(LPCTSTR templateName, HWND parentWindow);
- // INT_PTR Create(LPCWSTR templateName, HWND parentWindow);
+ INT_PTR Create(UINT resID, HWND parentWindow)
+ { return Create(MAKEINTRESOURCEW(resID), parentWindow); }
+ #ifndef _UNICODE
+ INT_PTR Create(LPCWSTR templateName, HWND parentWindow);
+ #endif
+
bool End(INT_PTR result)
{ return BOOLToBool(::EndDialog(_window, result)); }
virtual void OnOK() { End(IDOK); }
diff --git a/Windows/Control/ListView.h b/Windows/Control/ListView.h
index 845a8945..a66b272b 100755
--- a/Windows/Control/ListView.h
+++ b/Windows/Control/ListView.h
@@ -18,18 +18,35 @@ public:
int x, int y, int width, int height,
HWND parentWindow, HMENU idOrHMenu,
HINSTANCE instance, LPVOID createParam);
-
+
+ bool SetUnicodeFormat(bool fUnicode)
+ { return BOOLToBool(ListView_SetUnicodeFormat(_window, BOOLToBool(fUnicode))); }
+
bool DeleteAllItems()
{ return BOOLToBool(ListView_DeleteAllItems(_window)); }
int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo)
{ return ListView_InsertColumn(_window, columnIndex, columnInfo); }
+ #ifndef _UNICODE
+ int InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo)
+ { return (int)SendMessage(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
+ #endif
bool DeleteColumn(int columnIndex)
{ return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
int InsertItem(const LVITEM* item)
{ return ListView_InsertItem(_window, item); }
+ #ifndef _UNICODE
+ int InsertItem(const LV_ITEMW* item)
+ { return (int)SendMessage(LVM_INSERTITEMW, 0, (LPARAM)item); }
+ #endif
+
bool SetItem(const LVITEM* item)
{ return BOOLToBool(ListView_SetItem(_window, item)); }
+ #ifndef _UNICODE
+ bool SetItem(const LV_ITEMW* item)
+ { return BOOLToBool((BOOL)SendMessage(LVM_SETITEMW, 0, (LPARAM)item)); }
+ #endif
+
bool DeleteItem(int itemIndex)
{ return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); }
diff --git a/Windows/Control/PropertyPage.cpp b/Windows/Control/PropertyPage.cpp
index 9122e710..9198131c 100755
--- a/Windows/Control/PropertyPage.cpp
+++ b/Windows/Control/PropertyPage.cpp
@@ -3,6 +3,15 @@
#include "StdAfx.h"
#include "Windows/Control/PropertyPage.h"
+#include "../../Common/Vector.h"
+#ifndef _UNICODE
+#include "../../Common/StringConvert.h"
+#endif
+
+extern HINSTANCE g_hInstance;
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
namespace NWindows {
namespace NControl {
@@ -55,5 +64,102 @@ bool CPropertyPage::OnNotify(UINT controlID, LPNMHDR lParam)
return true;
}
+int MyPropertySheet(const CObjectVector<CPageInfo> &pagesInfo, HWND hwndParent, const UString &title)
+{
+ #ifndef _UNICODE
+ AStringVector titles;
+ #endif
+ #ifndef _UNICODE
+ CRecordVector<PROPSHEETPAGEA> pagesA;
+ #endif
+ CRecordVector<PROPSHEETPAGEW> pagesW;
+
+ int i;
+ #ifndef _UNICODE
+ for (i = 0; i < pagesInfo.Size(); i++)
+ titles.Add(GetSystemString(pagesInfo[i].Title));
+ #endif
+
+ for (i = 0; i < pagesInfo.Size(); i++)
+ {
+ const CPageInfo &pageInfo = pagesInfo[i];
+ #ifndef _UNICODE
+ {
+ PROPSHEETPAGE page;
+ page.dwSize = sizeof(page);
+ page.dwFlags = PSP_HASHELP;
+ page.hInstance = g_hInstance;
+ page.pszTemplate = MAKEINTRESOURCE(pageInfo.ID);
+ page.pszIcon = NULL;
+ page.pfnDlgProc = NWindows::NControl::ProperyPageProcedure;
+
+ if (titles[i].IsEmpty())
+ page.pszTitle = NULL;
+ else
+ {
+ page.dwFlags |= PSP_USETITLE;
+ page.pszTitle = titles[i];
+ }
+ page.lParam = (LPARAM)pageInfo.Page;
+ page.pfnCallback = NULL;
+ pagesA.Add(page);
+ }
+ #endif
+ {
+ PROPSHEETPAGEW page;
+ page.dwSize = sizeof(page);
+ page.dwFlags = PSP_HASHELP;
+ page.hInstance = g_hInstance;
+ page.pszTemplate = MAKEINTRESOURCEW(pageInfo.ID);
+ page.pszIcon = NULL;
+ page.pfnDlgProc = NWindows::NControl::ProperyPageProcedure;
+
+ if (pageInfo.Title.IsEmpty())
+ page.pszTitle = NULL;
+ else
+ {
+ page.dwFlags |= PSP_USETITLE;
+ page.pszTitle = pageInfo.Title;
+ }
+ page.lParam = (LPARAM)pageInfo.Page;
+ page.pfnCallback = NULL;
+ pagesW.Add(page);
+ }
+ }
+
+ int res;
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ PROPSHEETHEADER sheet;
+ sheet.dwSize = sizeof(sheet);
+ sheet.dwFlags = PSH_PROPSHEETPAGE;
+ sheet.hwndParent = hwndParent;
+ sheet.hInstance = g_hInstance;
+ AString titleA = GetSystemString(title);
+ sheet.pszCaption = titleA;
+ sheet.nPages = pagesInfo.Size();
+ sheet.nStartPage = 0;
+ sheet.ppsp = &pagesA.Front();
+ sheet.pfnCallback = NULL;
+ res = ::PropertySheetA(&sheet);
+ }
+ else
+ #endif
+ {
+ PROPSHEETHEADERW sheet;
+ sheet.dwSize = sizeof(sheet);
+ sheet.dwFlags = PSH_PROPSHEETPAGE;
+ sheet.hwndParent = hwndParent;
+ sheet.hInstance = g_hInstance;
+ sheet.pszCaption = title;
+ sheet.nPages = pagesInfo.Size();
+ sheet.nStartPage = 0;
+ sheet.ppsp = &pagesW.Front();
+ sheet.pfnCallback = NULL;
+ res = ::PropertySheetW(&sheet);
+ }
+ return res;
+}
}}
diff --git a/Windows/Control/PropertyPage.h b/Windows/Control/PropertyPage.h
index aec613df..a80d04d0 100755
--- a/Windows/Control/PropertyPage.h
+++ b/Windows/Control/PropertyPage.h
@@ -33,6 +33,14 @@ public:
virtual void OnReset(const PSHNOTIFY *aPSHNOTIFY) { OnReset(); }
};
+struct CPageInfo
+{
+ CPropertyPage *Page;
+ UString Title;
+ UINT ID;
+};
+
+int MyPropertySheet(const CObjectVector<CPageInfo> &pagesInfo, HWND hwndParent, const UString &title);
}}
diff --git a/Windows/Control/StatusBar.h b/Windows/Control/StatusBar.h
index e9527192..8adf1c05 100755
--- a/Windows/Control/StatusBar.h
+++ b/Windows/Control/StatusBar.h
@@ -18,12 +18,24 @@ public:
{ return BOOLToBool(SendMessage(SB_SETPARTS, numParts, (LPARAM)edgePostions)); }
bool SetText(LPCTSTR text)
{ return CWindow::SetText(text); }
+
bool SetText(int index, LPCTSTR text, UINT type)
{ return BOOLToBool(SendMessage(SB_SETTEXT, index | type, (LPARAM)text)); }
bool SetText(int index, LPCTSTR text)
{ return SetText(index, text, 0); }
void Simple(bool simple)
{ SendMessage(SB_SIMPLE, BoolToBOOL(simple), 0); }
+
+ #ifndef _UNICODE
+ bool Create(LONG style, LPCWSTR text, HWND hwndParent, UINT id)
+ { return (_window = ::CreateStatusWindowW(style, text, hwndParent, id)) != 0; }
+ bool SetText(LPCWSTR text)
+ { return CWindow::SetText(text); }
+ bool SetText(int index, LPCWSTR text, UINT type)
+ { return BOOLToBool(SendMessage(SB_SETTEXTW, index | type, (LPARAM)text)); }
+ bool SetText(int index, LPCWSTR text)
+ { return SetText(index, text, 0); }
+ #endif
};
}}
diff --git a/Windows/Control/ToolBar.h b/Windows/Control/ToolBar.h
index 169e2dd2..8c5e95f9 100755
--- a/Windows/Control/ToolBar.h
+++ b/Windows/Control/ToolBar.h
@@ -23,6 +23,10 @@ public:
{ return HIMAGELIST(SendMessage(TB_SETIMAGELIST, listIndex, (LPARAM)imageList)); }
bool AddButton(UINT numButtons, LPTBBUTTON buttons)
{ return BOOLToBool(SendMessage(TB_ADDBUTTONS, numButtons, (LPARAM)buttons)); }
+ #ifndef _UNICODE
+ bool AddButtonW(UINT numButtons, LPTBBUTTON buttons)
+ { return BOOLToBool(SendMessage(TB_ADDBUTTONSW, numButtons, (LPARAM)buttons)); }
+ #endif
};
}}
diff --git a/Windows/Control/Window2.cpp b/Windows/Control/Window2.cpp
index 2fe9019f..8da2a0b3 100755
--- a/Windows/Control/Window2.cpp
+++ b/Windows/Control/Window2.cpp
@@ -2,11 +2,22 @@
#include "StdAfx.h"
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
#include "Windows/Control/Window2.h"
// extern HINSTANCE g_hInstance;
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
namespace NWindows {
+
+#ifndef _UNICODE
+ATOM MyRegisterClass(CONST WNDCLASSW *wndClass);
+#endif
+
namespace NControl {
static LRESULT CALLBACK WindowProcedure(HWND aHWND, UINT message,
@@ -17,12 +28,17 @@ static LRESULT CALLBACK WindowProcedure(HWND aHWND, UINT message,
tempWindow.SetUserDataLongPtr(
LONG_PTR(((LPCREATESTRUCT)lParam)->lpCreateParams));
CWindow2 *window = (CWindow2*)(tempWindow.GetUserDataLongPtr());
- if (window == NULL)
- return DefWindowProc(aHWND, message, wParam, lParam);
- if (message == WM_NCCREATE)
+ if (window != NULL && message == WM_NCCREATE)
window->Attach(aHWND);
if (window == 0)
- return DefWindowProc(aHWND, message, wParam, lParam);
+ {
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return DefWindowProcW(aHWND, message, wParam, lParam);
+ else
+ #endif
+ return DefWindowProc(aHWND, message, wParam, lParam);
+ }
return window->OnMessage(message, wParam, lParam);
}
@@ -55,6 +71,68 @@ bool CWindow2::CreateEx(DWORD exStyle, LPCTSTR className,
idOrHMenu, instance, this);
}
+#ifndef _UNICODE
+
+bool CWindow2::CreateEx(DWORD exStyle, LPCWSTR className,
+ LPCWSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance)
+{
+ bool needRegister;
+ if(g_IsNT)
+ {
+ WNDCLASSW windowClass;
+ needRegister = ::GetClassInfoW(instance, className, &windowClass) == 0;
+ }
+ else
+ {
+ WNDCLASSA windowClassA;
+ AString classNameA;
+ LPCSTR classNameP;
+ if (IS_INTRESOURCE(className))
+ classNameP = (LPCSTR)className;
+ else
+ {
+ classNameA = GetSystemString(className);
+ classNameP = classNameA;
+ }
+ needRegister = ::GetClassInfoA(instance, classNameP, &windowClassA) == 0;
+ }
+ if (needRegister)
+ {
+ WNDCLASSW windowClass;
+ // windowClass.style = CS_HREDRAW | CS_VREDRAW;
+ windowClass.style = 0;
+ windowClass.lpfnWndProc = WindowProcedure;
+ windowClass.cbClsExtra = NULL;
+ windowClass.cbWndExtra = NULL;
+ windowClass.hInstance = instance;
+ windowClass.hIcon = NULL;
+ windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+ windowClass.lpszMenuName = NULL;
+ windowClass.lpszClassName = className;
+ if (MyRegisterClass(&windowClass) == 0)
+ return false;
+ }
+ return CWindow::CreateEx(exStyle, className, windowName,
+ style, x, y, width, height, parentWindow,
+ idOrHMenu, instance, this);
+
+}
+#endif
+
+LRESULT CWindow2::DefProc(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return DefWindowProcW(_window, message, wParam, lParam);
+ else
+ #endif
+ return DefWindowProc(_window, message, wParam, lParam);
+}
+
LRESULT CWindow2::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT result;
diff --git a/Windows/Control/Window2.h b/Windows/Control/Window2.h
index 8c9a9274..e7df5bb8 100755
--- a/Windows/Control/Window2.h
+++ b/Windows/Control/Window2.h
@@ -11,12 +11,11 @@ namespace NControl {
class CWindow2: public CWindow
{
+ LRESULT DefProc(UINT message, WPARAM wParam, LPARAM lParam);
public:
CWindow2(HWND newWindow = NULL): CWindow(newWindow){};
virtual ~CWindow2() {};
- LRESULT DefProc(UINT message, WPARAM wParam, LPARAM lParam)
- { return ::DefWindowProc(_window, message, wParam, lParam); }
bool CreateEx(DWORD exStyle, LPCTSTR className,
LPCTSTR windowName, DWORD style,
@@ -24,6 +23,14 @@ public:
HWND parentWindow, HMENU idOrHMenu,
HINSTANCE instance);
+ #ifndef _UNICODE
+ bool CreateEx(DWORD exStyle, LPCWSTR className,
+ LPCWSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance);
+ #endif
+
virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
virtual bool OnCreate(CREATESTRUCT *createStruct) { return true; }
// virtual LRESULT OnCommand(WPARAM wParam, LPARAM lParam);
diff --git a/Windows/DLL.cpp b/Windows/DLL.cpp
index cd02eef6..9e92dc26 100755
--- a/Windows/DLL.cpp
+++ b/Windows/DLL.cpp
@@ -8,6 +8,10 @@
#include "../Common/StringConvert.h"
#endif
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
namespace NWindows {
namespace NDLL {
@@ -54,25 +58,21 @@ bool CLibrary::Load(LPCTSTR fileName)
}
#ifndef _UNICODE
-static inline UINT GetCurrentCodePage()
- { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+CSysString GetSysPath(LPCWSTR sysPath)
+ { return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
+
bool CLibrary::LoadEx(LPCWSTR fileName, DWORD flags)
{
- HMODULE module = ::LoadLibraryExW(fileName, NULL, flags);
- if (module != 0)
- return LoadOperations(module);
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
- return LoadEx(UnicodeStringToMultiByte(fileName, GetCurrentCodePage()), flags);
+ if (g_IsNT)
+ return LoadOperations(::LoadLibraryExW(fileName, NULL, flags));
+ return LoadEx(GetSysPath(fileName), flags);
}
bool CLibrary::Load(LPCWSTR fileName)
{
- HMODULE module = ::LoadLibraryW(fileName);
- if (module != 0)
- return LoadOperations(module);
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
- return Load(UnicodeStringToMultiByte(fileName, GetCurrentCodePage()));
+ if (g_IsNT)
+ return LoadOperations(::LoadLibraryW(fileName));
+ return Load(GetSysPath(fileName));
}
#endif
@@ -93,15 +93,17 @@ bool MyGetModuleFileName(HMODULE hModule, CSysString &result)
bool MyGetModuleFileName(HMODULE hModule, UString &result)
{
result.Empty();
- wchar_t fullPath[MAX_PATH + 2];
- DWORD size = ::GetModuleFileNameW(hModule, fullPath, MAX_PATH + 1);
- if (size <= MAX_PATH && size != 0)
+ if (g_IsNT)
{
- result = fullPath;
- return true;
- }
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
+ wchar_t fullPath[MAX_PATH + 2];
+ DWORD size = ::GetModuleFileNameW(hModule, fullPath, MAX_PATH + 1);
+ if (size <= MAX_PATH && size != 0)
+ {
+ result = fullPath;
+ return true;
+ }
return false;
+ }
CSysString resultSys;
if (!MyGetModuleFileName(hModule, resultSys))
return false;
diff --git a/Windows/Error.cpp b/Windows/Error.cpp
index 5852d650..e559c4cc 100755
--- a/Windows/Error.cpp
+++ b/Windows/Error.cpp
@@ -7,6 +7,10 @@
#include "Common/StringConvert.h"
#endif
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
namespace NWindows {
namespace NError {
@@ -14,16 +18,9 @@ bool MyFormatMessage(DWORD messageID, CSysString &message)
{
LPVOID msgBuf;
if(::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- messageID,
- 0, // Default language
- (LPTSTR) &msgBuf,
- 0,
- NULL) == 0)
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,messageID, 0, (LPTSTR) &msgBuf,0, NULL) == 0)
return false;
-
message = (LPCTSTR)msgBuf;
::LocalFree(msgBuf);
return true;
@@ -32,27 +29,21 @@ bool MyFormatMessage(DWORD messageID, CSysString &message)
#ifndef _UNICODE
bool MyFormatMessage(DWORD messageID, UString &message)
{
- LPVOID msgBuf;
- if(::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- messageID,
- 0, // Default language
- (LPWSTR) &msgBuf,
- 0,
- NULL) == 0)
+ if (g_IsNT)
{
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
+ LPVOID msgBuf;
+ if(::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, messageID, 0, (LPWSTR) &msgBuf, 0, NULL) == 0)
return false;
- CSysString messageSys;
- bool result = MyFormatMessage(messageID, messageSys);
- message = GetUnicodeString(messageSys);
- return result;
+ message = (LPCWSTR)msgBuf;
+ ::LocalFree(msgBuf);
+ return true;
}
- message = (LPCWSTR)msgBuf;
- ::LocalFree(msgBuf);
- return true;
+ CSysString messageSys;
+ bool result = MyFormatMessage(messageID, messageSys);
+ message = GetUnicodeString(messageSys);
+ return result;
}
#endif
diff --git a/Windows/FileDevice.cpp b/Windows/FileDevice.cpp
new file mode 100755
index 00000000..76f1aa7a
--- /dev/null
+++ b/Windows/FileDevice.cpp
@@ -0,0 +1,49 @@
+// Windows/FileDevice.cpp
+
+#include "StdAfx.h"
+
+#include "FileDevice.h"
+
+namespace NWindows {
+namespace NFile {
+namespace NDevice {
+
+bool CFileBase::GetLengthSmart(UInt64 &length)
+{
+ PARTITION_INFORMATION partInfo;
+ if (GetPartitionInfo(&partInfo))
+ {
+ length = partInfo.PartitionLength.QuadPart;
+ return true;
+ }
+ DISK_GEOMETRY geom;
+ if (!GetGeometry(&geom))
+ if (!GetCdRomGeometry(&geom))
+ return false;
+ length = geom.Cylinders.QuadPart * geom.TracksPerCylinder * geom.SectorsPerTrack * geom.BytesPerSector;
+ return true;
+}
+
+bool CInFile::Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
+ { return Create(fileName, GENERIC_READ, shareMode, creationDisposition, flagsAndAttributes); }
+
+bool CInFile::Open(LPCTSTR fileName)
+ { return Open(fileName, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); }
+
+#ifndef _UNICODE
+bool CInFile::Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
+ { return Create(fileName, GENERIC_READ, shareMode, creationDisposition, flagsAndAttributes); }
+
+bool CInFile::Open(LPCWSTR fileName)
+ { return Open(fileName, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); }
+#endif
+
+bool CInFile::Read(void *data, UInt32 size, UInt32 &processedSize)
+{
+ DWORD processedLoc = 0;
+ bool res = BOOLToBool(::ReadFile(_handle, data, size, &processedLoc, NULL));
+ processedSize = (UInt32)processedLoc;
+ return res;
+}
+
+}}}
diff --git a/Windows/FileDevice.h b/Windows/FileDevice.h
new file mode 100755
index 00000000..659a9697
--- /dev/null
+++ b/Windows/FileDevice.h
@@ -0,0 +1,119 @@
+// Windows/FileDevice.h
+
+#ifndef __WINDOWS_FILEDEVICE_H
+#define __WINDOWS_FILEDEVICE_H
+
+#include "FileIO.h"
+#include "Defs.h"
+
+namespace NWindows {
+namespace NFile {
+namespace NDevice {
+
+typedef struct _GET_LENGTH_INFORMATION
+{
+ LARGE_INTEGER Length;
+} GET_LENGTH_INFORMATION, *PGET_LENGTH_INFORMATION;
+
+#define IOCTL_DISK_GET_LENGTH_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0017, METHOD_BUFFERED, FILE_READ_ACCESS)
+
+/*
+typedef struct _DISK_GEOMETRY_EX {
+ DISK_GEOMETRY Geometry; // Standard disk geometry: may be faked by driver.
+ LARGE_INTEGER DiskSize; // Must always be correct
+ BYTE Data[1]; // Partition, Detect info
+} DISK_GEOMETRY_EX, *PDISK_GEOMETRY_EX;
+*/
+
+#define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM
+#define IOCTL_CDROM_GET_DRIVE_GEOMETRY CTL_CODE(IOCTL_CDROM_BASE, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS)
+#define IOCTL_CDROM_MEDIA_REMOVAL CTL_CODE(IOCTL_CDROM_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
+
+class CFileBase: public NIO::CFileBase
+{
+public:
+ bool DeviceIoControl(DWORD controlCode, LPVOID inBuffer, DWORD inSize,
+ LPVOID outBuffer, DWORD outSize, LPDWORD bytesReturned, LPOVERLAPPED overlapped) const
+ {
+ return BOOLToBool(::DeviceIoControl(_handle, controlCode, inBuffer, inSize,
+ outBuffer, outSize, bytesReturned, overlapped));
+ }
+
+ bool DeviceIoControl(DWORD controlCode, LPVOID inBuffer,
+ DWORD inSize, LPVOID outBuffer, DWORD outSize) const
+ {
+ DWORD ret;
+ return DeviceIoControl(controlCode, inBuffer, inSize, outBuffer, outSize, &ret, 0);
+ }
+
+ bool DeviceIoControlIn(DWORD controlCode, LPVOID inBuffer, DWORD inSize) const
+ { return DeviceIoControl(controlCode, inBuffer, inSize, NULL, 0); }
+
+ bool DeviceIoControlOut(DWORD controlCode, LPVOID outBuffer, DWORD outSize) const
+ { return DeviceIoControl(controlCode, NULL, 0, outBuffer, outSize); }
+
+ bool GetGeometry(DISK_GEOMETRY *res) const
+ { return DeviceIoControlOut(IOCTL_DISK_GET_DRIVE_GEOMETRY, res, sizeof(*res)); }
+
+ bool GetCdRomGeometry(DISK_GEOMETRY *res) const
+ { return DeviceIoControlOut(IOCTL_CDROM_GET_DRIVE_GEOMETRY, res, sizeof(*res)); }
+
+ /*
+ bool GetCdRomGeometryEx(DISK_GEOMETRY_EX *res) const
+ { return DeviceIoControlOut(IOCTL_CDROM_GET_DRIVE_GEOMETRY, res, sizeof(*res)); }
+ */
+
+ bool CdRomLock(bool lock) const
+ {
+ PREVENT_MEDIA_REMOVAL rem;
+ rem.PreventMediaRemoval = BoolToBOOL(lock);
+ return DeviceIoControlIn(IOCTL_CDROM_MEDIA_REMOVAL, &rem, sizeof(rem));
+ }
+
+ bool GetLengthInfo(UInt64 &length) const
+ {
+ GET_LENGTH_INFORMATION lengthInfo;
+ bool res = DeviceIoControlOut(IOCTL_DISK_GET_LENGTH_INFO, &lengthInfo, sizeof(lengthInfo));
+ length = lengthInfo.Length.QuadPart;
+ return res;
+ }
+
+ bool GetLengthSmart(UInt64 &length);
+
+
+ bool FormatTracks(const FORMAT_PARAMETERS *formatParams,
+ BAD_TRACK_NUMBER *badTrackNumbers, DWORD numBadTrackNumbers,
+ DWORD &numBadTrackNumbersReturned)
+ {
+ DWORD ret;
+ bool res = DeviceIoControl(IOCTL_DISK_FORMAT_TRACKS, badTrackNumbers, sizeof(*formatParams),
+ badTrackNumbers, numBadTrackNumbers * sizeof(*badTrackNumbers), &ret, NULL);
+ numBadTrackNumbersReturned = ret / sizeof(*badTrackNumbers);
+ return res;
+ }
+
+ bool Performance(DISK_PERFORMANCE *res)
+ { return DeviceIoControlOut(IOCTL_DISK_PERFORMANCE, LPVOID(res), sizeof(*res)); }
+
+ bool GetPartitionInfo(PARTITION_INFORMATION *res)
+ { return DeviceIoControlOut(IOCTL_DISK_GET_PARTITION_INFO, LPVOID(res), sizeof(*res)); }
+
+ bool Verify(const VERIFY_INFORMATION *verifyInformation)
+ { return DeviceIoControlIn(IOCTL_DISK_VERIFY, LPVOID(verifyInformation), sizeof(*verifyInformation)); }
+};
+
+class CInFile: public CFileBase
+{
+public:
+ bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
+ bool Open(LPCTSTR fileName);
+ #ifndef _UNICODE
+ bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
+ bool Open(LPCWSTR fileName);
+ #endif
+ bool Read(void *data, UInt32 size, UInt32 &processedSize);
+};
+
+}}}
+
+#endif
diff --git a/Windows/FileDir.cpp b/Windows/FileDir.cpp
index f7925604..3d0430c6 100755
--- a/Windows/FileDir.cpp
+++ b/Windows/FileDir.cpp
@@ -10,25 +10,32 @@
#include "../Common/StringConvert.h"
#endif
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
namespace NWindows {
namespace NFile {
namespace NDirectory {
#ifndef _UNICODE
-static inline UINT GetCurrentCodePage()
- { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+static UString GetUnicodePath(const CSysString &sysPath)
+ { return MultiByteToUnicodeString(sysPath, GetCurrentCodePage()); }
+static CSysString GetSysPath(LPCWSTR sysPath)
+ { return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
#endif
bool MyGetWindowsDirectory(CSysString &path)
{
- DWORD needLength = ::GetWindowsDirectory(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
+ UINT needLength = ::GetWindowsDirectory(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
path.ReleaseBuffer();
return (needLength > 0 && needLength <= MAX_PATH);
}
bool MyGetSystemDirectory(CSysString &path)
{
- DWORD needLength = ::GetSystemDirectory(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
+ UINT needLength = ::GetSystemDirectory(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
path.ReleaseBuffer();
return (needLength > 0 && needLength <= MAX_PATH);
}
@@ -36,31 +43,31 @@ bool MyGetSystemDirectory(CSysString &path)
#ifndef _UNICODE
bool MyGetWindowsDirectory(UString &path)
{
- DWORD needLength = ::GetWindowsDirectoryW(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
- path.ReleaseBuffer();
- if (needLength != 0)
- return (needLength <= MAX_PATH);
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
+ if (g_IsNT)
+ {
+ UINT needLength = ::GetWindowsDirectoryW(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
+ path.ReleaseBuffer();
+ return (needLength > 0 && needLength <= MAX_PATH);
+ }
CSysString sysPath;
if (!MyGetWindowsDirectory(sysPath))
return false;
- path = MultiByteToUnicodeString(sysPath, GetCurrentCodePage());
+ path = GetUnicodePath(sysPath);
return true;
}
bool MyGetSystemDirectory(UString &path)
{
- DWORD needLength = ::GetSystemDirectoryW(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
- path.ReleaseBuffer();
- if (needLength != 0)
- return (needLength <= MAX_PATH);
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
+ if (g_IsNT)
+ {
+ UINT needLength = ::GetSystemDirectoryW(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
+ path.ReleaseBuffer();
+ return (needLength > 0 && needLength <= MAX_PATH);
+ }
CSysString sysPath;
if (!MyGetSystemDirectory(sysPath))
return false;
- path = MultiByteToUnicodeString(sysPath, GetCurrentCodePage());
+ path = GetUnicodePath(sysPath);
return true;
}
#endif
@@ -68,50 +75,34 @@ bool MyGetSystemDirectory(UString &path)
#ifndef _UNICODE
bool MySetFileAttributes(LPCWSTR fileName, DWORD fileAttributes)
{
- if (::SetFileAttributesW(fileName, fileAttributes))
- return true;
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
- return MySetFileAttributes(UnicodeStringToMultiByte(fileName,
- GetCurrentCodePage()), fileAttributes);
+ if (g_IsNT)
+ return BOOLToBool(::SetFileAttributesW(fileName, fileAttributes));
+ return MySetFileAttributes(GetSysPath(fileName), fileAttributes);
}
bool MyRemoveDirectory(LPCWSTR pathName)
{
- if (::RemoveDirectoryW(pathName))
- return true;
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
- return MyRemoveDirectory(UnicodeStringToMultiByte(pathName,
- GetCurrentCodePage()));
+ if (g_IsNT)
+ return BOOLToBool(::RemoveDirectoryW(pathName));
+ return MyRemoveDirectory(GetSysPath(pathName));
}
bool MyMoveFile(LPCWSTR existFileName, LPCWSTR newFileName)
{
- if (::MoveFileW(existFileName, newFileName))
- return true;
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
- UINT codePage = GetCurrentCodePage();
- return MyMoveFile(UnicodeStringToMultiByte(existFileName, codePage),
- UnicodeStringToMultiByte(newFileName, codePage));
+ if (g_IsNT)
+ return BOOLToBool(::MoveFileW(existFileName, newFileName));
+ return MyMoveFile(GetSysPath(existFileName), GetSysPath(newFileName));
}
#endif
-bool MyCreateDirectory(LPCTSTR pathName)
-{
- return BOOLToBool(::CreateDirectory(pathName, NULL));
-}
+bool MyCreateDirectory(LPCTSTR pathName) { return BOOLToBool(::CreateDirectory(pathName, NULL)); }
#ifndef _UNICODE
bool MyCreateDirectory(LPCWSTR pathName)
{
- if (::CreateDirectoryW(pathName, NULL))
- return true;
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
- return MyCreateDirectory(UnicodeStringToMultiByte(pathName,
- GetCurrentCodePage()));
+ if (g_IsNT)
+ return BOOLToBool(::CreateDirectoryW(pathName, NULL));
+ return MyCreateDirectory(GetSysPath(pathName));
}
#endif
@@ -246,19 +237,17 @@ bool DeleteFileAlways(LPCTSTR name)
#ifndef _UNICODE
bool DeleteFileAlways(LPCWSTR name)
{
- if(!MySetFileAttributes(name, 0))
- return false;
- if (::DeleteFileW(name))
- return true;
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
- return DeleteFileAlways(UnicodeStringToMultiByte(name,
- GetCurrentCodePage()));
+ if (g_IsNT)
+ {
+ if(!MySetFileAttributes(name, 0))
+ return false;
+ return BOOLToBool(::DeleteFileW(name));
+ }
+ return DeleteFileAlways(GetSysPath(name));
}
#endif
-static bool RemoveDirectorySubItems2(const CSysString pathPrefix,
- const NFind::CFileInfo &fileInfo)
+static bool RemoveDirectorySubItems2(const CSysString pathPrefix, const NFind::CFileInfo &fileInfo)
{
if(fileInfo.IsDirectory())
return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name);
@@ -282,8 +271,7 @@ bool RemoveDirectoryWithSubItems(const CSysString &path)
}
#ifndef _UNICODE
-static bool RemoveDirectorySubItems2(const UString pathPrefix,
- const NFind::CFileInfoW &fileInfo)
+static bool RemoveDirectorySubItems2(const UString pathPrefix, const NFind::CFileInfoW &fileInfo)
{
if(fileInfo.IsDirectory())
return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name);
@@ -310,21 +298,17 @@ bool RemoveDirectoryWithSubItems(const UString &path)
bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath)
{
- DWORD needLength = ::GetShortPathName(longPath,
- shortPath.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
+ DWORD needLength = ::GetShortPathName(longPath, shortPath.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
shortPath.ReleaseBuffer();
- if (needLength == 0 || needLength >= MAX_PATH)
- return false;
- return true;
+ return (needLength > 0 && needLength < MAX_PATH);
}
-bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath,
- int &fileNamePartStartIndex)
+bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath, int &fileNamePartStartIndex)
{
+ resultPath.Empty();
LPTSTR fileNamePointer = 0;
LPTSTR buffer = resultPath.GetBuffer(MAX_PATH);
- DWORD needLength = ::GetFullPathName(fileName, MAX_PATH + 1,
- buffer, &fileNamePointer);
+ DWORD needLength = ::GetFullPathName(fileName, MAX_PATH + 1, buffer, &fileNamePointer);
resultPath.ReleaseBuffer();
if (needLength == 0 || needLength >= MAX_PATH)
return false;
@@ -336,39 +320,32 @@ bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath,
}
#ifndef _UNICODE
-bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath,
- int &fileNamePartStartIndex)
+bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath, int &fileNamePartStartIndex)
{
resultPath.Empty();
- LPWSTR fileNamePointer = 0;
- LPWSTR buffer = resultPath.GetBuffer(MAX_PATH);
- DWORD needLength = ::GetFullPathNameW(fileName, MAX_PATH + 1,
- buffer, &fileNamePointer);
- resultPath.ReleaseBuffer();
- if (needLength == 0)
+ if (g_IsNT)
{
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
+ LPWSTR fileNamePointer = 0;
+ LPWSTR buffer = resultPath.GetBuffer(MAX_PATH);
+ DWORD needLength = ::GetFullPathNameW(fileName, MAX_PATH + 1, buffer, &fileNamePointer);
+ resultPath.ReleaseBuffer();
+ if (needLength == 0 || needLength >= MAX_PATH)
return false;
-
- const UINT currentPage = GetCurrentCodePage();
+ if (fileNamePointer == 0)
+ fileNamePartStartIndex = MyStringLen(fileName);
+ else
+ fileNamePartStartIndex = (int)(fileNamePointer - buffer);
+ }
+ else
+ {
CSysString sysPath;
- if (!MyGetFullPathName(UnicodeStringToMultiByte(fileName,
- currentPage), sysPath, fileNamePartStartIndex))
+ if (!MyGetFullPathName(GetSysPath(fileName), sysPath, fileNamePartStartIndex))
return false;
- UString resultPath1 = MultiByteToUnicodeString(
- sysPath.Left(fileNamePartStartIndex), currentPage);
- UString resultPath2 = MultiByteToUnicodeString(
- sysPath.Mid(fileNamePartStartIndex), currentPage);
+ UString resultPath1 = GetUnicodePath(sysPath.Left(fileNamePartStartIndex));
+ UString resultPath2 = GetUnicodePath(sysPath.Mid(fileNamePartStartIndex));
fileNamePartStartIndex = resultPath1.Length();
resultPath = resultPath1 + resultPath2;
- return true;
}
- else if (needLength >= MAX_PATH)
- return false;
- if (fileNamePointer == 0)
- fileNamePartStartIndex = MyStringLen(fileName);
- else
- fileNamePartStartIndex = fileNamePointer - buffer;
return true;
}
#endif
@@ -430,8 +407,7 @@ bool GetOnlyDirPrefix(LPCWSTR fileName, UString &resultName)
bool MyGetCurrentDirectory(CSysString &path)
{
- DWORD needLength = ::GetCurrentDirectory(MAX_PATH + 1,
- path.GetBuffer(MAX_PATH + 1));
+ DWORD needLength = ::GetCurrentDirectory(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
path.ReleaseBuffer();
return (needLength > 0 && needLength <= MAX_PATH);
}
@@ -439,26 +415,22 @@ bool MyGetCurrentDirectory(CSysString &path)
#ifndef _UNICODE
bool MySetCurrentDirectory(LPCWSTR path)
{
- if (::SetCurrentDirectoryW(path))
- return true;
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
- return MySetCurrentDirectory(UnicodeStringToMultiByte(path,
- GetCurrentCodePage()));
+ if (g_IsNT)
+ return BOOLToBool(::SetCurrentDirectoryW(path));
+ return MySetCurrentDirectory(GetSysPath(path));
}
bool MyGetCurrentDirectory(UString &path)
{
- DWORD needLength = ::GetCurrentDirectoryW(MAX_PATH + 1,
- path.GetBuffer(MAX_PATH + 1));
- path.ReleaseBuffer();
- if (needLength != 0)
- return (needLength <= MAX_PATH);
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
+ if (g_IsNT)
+ {
+ DWORD needLength = ::GetCurrentDirectoryW(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
+ path.ReleaseBuffer();
+ return (needLength > 0 && needLength <= MAX_PATH);
+ }
CSysString sysPath;
if (!MyGetCurrentDirectory(sysPath))
return false;
- path = MultiByteToUnicodeString(sysPath, GetCurrentCodePage());
+ path = GetUnicodePath(sysPath);
return true;
}
#endif
@@ -469,39 +441,35 @@ bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
{
LPTSTR filePartPointer;
DWORD value = ::SearchPath(path, fileName, extension,
- MAX_PATH, resultPath.GetBuffer(MAX_PATH), &filePartPointer);
+ MAX_PATH, resultPath.GetBuffer(MAX_PATH + 1), &filePartPointer);
filePart = (UINT32)(filePartPointer - (LPCTSTR)resultPath);
resultPath.ReleaseBuffer();
- if (value == 0 || value > MAX_PATH)
- return false;
- return true;
+ return (value > 0 && value <= MAX_PATH);
}
#ifndef _UNICODE
bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
UString &resultPath, UINT32 &filePart)
{
- LPWSTR filePartPointer = 0;
- DWORD value = ::SearchPathW(path, fileName, extension,
- MAX_PATH, resultPath.GetBuffer(MAX_PATH), &filePartPointer);
- resultPath.ReleaseBuffer();
- if (value != 0)
- return (value <= MAX_PATH);
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
+ if (g_IsNT)
+ {
+ LPWSTR filePartPointer = 0;
+ DWORD value = ::SearchPathW(path, fileName, extension,
+ MAX_PATH, resultPath.GetBuffer(MAX_PATH + 1), &filePartPointer);
+ filePart = (UINT32)(filePartPointer - (LPCWSTR)resultPath);
+ resultPath.ReleaseBuffer();
+ return (value > 0 && value <= MAX_PATH);
+ }
- const UINT currentPage = GetCurrentCodePage();
CSysString sysPath;
if (!MySearchPath(
- path != 0 ? (LPCTSTR)UnicodeStringToMultiByte(path, currentPage): 0,
- fileName != 0 ? (LPCTSTR)UnicodeStringToMultiByte(fileName, currentPage): 0,
- extension != 0 ? (LPCTSTR)UnicodeStringToMultiByte(extension, currentPage): 0,
+ path != 0 ? (LPCTSTR)GetSysPath(path): 0,
+ fileName != 0 ? (LPCTSTR)GetSysPath(fileName): 0,
+ extension != 0 ? (LPCTSTR)GetSysPath(extension): 0,
sysPath, filePart))
return false;
- UString resultPath1 = MultiByteToUnicodeString(
- sysPath.Left(filePart), currentPage);
- UString resultPath2 = MultiByteToUnicodeString(
- sysPath.Mid(filePart), currentPage);
+ UString resultPath1 = GetUnicodePath(sysPath.Left(filePart));
+ UString resultPath2 = GetUnicodePath(sysPath.Mid(filePart));
filePart = resultPath1.Length();
resultPath = resultPath1 + resultPath2;
return true;
@@ -510,8 +478,7 @@ bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
bool MyGetTempPath(CSysString &path)
{
- DWORD needLength = ::GetTempPath(MAX_PATH + 1,
- path.GetBuffer(MAX_PATH));
+ DWORD needLength = ::GetTempPath(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
path.ReleaseBuffer();
return (needLength > 0 && needLength <= MAX_PATH);
}
@@ -520,27 +487,23 @@ bool MyGetTempPath(CSysString &path)
bool MyGetTempPath(UString &path)
{
path.Empty();
- DWORD needLength = ::GetTempPathW(MAX_PATH + 1,
- path.GetBuffer(MAX_PATH));
- path.ReleaseBuffer();
- if (needLength == 0)
+ if (g_IsNT)
{
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
- CSysString sysPath;
- if (!MyGetTempPath(sysPath))
- return false;
- path = MultiByteToUnicodeString(sysPath, GetCurrentCodePage());
- return true;
+ DWORD needLength = ::GetTempPathW(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
+ path.ReleaseBuffer();
+ return (needLength > 0 && needLength <= MAX_PATH);
}
- return (needLength > 0 && needLength <= MAX_PATH);
+ CSysString sysPath;
+ if (!MyGetTempPath(sysPath))
+ return false;
+ path = GetUnicodePath(sysPath);
+ return true;
}
#endif
UINT MyGetTempFileName(LPCTSTR dirPath, LPCTSTR prefix, CSysString &path)
{
- UINT number = ::GetTempFileName(dirPath, prefix, 0,
- path.GetBuffer(MAX_PATH));
+ UINT number = ::GetTempFileName(dirPath, prefix, 0, path.GetBuffer(MAX_PATH + 1));
path.ReleaseBuffer();
return number;
}
@@ -548,22 +511,18 @@ UINT MyGetTempFileName(LPCTSTR dirPath, LPCTSTR prefix, CSysString &path)
#ifndef _UNICODE
UINT MyGetTempFileName(LPCWSTR dirPath, LPCWSTR prefix, UString &path)
{
- UINT number = ::GetTempFileNameW(dirPath, prefix, 0,
- path.GetBuffer(MAX_PATH));
- path.ReleaseBuffer();
- if (number == 0)
+ if (g_IsNT)
{
- if (::GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
- {
- const UINT currentPage = GetCurrentCodePage();
- CSysString sysPath;
- number = MyGetTempFileName(
- dirPath ? (LPCTSTR)UnicodeStringToMultiByte(dirPath, currentPage): 0,
- prefix ? (LPCTSTR)UnicodeStringToMultiByte(prefix, currentPage): 0,
- sysPath);
- path = MultiByteToUnicodeString(sysPath, currentPage);
- }
+ UINT number = ::GetTempFileNameW(dirPath, prefix, 0, path.GetBuffer(MAX_PATH));
+ path.ReleaseBuffer();
+ return number;
}
+ CSysString sysPath;
+ UINT number = MyGetTempFileName(
+ dirPath ? (LPCTSTR)GetSysPath(dirPath): 0,
+ prefix ? (LPCTSTR)GetSysPath(prefix): 0,
+ sysPath);
+ path = GetUnicodePath(sysPath);
return number;
}
#endif
diff --git a/Windows/FileFind.cpp b/Windows/FileFind.cpp
index 36694593..ebf494bd 100755
--- a/Windows/FileFind.cpp
+++ b/Windows/FileFind.cpp
@@ -7,6 +7,10 @@
#include "../Common/StringConvert.h"
#endif
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
namespace NWindows {
namespace NFile {
namespace NFind {
@@ -41,8 +45,7 @@ static void ConvertWIN32_FIND_DATA_To_FileInfo(
fileInfo.CreationTime = findData.ftCreationTime;
fileInfo.LastAccessTime = findData.ftLastAccessTime;
fileInfo.LastWriteTime = findData.ftLastWriteTime;
- fileInfo.Size = (((UINT64)findData.nFileSizeHigh) << 32) +
- findData.nFileSizeLow;
+ fileInfo.Size = (((UInt64)findData.nFileSizeHigh) << 32) + findData.nFileSizeLow;
fileInfo.Name = findData.cFileName;
#ifndef _WIN32_WCE
fileInfo.ReparseTag = findData.dwReserved0;
@@ -53,8 +56,7 @@ static void ConvertWIN32_FIND_DATA_To_FileInfo(
#ifndef _UNICODE
-static inline UINT GetCurrentCodePage()
- { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
static void ConvertWIN32_FIND_DATA_To_FileInfo(
const WIN32_FIND_DATAW &findData,
@@ -64,8 +66,7 @@ static void ConvertWIN32_FIND_DATA_To_FileInfo(
fileInfo.CreationTime = findData.ftCreationTime;
fileInfo.LastAccessTime = findData.ftLastAccessTime;
fileInfo.LastWriteTime = findData.ftLastWriteTime;
- fileInfo.Size = (((UINT64)findData.nFileSizeHigh) << 32) +
- findData.nFileSizeLow;
+ fileInfo.Size = (((UInt64)findData.nFileSizeHigh) << 32) + findData.nFileSizeLow;
fileInfo.Name = findData.cFileName;
#ifndef _WIN32_WCE
fileInfo.ReparseTag = findData.dwReserved0;
@@ -82,8 +83,7 @@ static void ConvertWIN32_FIND_DATA_To_FileInfo(
fileInfo.CreationTime = findData.ftCreationTime;
fileInfo.LastAccessTime = findData.ftLastAccessTime;
fileInfo.LastWriteTime = findData.ftLastWriteTime;
- fileInfo.Size = (((UINT64)findData.nFileSizeHigh) << 32) +
- findData.nFileSizeLow;
+ fileInfo.Size = (((UInt64)findData.nFileSizeHigh) << 32) + findData.nFileSizeLow;
fileInfo.Name = GetUnicodeString(findData.cFileName, GetCurrentCodePage());
#ifndef _WIN32_WCE
fileInfo.ReparseTag = findData.dwReserved0;
@@ -110,8 +110,7 @@ bool CFindFile::FindFirst(LPCTSTR wildcard, CFileInfo &fileInfo)
Close();
WIN32_FIND_DATA findData;
_handle = ::FindFirstFile(wildcard, &findData);
- _handleAllocated = (_handle != INVALID_HANDLE_VALUE);
- if (_handleAllocated)
+ if (_handleAllocated = (_handle != INVALID_HANDLE_VALUE))
ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
return _handleAllocated;
}
@@ -120,24 +119,20 @@ bool CFindFile::FindFirst(LPCTSTR wildcard, CFileInfo &fileInfo)
bool CFindFile::FindFirst(LPCWSTR wildcard, CFileInfoW &fileInfo)
{
Close();
- WIN32_FIND_DATAW findDataW;
- ::SetLastError(0);
- _handle = ::FindFirstFileW(wildcard, &findDataW);
- if ((_handle == INVALID_HANDLE_VALUE || _handle == 0) &&
- ::GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
+ if (g_IsNT)
{
- WIN32_FIND_DATA findData;
- _handle = ::FindFirstFile(UnicodeStringToMultiByte(wildcard,
- GetCurrentCodePage()), &findData);
- _handleAllocated = (_handle != INVALID_HANDLE_VALUE);
- if (_handleAllocated)
+ WIN32_FIND_DATAW findData;
+ _handle = ::FindFirstFileW(wildcard, &findData);
+ if (_handleAllocated = (_handle != INVALID_HANDLE_VALUE))
ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
}
else
{
- _handleAllocated = (_handle != INVALID_HANDLE_VALUE);
- if (_handleAllocated)
- ConvertWIN32_FIND_DATA_To_FileInfo(findDataW, fileInfo);
+ WIN32_FIND_DATAA findData;
+ _handle = ::FindFirstFileA(UnicodeStringToMultiByte(wildcard,
+ GetCurrentCodePage()), &findData);
+ if (_handleAllocated = (_handle != INVALID_HANDLE_VALUE))
+ ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
}
return _handleAllocated;
}
@@ -155,18 +150,20 @@ bool CFindFile::FindNext(CFileInfo &fileInfo)
#ifndef _UNICODE
bool CFindFile::FindNext(CFileInfoW &fileInfo)
{
- WIN32_FIND_DATAW findDataW;
- if (::FindNextFileW(_handle, &findDataW))
+ if (g_IsNT)
{
- ConvertWIN32_FIND_DATA_To_FileInfo(findDataW, fileInfo);
- return true;
+ WIN32_FIND_DATAW findData;
+ if (!::FindNextFileW(_handle, &findData))
+ return false;
+ ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
+ }
+ else
+ {
+ WIN32_FIND_DATAA findData;
+ if (!::FindNextFileA(_handle, &findData))
+ return false;
+ ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
}
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
- WIN32_FIND_DATA findData;
- if (!::FindNextFile(_handle, &findData))
- return false;
- ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
return true;
}
#endif
@@ -290,14 +287,9 @@ HANDLE CFindChangeNotification::FindFirst(LPCTSTR pathName, bool watchSubtree,
HANDLE CFindChangeNotification::FindFirst(LPCWSTR pathName, bool watchSubtree,
DWORD notifyFilter)
{
- ::SetLastError(0);
- _handle = ::FindFirstChangeNotificationW(pathName,
- BoolToBOOL(watchSubtree), notifyFilter);
- if ((_handle == 0 || _handle == INVALID_HANDLE_VALUE) &&
- ::GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
- return FindFirst(UnicodeStringToMultiByte(pathName,
- GetCurrentCodePage()), watchSubtree, notifyFilter);
- return _handle;
+ if (g_IsNT)
+ return (_handle = ::FindFirstChangeNotificationW(pathName, BoolToBOOL(watchSubtree), notifyFilter));
+ return FindFirst(UnicodeStringToMultiByte(pathName, GetCurrentCodePage()), watchSubtree, notifyFilter);
}
#endif
@@ -330,6 +322,44 @@ bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings)
return false;
return true;
}
+
+#ifndef _UNICODE
+bool MyGetLogicalDriveStrings(UStringVector &driveStrings)
+{
+ driveStrings.Clear();
+ if (g_IsNT)
+ {
+ UINT32 size = GetLogicalDriveStringsW(0, NULL);
+ if (size == 0)
+ return false;
+ UString buffer;
+ UINT32 newSize = GetLogicalDriveStringsW(size, buffer.GetBuffer(size));
+ if(newSize == 0)
+ return false;
+ if(newSize > size)
+ return false;
+ UString string;
+ for(UINT32 i = 0; i < newSize; i++)
+ {
+ WCHAR c = buffer[i];
+ if(c == L'\0')
+ {
+ driveStrings.Add(string);
+ string.Empty();
+ }
+ else
+ string += c;
+ }
+ return string.IsEmpty();
+ }
+ CSysStringVector driveStringsA;
+ bool res = MyGetLogicalDriveStrings(driveStringsA);
+ for (int i = 0; i < driveStringsA.Size(); i++)
+ driveStrings.Add(GetUnicodeString(driveStringsA[i]));
+ return res;
+}
+#endif
+
#endif
}}}
diff --git a/Windows/FileFind.h b/Windows/FileFind.h
index d25ac7ce..7da15a14 100755
--- a/Windows/FileFind.h
+++ b/Windows/FileFind.h
@@ -4,6 +4,7 @@
#define __WINDOWS_FILEFIND_H
#include "../Common/String.h"
+#include "../Common/Types.h"
#include "FileName.h"
#include "Defs.h"
@@ -30,7 +31,7 @@ public:
FILETIME CreationTime;
FILETIME LastAccessTime;
FILETIME LastWriteTime;
- UINT64 Size;
+ UInt64 Size;
#ifndef _WIN32_WCE
UINT32 ReparseTag;
@@ -38,7 +39,6 @@ public:
DWORD ObjectID;
#endif
-
bool IsArchived() const { return MatchesMask(FILE_ATTRIBUTE_ARCHIVE); }
bool IsCompressed() const { return MatchesMask(FILE_ATTRIBUTE_COMPRESSED); }
bool IsDirectory() const { return MatchesMask(FILE_ATTRIBUTE_DIRECTORY); }
@@ -51,7 +51,6 @@ public:
bool IsSparse() const { return MatchesMask(FILE_ATTRIBUTE_SPARSE_FILE); }
bool IsSystem() const { return MatchesMask(FILE_ATTRIBUTE_SYSTEM); }
bool IsTemporary() const { return MatchesMask(FILE_ATTRIBUTE_TEMPORARY); }
-
};
class CFileInfo: public CFileInfoBase
@@ -144,27 +143,30 @@ public:
#ifndef _WIN32_WCE
bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings);
+#ifndef _UNICODE
+bool MyGetLogicalDriveStrings(UStringVector &driveStrings);
+#endif
#endif
-inline bool MyGetCompressedFileSize(LPCTSTR fileName, UINT64 &size)
+inline bool MyGetCompressedFileSize(LPCTSTR fileName, UInt64 &size)
{
DWORD highPart;
DWORD lowPart = ::GetCompressedFileSize(fileName, &highPart);
if (lowPart == INVALID_FILE_SIZE)
if (::GetLastError() != NO_ERROR)
return false;
- size = (UINT64(highPart) << 32) | lowPart;
+ size = (UInt64(highPart) << 32) | lowPart;
return true;
}
-inline bool MyGetCompressedFileSizeW(LPCWSTR fileName, UINT64 &size)
+inline bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size)
{
DWORD highPart;
DWORD lowPart = ::GetCompressedFileSizeW(fileName, &highPart);
if (lowPart == INVALID_FILE_SIZE)
if (::GetLastError() != NO_ERROR)
return false;
- size = (UINT64(highPart) << 32) | lowPart;
+ size = (UInt64(highPart) << 32) | lowPart;
return true;
}
diff --git a/Windows/FileIO.cpp b/Windows/FileIO.cpp
index f265f537..203de843 100755
--- a/Windows/FileIO.cpp
+++ b/Windows/FileIO.cpp
@@ -8,14 +8,15 @@
#include "../Common/StringConvert.h"
#endif
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
namespace NWindows {
namespace NFile {
namespace NIO {
-CFileBase::~CFileBase()
-{
- Close();
-}
+CFileBase::~CFileBase() { Close(); }
bool CFileBase::Create(LPCTSTR fileName, DWORD desiredAccess,
DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
@@ -24,25 +25,23 @@ bool CFileBase::Create(LPCTSTR fileName, DWORD desiredAccess,
_handle = ::CreateFile(fileName, desiredAccess, shareMode,
(LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
flagsAndAttributes, (HANDLE) NULL);
- _fileIsOpen = _handle != INVALID_HANDLE_VALUE;
- return _fileIsOpen;
+ return (_fileIsOpen = (_handle != INVALID_HANDLE_VALUE));
}
#ifndef _UNICODE
bool CFileBase::Create(LPCWSTR fileName, DWORD desiredAccess,
DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
{
- Close();
- // MessageBoxW(0, fileName, 0, 0);
- // ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- _handle = ::CreateFileW(fileName, desiredAccess, shareMode,
+ if (g_IsNT)
+ {
+ Close();
+ _handle = ::CreateFileW(fileName, desiredAccess, shareMode,
(LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
flagsAndAttributes, (HANDLE) NULL);
- if ((_handle == INVALID_HANDLE_VALUE || _handle == 0) &&
- ::GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
- return Create(UnicodeStringToMultiByte(fileName, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP),
- desiredAccess, shareMode, creationDisposition, flagsAndAttributes);
- return (_fileIsOpen = _handle != INVALID_HANDLE_VALUE);
+ return (_fileIsOpen = (_handle != INVALID_HANDLE_VALUE));
+ }
+ return Create(UnicodeStringToMultiByte(fileName, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP),
+ desiredAccess, shareMode, creationDisposition, flagsAndAttributes);
}
#endif
@@ -55,46 +54,46 @@ bool CFileBase::Close()
return result;
}
-bool CFileBase::GetPosition(UINT64 &position) const
+bool CFileBase::GetPosition(UInt64 &position) const
{
return Seek(0, FILE_CURRENT, position);
}
-bool CFileBase::GetLength(UINT64 &length) const
+bool CFileBase::GetLength(UInt64 &length) const
{
DWORD sizeHigh;
DWORD sizeLow = ::GetFileSize(_handle, &sizeHigh);
if(sizeLow == 0xFFFFFFFF)
- if(::GetLastError() != NO_ERROR )
+ if(::GetLastError() != NO_ERROR)
return false;
- length = (((UINT64)sizeHigh) << 32) + sizeLow;
+ length = (((UInt64)sizeHigh) << 32) + sizeLow;
return true;
}
-bool CFileBase::Seek(INT64 distanceToMove, DWORD moveMethod, UINT64 &newPosition) const
+bool CFileBase::Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const
{
- LARGE_INTEGER *pointer = (LARGE_INTEGER *)&distanceToMove;
- pointer->LowPart = ::SetFilePointer(_handle, pointer->LowPart,
- &pointer->HighPart, moveMethod);
- if (pointer->LowPart == 0xFFFFFFFF)
+ LARGE_INTEGER value;
+ value.QuadPart = distanceToMove;
+ value.LowPart = ::SetFilePointer(_handle, value.LowPart, &value.HighPart, moveMethod);
+ if (value.LowPart == 0xFFFFFFFF)
if(::GetLastError() != NO_ERROR)
return false;
- newPosition = *((UINT64 *)pointer);
+ newPosition = value.QuadPart;
return true;
}
-bool CFileBase::Seek(UINT64 position, UINT64 &newPosition)
+bool CFileBase::Seek(UInt64 position, UInt64 &newPosition)
{
return Seek(position, FILE_BEGIN, newPosition);
}
bool CFileBase::SeekToBegin()
{
- UINT64 newPosition;
+ UInt64 newPosition;
return Seek(0, newPosition);
}
-bool CFileBase::SeekToEnd(UINT64 &newPosition)
+bool CFileBase::SeekToEnd(UInt64 &newPosition)
{
return Seek(0, FILE_END, newPosition);
}
@@ -109,41 +108,27 @@ bool CFileBase::GetFileInformation(CByHandleFileInfo &fileInfo) const
fileInfo.LastAccessTime = winFileInfo.ftLastAccessTime;
fileInfo.LastWriteTime = winFileInfo.ftLastWriteTime;
fileInfo.VolumeSerialNumber = winFileInfo.dwFileAttributes;
- fileInfo.Size = (((UINT64)winFileInfo.nFileSizeHigh) << 32) +
- winFileInfo.nFileSizeLow;
+ fileInfo.Size = (((UInt64)winFileInfo.nFileSizeHigh) << 32) + winFileInfo.nFileSizeLow;
fileInfo.NumberOfLinks = winFileInfo.nNumberOfLinks;
- fileInfo.FileIndex = (((UINT64)winFileInfo.nFileIndexHigh) << 32) +
- winFileInfo.nFileIndexLow;
+ fileInfo.FileIndex = (((UInt64)winFileInfo.nFileIndexHigh) << 32) + winFileInfo.nFileIndexLow;
return true;
}
/////////////////////////
// CInFile
-bool CInFile::Open(LPCTSTR fileName, DWORD shareMode,
- DWORD creationDisposition, DWORD flagsAndAttributes)
-{
- return Create(fileName, GENERIC_READ, shareMode,
- creationDisposition, flagsAndAttributes);
-}
+bool CInFile::Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
+ { return Create(fileName, GENERIC_READ, shareMode, creationDisposition, flagsAndAttributes); }
bool CInFile::Open(LPCTSTR fileName)
-{
- return Open(fileName, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL);
-}
+ { return Open(fileName, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); }
#ifndef _UNICODE
-bool CInFile::Open(LPCWSTR fileName, DWORD shareMode,
- DWORD creationDisposition, DWORD flagsAndAttributes)
-{
- return Create(fileName, GENERIC_READ, shareMode,
- creationDisposition, flagsAndAttributes);
-}
+bool CInFile::Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
+ { return Create(fileName, GENERIC_READ, shareMode, creationDisposition, flagsAndAttributes); }
bool CInFile::Open(LPCWSTR fileName)
-{
- return Open(fileName, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL);
-}
+ { return Open(fileName, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); }
#endif
// ReadFile and WriteFile functions in Windows have BUG:
@@ -151,24 +136,24 @@ bool CInFile::Open(LPCWSTR fileName)
// from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES
// (Insufficient system resources exist to complete the requested service).
-static UINT32 kChunkSizeMax = (1 << 24);
+static UInt32 kChunkSizeMax = (1 << 24);
-bool CInFile::ReadPart(void *data, UINT32 size, UINT32 &processedSize)
+bool CInFile::ReadPart(void *data, UInt32 size, UInt32 &processedSize)
{
if (size > kChunkSizeMax)
size = kChunkSizeMax;
DWORD processedLoc = 0;
bool res = BOOLToBool(::ReadFile(_handle, data, size, &processedLoc, NULL));
- processedSize = (UINT32)processedLoc;
+ processedSize = (UInt32)processedLoc;
return res;
}
-bool CInFile::Read(void *data, UINT32 size, UINT32 &processedSize)
+bool CInFile::Read(void *data, UInt32 size, UInt32 &processedSize)
{
processedSize = 0;
do
{
- UINT32 processedLoc = 0;
+ UInt32 processedLoc = 0;
bool res = ReadPart(data, size, processedLoc);
processedSize += processedLoc;
if (!res)
@@ -185,77 +170,53 @@ bool CInFile::Read(void *data, UINT32 size, UINT32 &processedSize)
/////////////////////////
// COutFile
-bool COutFile::Open(LPCTSTR fileName, DWORD shareMode,
- DWORD creationDisposition, DWORD flagsAndAttributes)
-{
- return CFileBase::Create(fileName, GENERIC_WRITE, shareMode,
- creationDisposition, flagsAndAttributes);
-}
+bool COutFile::Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
+ { return CFileBase::Create(fileName, GENERIC_WRITE, shareMode, creationDisposition, flagsAndAttributes); }
static inline DWORD GetCreationDisposition(bool createAlways)
- { return createAlways? CREATE_ALWAYS: CREATE_NEW; }
+ { return createAlways? CREATE_ALWAYS: CREATE_NEW; }
bool COutFile::Open(LPCTSTR fileName, DWORD creationDisposition)
-{
- return Open(fileName, FILE_SHARE_READ,
- creationDisposition, FILE_ATTRIBUTE_NORMAL);
-}
+ { return Open(fileName, FILE_SHARE_READ, creationDisposition, FILE_ATTRIBUTE_NORMAL); }
bool COutFile::Create(LPCTSTR fileName, bool createAlways)
-{
- return Open(fileName, GetCreationDisposition(createAlways));
-}
+ { return Open(fileName, GetCreationDisposition(createAlways)); }
#ifndef _UNICODE
-bool COutFile::Open(LPCWSTR fileName, DWORD shareMode,
- DWORD creationDisposition, DWORD flagsAndAttributes)
-{
- return CFileBase::Create(fileName, GENERIC_WRITE, shareMode,
- creationDisposition, flagsAndAttributes);
-}
+bool COutFile::Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
+ { return CFileBase::Create(fileName, GENERIC_WRITE, shareMode, creationDisposition, flagsAndAttributes); }
bool COutFile::Open(LPCWSTR fileName, DWORD creationDisposition)
-{
- return Open(fileName, FILE_SHARE_READ,
- creationDisposition, FILE_ATTRIBUTE_NORMAL);
-}
+ { return Open(fileName, FILE_SHARE_READ, creationDisposition, FILE_ATTRIBUTE_NORMAL); }
bool COutFile::Create(LPCWSTR fileName, bool createAlways)
-{
- return Open(fileName, GetCreationDisposition(createAlways));
-}
+ { return Open(fileName, GetCreationDisposition(createAlways)); }
#endif
-bool COutFile::SetTime(const FILETIME *creationTime,
- const FILETIME *lastAccessTime, const FILETIME *lastWriteTime)
-{
- return BOOLToBool(::SetFileTime(_handle, creationTime,
- lastAccessTime, lastWriteTime));
-}
+bool COutFile::SetTime(const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime)
+ { return BOOLToBool(::SetFileTime(_handle, creationTime, lastAccessTime, lastWriteTime)); }
bool COutFile::SetLastWriteTime(const FILETIME *lastWriteTime)
-{
- return SetTime(NULL, NULL, lastWriteTime);
-}
+ { return SetTime(NULL, NULL, lastWriteTime); }
-bool COutFile::WritePart(const void *data, UINT32 size, UINT32 &processedSize)
+bool COutFile::WritePart(const void *data, UInt32 size, UInt32 &processedSize)
{
if (size > kChunkSizeMax)
size = kChunkSizeMax;
DWORD processedLoc = 0;
bool res = BOOLToBool(::WriteFile(_handle, data, size, &processedLoc, NULL));
- processedSize = (UINT32)processedLoc;
+ processedSize = (UInt32)processedLoc;
return res;
}
-bool COutFile::Write(const void *data, UINT32 size, UINT32 &processedSize)
+bool COutFile::Write(const void *data, UInt32 size, UInt32 &processedSize)
{
processedSize = 0;
do
{
- UINT32 processedLoc = 0;
+ UInt32 processedLoc = 0;
bool res = WritePart(data, size, processedLoc);
processedSize += processedLoc;
if (!res)
@@ -269,14 +230,11 @@ bool COutFile::Write(const void *data, UINT32 size, UINT32 &processedSize)
return true;
}
-bool COutFile::SetEndOfFile()
-{
- return BOOLToBool(::SetEndOfFile(_handle));
-}
+bool COutFile::SetEndOfFile() { return BOOLToBool(::SetEndOfFile(_handle)); }
-bool COutFile::SetLength(UINT64 length)
+bool COutFile::SetLength(UInt64 length)
{
- UINT64 newPosition;
+ UInt64 newPosition;
if(!Seek(length, newPosition))
return false;
if(newPosition != length)
diff --git a/Windows/FileIO.h b/Windows/FileIO.h
index b4d8361d..18014844 100755
--- a/Windows/FileIO.h
+++ b/Windows/FileIO.h
@@ -3,6 +3,8 @@
#ifndef __WINDOWS_FILEIO_H
#define __WINDOWS_FILEIO_H
+#include "../Common/Types.h"
+
namespace NWindows {
namespace NFile {
namespace NIO {
@@ -14,9 +16,9 @@ struct CByHandleFileInfo
FILETIME LastAccessTime;
FILETIME LastWriteTime;
DWORD VolumeSerialNumber;
- UINT64 Size;
+ UInt64 Size;
DWORD NumberOfLinks;
- UINT64 FileIndex;
+ UInt64 FileIndex;
};
class CFileBase
@@ -32,19 +34,18 @@ protected:
#endif
public:
- CFileBase():
- _fileIsOpen(false){};
+ CFileBase(): _fileIsOpen(false){};
virtual ~CFileBase();
virtual bool Close();
- bool GetPosition(UINT64 &position) const;
- bool GetLength(UINT64 &length) const;
+ bool GetPosition(UInt64 &position) const;
+ bool GetLength(UInt64 &length) const;
- bool Seek(INT64 distanceToMove, DWORD moveMethod, UINT64 &newPosition) const;
- bool Seek(UINT64 position, UINT64 &newPosition);
+ bool Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const;
+ bool Seek(UInt64 position, UInt64 &newPosition);
bool SeekToBegin();
- bool SeekToEnd(UINT64 &newPosition);
+ bool SeekToEnd(UInt64 &newPosition);
bool GetFileInformation(CByHandleFileInfo &fileInfo) const;
};
@@ -52,16 +53,14 @@ public:
class CInFile: public CFileBase
{
public:
- bool Open(LPCTSTR fileName, DWORD shareMode,
- DWORD creationDisposition, DWORD flagsAndAttributes);
+ bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
bool Open(LPCTSTR fileName);
#ifndef _UNICODE
- bool Open(LPCWSTR fileName, DWORD shareMode,
- DWORD creationDisposition, DWORD flagsAndAttributes);
+ bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
bool Open(LPCWSTR fileName);
#endif
- bool ReadPart(void *data, UINT32 size, UINT32 &processedSize);
- bool Read(void *data, UINT32 size, UINT32 &processedSize);
+ bool ReadPart(void *data, UInt32 size, UInt32 &processedSize);
+ bool Read(void *data, UInt32 size, UInt32 &processedSize);
};
class COutFile: public CFileBase
@@ -69,14 +68,12 @@ class COutFile: public CFileBase
// DWORD m_CreationDisposition;
public:
// COutFile(): m_CreationDisposition(CREATE_NEW){};
- bool Open(LPCTSTR fileName, DWORD shareMode,
- DWORD creationDisposition, DWORD flagsAndAttributes);
+ bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
bool Open(LPCTSTR fileName, DWORD creationDisposition);
bool Create(LPCTSTR fileName, bool createAlways);
#ifndef _UNICODE
- bool Open(LPCWSTR fileName, DWORD shareMode,
- DWORD creationDisposition, DWORD flagsAndAttributes);
+ bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
bool Open(LPCWSTR fileName, DWORD creationDisposition);
bool Create(LPCWSTR fileName, bool createAlways);
#endif
@@ -88,13 +85,12 @@ public:
{ m_CreationDisposition = CREATE_ALWAYS; }
*/
- bool SetTime(const FILETIME *creationTime,
- const FILETIME *lastAccessTime, const FILETIME *lastWriteTime);
+ bool SetTime(const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime);
bool SetLastWriteTime(const FILETIME *lastWriteTime);
- bool WritePart(const void *data, UINT32 size, UINT32 &processedSize);
- bool Write(const void *data, UINT32 size, UINT32 &processedSize);
+ bool WritePart(const void *data, UInt32 size, UInt32 &processedSize);
+ bool Write(const void *data, UInt32 size, UInt32 &processedSize);
bool SetEndOfFile();
- bool SetLength(UINT64 length);
+ bool SetLength(UInt64 length);
};
}}}
diff --git a/Windows/FileSystem.cpp b/Windows/FileSystem.cpp
index 2f35524d..37c76856 100755
--- a/Windows/FileSystem.cpp
+++ b/Windows/FileSystem.cpp
@@ -5,6 +5,10 @@
#include "FileSystem.h"
#include "Defs.h"
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
namespace NWindows {
namespace NFile {
namespace NSystem {
@@ -29,6 +33,41 @@ bool MyGetVolumeInformation(
return result;
}
+
+#ifndef _UNICODE
+bool MyGetVolumeInformation(
+ LPCWSTR rootPathName,
+ UString &volumeName,
+ LPDWORD volumeSerialNumber,
+ LPDWORD maximumComponentLength,
+ LPDWORD fileSystemFlags,
+ UString &fileSystemName)
+{
+ if (g_IsNT)
+ {
+ bool result = BOOLToBool(GetVolumeInformationW(
+ rootPathName,
+ volumeName.GetBuffer(MAX_PATH), MAX_PATH,
+ volumeSerialNumber,
+ maximumComponentLength,
+ fileSystemFlags,
+ fileSystemName.GetBuffer(MAX_PATH), MAX_PATH));
+ volumeName.ReleaseBuffer();
+ fileSystemName.ReleaseBuffer();
+ return result;
+ }
+ AString volumeNameA, fileSystemNameA;
+ bool result = MyGetVolumeInformation(GetSystemString(rootPathName), volumeNameA,
+ volumeSerialNumber, maximumComponentLength, fileSystemFlags,fileSystemNameA);
+ if (result)
+ {
+ volumeName = GetUnicodeString(volumeNameA);
+ fileSystemName = GetUnicodeString(fileSystemNameA);
+ }
+ return result;
+}
+#endif
+
typedef BOOL (WINAPI * GetDiskFreeSpaceExPointer)(
LPCTSTR lpDirectoryName, // directory name
PULARGE_INTEGER lpFreeBytesAvailable, // bytes available to caller
@@ -37,7 +76,7 @@ typedef BOOL (WINAPI * GetDiskFreeSpaceExPointer)(
);
bool MyGetDiskFreeSpace(LPCTSTR rootPathName,
- UINT64 &clusterSize, UINT64 &totalSize, UINT64 &freeSize)
+ UInt64 &clusterSize, UInt64 &totalSize, UInt64 &freeSize)
{
GetDiskFreeSpaceExPointer pGetDiskFreeSpaceEx =
(GetDiskFreeSpaceExPointer)GetProcAddress(
@@ -46,11 +85,13 @@ bool MyGetDiskFreeSpace(LPCTSTR rootPathName,
bool sizeIsDetected = false;
if (pGetDiskFreeSpaceEx)
{
- UINT64 i64FreeBytesToCaller;
+ ULARGE_INTEGER i64FreeBytesToCaller, totalSize2, freeSize2;
sizeIsDetected = BOOLToBool(pGetDiskFreeSpaceEx(rootPathName,
- (PULARGE_INTEGER)&i64FreeBytesToCaller,
- (PULARGE_INTEGER)&totalSize,
- (PULARGE_INTEGER)&freeSize));
+ &i64FreeBytesToCaller,
+ &totalSize2,
+ &freeSize2));
+ totalSize = totalSize2.QuadPart;
+ freeSize = freeSize2.QuadPart;
}
DWORD numSectorsPerCluster;
@@ -65,13 +106,21 @@ bool MyGetDiskFreeSpace(LPCTSTR rootPathName,
&totalNumberOfClusters))
return false;
- clusterSize = UINT64(bytesPerSector) * UINT64(numSectorsPerCluster);
+ clusterSize = (UInt64)bytesPerSector * (UInt64)numSectorsPerCluster;
if (!sizeIsDetected)
{
- totalSize = clusterSize * UINT64(totalNumberOfClusters);
- freeSize = clusterSize * UINT64(numberOfFreeClusters);
+ totalSize = clusterSize * (UInt64)totalNumberOfClusters;
+ freeSize = clusterSize * (UInt64)numberOfFreeClusters;
}
return true;
}
+#ifndef _UNICODE
+bool MyGetDiskFreeSpace(LPCWSTR rootPathName,
+ UInt64 &clusterSize, UInt64 &totalSize, UInt64 &freeSize)
+{
+ return MyGetDiskFreeSpace(GetSystemString(rootPathName), clusterSize, totalSize, freeSize);
+}
+#endif
+
}}}
diff --git a/Windows/FileSystem.h b/Windows/FileSystem.h
index 62f50d40..25488804 100755
--- a/Windows/FileSystem.h
+++ b/Windows/FileSystem.h
@@ -4,6 +4,11 @@
#define __WINDOWS_FILESYSTEM_H
#include "../Common/String.h"
+#include "../Common/Types.h"
+
+#ifndef _UNICODE
+#include "../Common/StringConvert.h"
+#endif
namespace NWindows {
namespace NFile {
@@ -17,8 +22,28 @@ bool MyGetVolumeInformation(
LPDWORD fileSystemFlags,
CSysString &fileSystemName);
+#ifndef _UNICODE
+bool MyGetVolumeInformation(
+ LPCWSTR rootPathName,
+ UString &volumeName,
+ LPDWORD volumeSerialNumber,
+ LPDWORD maximumComponentLength,
+ LPDWORD fileSystemFlags,
+ UString &fileSystemName);
+#endif
+
+inline UINT MyGetDriveType(LPCTSTR pathName) { return GetDriveType(pathName); }
+#ifndef _UNICODE
+inline UINT MyGetDriveType(LPCWSTR pathName) { return GetDriveType(GetSystemString(pathName)); }
+#endif
+
bool MyGetDiskFreeSpace(LPCTSTR rootPathName,
- UINT64 &clusterSize, UINT64 &totalSize, UINT64 &freeSize);
+ UInt64 &clusterSize, UInt64 &totalSize, UInt64 &freeSize);
+
+#ifndef _UNICODE
+bool MyGetDiskFreeSpace(LPCWSTR rootPathName,
+ UInt64 &clusterSize, UInt64 &totalSize, UInt64 &freeSize);
+#endif
}}}
diff --git a/Windows/MemoryLock.cpp b/Windows/MemoryLock.cpp
new file mode 100755
index 00000000..b468e528
--- /dev/null
+++ b/Windows/MemoryLock.cpp
@@ -0,0 +1,78 @@
+// Common/MemoryLock.cpp
+
+#include "StdAfx.h"
+
+namespace NWindows {
+namespace NSecurity {
+
+#ifndef _UNICODE
+typedef BOOL (WINAPI * OpenProcessTokenP)(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle);
+typedef BOOL (WINAPI * LookupPrivilegeValueP)(LPCTSTR lpSystemName, LPCTSTR lpName, PLUID lpLuid);
+typedef BOOL (WINAPI * AdjustTokenPrivilegesP)(HANDLE TokenHandle, BOOL DisableAllPrivileges,
+ PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState,PDWORD ReturnLength);
+#endif
+
+#ifdef _UNICODE
+bool EnableLockMemoryPrivilege(
+#else
+static bool EnableLockMemoryPrivilege2(HMODULE hModule,
+#endif
+bool enable)
+{
+ #ifndef _UNICODE
+ if (hModule == NULL)
+ return false;
+ OpenProcessTokenP openProcessToken = (OpenProcessTokenP)GetProcAddress(hModule, "OpenProcessToken");
+ LookupPrivilegeValueP lookupPrivilegeValue = (LookupPrivilegeValueP)GetProcAddress(hModule, "LookupPrivilegeValueA" );
+ AdjustTokenPrivilegesP adjustTokenPrivileges = (AdjustTokenPrivilegesP)GetProcAddress(hModule, "AdjustTokenPrivileges");
+ if (openProcessToken == NULL || adjustTokenPrivileges == NULL || lookupPrivilegeValue == NULL)
+ return false;
+ #endif
+
+ HANDLE token;
+ if (!
+ #ifdef _UNICODE
+ ::OpenProcessToken
+ #else
+ openProcessToken
+ #endif
+ (::GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token))
+ return false;
+ TOKEN_PRIVILEGES tp;
+ bool res = false;
+ if (
+ #ifdef _UNICODE
+ ::LookupPrivilegeValue
+ #else
+ lookupPrivilegeValue
+ #endif
+ (NULL, SE_LOCK_MEMORY_NAME, &(tp.Privileges[0].Luid)))
+ {
+ tp.PrivilegeCount = 1;
+ tp.Privileges[0].Attributes = enable ? SE_PRIVILEGE_ENABLED: 0;
+ if (
+ #ifdef _UNICODE
+ ::AdjustTokenPrivileges
+ #else
+ adjustTokenPrivileges
+ #endif
+ (token, FALSE, &tp, 0, NULL, NULL))
+ res = (GetLastError() == ERROR_SUCCESS);
+ }
+ ::CloseHandle(token);
+ return res;
+}
+
+#ifndef _UNICODE
+bool EnableLockMemoryPrivilege(bool enable)
+{
+ HMODULE hModule = LoadLibrary(TEXT("Advapi32.dll"));
+ if(hModule == NULL)
+ return false;
+ bool res = EnableLockMemoryPrivilege2(hModule, enable);
+ ::FreeLibrary(hModule);
+ return res;
+}
+#endif
+
+}}
diff --git a/Windows/MemoryLock.h b/Windows/MemoryLock.h
new file mode 100755
index 00000000..03a88b41
--- /dev/null
+++ b/Windows/MemoryLock.h
@@ -0,0 +1,13 @@
+// Windows/MemoryLock.h
+
+#ifndef __WINDOWS_MEMORYLOCK_H
+#define __WINDOWS_MEMORYLOCK_H
+
+namespace NWindows {
+namespace NSecurity {
+
+bool EnableLockMemoryPrivilege(bool enable = true);
+
+}}
+
+#endif
diff --git a/Windows/Menu.cpp b/Windows/Menu.cpp
new file mode 100755
index 00000000..5869b365
--- /dev/null
+++ b/Windows/Menu.cpp
@@ -0,0 +1,178 @@
+// Windows/Menu.cpp
+
+#include "StdAfx.h"
+
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
+#include "Windows/Menu.h"
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+namespace NWindows {
+
+static void ConvertItemToSysForm(const CMenuItem &item, MENUITEMINFOW &si)
+{
+ ZeroMemory(&si, sizeof(si));
+ si.cbSize = sizeof(si);
+ si.fMask = item.fMask;
+ si.fType = item.fType;
+ si.fState = item.fState;
+ si.wID = item.wID;
+ si.hSubMenu = item.hSubMenu;
+ si.hbmpChecked = item.hbmpChecked;
+ si.hbmpUnchecked = item.hbmpUnchecked;
+ si.dwItemData = item.dwItemData;
+}
+
+#ifndef _UNICODE
+static void ConvertItemToSysForm(const CMenuItem &item, MENUITEMINFOA &si)
+{
+ ZeroMemory(&si, sizeof(si));
+ si.cbSize = sizeof(si);
+ si.fMask = item.fMask;
+ si.fType = item.fType;
+ si.fState = item.fState;
+ si.wID = item.wID;
+ si.hSubMenu = item.hSubMenu;
+ si.hbmpChecked = item.hbmpChecked;
+ si.hbmpUnchecked = item.hbmpUnchecked;
+ si.dwItemData = item.dwItemData;
+}
+#endif
+
+static void ConvertItemToMyForm(const MENUITEMINFOW &si, CMenuItem &item)
+{
+ item.fMask = si.fMask;
+ item.fType = si.fType;
+ item.fState = si.fState;
+ item.wID = si.wID;
+ item.hSubMenu = si.hSubMenu;
+ item.hbmpChecked = si.hbmpChecked;
+ item.hbmpUnchecked = si.hbmpUnchecked;
+ item.dwItemData = si.dwItemData;
+}
+
+#ifndef _UNICODE
+static void ConvertItemToMyForm(const MENUITEMINFOA &si, CMenuItem &item)
+{
+ item.fMask = si.fMask;
+ item.fType = si.fType;
+ item.fState = si.fState;
+ item.wID = si.wID;
+ item.hSubMenu = si.hSubMenu;
+ item.hbmpChecked = si.hbmpChecked;
+ item.hbmpUnchecked = si.hbmpUnchecked;
+ item.dwItemData = si.dwItemData;
+}
+#endif
+
+bool CMenu::GetItem(UINT itemIndex, bool byPosition, CMenuItem &item)
+{
+ const UINT kMaxSize = 512;
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ CHAR s[kMaxSize + 1];
+ MENUITEMINFOA si;
+ ConvertItemToSysForm(item, si);
+ if (item.IsString())
+ {
+ si.cch = kMaxSize;
+ si.dwTypeData = s;
+ }
+ if(GetItemInfo(itemIndex, byPosition, &si))
+ {
+ ConvertItemToMyForm(si, item);
+ if (item.IsString())
+ item.StringValue = GetUnicodeString(s);
+ return true;
+ }
+ }
+ else
+ #endif
+ {
+ wchar_t s[kMaxSize + 1];
+ MENUITEMINFOW si;
+ ConvertItemToSysForm(item, si);
+ if (item.IsString())
+ {
+ si.cch = kMaxSize;
+ si.dwTypeData = s;
+ }
+ if(GetItemInfo(itemIndex, byPosition, &si))
+ {
+ ConvertItemToMyForm(si, item);
+ if (item.IsString())
+ item.StringValue = s;
+ return true;
+ }
+ }
+ return false;
+}
+
+bool CMenu::SetItem(UINT itemIndex, bool byPosition, const CMenuItem &item)
+{
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ MENUITEMINFOA si;
+ ConvertItemToSysForm(item, si);
+ AString s;
+ if (item.IsString())
+ {
+ s = GetSystemString(item.StringValue);
+ si.dwTypeData = (LPTSTR)(LPCTSTR)s;
+ }
+ return SetItemInfo(itemIndex, byPosition, &si);
+ }
+ else
+ #endif
+ {
+ MENUITEMINFOW si;
+ ConvertItemToSysForm(item, si);
+ if (item.IsString())
+ si.dwTypeData = (LPWSTR)(LPCWSTR)item.StringValue;
+ return SetItemInfo(itemIndex, byPosition, &si);
+ }
+}
+
+bool CMenu::InsertItem(UINT itemIndex, bool byPosition, const CMenuItem &item)
+{
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ MENUITEMINFOA si;
+ ConvertItemToSysForm(item, si);
+ AString s;
+ if (item.IsString())
+ {
+ s = GetSystemString(item.StringValue);
+ si.dwTypeData = (LPTSTR)(LPCTSTR)s;
+ }
+ return InsertItem(itemIndex, byPosition, &si);
+ }
+ else
+ #endif
+ {
+ MENUITEMINFOW si;
+ ConvertItemToSysForm(item, si);
+ if (item.IsString())
+ si.dwTypeData = (LPWSTR)(LPCWSTR)item.StringValue;
+ return InsertItem(itemIndex, byPosition, &si);
+ }
+}
+
+#ifndef _UNICODE
+bool CMenu::AppendItem(UINT flags, UINT_PTR newItemID, LPCWSTR newItem)
+{
+ if (g_IsNT)
+ return BOOLToBool(::AppendMenuW(_menu, flags, newItemID, newItem));
+ else
+ return AppendItem(flags, newItemID, GetSystemString(newItem));
+}
+#endif
+
+}
diff --git a/Windows/Menu.h b/Windows/Menu.h
index 69b20601..11ba5537 100755
--- a/Windows/Menu.h
+++ b/Windows/Menu.h
@@ -8,6 +8,26 @@
namespace NWindows {
+struct CMenuItem
+{
+ UString StringValue;
+ UINT fMask;
+ UINT fType;
+ UINT fState;
+ UINT wID;
+ HMENU hSubMenu;
+ HBITMAP hbmpChecked;
+ HBITMAP hbmpUnchecked;
+ ULONG_PTR dwItemData;
+ // LPTSTR dwTypeData;
+ // UINT cch;
+ // HBITMAP hbmpItem;
+ bool IsString() const // change it MIIM_STRING
+ { return ((fMask & MIIM_TYPE) != 0 && (fType == MFT_STRING)); }
+ CMenuItem(): fMask(0), fType(0), fState(0), wID(0), hSubMenu(0), hbmpChecked(0),
+ hbmpUnchecked(0), dwItemData(0) {}
+};
+
class CMenu
{
HMENU _menu;
@@ -61,6 +81,11 @@ public:
UINT GetItemState(UINT id, UINT flags)
{ return ::GetMenuState(_menu, id, flags); }
+ bool GetItemInfo(UINT itemIndex, bool byPosition, LPMENUITEMINFO itemInfo)
+ { return BOOLToBool(::GetMenuItemInfo(_menu, itemIndex, BoolToBOOL(byPosition), itemInfo)); }
+ bool SetItemInfo(UINT itemIndex, bool byPosition, LPMENUITEMINFO itemInfo)
+ { return BOOLToBool(::SetMenuItemInfo(_menu, itemIndex, BoolToBOOL(byPosition), itemInfo)); }
+
bool AppendItem(UINT flags, UINT_PTR newItemID, LPCTSTR newItem)
{ return BOOLToBool(::AppendMenu(_menu, flags, newItemID, newItem)); }
@@ -68,18 +93,24 @@ public:
{ return BOOLToBool(::InsertMenu(_menu, position, flags, idNewItem, newItem)); }
bool InsertItem(UINT itemIndex, bool byPosition, LPCMENUITEMINFO itemInfo)
- { return BOOLToBool(::InsertMenuItem(_menu, itemIndex,
- BoolToBOOL(byPosition), itemInfo)); }
+ { return BOOLToBool(::InsertMenuItem(_menu, itemIndex, BoolToBOOL(byPosition), itemInfo)); }
bool RemoveItem(UINT item, UINT flags)
{ return BOOLToBool(::RemoveMenu(_menu, item, flags)); }
- bool GetItemInfo(UINT itemIndex, bool byPosition, LPMENUITEMINFO itemInfo)
- { return BOOLToBool(::GetMenuItemInfo(_menu, itemIndex,
- BoolToBOOL(byPosition), itemInfo)); }
- bool SetItemInfo(UINT itemIndex, bool byPosition, LPMENUITEMINFO itemInfo)
- { return BOOLToBool(::SetMenuItemInfo(_menu, itemIndex,
- BoolToBOOL(byPosition), itemInfo)); }
+ #ifndef _UNICODE
+ bool GetItemInfo(UINT itemIndex, bool byPosition, LPMENUITEMINFOW itemInfo)
+ { return BOOLToBool(::GetMenuItemInfoW(_menu, itemIndex, BoolToBOOL(byPosition), itemInfo)); }
+ bool InsertItem(UINT itemIndex, bool byPosition, LPMENUITEMINFOW itemInfo)
+ { return BOOLToBool(::InsertMenuItemW(_menu, itemIndex, BoolToBOOL(byPosition), itemInfo)); }
+ bool SetItemInfo(UINT itemIndex, bool byPosition, LPMENUITEMINFOW itemInfo)
+ { return BOOLToBool(::SetMenuItemInfoW(_menu, itemIndex, BoolToBOOL(byPosition), itemInfo)); }
+ bool AppendItem(UINT flags, UINT_PTR newItemID, LPCWSTR newItem);
+ #endif
+
+ bool GetItem(UINT itemIndex, bool byPosition, CMenuItem &item);
+ bool SetItem(UINT itemIndex, bool byPosition, const CMenuItem &item);
+ bool InsertItem(UINT itemIndex, bool byPosition, const CMenuItem &item);
int Track(UINT flags, int x, int y, HWND hWnd)
{ return ::TrackPopupMenuEx(_menu, flags, x, y, hWnd, NULL); }
diff --git a/Windows/Net.cpp b/Windows/Net.cpp
index 19730d7f..113cec94 100755
--- a/Windows/Net.cpp
+++ b/Windows/Net.cpp
@@ -4,6 +4,14 @@
#include "Windows/Net.h"
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
namespace NWindows {
namespace NNet {
@@ -15,8 +23,17 @@ DWORD CEnum::Open(DWORD scope, DWORD type, DWORD usage, LPNETRESOURCE netResourc
return result;
}
-static void SetComplexString(bool &defined, CSysString &destString,
- LPCTSTR srsString)
+#ifndef _UNICODE
+DWORD CEnum::Open(DWORD scope, DWORD type, DWORD usage, LPNETRESOURCEW netResource)
+{
+ Close();
+ DWORD result = ::WNetOpenEnumW(scope, type, usage, netResource, &_handle);
+ _handleAllocated = (result == NO_ERROR);
+ return result;
+}
+#endif
+
+static void SetComplexString(bool &defined, CSysString &destString, LPCTSTR srsString)
{
defined = (srsString != 0);
if (defined)
@@ -25,8 +42,7 @@ static void SetComplexString(bool &defined, CSysString &destString,
destString.Empty();
}
-static void ConvertNETRESOURCEToCResource(const NETRESOURCE &netResource,
- CResource &resource)
+static void ConvertNETRESOURCEToCResource(const NETRESOURCE &netResource, CResource &resource)
{
resource.Scope = netResource.dwScope;
resource.Type = netResource.dwType;
@@ -38,8 +54,7 @@ static void ConvertNETRESOURCEToCResource(const NETRESOURCE &netResource,
SetComplexString(resource.ProviderIsDefined, resource.Provider, netResource.lpProvider);
}
-static void SetComplexString2(LPTSTR *destString, bool defined,
- const CSysString &srcString)
+static void SetComplexString2(LPTSTR *destString, bool defined, const CSysString &srcString)
{
if (defined)
*destString = (TCHAR *)(const TCHAR *)srcString;
@@ -47,8 +62,7 @@ static void SetComplexString2(LPTSTR *destString, bool defined,
*destString = 0;
}
-static void ConvertCResourceToNETRESOURCE(const CResource &resource,
- NETRESOURCE &netResource)
+static void ConvertCResourceToNETRESOURCE(const CResource &resource, NETRESOURCE &netResource)
{
netResource.dwScope = resource.Scope;
netResource.dwType = resource.Type;
@@ -60,8 +74,69 @@ static void ConvertCResourceToNETRESOURCE(const CResource &resource,
SetComplexString2(&netResource.lpProvider, resource.ProviderIsDefined, resource.Provider);
}
-DWORD CEnum::Open(DWORD scope, DWORD type, DWORD usage,
- const CResource *resource)
+#ifndef _UNICODE
+
+static void SetComplexString(bool &defined, UString &destString, LPCWSTR srsString)
+{
+ defined = (srsString != 0);
+ if (defined)
+ destString = srsString;
+ else
+ destString.Empty();
+}
+
+static void ConvertNETRESOURCEToCResource(const NETRESOURCEW &netResource, CResourceW &resource)
+{
+ resource.Scope = netResource.dwScope;
+ resource.Type = netResource.dwType;
+ resource.DisplayType = netResource.dwDisplayType;
+ resource.Usage = netResource.dwUsage;
+ SetComplexString(resource.LocalNameIsDefined, resource.LocalName, netResource.lpLocalName);
+ SetComplexString(resource.RemoteNameIsDefined, resource.RemoteName, netResource.lpRemoteName);
+ SetComplexString(resource.CommentIsDefined, resource.Comment, netResource.lpComment);
+ SetComplexString(resource.ProviderIsDefined, resource.Provider, netResource.lpProvider);
+}
+
+static void SetComplexString2(LPWSTR *destString, bool defined, const UString &srcString)
+{
+ if (defined)
+ *destString = (WCHAR *)(const WCHAR *)srcString;
+ else
+ *destString = 0;
+}
+
+static void ConvertCResourceToNETRESOURCE(const CResourceW &resource, NETRESOURCEW &netResource)
+{
+ netResource.dwScope = resource.Scope;
+ netResource.dwType = resource.Type;
+ netResource.dwDisplayType = resource.DisplayType;
+ netResource.dwUsage = resource.Usage;
+ SetComplexString2(&netResource.lpLocalName, resource.LocalNameIsDefined, resource.LocalName);
+ SetComplexString2(&netResource.lpRemoteName, resource.RemoteNameIsDefined, resource.RemoteName);
+ SetComplexString2(&netResource.lpComment, resource.CommentIsDefined, resource.Comment);
+ SetComplexString2(&netResource.lpProvider, resource.ProviderIsDefined, resource.Provider);
+}
+
+static void ConvertResourceWToResource(const CResourceW &resourceW, CResource &resource)
+{
+ *(CResourceBase *)&resource = *(CResourceBase *)&resourceW;
+ resource.LocalName = GetSystemString(resourceW.LocalName);
+ resource.RemoteName = GetSystemString(resourceW.RemoteName);
+ resource.Comment = GetSystemString(resourceW.Comment);
+ resource.Provider = GetSystemString(resourceW.Provider);
+}
+
+static void ConvertResourceToResourceW(const CResource &resource, CResourceW &resourceW)
+{
+ *(CResourceBase *)&resourceW = *(CResourceBase *)&resource;
+ resourceW.LocalName = GetUnicodeString(resource.LocalName);
+ resourceW.RemoteName = GetUnicodeString(resource.RemoteName);
+ resourceW.Comment = GetUnicodeString(resource.Comment);
+ resourceW.Provider = GetUnicodeString(resource.Provider);
+}
+#endif
+
+DWORD CEnum::Open(DWORD scope, DWORD type, DWORD usage, const CResource *resource)
{
NETRESOURCE netResource;
LPNETRESOURCE pointer;
@@ -75,6 +150,35 @@ DWORD CEnum::Open(DWORD scope, DWORD type, DWORD usage,
return Open(scope, type, usage, pointer);
}
+#ifndef _UNICODE
+DWORD CEnum::Open(DWORD scope, DWORD type, DWORD usage, const CResourceW *resource)
+{
+ if (g_IsNT)
+ {
+ NETRESOURCEW netResource;
+ LPNETRESOURCEW pointer;
+ if (resource == 0)
+ pointer = 0;
+ else
+ {
+ ConvertCResourceToNETRESOURCE(*resource, netResource);
+ pointer = &netResource;
+ }
+ return Open(scope, type, usage, pointer);
+ }
+ CResource *pointer;
+ CResource resourceA;
+ if (resource == 0)
+ pointer = 0;
+ else
+ {
+ ConvertResourceWToResource(*resource, resourceA);
+ pointer = &resourceA;
+ }
+ return Open(scope, type, usage, pointer);
+}
+#endif
+
DWORD CEnum::Close()
{
if(!_handleAllocated)
@@ -89,6 +193,13 @@ DWORD CEnum::Next(LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
return ::WNetEnumResource(_handle, lpcCount, lpBuffer, lpBufferSize);
}
+#ifndef _UNICODE
+DWORD CEnum::NextW(LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
+{
+ return ::WNetEnumResourceW(_handle, lpcCount, lpBuffer, lpBufferSize);
+}
+#endif
+
DWORD CEnum::Next(CResource &resource)
{
CByteBuffer byteBuffer;
@@ -107,6 +218,34 @@ DWORD CEnum::Next(CResource &resource)
return result;
}
+#ifndef _UNICODE
+DWORD CEnum::Next(CResourceW &resource)
+{
+ if (g_IsNT)
+ {
+ CByteBuffer byteBuffer;
+ const DWORD kBufferSize = 16384;
+ byteBuffer.SetCapacity(kBufferSize);
+ LPNETRESOURCEW lpnrLocal = (LPNETRESOURCEW) (BYTE *)(byteBuffer);
+ ZeroMemory(lpnrLocal, kBufferSize);
+ DWORD bufferSize = kBufferSize;
+ DWORD numEntries = 1;
+ DWORD result = NextW(&numEntries, lpnrLocal, &bufferSize);
+ if (result != NO_ERROR)
+ return result;
+ if (numEntries != 1)
+ return (DWORD)E_FAIL;
+ ConvertNETRESOURCEToCResource(lpnrLocal[0], resource);
+ return result;
+ }
+ CResource resourceA;
+ DWORD result = Next(resourceA);
+ ConvertResourceToResourceW(resourceA, resource);
+ return result;
+}
+#endif
+
+
DWORD GetResourceParent(const CResource &resource, CResource &parentResource)
{
CByteBuffer byteBuffer;
@@ -124,6 +263,33 @@ DWORD GetResourceParent(const CResource &resource, CResource &parentResource)
return result;
}
+#ifndef _UNICODE
+DWORD GetResourceParent(const CResourceW &resource, CResourceW &parentResource)
+{
+ if (g_IsNT)
+ {
+ CByteBuffer byteBuffer;
+ const DWORD kBufferSize = 16384;
+ byteBuffer.SetCapacity(kBufferSize);
+ LPNETRESOURCEW lpnrLocal = (LPNETRESOURCEW) (BYTE *)(byteBuffer);
+ ZeroMemory(lpnrLocal, kBufferSize);
+ DWORD bufferSize = kBufferSize;
+ NETRESOURCEW netResource;
+ ConvertCResourceToNETRESOURCE(resource, netResource);
+ DWORD result = ::WNetGetResourceParentW(&netResource, lpnrLocal, &bufferSize);
+ if (result != NO_ERROR)
+ return result;
+ ConvertNETRESOURCEToCResource(lpnrLocal[0], parentResource);
+ return result;
+ }
+ CResource resourceA, parentResourceA;
+ ConvertResourceWToResource(resource, resourceA);
+ DWORD result = GetResourceParent(resourceA, parentResourceA);
+ ConvertResourceToResourceW(parentResourceA, parentResource);
+ return result;
+}
+#endif
+
DWORD GetResourceInformation(const CResource &resource,
CResource &destResource, CSysString &systemPathPart)
{
@@ -146,6 +312,40 @@ DWORD GetResourceInformation(const CResource &resource,
return result;
}
+#ifndef _UNICODE
+DWORD GetResourceInformation(const CResourceW &resource,
+ CResourceW &destResource, UString &systemPathPart)
+{
+ if (g_IsNT)
+ {
+ CByteBuffer byteBuffer;
+ const DWORD kBufferSize = 16384;
+ byteBuffer.SetCapacity(kBufferSize);
+ LPNETRESOURCEW lpnrLocal = (LPNETRESOURCEW) (BYTE *)(byteBuffer);
+ ZeroMemory(lpnrLocal, kBufferSize);
+ DWORD bufferSize = kBufferSize;
+ NETRESOURCEW netResource;
+ ConvertCResourceToNETRESOURCE(resource, netResource);
+ LPWSTR lplpSystem;
+ DWORD result = ::WNetGetResourceInformationW(&netResource,
+ lpnrLocal, &bufferSize, &lplpSystem);
+ if (result != NO_ERROR)
+ return result;
+ if (lplpSystem != 0)
+ systemPathPart = lplpSystem;
+ ConvertNETRESOURCEToCResource(lpnrLocal[0], destResource);
+ return result;
+ }
+ CResource resourceA, destResourceA;
+ ConvertResourceWToResource(resource, resourceA);
+ AString systemPathPartA;
+ DWORD result = GetResourceInformation(resourceA, destResourceA, systemPathPartA);
+ ConvertResourceToResourceW(destResourceA, destResource);
+ systemPathPart = GetUnicodeString(systemPathPartA);
+ return result;
+}
+#endif
+
DWORD AddConnection2(const CResource &resource,
LPCTSTR password, LPCTSTR userName, DWORD flags)
{
@@ -155,4 +355,26 @@ DWORD AddConnection2(const CResource &resource,
password, userName, flags);
}
+DWORD AddConnection2(const CResource &resource, LPCTSTR password, LPCTSTR userName, DWORD flags);
+
+#ifndef _UNICODE
+DWORD AddConnection2(const CResourceW &resource, LPCWSTR password, LPCWSTR userName, DWORD flags)
+{
+ if (g_IsNT)
+ {
+ NETRESOURCEW netResource;
+ ConvertCResourceToNETRESOURCE(resource, netResource);
+ return ::WNetAddConnection2W(&netResource,password, userName, flags);
+ }
+ CResource resourceA;
+ ConvertResourceWToResource(resource, resourceA);
+ CSysString passwordA = GetSystemString(password);
+ CSysString userNameA = GetSystemString(userName);
+ return AddConnection2(resourceA,
+ password ? (LPCTSTR)passwordA: 0,
+ userName ? (LPCTSTR)userNameA: 0,
+ flags);
+}
+#endif
+
}}
diff --git a/Windows/Net.h b/Windows/Net.h
index 0f7f6f85..ff501d70 100755
--- a/Windows/Net.h
+++ b/Windows/Net.h
@@ -9,7 +9,7 @@
namespace NWindows {
namespace NNet {
-struct CResource
+struct CResourceBase
{
DWORD Scope;
DWORD Type;
@@ -19,33 +19,68 @@ struct CResource
bool RemoteNameIsDefined;
bool CommentIsDefined;
bool ProviderIsDefined;
+};
+
+struct CResource: public CResourceBase
+{
CSysString LocalName;
CSysString RemoteName;
CSysString Comment;
CSysString Provider;
};
+#ifdef _UNICODE
+typedef CResource CResourceW;
+#else
+struct CResourceW: public CResourceBase
+{
+ UString LocalName;
+ UString RemoteName;
+ UString Comment;
+ UString Provider;
+};
+#endif
+
class CEnum
{
HANDLE _handle;
bool _handleAllocated;
+ DWORD Open(DWORD scope, DWORD type, DWORD usage, LPNETRESOURCE netResource);
+ DWORD Next(LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize);
+ #ifndef _UNICODE
+ DWORD Open(DWORD scope, DWORD type, DWORD usage, LPNETRESOURCEW netResource);
+ DWORD NextW(LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize);
+ #endif
protected:
bool IsHandleAllocated() const { return _handleAllocated; }
public:
CEnum(): _handleAllocated(false) {}
~CEnum() { Close(); }
- DWORD Open(DWORD scope, DWORD type, DWORD usage, LPNETRESOURCE netResource);
- DWORD Open(DWORD scope, DWORD type, DWORD usage, const CResource *resource);
DWORD Close();
- DWORD Next(LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize);
+ DWORD Open(DWORD scope, DWORD type, DWORD usage, const CResource *resource);
DWORD Next(CResource &resource);
+ #ifndef _UNICODE
+ DWORD Open(DWORD scope, DWORD type, DWORD usage, const CResourceW *resource);
+ DWORD Next(CResourceW &resource);
+ #endif
};
DWORD GetResourceParent(const CResource &resource, CResource &parentResource);
+#ifndef _UNICODE
+DWORD GetResourceParent(const CResourceW &resource, CResourceW &parentResource);
+#endif
+
DWORD GetResourceInformation(const CResource &resource,
CResource &destResource, CSysString &systemPathPart);
-DWORD AddConnection2(const CResource &resource,
- LPCTSTR password, LPCTSTR userName, DWORD flags);
+#ifndef _UNICODE
+DWORD GetResourceInformation(const CResourceW &resource,
+ CResourceW &destResource, UString &systemPathPart);
+#endif
+
+DWORD AddConnection2(const CResource &resource, LPCTSTR password, LPCTSTR userName, DWORD flags);
+#ifndef _UNICODE
+DWORD AddConnection2(const CResourceW &resource, LPCWSTR password, LPCWSTR userName, DWORD flags);
+#endif
}}
diff --git a/Windows/Registry.cpp b/Windows/Registry.cpp
index baad469d..9dbaf2bb 100755
--- a/Windows/Registry.cpp
+++ b/Windows/Registry.cpp
@@ -2,8 +2,15 @@
#include "StdAfx.h"
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
#include "Windows/Registry.h"
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
namespace NWindows {
namespace NRegistry {
@@ -86,11 +93,10 @@ LONG CKey::RecurseDeleteKey(LPCTSTR subKeyName)
if (res != ERROR_SUCCESS)
return res;
FILETIME fileTime;
- const UINT32 kBufferSize = MAX_PATH + 1; // 256 in ATL
+ const UInt32 kBufferSize = MAX_PATH + 1; // 256 in ATL
DWORD size = kBufferSize;
TCHAR buffer[kBufferSize];
- while (RegEnumKeyEx(key._object, 0, buffer, &size, NULL, NULL, NULL,
- &fileTime) == ERROR_SUCCESS)
+ while (RegEnumKeyEx(key._object, 0, buffer, &size, NULL, NULL, NULL, &fileTime) == ERROR_SUCCESS)
{
res = key.RecurseDeleteKey(buffer);
if (res != ERROR_SUCCESS)
@@ -105,57 +111,81 @@ LONG CKey::RecurseDeleteKey(LPCTSTR subKeyName)
/////////////////////////
// Value Functions
-static inline UINT32 BoolToUINT32(bool value)
- { return (value ? 1: 0); }
+static inline UInt32 BoolToUINT32(bool value) { return (value ? 1: 0); }
+static inline bool UINT32ToBool(UInt32 value) { return (value != 0); }
-static inline bool UINT32ToBool(UINT32 value)
- { return (value != 0); }
+LONG CKey::DeleteValue(LPCTSTR name)
+{
+ MYASSERT(_object != NULL);
+ return ::RegDeleteValue(_object, name);
+}
-LONG CKey::DeleteValue(LPCTSTR value)
+#ifndef _UNICODE
+LONG CKey::DeleteValue(LPCWSTR name)
{
MYASSERT(_object != NULL);
- return RegDeleteValue(_object, (LPTSTR)value);
+ if (g_IsNT)
+ return ::RegDeleteValueW(_object, name);
+ return DeleteValue(name == 0 ? 0 : (LPCSTR)GetSystemString(name));
}
+#endif
-LONG CKey::SetValue(LPCTSTR valueName, UINT32 value)
+LONG CKey::SetValue(LPCTSTR name, UInt32 value)
{
MYASSERT(_object != NULL);
- return RegSetValueEx(_object, valueName, NULL, REG_DWORD,
- (BYTE * const)&value, sizeof(UINT32));
+ return RegSetValueEx(_object, name, NULL, REG_DWORD,
+ (BYTE * const)&value, sizeof(UInt32));
}
-LONG CKey::SetValue(LPCTSTR valueName, bool value)
+LONG CKey::SetValue(LPCTSTR name, bool value)
{
- return SetValue(valueName, BoolToUINT32(value));
+ return SetValue(name, BoolToUINT32(value));
}
-LONG CKey::SetValue(LPCTSTR valueName, LPCTSTR value)
+LONG CKey::SetValue(LPCTSTR name, LPCTSTR value)
{
MYASSERT(value != NULL);
MYASSERT(_object != NULL);
- return RegSetValueEx(_object, valueName, NULL, REG_SZ,
+ return RegSetValueEx(_object, name, NULL, REG_SZ,
(const BYTE * )value, (lstrlen(value) + 1) * sizeof(TCHAR));
}
-LONG CKey::SetValue(LPCTSTR valueName, const CSysString &value)
+/*
+LONG CKey::SetValue(LPCTSTR name, const CSysString &value)
{
MYASSERT(value != NULL);
MYASSERT(_object != NULL);
- return RegSetValueEx(_object, valueName, NULL, REG_SZ,
+ return RegSetValueEx(_object, name, NULL, REG_SZ,
(const BYTE *)(const TCHAR *)value, (value.Length() + 1) * sizeof(TCHAR));
}
+*/
-LONG CKey::SetValue(LPCTSTR valueName, const void *value, UINT32 size)
+#ifndef _UNICODE
+
+LONG CKey::SetValue(LPCWSTR name, LPCWSTR value)
{
MYASSERT(value != NULL);
MYASSERT(_object != NULL);
- return RegSetValueEx(_object, valueName, NULL, REG_BINARY,
+ if (g_IsNT)
+ return RegSetValueExW(_object, name, NULL, REG_SZ,
+ (const BYTE * )value, (wcslen(value) + 1) * sizeof(wchar_t));
+ return SetValue(name == 0 ? 0 : (LPCSTR)GetSystemString(name),
+ value == 0 ? 0 : (LPCSTR)GetSystemString(value));
+}
+
+#endif
+
+
+LONG CKey::SetValue(LPCTSTR name, const void *value, UInt32 size)
+{
+ MYASSERT(value != NULL);
+ MYASSERT(_object != NULL);
+ return RegSetValueEx(_object, name, NULL, REG_BINARY,
(const BYTE *)value, size);
}
-LONG SetValue(HKEY parentKey, LPCTSTR keyName,
- LPCTSTR valueName, LPCTSTR value)
+LONG SetValue(HKEY parentKey, LPCTSTR keyName, LPCTSTR valueName, LPCTSTR value)
{
MYASSERT(value != NULL);
CKey key;
@@ -175,92 +205,120 @@ LONG CKey::SetKeyValue(LPCTSTR keyName, LPCTSTR valueName, LPCTSTR value)
return res;
}
-LONG CKey::QueryValue(LPCTSTR valueName, UINT32 &value)
+LONG CKey::QueryValue(LPCTSTR name, UInt32 &value)
{
DWORD type = NULL;
DWORD count = sizeof(DWORD);
- LONG res = RegQueryValueEx(_object, (LPTSTR)valueName, NULL, &type,
+ LONG res = RegQueryValueEx(_object, (LPTSTR)name, NULL, &type,
(LPBYTE)&value, &count);
MYASSERT((res!=ERROR_SUCCESS) || (type == REG_DWORD));
- MYASSERT((res!=ERROR_SUCCESS) || (count == sizeof(UINT32)));
+ MYASSERT((res!=ERROR_SUCCESS) || (count == sizeof(UInt32)));
return res;
}
-LONG CKey::QueryValue(LPCTSTR valueName, bool &value)
+LONG CKey::QueryValue(LPCTSTR name, bool &value)
{
- UINT32 uintValue = BoolToUINT32(value);
- LONG res = QueryValue(valueName, uintValue);
+ UInt32 uintValue = BoolToUINT32(value);
+ LONG res = QueryValue(name, uintValue);
value = UINT32ToBool(uintValue);
return res;
}
-LONG CKey::QueryValue(LPCTSTR valueName, LPTSTR value, UINT32 &count)
+LONG CKey::QueryValue(LPCTSTR name, LPTSTR value, UInt32 &count)
{
MYASSERT(count != NULL);
DWORD type = NULL;
- LONG res = RegQueryValueEx(_object, (LPTSTR)valueName, NULL, &type,
- (LPBYTE)value, (DWORD *)&count);
- MYASSERT((res!=ERROR_SUCCESS) || (type == REG_SZ) ||
- (type == REG_MULTI_SZ) || (type == REG_EXPAND_SZ));
+ LONG res = RegQueryValueEx(_object, (LPTSTR)name, NULL, &type, (LPBYTE)value, (DWORD *)&count);
+ MYASSERT((res!=ERROR_SUCCESS) || (type == REG_SZ) || (type == REG_MULTI_SZ) || (type == REG_EXPAND_SZ));
return res;
}
-LONG CKey::QueryValue(LPCTSTR valueName, CSysString &value)
+LONG CKey::QueryValue(LPCTSTR name, CSysString &value)
{
value.Empty();
DWORD type = NULL;
- UINT32 currentSize = 0;
- LONG res = RegQueryValueEx(_object, (LPTSTR)valueName, NULL, &type,
- NULL, (DWORD *)&currentSize);
+ UInt32 currentSize = 0;
+ LONG res = RegQueryValueEx(_object, (LPTSTR)name, NULL, &type, NULL, (DWORD *)&currentSize);
if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA)
return res;
- res = QueryValue(valueName, value.GetBuffer(currentSize), currentSize);
+ res = QueryValue(name, value.GetBuffer(currentSize), currentSize);
value.ReleaseBuffer();
return res;
}
-LONG CKey::QueryValue(LPCTSTR valueName, void *value, UINT32 &count)
+#ifndef _UNICODE
+LONG CKey::QueryValue(LPCWSTR name, LPWSTR value, UInt32 &count)
+{
+ MYASSERT(count != NULL);
+ DWORD type = NULL;
+ LONG res = RegQueryValueExW(_object, name, NULL, &type, (LPBYTE)value, (DWORD *)&count);
+ MYASSERT((res!=ERROR_SUCCESS) || (type == REG_SZ) || (type == REG_MULTI_SZ) || (type == REG_EXPAND_SZ));
+ return res;
+}
+LONG CKey::QueryValue(LPCWSTR name, UString &value)
+{
+ value.Empty();
+ DWORD type = NULL;
+ UInt32 currentSize = 0;
+
+ LONG res;
+ if (g_IsNT)
+ {
+ res = RegQueryValueExW(_object, name, NULL, &type, NULL, (DWORD *)&currentSize);
+ if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA)
+ return res;
+ res = QueryValue(name, value.GetBuffer(currentSize), currentSize);
+ value.ReleaseBuffer();
+ }
+ else
+ {
+ AString vTemp;
+ res = QueryValue(name == 0 ? 0 : (LPCSTR)GetSystemString(name), vTemp);
+ value = GetUnicodeString(vTemp);
+ }
+ return res;
+}
+#endif
+
+LONG CKey::QueryValue(LPCTSTR name, void *value, UInt32 &count)
{
DWORD type = NULL;
- LONG res = RegQueryValueEx(_object, (LPTSTR)valueName, NULL, &type,
- (LPBYTE)value, (DWORD *)&count);
+ LONG res = RegQueryValueEx(_object, (LPTSTR)name, NULL, &type, (LPBYTE)value, (DWORD *)&count);
MYASSERT((res!=ERROR_SUCCESS) || (type == REG_BINARY));
return res;
}
-LONG CKey::QueryValue(LPCTSTR valueName, CByteBuffer &value, UINT32 &dataSize)
+LONG CKey::QueryValue(LPCTSTR name, CByteBuffer &value, UInt32 &dataSize)
{
DWORD type = NULL;
dataSize = 0;
- LONG res = RegQueryValueEx(_object, (LPTSTR)valueName, NULL, &type,
- NULL, (DWORD *)&dataSize);
+ LONG res = RegQueryValueEx(_object, (LPTSTR)name, NULL, &type, NULL, (DWORD *)&dataSize);
if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA)
return res;
value.SetCapacity(dataSize);
- return QueryValue(valueName, (BYTE *)value, dataSize);
+ return QueryValue(name, (BYTE *)value, dataSize);
}
LONG CKey::EnumKeys(CSysStringVector &keyNames)
{
keyNames.Clear();
CSysString keyName;
- for(UINT32 index = 0; true; index++)
+ for(UInt32 index = 0; true; index++)
{
- const UINT32 kBufferSize = MAX_PATH + 1; // 256 in ATL
+ const UInt32 kBufferSize = MAX_PATH + 1; // 256 in ATL
FILETIME lastWriteTime;
- UINT32 aNameSize = kBufferSize;
- LONG aResult = ::RegEnumKeyEx(_object, index, keyName.GetBuffer(kBufferSize),
- (DWORD *)&aNameSize, NULL, NULL, NULL, &lastWriteTime);
+ UInt32 nameSize = kBufferSize;
+ LONG result = ::RegEnumKeyEx(_object, index, keyName.GetBuffer(kBufferSize),
+ (DWORD *)&nameSize, NULL, NULL, NULL, &lastWriteTime);
keyName.ReleaseBuffer();
- if(aResult == ERROR_NO_MORE_ITEMS)
+ if(result == ERROR_NO_MORE_ITEMS)
break;
- if(aResult != ERROR_SUCCESS)
- return aResult;
+ if(result != ERROR_SUCCESS)
+ return result;
keyNames.Add(keyName);
}
return ERROR_SUCCESS;
}
-
}}
diff --git a/Windows/Registry.h b/Windows/Registry.h
index a020900c..435717bd 100755
--- a/Windows/Registry.h
+++ b/Windows/Registry.h
@@ -5,14 +5,14 @@
#include "Common/Buffer.h"
#include "Common/String.h"
+#include "Common/Types.h"
namespace NWindows {
namespace NRegistry {
const TCHAR kKeyNameDelimiter = TEXT('\\');
-LONG SetValue(HKEY parentKey, LPCTSTR keyName,
- LPCTSTR valueName, LPCTSTR value);
+LONG SetValue(HKEY parentKey, LPCTSTR keyName, LPCTSTR valueName, LPCTSTR value);
class CKey
{
@@ -38,22 +38,36 @@ public:
LONG DeleteSubKey(LPCTSTR subKeyName);
LONG RecurseDeleteKey(LPCTSTR subKeyName);
- LONG DeleteValue(LPCTSTR value);
- LONG SetValue(LPCTSTR valueName, UINT32 value);
+ LONG DeleteValue(LPCTSTR name);
+ #ifndef _UNICODE
+ LONG DeleteValue(LPCWSTR name);
+ #endif
+
+ LONG SetValue(LPCTSTR valueName, UInt32 value);
LONG SetValue(LPCTSTR valueName, bool value);
LONG SetValue(LPCTSTR valueName, LPCTSTR value);
- LONG SetValue(LPCTSTR valueName, const CSysString &value);
- LONG SetValue(LPCTSTR valueName, const void *value, UINT32 size);
+ // LONG SetValue(LPCTSTR valueName, const CSysString &value);
+ #ifndef _UNICODE
+ LONG SetValue(LPCWSTR name, LPCWSTR value);
+ // LONG SetValue(LPCWSTR name, const UString &value);
+ #endif
+
+ LONG SetValue(LPCTSTR name, const void *value, UInt32 size);
LONG SetKeyValue(LPCTSTR keyName, LPCTSTR valueName, LPCTSTR value);
- LONG QueryValue(LPCTSTR valueName, UINT32 &value);
- LONG QueryValue(LPCTSTR valueName, bool &value);
- LONG QueryValue(LPCTSTR valueName, LPTSTR value, UINT32 &dataSize);
- LONG QueryValue(LPCTSTR valueName, CSysString &value);
+ LONG QueryValue(LPCTSTR name, UInt32 &value);
+ LONG QueryValue(LPCTSTR name, bool &value);
+ LONG QueryValue(LPCTSTR name, LPTSTR value, UInt32 &dataSize);
+ LONG QueryValue(LPCTSTR name, CSysString &value);
+
+ #ifndef _UNICODE
+ LONG QueryValue(LPCWSTR name, LPWSTR value, UInt32 &dataSize);
+ LONG QueryValue(LPCWSTR name, UString &value);
+ #endif
- LONG QueryValue(LPCTSTR valueName, void *value, UINT32 &dataSize);
- LONG QueryValue(LPCTSTR valueName, CByteBuffer &value, UINT32 &dataSize);
+ LONG QueryValue(LPCTSTR name, void *value, UInt32 &dataSize);
+ LONG QueryValue(LPCTSTR name, CByteBuffer &value, UInt32 &dataSize);
LONG EnumKeys(CSysStringVector &keyNames);
};
diff --git a/Windows/ResourceString.cpp b/Windows/ResourceString.cpp
index b327298d..48dd4936 100755
--- a/Windows/ResourceString.cpp
+++ b/Windows/ResourceString.cpp
@@ -8,6 +8,9 @@
#endif
extern HINSTANCE g_hInstance;
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
namespace NWindows {
@@ -20,7 +23,8 @@ CSysString MyLoadString(UINT resourceID)
{
size += 256;
len = ::LoadString(g_hInstance, resourceID, s.GetBuffer(size - 1), size);
- } while (size - len <= 1);
+ }
+ while (size - len <= 1);
s.ReleaseBuffer();
return s;
}
@@ -28,23 +32,22 @@ CSysString MyLoadString(UINT resourceID)
#ifndef _UNICODE
UString MyLoadStringW(UINT resourceID)
{
- UString s;
- int size = 256;
- int len;
- do
+ if (g_IsNT)
{
- size += 256;
- len = ::LoadStringW(g_hInstance, resourceID, s.GetBuffer(size - 1), size);
- if (len == 0)
+ UString s;
+ int size = 256;
+ int len;
+ do
{
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- break;
- return GetUnicodeString(MyLoadString(resourceID));
- }
- } while (size - len <= 1);
- s.ReleaseBuffer();
- return s;
+ size += 256;
+ len = ::LoadStringW(g_hInstance, resourceID, s.GetBuffer(size - 1), size);
+ }
+ while (size - len <= 1);
+ s.ReleaseBuffer();
+ return s;
+ }
+ return GetUnicodeString(MyLoadString(resourceID));
}
#endif
-} \ No newline at end of file
+}
diff --git a/Windows/Security.cpp b/Windows/Security.cpp
new file mode 100755
index 00000000..3500de46
--- /dev/null
+++ b/Windows/Security.cpp
@@ -0,0 +1,181 @@
+// Windows/Security.h
+
+#include "StdAfx.h"
+
+#include "Windows/Security.h"
+#include "Windows/Defs.h"
+
+#include "Common/StringConvert.h"
+#include "Defs.h"
+
+namespace NWindows {
+namespace NSecurity {
+
+/*
+bool MyLookupAccountSid(LPCTSTR systemName, PSID sid,
+ CSysString &accountName, CSysString &domainName, PSID_NAME_USE sidNameUse)
+{
+ DWORD accountNameSize = 0, domainNameSize = 0;
+
+ if (!::LookupAccountSid(systemName, sid,
+ accountName.GetBuffer(0), &accountNameSize,
+ domainName.GetBuffer(0), &domainNameSize, sidNameUse))
+ {
+ if (::GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+ return false;
+ }
+ bool result = BOOLToBool(::LookupAccountSid(systemName, sid,
+ accountName.GetBuffer(accountNameSize), &accountNameSize,
+ domainName.GetBuffer(domainNameSize), &domainNameSize, sidNameUse));
+ accountName.ReleaseBuffer();
+ domainName.ReleaseBuffer();
+ return result;
+}
+*/
+
+static void SetLsaString(LPWSTR src, PLSA_UNICODE_STRING dest)
+{
+ int len = wcslen(src);
+ dest->Length = len * sizeof(WCHAR);
+ dest->MaximumLength = (len + 1) * sizeof(WCHAR);
+ dest->Buffer = src;
+}
+
+/*
+static void MyLookupSids(CPolicy &policy, PSID ps)
+{
+ LSA_REFERENCED_DOMAIN_LIST *referencedDomains = NULL;
+ LSA_TRANSLATED_NAME *names = NULL;
+ NTSTATUS nts = policy.LookupSids(1, &ps, &referencedDomains, &names);
+ int res = LsaNtStatusToWinError(nts);
+ LsaFreeMemory(referencedDomains);
+ LsaFreeMemory(names);
+}
+*/
+
+#ifndef _UNICODE
+typedef BOOL (WINAPI * LookupAccountNameWP)(
+ LPCWSTR lpSystemName,
+ LPCWSTR lpAccountName,
+ PSID Sid,
+ LPDWORD cbSid,
+ LPWSTR ReferencedDomainName,
+ LPDWORD cchReferencedDomainName,
+ PSID_NAME_USE peUse
+ );
+#endif
+
+static PSID GetSid(LPWSTR accountName)
+{
+ #ifndef _UNICODE
+ HMODULE hModule = GetModuleHandle(TEXT("Advapi32.dll"));
+ if (hModule == NULL)
+ return NULL;
+ LookupAccountNameWP lookupAccountNameW = (LookupAccountNameWP)GetProcAddress(hModule, "LookupAccountNameW");
+ if (lookupAccountNameW == NULL)
+ return NULL;
+ #endif
+
+ DWORD sidLen = 0, domainLen = 0;
+ SID_NAME_USE sidNameUse;
+ if (!
+ #ifdef _UNICODE
+ ::LookupAccountNameW
+ #else
+ lookupAccountNameW
+ #endif
+ (NULL, accountName, NULL, &sidLen, NULL, &domainLen, &sidNameUse))
+ {
+ if(::GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+ {
+ PSID pSid = ::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sidLen);
+ LPWSTR domainName = (LPWSTR)::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (domainLen + 1) * sizeof(WCHAR));
+ BOOL res =
+ #ifdef _UNICODE
+ ::LookupAccountNameW
+ #else
+ lookupAccountNameW
+ #endif
+ (NULL, accountName, pSid, &sidLen, domainName, &domainLen, &sidNameUse);
+ ::HeapFree(GetProcessHeap(), 0, domainName);
+ if (res)
+ return pSid;
+ }
+ }
+ return NULL;
+}
+
+bool AddLockMemoryPrivilege()
+{
+ CPolicy policy;
+ LSA_OBJECT_ATTRIBUTES attr;
+ attr.Length = sizeof(attr);
+ attr.RootDirectory = NULL;
+ attr.ObjectName = NULL;
+ attr.Attributes = 0;
+ attr.SecurityDescriptor = NULL;
+ attr.SecurityQualityOfService = NULL;
+ if (policy.Open(NULL, &attr,
+ // GENERIC_WRITE)
+ POLICY_ALL_ACCESS)
+ // STANDARD_RIGHTS_REQUIRED,
+ // GENERIC_READ | GENERIC_EXECUTE | POLICY_VIEW_LOCAL_INFORMATION | POLICY_LOOKUP_NAMES)
+ != 0)
+ return false;
+ LSA_UNICODE_STRING userRights;
+ UString s = GetUnicodeString(SE_LOCK_MEMORY_NAME);
+ SetLsaString((LPWSTR)(LPCWSTR)s, &userRights);
+ WCHAR userName[256 + 2];
+ DWORD size = 256;
+ if (!GetUserNameW(userName, &size))
+ return false;
+ PSID psid = GetSid(userName);
+ if (psid == NULL)
+ return false;
+ bool res = false;
+
+ /*
+ PLSA_UNICODE_STRING userRightsArray;
+ ULONG countOfRights;
+ NTSTATUS status = policy.EnumerateAccountRights(psid, &userRightsArray, &countOfRights);
+ if (status != 0)
+ return false;
+ bool finded = false;
+ for (ULONG i = 0; i < countOfRights; i++)
+ {
+ LSA_UNICODE_STRING &ur = userRightsArray[i];
+ if (ur.Length != s.Length() * sizeof(WCHAR))
+ continue;
+ if (wcsncmp(ur.Buffer, s, s.Length()) != 0)
+ continue;
+ finded = true;
+ res = true;
+ break;
+ }
+ if (!finded)
+ */
+ {
+ /*
+ LSA_ENUMERATION_INFORMATION *enums;
+ ULONG countReturned;
+ NTSTATUS status = policy.EnumerateAccountsWithUserRight(&userRights, &enums, &countReturned);
+ if (status == 0)
+ {
+ for (ULONG i = 0; i < countReturned; i++)
+ MyLookupSids(policy, enums[i].Sid);
+ if (enums)
+ ::LsaFreeMemory(enums);
+ res = true;
+ }
+ */
+ NTSTATUS status = policy.AddAccountRights(psid, &userRights);
+ if (status == 0)
+ res = true;
+ // ULONG res = LsaNtStatusToWinError(status);
+ }
+ HeapFree(GetProcessHeap(), 0, psid);
+ return res;
+}
+
+}}
+
diff --git a/Windows/Security.h b/Windows/Security.h
new file mode 100755
index 00000000..929986d8
--- /dev/null
+++ b/Windows/Security.h
@@ -0,0 +1,168 @@
+// Windows/Security.h
+
+#ifndef __WINDOWS_SECURITY_H
+#define __WINDOWS_SECURITY_H
+
+#include "Common/String.h"
+#include "Windows/Defs.h"
+
+#include <NTSecAPI.h>
+
+namespace NWindows {
+namespace NSecurity {
+
+class CAccessToken
+{
+ HANDLE _handle;
+public:
+ CAccessToken(): _handle(NULL) {};
+ ~CAccessToken() { Close(); }
+ bool Close()
+ {
+ if (_handle == NULL)
+ return true;
+ bool res = BOOLToBool(::CloseHandle(_handle));
+ if (res)
+ _handle = NULL;
+ return res;
+ }
+
+ bool OpenProcessToken(HANDLE processHandle, DWORD desiredAccess)
+ {
+ Close();
+ return BOOLToBool(::OpenProcessToken(processHandle, desiredAccess, &_handle));
+ }
+
+ /*
+ bool OpenThreadToken(HANDLE threadHandle, DWORD desiredAccess, bool openAsSelf)
+ {
+ Close();
+ return BOOLToBool(::OpenTreadToken(threadHandle, desiredAccess, BoolToBOOL(anOpenAsSelf), &_handle));
+ }
+ */
+
+ bool AdjustPrivileges(bool disableAllPrivileges, PTOKEN_PRIVILEGES newState,
+ DWORD bufferLength, PTOKEN_PRIVILEGES previousState, PDWORD returnLength)
+ { return BOOLToBool(::AdjustTokenPrivileges(_handle, BoolToBOOL(disableAllPrivileges),
+ newState, bufferLength, previousState, returnLength)); }
+
+ bool AdjustPrivileges(bool disableAllPrivileges, PTOKEN_PRIVILEGES newState)
+ { return AdjustPrivileges(disableAllPrivileges, newState, 0, NULL, NULL); }
+
+ bool AdjustPrivileges(PTOKEN_PRIVILEGES newState)
+ { return AdjustPrivileges(false, newState); }
+
+};
+
+#ifndef _UNICODE
+typedef NTSTATUS (NTAPI *LsaOpenPolicyP)(PLSA_UNICODE_STRING SystemName,
+ PLSA_OBJECT_ATTRIBUTES ObjectAttributes, ACCESS_MASK DesiredAccess, PLSA_HANDLE PolicyHandle);
+typedef NTSTATUS (NTAPI *LsaCloseP)(LSA_HANDLE ObjectHandle);
+typedef NTSTATUS (NTAPI *LsaAddAccountRightsP)(LSA_HANDLE PolicyHandle,
+ PSID AccountSid, PLSA_UNICODE_STRING UserRights, ULONG CountOfRights );
+#define MY_STATUS_NOT_IMPLEMENTED ((NTSTATUS)0xC0000002L)
+#endif
+
+struct CPolicy
+{
+protected:
+ LSA_HANDLE _handle;
+ #ifndef _UNICODE
+ HMODULE hModule;
+ #endif
+public:
+ operator LSA_HANDLE() const { return _handle; }
+ CPolicy(): _handle(NULL)
+ {
+ #ifndef _UNICODE
+ hModule = GetModuleHandle(TEXT("Advapi32.dll"));
+ #endif
+ };
+ ~CPolicy() { Close(); }
+
+ NTSTATUS Open(PLSA_UNICODE_STRING systemName, PLSA_OBJECT_ATTRIBUTES objectAttributes,
+ ACCESS_MASK desiredAccess)
+ {
+ #ifndef _UNICODE
+ if (hModule == NULL)
+ return MY_STATUS_NOT_IMPLEMENTED;
+ LsaOpenPolicyP lsaOpenPolicy = (LsaOpenPolicyP)GetProcAddress(hModule, "LsaOpenPolicy");
+ if (lsaOpenPolicy == NULL)
+ return MY_STATUS_NOT_IMPLEMENTED;
+ #endif
+
+ Close();
+ return
+ #ifdef _UNICODE
+ ::LsaOpenPolicy
+ #else
+ lsaOpenPolicy
+ #endif
+ (systemName, objectAttributes, desiredAccess, &_handle);
+ }
+
+ NTSTATUS Close()
+ {
+ if (_handle == NULL)
+ return 0;
+
+ #ifndef _UNICODE
+ if (hModule == NULL)
+ return MY_STATUS_NOT_IMPLEMENTED;
+ LsaCloseP lsaClose = (LsaCloseP)GetProcAddress(hModule, "LsaClose");
+ if (lsaClose == NULL)
+ return MY_STATUS_NOT_IMPLEMENTED;
+ #endif
+
+ NTSTATUS res =
+ #ifdef _UNICODE
+ ::LsaClose
+ #else
+ lsaClose
+ #endif
+ (_handle);
+ _handle = NULL;
+ return res;
+ }
+
+ NTSTATUS EnumerateAccountsWithUserRight(PLSA_UNICODE_STRING userRights,
+ PLSA_ENUMERATION_INFORMATION *enumerationBuffer, PULONG countReturned)
+ { return LsaEnumerateAccountsWithUserRight(_handle, userRights, (void **)enumerationBuffer, countReturned); }
+
+ NTSTATUS EnumerateAccountRights(PSID sid, PLSA_UNICODE_STRING* userRights, PULONG countOfRights)
+ { return ::LsaEnumerateAccountRights(_handle, sid, userRights, countOfRights); }
+
+ NTSTATUS LookupSids(ULONG count, PSID* sids,
+ PLSA_REFERENCED_DOMAIN_LIST* referencedDomains, PLSA_TRANSLATED_NAME* names)
+ { return LsaLookupSids(_handle, count, sids, referencedDomains, names); }
+
+ NTSTATUS AddAccountRights(PSID accountSid, PLSA_UNICODE_STRING userRights, ULONG countOfRights)
+ {
+ #ifndef _UNICODE
+ if (hModule == NULL)
+ return MY_STATUS_NOT_IMPLEMENTED;
+ LsaAddAccountRightsP lsaAddAccountRights = (LsaAddAccountRightsP)GetProcAddress(hModule, "LsaAddAccountRights");
+ if (lsaAddAccountRights == NULL)
+ return MY_STATUS_NOT_IMPLEMENTED;
+ #endif
+
+ return
+ #ifdef _UNICODE
+ ::LsaAddAccountRights
+ #else
+ lsaAddAccountRights
+ #endif
+ (_handle, accountSid, userRights, countOfRights);
+ }
+ NTSTATUS AddAccountRights(PSID accountSid, PLSA_UNICODE_STRING userRights)
+ { return AddAccountRights(accountSid, userRights, 1); }
+
+ NTSTATUS RemoveAccountRights(PSID accountSid, bool allRights, PLSA_UNICODE_STRING userRights, ULONG countOfRights)
+ { return LsaRemoveAccountRights(_handle, accountSid, BoolToBOOL(allRights), userRights, countOfRights); }
+};
+
+bool AddLockMemoryPrivilege();
+
+}}
+
+#endif
diff --git a/Windows/Shell.cpp b/Windows/Shell.cpp
index 2d0e8bb2..490eb199 100755
--- a/Windows/Shell.cpp
+++ b/Windows/Shell.cpp
@@ -2,10 +2,17 @@
#include "StdAfx.h"
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
#include "Common/MyCom.h"
#include "Windows/Shell.h"
#include "Windows/COM.h"
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
namespace NWindows {
namespace NShell {
@@ -77,26 +84,34 @@ CDrop::~CDrop()
Free();
}
-UINT CDrop::QueryFile(UINT fileIndex, LPTSTR fileName, UINT fileNameSize)
-{
- return ::DragQueryFile(m_Object, fileIndex, fileName, fileNameSize);
-}
-
UINT CDrop::QueryCountOfFiles()
{
- return QueryFile(0xFFFFFFFF, NULL, 0);
+ return QueryFile(0xFFFFFFFF, (LPTSTR)NULL, 0);
}
-CSysString CDrop::QueryFileName(UINT fileIndex)
+UString CDrop::QueryFileName(UINT fileIndex)
{
- CSysString fileName;
- UINT bufferSize = QueryFile(fileIndex, NULL, 0);
- QueryFile(fileIndex, fileName.GetBuffer(bufferSize), bufferSize + 1);
- fileName.ReleaseBuffer();
+ UString fileName;
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ AString fileNameA;
+ UINT bufferSize = QueryFile(fileIndex, (LPTSTR)NULL, 0);
+ QueryFile(fileIndex, fileNameA.GetBuffer(bufferSize + 2), bufferSize + 1);
+ fileNameA.ReleaseBuffer();
+ fileName = GetUnicodeString(fileNameA);
+ }
+ else
+ #endif
+ {
+ UINT bufferSize = QueryFile(fileIndex, (LPWSTR)NULL, 0);
+ QueryFile(fileIndex, fileName.GetBuffer(bufferSize + 2), bufferSize + 1);
+ fileName.ReleaseBuffer();
+ }
return fileName;
}
-void CDrop::QueryFileNames(CSysStringVector &fileNames)
+void CDrop::QueryFileNames(UStringVector &fileNames)
{
fileNames.Clear();
UINT numFiles = QueryCountOfFiles();
@@ -111,8 +126,7 @@ void CDrop::QueryFileNames(CSysStringVector &fileNames)
bool GetPathFromIDList(LPCITEMIDLIST itemIDList, CSysString &path)
{
- bool result = BOOLToBool(::SHGetPathFromIDList(itemIDList,
- path.GetBuffer(MAX_PATH)));
+ bool result = BOOLToBool(::SHGetPathFromIDList(itemIDList, path.GetBuffer(MAX_PATH * 2)));
path.ReleaseBuffer();
return result;
}
@@ -177,4 +191,80 @@ bool BrowseForFolder(HWND owner, LPCTSTR title,
// BIF_STATUSTEXT; BIF_USENEWUI (Version 5.0)
}
+#ifndef _UNICODE
+
+bool GetPathFromIDList(LPCITEMIDLIST itemIDList, UString &path)
+{
+ bool result = BOOLToBool(::SHGetPathFromIDListW(itemIDList, path.GetBuffer(MAX_PATH * 2)));
+ path.ReleaseBuffer();
+ return result;
+}
+
+bool BrowseForFolder(LPBROWSEINFOW browseInfo, UString &resultPath)
+{
+ NWindows::NCOM::CComInitializer comInitializer;
+ LPITEMIDLIST itemIDList = ::SHBrowseForFolderW(browseInfo);
+ if (itemIDList == NULL)
+ return false;
+ CItemIDList itemIDListHolder;
+ itemIDListHolder.Attach(itemIDList);
+ return GetPathFromIDList(itemIDList, resultPath);
+}
+
+
+int CALLBACK BrowseCallbackProc2(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM data)
+{
+ switch(uMsg)
+ {
+ case BFFM_INITIALIZED:
+ {
+ SendMessageW(hwnd, BFFM_SETSELECTIONW, TRUE, data);
+ break;
+ }
+ case BFFM_SELCHANGED:
+ {
+ wchar_t dir[MAX_PATH * 2];
+ if (::SHGetPathFromIDListW((LPITEMIDLIST) lp , dir))
+ SendMessageW(hwnd, BFFM_SETSTATUSTEXTW, 0, (LPARAM)dir);
+ else
+ SendMessageW(hwnd, BFFM_SETSTATUSTEXTW, 0, (LPARAM)L"");
+ break;
+ }
+ default:
+ break;
+ }
+ return 0;
+}
+
+
+static bool BrowseForFolder(HWND owner, LPCWSTR title, UINT ulFlags,
+ LPCWSTR initialFolder, UString &resultPath)
+{
+ UString displayName;
+ BROWSEINFOW browseInfo;
+ browseInfo.hwndOwner = owner;
+ browseInfo.pidlRoot = NULL;
+ browseInfo.pszDisplayName = displayName.GetBuffer(MAX_PATH);
+ browseInfo.lpszTitle = title;
+ browseInfo.ulFlags = ulFlags;
+ browseInfo.lpfn = (initialFolder != NULL) ? BrowseCallbackProc2 : NULL;
+ browseInfo.lParam = (LPARAM)initialFolder;
+ return BrowseForFolder(&browseInfo, resultPath);
+}
+
+bool BrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath)
+{
+ if (g_IsNT)
+ return BrowseForFolder(owner, title,
+ BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT, initialFolder, resultPath);
+ // BIF_STATUSTEXT; BIF_USENEWUI (Version 5.0)
+ CSysString s;
+ bool res = BrowseForFolder(owner, GetSystemString(title),
+ BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT, GetSystemString(initialFolder), s);
+ resultPath = GetUnicodeString(s);
+ return res;
+}
+
+#endif
+
}}
diff --git a/Windows/Shell.h b/Windows/Shell.h
index f4d85a46..4770a454 100755
--- a/Windows/Shell.h
+++ b/Windows/Shell.h
@@ -63,21 +63,29 @@ public:
bool QueryPoint(LPPOINT point)
{ return BOOLToBool(::DragQueryPoint(m_Object, point)); }
void Finish() { ::DragFinish(m_Object); }
- UINT QueryFile(UINT fileIndex, LPTSTR fileName, UINT fileNameSize);
+ UINT QueryFile(UINT fileIndex, LPTSTR fileName, UINT fileNameSize)
+ { return ::DragQueryFile(m_Object, fileIndex, fileName, fileNameSize); }
+ #ifndef _UNICODE
+ UINT QueryFile(UINT fileIndex, LPWSTR fileName, UINT fileNameSize)
+ { return ::DragQueryFileW(m_Object, fileIndex, fileName, fileNameSize); }
+ #endif
UINT QueryCountOfFiles();
- CSysString QueryFileName(UINT fileIndex);
- void QueryFileNames(CSysStringVector &fileNames);
+ UString QueryFileName(UINT fileIndex);
+ void QueryFileNames(UStringVector &fileNames);
};
/////////////////////////////
// Functions
bool GetPathFromIDList(LPCITEMIDLIST itemIDList, CSysString &path);
-
bool BrowseForFolder(LPBROWSEINFO lpbi, CSysString &resultPath);
-bool BrowseForFolder(HWND owner, LPCTSTR title,
- LPCTSTR initialFolder, CSysString &resultPath);
+bool BrowseForFolder(HWND owner, LPCTSTR title, LPCTSTR initialFolder, CSysString &resultPath);
+#ifndef _UNICODE
+bool GetPathFromIDList(LPCITEMIDLIST itemIDList, UString &path);
+bool BrowseForFolder(LPBROWSEINFO lpbi, UString &resultPath);
+bool BrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath);
+#endif
}}
diff --git a/Windows/Window.cpp b/Windows/Window.cpp
index 61e005c8..b30ccdc3 100755
--- a/Windows/Window.cpp
+++ b/Windows/Window.cpp
@@ -2,24 +2,115 @@
#include "StdAfx.h"
-#include "Windows/Window.h"
#ifndef _UNICODE
#include "Common/StringConvert.h"
#endif
+#include "Windows/Window.h"
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
namespace NWindows {
#ifndef _UNICODE
-bool CWindow::SetText(LPCWSTR s)
-{
- if (::SetWindowTextW(_window, s))
- return true;
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
- return SetText(UnicodeStringToMultiByte(s));
+ATOM MyRegisterClass(CONST WNDCLASSW *wndClass)
+{
+ if (g_IsNT)
+ return RegisterClassW(wndClass);
+ WNDCLASSA wndClassA;
+ wndClassA.style = wndClass->style;
+ wndClassA.lpfnWndProc = wndClass->lpfnWndProc;
+ wndClassA.cbClsExtra = wndClass->cbClsExtra;
+ wndClassA.cbWndExtra = wndClass->cbWndExtra;
+ wndClassA.hInstance = wndClass->hInstance;
+ wndClassA.hIcon = wndClass->hIcon;
+ wndClassA.hCursor = wndClass->hCursor;
+ wndClassA.hbrBackground = wndClass->hbrBackground;
+ AString menuName;
+ AString className;
+ if (IS_INTRESOURCE(wndClass->lpszMenuName))
+ wndClassA.lpszMenuName = (LPCSTR)wndClass->lpszMenuName;
+ else
+ {
+ menuName = GetSystemString(wndClass->lpszMenuName);
+ wndClassA.lpszMenuName = menuName;
+ }
+ if (IS_INTRESOURCE(wndClass->lpszClassName))
+ wndClassA.lpszClassName = (LPCSTR)wndClass->lpszClassName;
+ else
+ {
+ className = GetSystemString(wndClass->lpszClassName);
+ wndClassA.lpszClassName = className;
+ }
+ return RegisterClassA(&wndClassA);
+}
+
+bool CWindow::Create(LPCWSTR className,
+ LPCWSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance, LPVOID createParam)
+{
+ if (g_IsNT)
+ {
+ _window = ::CreateWindowW(className, windowName,
+ style, x, y, width, height, parentWindow,
+ idOrHMenu, instance, createParam);
+ return (_window != NULL);
+ }
+ return Create(GetSystemString(className), GetSystemString(windowName),
+ style, x, y, width, height, parentWindow,
+ idOrHMenu, instance, createParam);
}
+
+bool CWindow::CreateEx(DWORD exStyle, LPCWSTR className,
+ LPCWSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance, LPVOID createParam)
+{
+ if (g_IsNT)
+ {
+ _window = ::CreateWindowExW(exStyle, className, windowName,
+ style, x, y, width, height, parentWindow,
+ idOrHMenu, instance, createParam);
+ return (_window != NULL);
+ }
+ AString classNameA;
+ LPCSTR classNameP;
+ if (IS_INTRESOURCE(className))
+ classNameP = (LPCSTR)className;
+ else
+ {
+ classNameA = GetSystemString(className);
+ classNameP = classNameA;
+ }
+ AString windowNameA;
+ LPCSTR windowNameP;
+ if (IS_INTRESOURCE(windowName))
+ windowNameP = (LPCSTR)windowName;
+ else
+ {
+ windowNameA = GetSystemString(windowName);
+ windowNameP = windowNameA;
+ }
+ return CreateEx(exStyle, classNameP, windowNameP,
+ style, x, y, width, height, parentWindow,
+ idOrHMenu, instance, createParam);
+}
+
#endif
+#ifndef _UNICODE
+bool MySetWindowText(HWND wnd, LPCWSTR s)
+{
+ if (g_IsNT)
+ return BOOLToBool(::SetWindowTextW(wnd, s));
+ return BOOLToBool(::SetWindowTextA(wnd, UnicodeStringToMultiByte(s)));
+}
+#endif
+
bool CWindow::GetText(CSysString &s)
{
s.Empty();
@@ -36,28 +127,26 @@ bool CWindow::GetText(CSysString &s)
#ifndef _UNICODE
bool CWindow::GetText(UString &s)
{
- s.Empty();
- int length = GetWindowTextLengthW(_window);
- if (length == 0)
+ if (g_IsNT)
{
- UINT lastError = ::GetLastError();
- if (lastError == ERROR_SUCCESS)
- return true;
- if (lastError != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
- CSysString sysString;
- bool result = GetText(sysString);
- s = GetUnicodeString(sysString);
- return result;
+ s.Empty();
+ int length = GetWindowTextLengthW(_window);
+ if (length == 0)
+ return (::GetLastError() == ERROR_SUCCESS);
+ length = GetWindowTextW(_window, s.GetBuffer(length), length + 1);
+ s.ReleaseBuffer();
+ if (length == 0)
+ return (::GetLastError() == ERROR_SUCCESS);
+ return true;
}
- length = GetWindowTextW(_window, s.GetBuffer(length), length + 1);
- s.ReleaseBuffer();
- if (length == 0)
- return (::GetLastError() == ERROR_SUCCESS);
- return true;
+ CSysString sysString;
+ bool result = GetText(sysString);
+ s = GetUnicodeString(sysString);
+ return result;
}
#endif
-
+
+
/*
bool CWindow::ModifyStyleBase(int styleOffset,
DWORD remove, DWORD add, UINT flags)
diff --git a/Windows/Window.h b/Windows/Window.h
index a3c670eb..c2818444 100755
--- a/Windows/Window.h
+++ b/Windows/Window.h
@@ -8,6 +8,21 @@
namespace NWindows {
+inline ATOM MyRegisterClass(CONST WNDCLASS *wndClass)
+ { return ::RegisterClass(wndClass); }
+
+#ifndef _UNICODE
+ATOM MyRegisterClass(CONST WNDCLASSW *wndClass);
+#endif
+
+#ifdef _UNICODE
+inline bool MySetWindowText(HWND wnd, LPCWSTR s) { return BOOLToBool(::SetWindowText(wnd, s)); }
+#else
+bool MySetWindowText(HWND wnd, LPCWSTR s);
+#endif
+
+
+
class CWindow
{
private:
@@ -22,8 +37,7 @@ public:
return *this;
}
operator HWND() const { return _window; }
- void Attach(HWND newWindow)
- { _window = newWindow; }
+ void Attach(HWND newWindow) { _window = newWindow; }
HWND Detach()
{
HWND window = _window;
@@ -31,18 +45,11 @@ public:
return window;
}
- HWND GetParent() const
- { return ::GetParent(_window); }
- bool GetWindowRect(LPRECT rect) const
- { return BOOLToBool(::GetWindowRect(_window,rect )); }
- bool IsZoomed() const
- { return BOOLToBool(::IsZoomed(_window)); }
-
- bool ClientToScreen(LPPOINT point) const
- { return BOOLToBool(::ClientToScreen(_window, point)); }
-
- bool ScreenToClient(LPPOINT point) const
- { return BOOLToBool(::ScreenToClient(_window, point)); }
+ HWND GetParent() const { return ::GetParent(_window); }
+ bool GetWindowRect(LPRECT rect) const { return BOOLToBool(::GetWindowRect(_window,rect )); }
+ bool IsZoomed() const { return BOOLToBool(::IsZoomed(_window)); }
+ bool ClientToScreen(LPPOINT point) const { return BOOLToBool(::ClientToScreen(_window, point)); }
+ bool ScreenToClient(LPPOINT point) const { return BOOLToBool(::ScreenToClient(_window, point)); }
bool CreateEx(DWORD exStyle, LPCTSTR className,
LPCTSTR windowName, DWORD style,
@@ -56,6 +63,32 @@ public:
return (_window != NULL);
}
+ bool Create(LPCTSTR className,
+ LPCTSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance, LPVOID createParam)
+ {
+ _window = ::CreateWindow(className, windowName,
+ style, x, y, width, height, parentWindow,
+ idOrHMenu, instance, createParam);
+ return (_window != NULL);
+ }
+
+ #ifndef _UNICODE
+ bool Create(LPCWSTR className,
+ LPCWSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance, LPVOID createParam);
+ bool CreateEx(DWORD exStyle, LPCWSTR className,
+ LPCWSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance, LPVOID createParam);
+ #endif
+
+
bool Destroy()
{
if (_window == NULL)
@@ -65,25 +98,17 @@ public:
_window = NULL;
return result;
}
- bool IsWindow()
- { return BOOLToBool(::IsWindow(_window)); }
+ bool IsWindow() { return BOOLToBool(::IsWindow(_window)); }
bool Move(int x, int y, int width, int height, bool repaint = true)
{ return BOOLToBool(::MoveWindow(_window, x, y, width, height, BoolToBOOL(repaint))); }
- bool GetClientRect(LPRECT rect)
- { return BOOLToBool(::GetClientRect(_window, rect)); }
- bool Show(int cmdShow)
- { return BOOLToBool(::ShowWindow(_window, cmdShow)); }
- bool SetPlacement(CONST WINDOWPLACEMENT *placement)
- { return BOOLToBool(::SetWindowPlacement(_window, placement)); }
- bool GetPlacement(WINDOWPLACEMENT *placement)
- { return BOOLToBool(::GetWindowPlacement(_window, placement)); }
-
- bool Update()
- { return BOOLToBool(::UpdateWindow(_window)); }
+ bool GetClientRect(LPRECT rect) { return BOOLToBool(::GetClientRect(_window, rect)); }
+ bool Show(int cmdShow) { return BOOLToBool(::ShowWindow(_window, cmdShow)); }
+ bool SetPlacement(CONST WINDOWPLACEMENT *placement) { return BOOLToBool(::SetWindowPlacement(_window, placement)); }
+ bool GetPlacement(WINDOWPLACEMENT *placement) { return BOOLToBool(::GetWindowPlacement(_window, placement)); }
+ bool Update() { return BOOLToBool(::UpdateWindow(_window)); }
bool InvalidateRect(LPCRECT rect, bool backgroundErase = true)
{ return BOOLToBool(::InvalidateRect(_window, rect, BoolToBOOL(backgroundErase))); }
- void SetRedraw(bool redraw = true)
- { SendMessage(WM_SETREDRAW, BoolToBOOL(redraw), 0); }
+ void SetRedraw(bool redraw = true) { SendMessage(WM_SETREDRAW, BoolToBOOL(redraw), 0); }
#ifndef _WIN32_WCE
LONG SetStyle(LONG_PTR style)
@@ -109,6 +134,11 @@ public:
#ifndef _WIN32_WCE
LONG_PTR SetLongPtr(int index, LONG_PTR newLongPtr )
{ return ::SetWindowLongPtr(_window, index, newLongPtr); }
+ #ifndef _UNICODE
+ LONG_PTR SetLongPtrW(int index, LONG_PTR newLongPtr )
+ { return ::SetWindowLongPtrW(_window, index, newLongPtr); }
+ #endif
+
LONG_PTR GetLongPtr(int index) const
{ return ::GetWindowLongPtr(_window, index ); }
LONG_PTR SetUserDataLongPtr(LONG_PTR newLongPtr )
@@ -124,18 +154,25 @@ public:
{ return ModifyStyleBase(GWL_EXSTYLE, remove, add, flags); }
*/
- HWND SetFocus()
- { return ::SetFocus(_window); }
+ HWND SetFocus() { return ::SetFocus(_window); }
LRESULT SendMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0)
- { return ::SendMessage(_window, message, wParam, lParam) ;}
+ { return ::SendMessage(_window, message, wParam, lParam) ;}
+ #ifndef _UNICODE
+ LRESULT SendMessageW(UINT message, WPARAM wParam = 0, LPARAM lParam = 0)
+ { return ::SendMessageW(_window, message, wParam, lParam) ;}
+ #endif
+
bool PostMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0)
{ return BOOLToBool(::PostMessage(_window, message, wParam, lParam)) ;}
+ #ifndef _UNICODE
+ LRESULT PostMessageW(UINT message, WPARAM wParam = 0, LPARAM lParam = 0)
+ { return ::PostMessageW(_window, message, wParam, lParam) ;}
+ #endif
- bool SetText(LPCTSTR s)
- { return BOOLToBool(::SetWindowText(_window, s)); }
+ bool SetText(LPCTSTR s) { return BOOLToBool(::SetWindowText(_window, s)); }
#ifndef _UNICODE
- bool CWindow::SetText(LPCWSTR s);
+ bool CWindow::SetText(LPCWSTR s) { return MySetWindowText(_window, s); }
#endif
int GetTextLength() const