This commit is contained in:
Igor Pavlov
2005-12-09 00:00:00 +00:00
committed by Kornel Lesiński
parent acac987575
commit e8d0636d7a
13 changed files with 138 additions and 94 deletions

View File

@@ -192,7 +192,7 @@ SZ_RESULT SafeReadDirect(ISzInStream *inStream, Byte *data, size_t size)
{ {
Byte *inBuffer; Byte *inBuffer;
size_t processedSize; size_t processedSize;
RINOK(inStream->Read(inStream, &inBuffer, size, &processedSize)); RINOK(inStream->Read(inStream, (void **)&inBuffer, size, &processedSize));
if (processedSize == 0 || processedSize > size) if (processedSize == 0 || processedSize > size)
return SZE_FAIL; return SZE_FAIL;
size -= processedSize; size -= processedSize;

View File

@@ -105,8 +105,8 @@ static void PrintHelp()
" -mf{MF_ID}: set Match Finder: [bt2, bt3, bt4, bt4b, pat2r, pat2,\n" " -mf{MF_ID}: set Match Finder: [bt2, bt3, bt4, bt4b, pat2r, pat2,\n"
" pat2h, pat3h, pat4h, hc3, hc4], default: bt4\n" " pat2h, pat3h, pat4h, hc3, hc4], default: bt4\n"
" -eos: write End Of Stream marker\n" " -eos: write End Of Stream marker\n"
" -si: Read data from stdin\n" " -si: read data from stdin\n"
" -so: Write data to stdout\n" " -so: write data to stdout\n"
); );
} }
@@ -150,7 +150,7 @@ int main2(int n, const char *args[])
g_IsNT = IsItWindowsNT(); g_IsNT = IsItWindowsNT();
#endif #endif
fprintf(stderr, "\nLZMA 4.30 Copyright (c) 1999-2005 Igor Pavlov 2005-11-20\n"); fprintf(stderr, "\nLZMA 4.32 Copyright (c) 1999-2005 Igor Pavlov 2005-12-09\n");
if (n == 1) if (n == 1)
{ {

View File

@@ -14,7 +14,7 @@ const UInt32 kTopValue = (1 << kNumTopBits);
class CEncoder class CEncoder
{ {
UInt32 _ffNum; UInt32 _cacheSize;
Byte _cache; Byte _cache;
public: public:
UInt64 Low; UInt64 Low;
@@ -28,7 +28,7 @@ public:
Stream.Init(); Stream.Init();
Low = 0; Low = 0;
Range = 0xFFFFFFFF; Range = 0xFFFFFFFF;
_ffNum = 0; _cacheSize = 1;
_cache = 0; _cache = 0;
} }
@@ -54,36 +54,21 @@ public:
} }
} }
/*
void EncodeDirectBitsDiv(UInt32 value, UInt32 numTotalBits)
{
Low += value * (Range >>= numTotalBits);
Normalize();
}
void EncodeDirectBitsDiv2(UInt32 value, UInt32 numTotalBits)
{
if (numTotalBits <= kNumBottomBits)
EncodeDirectBitsDiv(value, numTotalBits);
else
{
EncodeDirectBitsDiv(value >> kNumBottomBits, (numTotalBits - kNumBottomBits));
EncodeDirectBitsDiv(value & ((1 << kBottomValueBits) - 1), kNumBottomBits);
}
}
*/
void ShiftLow() void ShiftLow()
{ {
if (Low < (UInt32)0xFF000000 || UInt32(Low >> 32) == 1) if ((UInt32)Low < (UInt32)0xFF000000 || (int)(Low >> 32) != 0)
{ {
Stream.WriteByte(Byte(_cache + Byte(Low >> 32))); Byte temp = _cache;
for (;_ffNum != 0; _ffNum--) do
Stream.WriteByte(Byte(0xFF + Byte(Low >> 32))); {
_cache = Byte(UInt32(Low) >> 24); Stream.WriteByte((Byte)(temp + (Byte)(Low >> 32)));
temp = 0xFF;
}
while(--_cacheSize != 0);
_cache = (Byte)((UInt32)Low >> 24);
} }
else _cacheSize++;
_ffNum++; Low = (UInt32)Low << 8;
Low = UInt32(Low) << 8;
} }
void EncodeDirectBits(UInt32 value, int numTotalBits) void EncodeDirectBits(UInt32 value, int numTotalBits)
@@ -118,7 +103,7 @@ public:
} }
} }
UInt64 GetProcessedSize() { return Stream.GetProcessedSize() + _ffNum; } UInt64 GetProcessedSize() { return Stream.GetProcessedSize() + _cacheSize + 4; }
}; };
class CDecoder class CDecoder
@@ -162,26 +147,6 @@ public:
Normalize(); Normalize();
} }
/*
UInt32 DecodeDirectBitsDiv(UInt32 numTotalBits)
{
Range >>= numTotalBits;
UInt32 threshold = Code / Range;
Code -= threshold * Range;
Normalize();
return threshold;
}
UInt32 DecodeDirectBitsDiv2(UInt32 numTotalBits)
{
if (numTotalBits <= kNumBottomBits)
return DecodeDirectBitsDiv(numTotalBits);
UInt32 result = DecodeDirectBitsDiv(numTotalBits - kNumBottomBits) << kNumBottomBits;
return (result | DecodeDirectBitsDiv(kNumBottomBits));
}
*/
UInt32 DecodeDirectBits(int numTotalBits) UInt32 DecodeDirectBits(int numTotalBits)
{ {
UInt32 range = Range; UInt32 range = Range;

View File

@@ -211,6 +211,10 @@ static HANDLE StartEditApplication(const UString &path, HWND window)
return 0; return 0;
} }
#ifndef _UNICODE
typedef BOOL (WINAPI * ShellExecuteExWP)(LPSHELLEXECUTEINFOW lpExecInfo);
#endif
static HANDLE StartApplication(const UString &path, HWND window) static HANDLE StartApplication(const UString &path, HWND window)
{ {
UINT32 result; UINT32 result;
@@ -228,7 +232,11 @@ static HANDLE StartApplication(const UString &path, HWND window)
execInfo.lpDirectory = NULL; execInfo.lpDirectory = NULL;
execInfo.nShow = SW_SHOWNORMAL; execInfo.nShow = SW_SHOWNORMAL;
execInfo.hProcess = 0; execInfo.hProcess = 0;
::ShellExecuteExW(&execInfo); ShellExecuteExWP shellExecuteExW = (ShellExecuteExWP)
::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "ShellExecuteExW");
if (shellExecuteExW == 0)
return 0;
shellExecuteExW(&execInfo);
result = (UINT32)execInfo.hInstApp; result = (UINT32)execInfo.hInstApp;
hProcess = execInfo.hProcess; hProcess = execInfo.hProcess;
} }

View File

@@ -51,6 +51,10 @@ struct CThreadDelete
} }
}; };
#ifndef _UNICODE
typedef int (WINAPI * SHFileOperationWP)(LPSHFILEOPSTRUCTW lpFileOp);
#endif
void CPanel::DeleteItems(bool toRecycleBin) void CPanel::DeleteItems(bool toRecycleBin)
{ {
CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
@@ -118,7 +122,16 @@ void CPanel::DeleteItems(bool toRecycleBin)
fo.fAnyOperationsAborted = FALSE; fo.fAnyOperationsAborted = FALSE;
fo.hNameMappings = 0; fo.hNameMappings = 0;
fo.lpszProgressTitle = 0; fo.lpszProgressTitle = 0;
int res = ::SHFileOperationW(&fo); int res;
#ifdef _UNICODE
res = ::SHFileOperationW(&fo);
#else
SHFileOperationWP shFileOperationW = (SHFileOperationWP)
::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHFileOperationW");
if (shFileOperationW == 0)
return;
res = shFileOperationW(&fo);
#endif
} }
/* /*
if (fo.fAnyOperationsAborted) if (fo.fAnyOperationsAborted)

View File

@@ -27,10 +27,10 @@ BEGIN
LTEXT "Destination folder already contains processed file.", IDC_STATIC_OVERWRITE_HEADER, marg, 7, xSize2, 8 LTEXT "Destination folder already contains processed file.", IDC_STATIC_OVERWRITE_HEADER, marg, 7, xSize2, 8
LTEXT "Would you like to replace the existing file", IDC_STATIC_OVERWRITE_QUESTION_BEGIN, marg, 28, xSize2, 8 LTEXT "Would you like to replace the existing file", IDC_STATIC_OVERWRITE_QUESTION_BEGIN, marg, 28, xSize2, 8
ICON "", IDC_STATIC_OVERWRITE_OLD_FILE_ICON, marg, 44, iconSize, iconSize ICON "", IDC_STATIC_OVERWRITE_OLD_FILE_ICON, marg, 44, iconSize, iconSize
LTEXT "", IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, fiXPos, 44, fiXSize, fiYSize LTEXT "", IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, fiXPos, 44, fiXSize, fiYSize, SS_NOPREFIX
LTEXT "with this one?",IDC_STATIC_OVERWRITE_QUESTION_END, marg, 98, xSize2, 8 LTEXT "with this one?",IDC_STATIC_OVERWRITE_QUESTION_END, marg, 98, xSize2, 8
ICON "",IDC_STATIC_OVERWRITE_NEW_FILE_ICON, marg, 114, iconSize, iconSize ICON "",IDC_STATIC_OVERWRITE_NEW_FILE_ICON, marg, 114, iconSize, iconSize
LTEXT "",IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, fiXPos, 114, fiXSize, fiYSize LTEXT "",IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, fiXPos, 114, fiXSize, fiYSize, SS_NOPREFIX
PUSHBUTTON "&Yes", IDYES, 78, b2YPos, bXSize, bYSize PUSHBUTTON "&Yes", IDYES, 78, b2YPos, bXSize, bYSize
PUSHBUTTON "Yes to &All", IDC_BUTTON_OVERWRITE_YES_TO_ALL, 152, b2YPos, bXSize, bYSize PUSHBUTTON "Yes to &All", IDC_BUTTON_OVERWRITE_YES_TO_ALL, 152, b2YPos, bXSize, bYSize
PUSHBUTTON "&No", IDNO, 226, b2YPos, bXSize, bYSize PUSHBUTTON "&No", IDNO, 226, b2YPos, bXSize, bYSize

View File

@@ -42,7 +42,7 @@ BEGIN
RTEXT "", IDC_PROGRESS_REMAINING_VALUE, valPos1, yPos, valSize, 8 RTEXT "", IDC_PROGRESS_REMAINING_VALUE, valPos1, yPos, valSize, 8
RTEXT "", IDC_PROGRESS_SPEED_TOTAL_VALUE, valPos2, marg, valSize, 8 RTEXT "", IDC_PROGRESS_SPEED_TOTAL_VALUE, valPos2, marg, valSize, 8
RTEXT "", IDC_PROGRESS_SPEED_VALUE, valPos2, yPos, valSize, 8 RTEXT "", IDC_PROGRESS_SPEED_VALUE, valPos2, yPos, valSize, 8
LTEXT "", IDC_PROGRESS_FILE_NAME, marg, yPos + 16, xSize2, 8 LTEXT "", IDC_PROGRESS_FILE_NAME, marg, yPos + 16, xSize2, 8, SS_NOPREFIX
CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER, CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER,
marg, bYPos - 20, xSize2, 13 marg, bYPos - 20, xSize2, 13
END END

View File

@@ -42,6 +42,33 @@ DWORD_PTR GetRealIconIndex(LPCTSTR path, UINT32 attributes, int &iconIndex)
return res; return res;
} }
#ifndef _UNICODE
typedef int (WINAPI * SHGetFileInfoWP)(LPCWSTR pszPath, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags);
struct CSHGetFileInfoInit
{
SHGetFileInfoWP shGetFileInfoW;
CSHGetFileInfoInit()
{
shGetFileInfoW = (SHGetFileInfoWP)
::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHGetFileInfoW");
}
} g_SHGetFileInfoInit;
#endif
DWORD_PTR MySHGetFileInfoW(LPCWSTR pszPath, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags)
{
#ifdef _UNICODE
return SHGetFileInfoW(
#else
if (g_SHGetFileInfoInit.shGetFileInfoW == 0)
return 0;
return g_SHGetFileInfoInit.shGetFileInfoW(
#endif
pszPath, dwFileAttributes, psfi, cbFileInfo, uFlags);
}
#ifndef _UNICODE #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) DWORD_PTR GetRealIconIndex(LPCWSTR path, UINT32 attributes, int &iconIndex)
@@ -49,7 +76,7 @@ DWORD_PTR GetRealIconIndex(LPCWSTR path, UINT32 attributes, int &iconIndex)
if(g_IsNT) if(g_IsNT)
{ {
SHFILEINFOW shellInfo; SHFILEINFOW shellInfo;
DWORD_PTR res = ::SHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, DWORD_PTR res = ::MySHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX); sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
iconIndex = shellInfo.iIcon; iconIndex = shellInfo.iIcon;
return res; return res;
@@ -79,7 +106,7 @@ DWORD_PTR GetRealIconIndex(const UString &fileName, UINT32 attributes,
{ {
SHFILEINFOW shellInfo; SHFILEINFOW shellInfo;
shellInfo.szTypeName[0] = 0; shellInfo.szTypeName[0] = 0;
DWORD_PTR res = ::SHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, DWORD_PTR res = ::MySHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX
| SHGFI_TYPENAME); | SHGFI_TYPENAME);
typeName = shellInfo.szTypeName; typeName = shellInfo.szTypeName;

View File

@@ -1,7 +1,7 @@
#define MY_VER_MAJOR 4 #define MY_VER_MAJOR 4
#define MY_VER_MINOR 31 #define MY_VER_MINOR 32
#define MY_VERSION "4.31" #define MY_VERSION "4.32"
#define MY_7ZIP_VERSION "7-Zip 4.31" #define MY_7ZIP_VERSION "7-Zip 4.32"
#define MY_DATE "2005-12-04" #define MY_DATE "2005-12-09"
#define MY_COPYRIGHT "Copyright (c) 1999-2005 Igor Pavlov" #define MY_COPYRIGHT "Copyright (c) 1999-2005 Igor Pavlov"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE

View File

@@ -2,7 +2,7 @@
;Defines ;Defines
!define VERSION_MAJOR 4 !define VERSION_MAJOR 4
!define VERSION_MINOR 31 !define VERSION_MINOR 32
!define VERSION_POSTFIX_FULL "" !define VERSION_POSTFIX_FULL ""
!ifdef WIN64 !ifdef WIN64
!ifdef IA64 !ifdef IA64

View File

@@ -1,10 +1,10 @@
LZMA SDK 4.30 LZMA SDK 4.32
------------- -------------
LZMA SDK 4.30 Copyright (C) 1999-2005 Igor Pavlov LZMA SDK 4.32 Copyright (C) 1999-2005 Igor Pavlov
LZMA SDK provides developers with documentation, source code, LZMA SDK provides the documentation, samples, header files, libraries,
and sample code necessary to write software that uses LZMA compression. and tools you need to develop applications that use LZMA compression.
LZMA is default and general compression method of 7z format LZMA is default and general compression method of 7z format
in 7-Zip compression program (www.7-zip.org). LZMA provides high in 7-Zip compression program (www.7-zip.org). LZMA provides high
@@ -20,15 +20,24 @@ decompressing.
LICENSE LICENSE
------- -------
LZMA SDK is licensed under two licenses: LZMA SDK is available under any of the following licenses:
1) GNU Lesser General Public License (GNU LGPL) 1) GNU Lesser General Public License (GNU LGPL)
2) Common Public License (CPL) 2) Common Public License (CPL)
3) Simplified license for unmodified code (read SPECIAL EXCEPTION)
4) Proprietary license
It means that you can select one of these two licenses and It means that you can select one of these four options and follow rules of that license.
follow rules of that license.
1,2) GNU LGPL and CPL licenses are pretty similar and both these
licenses are classified as
- "Free software licenses" at http://www.gnu.org/
- "OSI-approved" at http://www.opensource.org/
3) SPECIAL EXCEPTION
SPECIAL EXCEPTION
Igor Pavlov, as the author of this code, expressly permits you Igor Pavlov, as the author of this code, expressly permits you
to statically or dynamically link your code (or bind by name) to statically or dynamically link your code (or bind by name)
to the files from LZMA SDK without subjecting your linked to the files from LZMA SDK without subjecting your linked
@@ -36,7 +45,6 @@ code to the terms of the CPL or GNU LGPL.
Any modifications or additions to files from LZMA SDK, however, Any modifications or additions to files from LZMA SDK, however,
are subject to the GNU LGPL or CPL terms. are subject to the GNU LGPL or CPL terms.
SPECIAL EXCEPTION allows you to use LZMA SDK in applications with closed code, SPECIAL EXCEPTION allows you to use LZMA SDK in applications with closed code,
while you keep LZMA SDK code unmodified. while you keep LZMA SDK code unmodified.
@@ -50,17 +58,11 @@ of LZMA SDK as update for previous versions.
SPECIAL EXCEPTION #3: Igor Pavlov, as the author of this code, expressly permits SPECIAL EXCEPTION #3: Igor Pavlov, as the author of this code, expressly permits
you to use code of examples (LzmaTest.c, LzmaStateTest.c, LzmaAlone.cpp) as you to use code of examples (LzmaTest.c, LzmaStateTest.c, LzmaAlone.cpp,
public domain code. LzmaAlone.cs, LzmaAlone.java) as public domain code.
GNU LGPL and CPL licenses are pretty similar and both these
licenses are classified as
1) "Free software licenses" at http://www.gnu.org/
2) "OSI-approved" at http://www.opensource.org/
4) Proprietary license
LZMA SDK also can be available under a proprietary license which LZMA SDK also can be available under a proprietary license which
can include: can include:
@@ -87,11 +89,11 @@ LZMA SDK Contents
LZMA SDK includes: LZMA SDK includes:
- C++ source code of LZMA Encoder and Decoder - C++ source code of LZMA compressing and decompressing
- C++ source code for file->file LZMA compressing and decompressing
- ANSI-C compatible source code for LZMA decompressing - ANSI-C compatible source code for LZMA decompressing
- C# source code for LZMA compressing and decompressing
- Java source code for LZMA compressing and decompressing
- Compiled file->file LZMA compressing/decompressing program for Windows system - Compiled file->file LZMA compressing/decompressing program for Windows system
- C# source code for file->file LZMA compressing and decompressing
ANSI-C LZMA decompression code was ported from original C++ sources to C. ANSI-C LZMA decompression code was ported from original C++ sources to C.
Also it was simplified and optimized for code size. Also it was simplified and optimized for code size.
@@ -115,6 +117,7 @@ Files
--------------------- ---------------------
C - C / CPP source code C - C / CPP source code
CS - C# source code CS - C# source code
Java - Java source code
lzma.txt - LZMA SDK description (this file) lzma.txt - LZMA SDK description (this file)
7zFormat.txt - 7z Format description 7zFormat.txt - 7z Format description
7zC.txt - 7z ANSI-C Decoder description (this file) 7zC.txt - 7z ANSI-C Decoder description (this file)
@@ -162,8 +165,14 @@ CS - C# files
LzmaAlone - file->file LZMA compression/decompression LzmaAlone - file->file LZMA compression/decompression
RangeCoder - Range Coder (special code of compression/decompression) RangeCoder - Range Coder (special code of compression/decompression)
Source code of LZMA SDK is only part of big 7-Zip project. That is Java - Java files
why LZMA SDK uses such complex source code structure. SevenZip
Compression - files related to compression/decompression
LZ - files related to LZ (Lempel-Ziv) compression algorithm
LZMA - LZMA compression/decompression
RangeCoder - Range Coder (special code of compression/decompression)
C/C++ source code of LZMA SDK is part of 7-Zip project.
You can find ANSI-C LZMA decompressing code at folder You can find ANSI-C LZMA decompressing code at folder
C/7zip/Compress/LZMA_C C/7zip/Compress/LZMA_C

View File

@@ -1,4 +1,4 @@
7-Zip 4.31 Sources 7-Zip 4.32 Sources
------------------ ------------------
7-Zip is a file archiver for Windows 95/98/ME/NT/2000/2003/XP. 7-Zip is a file archiver for Windows 95/98/ME/NT/2000/2003/XP.

View File

@@ -152,6 +152,7 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM data)
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, data); SendMessage(hwnd, BFFM_SETSELECTION, TRUE, data);
break; break;
} }
/*
case BFFM_SELCHANGED: case BFFM_SELCHANGED:
{ {
TCHAR dir[MAX_PATH]; TCHAR dir[MAX_PATH];
@@ -161,6 +162,7 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM data)
SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)TEXT("")); SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)TEXT(""));
break; break;
} }
*/
default: default:
break; break;
} }
@@ -193,17 +195,30 @@ bool BrowseForFolder(HWND owner, LPCTSTR title,
#ifndef _UNICODE #ifndef _UNICODE
typedef BOOL (WINAPI * SHGetPathFromIDListWP)(LPCITEMIDLIST pidl, LPWSTR pszPath);
bool GetPathFromIDList(LPCITEMIDLIST itemIDList, UString &path) bool GetPathFromIDList(LPCITEMIDLIST itemIDList, UString &path)
{ {
bool result = BOOLToBool(::SHGetPathFromIDListW(itemIDList, path.GetBuffer(MAX_PATH * 2))); path.Empty();
SHGetPathFromIDListWP shGetPathFromIDListW = (SHGetPathFromIDListWP)
::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHGetPathFromIDListW");
if (shGetPathFromIDListW == 0)
return false;
bool result = BOOLToBool(shGetPathFromIDListW(itemIDList, path.GetBuffer(MAX_PATH * 2)));
path.ReleaseBuffer(); path.ReleaseBuffer();
return result; return result;
} }
typedef LPITEMIDLIST (WINAPI * SHBrowseForFolderWP)(LPBROWSEINFOW lpbi);
bool BrowseForFolder(LPBROWSEINFOW browseInfo, UString &resultPath) bool BrowseForFolder(LPBROWSEINFOW browseInfo, UString &resultPath)
{ {
NWindows::NCOM::CComInitializer comInitializer; NWindows::NCOM::CComInitializer comInitializer;
LPITEMIDLIST itemIDList = ::SHBrowseForFolderW(browseInfo); SHBrowseForFolderWP shBrowseForFolderW = (SHBrowseForFolderWP)
::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHBrowseForFolderW");
if (shBrowseForFolderW == 0)
return false;
LPITEMIDLIST itemIDList = shBrowseForFolderW(browseInfo);
if (itemIDList == NULL) if (itemIDList == NULL)
return false; return false;
CItemIDList itemIDListHolder; CItemIDList itemIDListHolder;
@@ -221,15 +236,18 @@ int CALLBACK BrowseCallbackProc2(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM data)
SendMessageW(hwnd, BFFM_SETSELECTIONW, TRUE, data); SendMessageW(hwnd, BFFM_SETSELECTIONW, TRUE, data);
break; break;
} }
/*
case BFFM_SELCHANGED: case BFFM_SELCHANGED:
{ {
wchar_t dir[MAX_PATH * 2]; wchar_t dir[MAX_PATH * 2];
if (::SHGetPathFromIDListW((LPITEMIDLIST) lp , dir))
if (shGetPathFromIDListW((LPITEMIDLIST)lp , dir))
SendMessageW(hwnd, BFFM_SETSTATUSTEXTW, 0, (LPARAM)dir); SendMessageW(hwnd, BFFM_SETSTATUSTEXTW, 0, (LPARAM)dir);
else else
SendMessageW(hwnd, BFFM_SETSTATUSTEXTW, 0, (LPARAM)L""); SendMessageW(hwnd, BFFM_SETSTATUSTEXTW, 0, (LPARAM)L"");
break; break;
} }
*/
default: default:
break; break;
} }
@@ -256,11 +274,15 @@ bool BrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &
{ {
if (g_IsNT) if (g_IsNT)
return BrowseForFolder(owner, title, return BrowseForFolder(owner, title,
BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT, initialFolder, resultPath); BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS
// | BIF_STATUSTEXT // This flag is not supported when BIF_NEWDIALOGSTYLE is specified.
, initialFolder, resultPath);
// BIF_STATUSTEXT; BIF_USENEWUI (Version 5.0) // BIF_STATUSTEXT; BIF_USENEWUI (Version 5.0)
CSysString s; CSysString s;
bool res = BrowseForFolder(owner, GetSystemString(title), bool res = BrowseForFolder(owner, GetSystemString(title),
BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT, GetSystemString(initialFolder), s); BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS
// | BIF_STATUSTEXT // This flag is not supported when BIF_NEWDIALOGSTYLE is specified.
, GetSystemString(initialFolder), s);
resultPath = GetUnicodeString(s); resultPath = GetUnicodeString(s);
return res; return res;
} }