4.59 beta

This commit is contained in:
Igor Pavlov
2008-08-13 00:00:00 +00:00
committed by Kornel Lesiński
parent 3901bf0ab8
commit 173c07e166
781 changed files with 22124 additions and 13650 deletions
+8 -4
View File
@@ -8,6 +8,8 @@
namespace NWindows {
namespace NCOM {
#ifdef _WIN32
class CComInitializer
{
public:
@@ -22,10 +24,10 @@ public:
bool _mustBeReleased;
CStgMedium(): _mustBeReleased(false) {}
~CStgMedium() { Free(); }
void Free()
{
if(_mustBeReleased)
ReleaseStgMedium(&_object);
void Free()
{
if(_mustBeReleased)
ReleaseStgMedium(&_object);
_mustBeReleased = false;
}
const STGMEDIUM* operator->() const { return &_object;}
@@ -33,6 +35,8 @@ public:
STGMEDIUM* operator&() { return &_object; }
};
#endif
//////////////////////////////////
// GUID <--> String Conversions
UString GUIDToStringW(REFGUID guid);
+28 -28
View File
@@ -13,9 +13,9 @@
namespace NWindows {
bool CClipboard::Open(HWND wndNewOwner)
{
m_Open = BOOLToBool(::OpenClipboard(wndNewOwner));
return m_Open;
{
m_Open = BOOLToBool(::OpenClipboard(wndNewOwner));
return m_Open;
}
CClipboard::~CClipboard()
@@ -23,11 +23,11 @@ CClipboard::~CClipboard()
Close();
}
bool CClipboard::Close()
bool CClipboard::Close()
{
if (!m_Open)
return true;
m_Open = !BOOLToBool(CloseClipboard());
m_Open = !BOOLToBool(CloseClipboard());
return !m_Open;
}
@@ -40,24 +40,24 @@ bool ClipboardIsFormatAvailableHDROP()
bool ClipboardGetTextString(AString &s)
{
s.Empty();
if (!IsClipboardFormatAvailable(CF_TEXT))
return false;
if (!IsClipboardFormatAvailable(CF_TEXT))
return false;
CClipboard clipboard;
if (!clipboard.Open(NULL))
return false;
if (!clipboard.Open(NULL))
return false;
HGLOBAL h = ::GetClipboardData(CF_TEXT);
if (h != NULL)
{
NMemory::CGlobalLock globalLock(h);
const char *p = (const char *)globalLock.GetPointer();
if (h != NULL)
{
NMemory::CGlobalLock globalLock(h);
const char *p = (const char *)globalLock.GetPointer();
if (p != NULL)
{
s = p;
return true;
}
}
}
return false;
}
*/
@@ -66,18 +66,18 @@ bool ClipboardGetTextString(AString &s)
bool ClipboardGetFileNames(UStringVector &names)
{
names.Clear();
if (!IsClipboardFormatAvailable(CF_HDROP))
return false;
if (!IsClipboardFormatAvailable(CF_HDROP))
return false;
CClipboard clipboard;
if (!clipboard.Open(NULL))
return false;
if (!clipboard.Open(NULL))
return false;
HGLOBAL h = ::GetClipboardData(CF_HDROP);
if (h != NULL)
{
NMemory::CGlobalLock globalLock(h);
void *p = (void *)globalLock.GetPointer();
if (h != NULL)
{
NMemory::CGlobalLock globalLock(h);
void *p = (void *)globalLock.GetPointer();
if (p != NULL)
{
NShell::CDrop drop(false);
@@ -85,7 +85,7 @@ bool ClipboardGetFileNames(UStringVector &names)
drop.QueryFileNames(names);
return true;
}
}
}
return false;
}
*/
@@ -94,7 +94,7 @@ static bool ClipboardSetData(UINT uFormat, const void *data, size_t size)
{
NMemory::CGlobal global;
if (!global.Alloc(GMEM_DDESHARE | GMEM_MOVEABLE, size))
return false;
return false;
{
NMemory::CGlobalLock globalLock(global);
LPVOID p = globalLock.GetPointer();
@@ -111,10 +111,10 @@ static bool ClipboardSetData(UINT uFormat, const void *data, size_t size)
bool ClipboardSetText(HWND owner, const UString &s)
{
CClipboard clipboard;
if (!clipboard.Open(owner))
return false;
if (!clipboard.Open(owner))
return false;
if (!::EmptyClipboard())
return false;
return false;
bool res;
res = ClipboardSetData(CF_UNICODETEXT, (const wchar_t *)s, (s.Length() + 1) * sizeof(wchar_t));
@@ -126,6 +126,6 @@ bool ClipboardSetText(HWND owner, const UString &s)
res |= ClipboardSetData(CF_OEMTEXT, (const char *)a, (a.Length() + 1) * sizeof(char));
#endif
return res;
}
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ class CClipboard
bool m_Open;
public:
CClipboard(): m_Open(false) {};
~CClipboard();
~CClipboard();
bool Open(HWND wndNewOwner);
bool Close();
};
+36 -36
View File
@@ -71,28 +71,28 @@ bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, LPCWSTR s
CHAR buffer[kBufferSize];
MyStringCopy(buffer, (const char *)GetSystemString(fullFileName));
OPENFILENAME info;
info.lStructSize = sizeof(info);
info.hwndOwner = hwnd;
info.hInstance = 0;
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.lpstrFilter = filterBuffer;
info.lpstrCustomFilter = NULL;
info.nMaxCustFilter = 0;
info.nFilterIndex = 0;
info.lpstrCustomFilter = NULL;
info.nMaxCustFilter = 0;
info.nFilterIndex = 0;
info.lpstrFile = buffer;
info.lpstrFile = buffer;
info.nMaxFile = kBufferSize;
info.lpstrFileTitle = NULL;
info.nMaxFileTitle = 0;
info.lpstrFileTitle = NULL;
info.nMaxFileTitle = 0;
info.lpstrInitialDir= NULL;
info.lpstrInitialDir= NULL;
info.lpstrTitle = 0;
AString titleA;
@@ -102,14 +102,14 @@ bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, LPCWSTR s
info.lpstrTitle = titleA;
}
info.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
info.nFileOffset = 0;
info.nFileExtension = 0;
info.lpstrDefExt = NULL;
info.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
info.nFileOffset = 0;
info.nFileExtension = 0;
info.lpstrDefExt = NULL;
info.lCustData = 0;
info.lpfnHook = NULL;
info.lpTemplateName = NULL;
info.lCustData = 0;
info.lpfnHook = NULL;
info.lpTemplateName = NULL;
bool res = BOOLToBool(::GetOpenFileNameA(&info));
resPath = GetUnicodeString(buffer);
@@ -121,39 +121,39 @@ bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, LPCWSTR s
WCHAR buffer[kBufferSize];
MyStringCopy(buffer, fullFileName);
OPENFILENAMEW info;
info.lStructSize = sizeof(info);
info.hwndOwner = hwnd;
info.hInstance = 0;
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.lpstrFilter = filterBuffer;
info.lpstrCustomFilter = NULL;
info.nMaxCustFilter = 0;
info.nFilterIndex = 0;
info.lpstrCustomFilter = NULL;
info.nMaxCustFilter = 0;
info.nFilterIndex = 0;
info.lpstrFile = buffer;
info.lpstrFile = buffer;
info.nMaxFile = kBufferSize;
info.lpstrFileTitle = NULL;
info.nMaxFileTitle = 0;
info.lpstrFileTitle = NULL;
info.nMaxFileTitle = 0;
info.lpstrInitialDir= NULL;
info.lpstrInitialDir= NULL;
info.lpstrTitle = title;
info.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
info.nFileOffset = 0;
info.nFileExtension = 0;
info.lpstrDefExt = NULL;
info.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
info.nFileOffset = 0;
info.nFileExtension = 0;
info.lpstrDefExt = NULL;
info.lCustData = 0;
info.lpfnHook = NULL;
info.lpTemplateName = NULL;
info.lCustData = 0;
info.lpfnHook = NULL;
info.lpTemplateName = NULL;
bool res = BOOLToBool(::GetOpenFileNameW(&info));
resPath = buffer;
+1 -1
View File
@@ -32,7 +32,7 @@ LRESULT CComboBox::GetLBText(int index, CSysString &s)
#ifndef _UNICODE
LRESULT CComboBox::AddString(LPCWSTR s)
{
{
if (g_IsNT)
return SendMessageW(CB_ADDSTRING, 0, (LPARAM)s);
return AddString(GetSystemString(s));
+14 -9
View File
@@ -34,19 +34,24 @@ public:
{ return SendMessage(CB_SETITEMDATA, index, lParam); }
LRESULT GetItemData(int index)
{ return SendMessage(CB_GETITEMDATA, index, 0); }
void ShowDropDown(bool show = true)
{ SendMessage(CB_SHOWDROPDOWN, show ? TRUE : FALSE, 0); }
};
class CComboBoxEx: public CWindow
class CComboBoxEx: public CComboBox
{
public:
LRESULT DeleteItem(int index)
{ return SendMessage(CBEM_DELETEITEM, index, 0); }
LRESULT InsertItem(COMBOBOXEXITEM *item)
{ return SendMessage(CBEM_INSERTITEM, 0, (LPARAM)item); }
DWORD SetExtendedStyle(DWORD exMask, DWORD exStyle)
{ return (DWORD)SendMessage(CBEM_SETEXTENDEDSTYLE, exMask, exStyle); }
HWND GetEditControl()
{ return (HWND)SendMessage(CBEM_GETEDITCONTROL, 0, 0); }
LRESULT DeleteItem(int index) { return SendMessage(CBEM_DELETEITEM, index, 0); }
LRESULT InsertItem(COMBOBOXEXITEM *item) { return SendMessage(CBEM_INSERTITEM, 0, (LPARAM)item); }
#ifndef _UNICODE
LRESULT InsertItem(COMBOBOXEXITEMW *item) { return SendMessage(CBEM_INSERTITEMW, 0, (LPARAM)item); }
#endif
LRESULT SetItem(COMBOBOXEXITEM *item) { return SendMessage(CBEM_SETITEM, 0, (LPARAM)item); }
DWORD SetExtendedStyle(DWORD exMask, DWORD exStyle) { return (DWORD)SendMessage(CBEM_SETEXTENDEDSTYLE, exMask, exStyle); }
HWND GetEditControl() { return (HWND)SendMessage(CBEM_GETEDITCONTROL, 0, 0); }
HIMAGELIST SetImageList(HIMAGELIST imageList) { return (HIMAGELIST)SendMessage(CBEM_SETIMAGELIST, 0, (LPARAM)imageList); }
};
}}
+11 -11
View File
@@ -15,7 +15,7 @@ extern bool g_IsNT;
namespace NWindows {
namespace NControl {
static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message,
static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message,
WPARAM wParam, LPARAM lParam)
{
CWindow dialogTmp(dialogHWND);
@@ -54,8 +54,8 @@ bool CDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
}
}
bool CDialog::OnCommand(WPARAM wParam, LPARAM lParam)
{
bool CDialog::OnCommand(WPARAM wParam, LPARAM lParam)
{
return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam);
}
@@ -63,11 +63,11 @@ bool CDialog::OnCommand(int code, int itemID, LPARAM lParam)
{
if (code == BN_CLICKED)
return OnButtonClicked(itemID, (HWND)lParam);
return false;
return false;
}
bool CDialog::OnButtonClicked(int buttonID, HWND /* buttonHWND */)
{
bool CDialog::OnButtonClicked(int buttonID, HWND /* buttonHWND */)
{
switch(buttonID)
{
case IDOK:
@@ -86,7 +86,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);
if (aHWND == 0)
return false;
@@ -95,14 +95,14 @@ bool CModelessDialog::Create(LPCTSTR templateName, HWND parentWindow)
}
INT_PTR CModalDialog::Create(LPCTSTR templateName, HWND parentWindow)
{
{
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);
@@ -126,7 +126,7 @@ bool CModelessDialog::Create(LPCWSTR templateName, HWND parentWindow)
}
INT_PTR CModalDialog::Create(LPCWSTR templateName, HWND parentWindow)
{
{
if (g_IsNT)
return DialogBoxParamW(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
AString name;
@@ -140,6 +140,6 @@ INT_PTR CModalDialog::Create(LPCWSTR templateName, HWND parentWindow)
}
return DialogBoxParamA(g_hInstance, templateNameA, parentWindow, DialogProcedure, (LPARAM)this);
}
#endif
#endif
}}
+5 -5
View File
@@ -29,9 +29,9 @@ public:
#ifndef _UNICODE
bool SetItemText(int itemID, LPCWSTR s)
{
{
CWindow window(GetItem(itemID));
return window.SetText(s);
return window.SetText(s);
}
#endif
@@ -40,9 +40,9 @@ public:
#ifndef _UNICODE
/*
bool GetItemText(int itemID, LPWSTR string, int maxCount)
{
{
CWindow window(GetItem(itemID));
return window.GetText(string, maxCount);
return window.GetText(string, maxCount);
}
*/
#endif
@@ -50,7 +50,7 @@ public:
bool SetItemInt(int itemID, UINT value, bool isSigned)
{ return BOOLToBool(SetDlgItemInt(_window, itemID, value, BoolToBOOL(isSigned))); }
bool GetItemInt(int itemID, bool isSigned, UINT &value)
{
{
BOOL result;
value = GetDlgItemInt(_window, itemID, &result, BoolToBOOL(isSigned));
return BOOLToBool(result);
+1 -1
View File
@@ -31,7 +31,7 @@ public:
bool Create(int width, int height, UINT flags, int initialNumber, int grow)
{
HIMAGELIST a = ImageList_Create(width, height, flags,
HIMAGELIST a = ImageList_Create(width, height, flags,
initialNumber, grow);
if(a == NULL)
return false;
+60 -22
View File
@@ -9,17 +9,17 @@ namespace NControl {
bool CListView::CreateEx(DWORD exStyle, DWORD style,
int x, int y, int width, int height,
HWND parentWindow, HMENU idOrHMenu,
HWND parentWindow, HMENU idOrHMenu,
HINSTANCE instance, LPVOID createParam)
{
return CWindow::CreateEx(exStyle, WC_LISTVIEW, TEXT(""), style, x, y, width,
height, parentWindow, idOrHMenu, instance, createParam);
}
bool CListView::GetItemParam(int itemIndex, LPARAM &param) const
{
bool CListView::GetItemParam(int index, LPARAM &param) const
{
LVITEM item;
item.iItem = itemIndex;
item.iItem = index;
item.iSubItem = 0;
item.mask = LVIF_PARAM;
bool aResult = GetItem(&item);
@@ -27,32 +27,70 @@ bool CListView::GetItemParam(int itemIndex, LPARAM &param) const
return aResult;
}
/*
int CListView::InsertItem(UINT mask, int item, LPCTSTR itemText,
UINT nState, UINT nStateMask, int nImage, LPARAM lParam)
int CListView::InsertColumn(int columnIndex, LPCTSTR text, int width)
{
LVCOLUMN ci;
ci.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
ci.pszText = (LPTSTR)text;
ci.iSubItem = columnIndex;
ci.cx = width;
return InsertColumn(columnIndex, &ci);
}
int CListView::InsertItem(int index, LPCTSTR text)
{
LVITEM item;
item.mask = nMask;
item.iItem = nItem;
item.mask = LVIF_TEXT | LVIF_PARAM;
item.iItem = index;
item.lParam = index;
item.pszText = (LPTSTR)text;
item.iSubItem = 0;
item.pszText = (LPTSTR)itemText;
item.state = nState;
item.stateMask = nStateMask;
item.iImage = nImage;
item.lParam = lParam;
return InsertItem(&item);
}
int CListView::InsertItem(int nItem, LPCTSTR itemText)
{
return InsertItem(LVIF_TEXT, nItem, itemText, 0, 0, 0, 0);
int CListView::SetSubItem(int index, int subIndex, LPCTSTR text)
{
LVITEM item;
item.mask = LVIF_TEXT;
item.iItem = index;
item.pszText = (LPTSTR)text;
item.iSubItem = subIndex;
return SetItem(&item);
}
int CListView::InsertItem(int nItem, LPCTSTR itemText, int nImage)
{
return InsertItem(LVIF_TEXT | LVIF_IMAGE, nItem, itemText, 0, 0, nImage, 0);
#ifndef _UNICODE
int CListView::InsertColumn(int columnIndex, LPCWSTR text, int width)
{
LVCOLUMNW ci;
ci.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
ci.pszText = (LPWSTR)text;
ci.iSubItem = columnIndex;
ci.cx = width;
return InsertColumn(columnIndex, &ci);
}
*/
int CListView::InsertItem(int index, LPCWSTR text)
{
LVITEMW item;
item.mask = LVIF_TEXT | LVIF_PARAM;
item.iItem = index;
item.lParam = index;
item.pszText = (LPWSTR)text;
item.iSubItem = 0;
return InsertItem(&item);
}
int CListView::SetSubItem(int index, int subIndex, LPCWSTR text)
{
LVITEMW item;
item.mask = LVIF_TEXT;
item.iItem = index;
item.pszText = (LPWSTR)text;
item.iSubItem = subIndex;
return SetItem(&item);
}
#endif
}}
+23 -21
View File
@@ -16,7 +16,7 @@ class CListView: public NWindows::CWindow
public:
bool CreateEx(DWORD exStyle, DWORD style,
int x, int y, int width, int height,
HWND parentWindow, HMENU idOrHMenu,
HWND parentWindow, HMENU idOrHMenu,
HINSTANCE instance, LPVOID createParam);
bool SetUnicodeFormat(bool fUnicode)
@@ -24,27 +24,28 @@ public:
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
int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo)
{ return ListView_InsertColumn(_window, columnIndex, columnInfo); }
int InsertColumn(int columnIndex, LPCTSTR text, int width);
int InsertItem(const LVITEM* item) { return ListView_InsertItem(_window, item); }
int InsertItem(int index, LPCTSTR text);
bool SetItem(const LVITEM* item) { return BOOLToBool(ListView_SetItem(_window, item)); }
int SetSubItem(int index, int subIndex, LPCTSTR text);
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)); }
int InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo)
{ return (int)SendMessage(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
int InsertColumn(int columnIndex, LPCWSTR text, int width);
int InsertItem(const LV_ITEMW* item) { return (int)SendMessage(LVM_INSERTITEMW, 0, (LPARAM)item); }
int InsertItem(int index, LPCWSTR text);
bool SetItem(const LV_ITEMW* item) { return BOOLToBool((BOOL)SendMessage(LVM_SETITEMW, 0, (LPARAM)item)); }
int SetSubItem(int index, int subIndex, LPCWSTR text);
#endif
bool DeleteItem(int itemIndex)
@@ -70,10 +71,10 @@ public:
int GetFocusedItem() const
{ return GetNextItem(-1, LVNI_FOCUSED); }
bool GetItem(LVITEM* item) const
bool GetItem(LVITEM* item) const
{ return BOOLToBool(ListView_GetItem(_window, item)); }
bool GetItemParam(int itemIndex, LPARAM &param) const;
void GetItemText(int itemIndex, int aSubItemIndex, LPTSTR aText, int aTextSizeMax) const
void GetItemText(int itemIndex, int aSubItemIndex, LPTSTR aText, int aTextSizeMax) const
{ ListView_GetItemText(_window, itemIndex, aSubItemIndex, aText, aTextSizeMax); }
bool SortItems(PFNLVCOMPARE compareFunction, LPARAM dataParam)
{ return BOOLToBool(ListView_SortItems(_window, compareFunction, dataParam)); }
@@ -119,7 +120,7 @@ public:
bool RedrawItems(int firstIndex, int lastIndex)
{ return BOOLToBool(ListView_RedrawItems(_window, firstIndex, lastIndex)); }
bool RedrawAllItems()
{
{
if (GetItemCount() > 0)
return RedrawItems(0, GetItemCount() - 1);
return true;
@@ -135,4 +136,5 @@ public:
};
}}
#endif
#endif
+2 -2
View File
@@ -15,7 +15,7 @@ extern bool g_IsNT;
namespace NWindows {
namespace NControl {
INT_PTR APIENTRY ProperyPageProcedure(HWND dialogHWND, UINT message,
INT_PTR APIENTRY ProperyPageProcedure(HWND dialogHWND, UINT message,
WPARAM wParam, LPARAM lParam)
{
CDialog tempDialog(dialogHWND);
@@ -38,7 +38,7 @@ INT_PTR APIENTRY ProperyPageProcedure(HWND dialogHWND, UINT message,
return dialog->OnMessage(message, wParam, lParam);
}
bool CPropertyPage::OnNotify(UINT /* controlID */, LPNMHDR lParam)
bool CPropertyPage::OnNotify(UINT /* controlID */, LPNMHDR lParam)
{
switch(lParam->code)
{
+1 -1
View File
@@ -6,4 +6,4 @@
#include "../../Common/MyWindows.h"
#include "../../Common/NewHandler.h"
#endif
#endif
+1 -1
View File
@@ -15,7 +15,7 @@ public:
bool GetMaxSize(LPSIZE size)
{ return LRESULTToBool(SendMessage(TB_GETMAXSIZE, 0, (LPARAM)size)); }
bool EnableButton(UINT buttonID, bool enable)
{ return LRESULTToBool(SendMessage(TB_ENABLEBUTTON, buttonID,
{ return LRESULTToBool(SendMessage(TB_ENABLEBUTTON, buttonID,
MAKELONG(BoolToBOOL(enable), 0))); }
void ButtonStructSize()
{ SendMessage(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON)); }
+11 -11
View File
@@ -20,7 +20,7 @@ ATOM MyRegisterClass(CONST WNDCLASSW *wndClass);
namespace NControl {
static LRESULT CALLBACK WindowProcedure(HWND aHWND, UINT message,
static LRESULT CALLBACK WindowProcedure(HWND aHWND, UINT message,
WPARAM wParam, LPARAM lParam)
{
CWindow tempWindow(aHWND);
@@ -42,10 +42,10 @@ static LRESULT CALLBACK WindowProcedure(HWND aHWND, UINT message,
return window->OnMessage(message, wParam, lParam);
}
bool CWindow2::CreateEx(DWORD exStyle, LPCTSTR className,
bool CWindow2::CreateEx(DWORD exStyle, LPCTSTR className,
LPCTSTR windowName, DWORD style,
int x, int y, int width, int height,
HWND parentWindow, HMENU idOrHMenu,
HWND parentWindow, HMENU idOrHMenu,
HINSTANCE instance)
{
WNDCLASS windowClass;
@@ -67,16 +67,16 @@ bool CWindow2::CreateEx(DWORD exStyle, LPCTSTR className,
return false;
}
return CWindow::CreateEx(exStyle, className, windowName,
style, x, y, width, height, parentWindow,
style, x, y, width, height, parentWindow,
idOrHMenu, instance, this);
}
#ifndef _UNICODE
bool CWindow2::CreateEx(DWORD exStyle, LPCWSTR className,
bool CWindow2::CreateEx(DWORD exStyle, LPCWSTR className,
LPCWSTR windowName, DWORD style,
int x, int y, int width, int height,
HWND parentWindow, HMENU idOrHMenu,
HWND parentWindow, HMENU idOrHMenu,
HINSTANCE instance)
{
bool needRegister;
@@ -117,7 +117,7 @@ bool CWindow2::CreateEx(DWORD exStyle, LPCWSTR className,
return false;
}
return CWindow::CreateEx(exStyle, className, windowName,
style, x, y, width, height, parentWindow,
style, x, y, width, height, parentWindow,
idOrHMenu, instance, this);
}
@@ -163,8 +163,8 @@ LRESULT CWindow2::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
return DefProc(message, wParam, lParam);
}
bool CWindow2::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT &result)
{
bool CWindow2::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT &result)
{
return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam, result);
}
@@ -179,8 +179,8 @@ bool CWindow2::OnCommand(int /* code */, int /* itemID */, LPARAM /* lParam */,
}
/*
bool CDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
{
bool CDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
{
switch(aButtonID)
{
case IDOK:
+3 -3
View File
@@ -17,17 +17,17 @@ public:
virtual ~CWindow2() {};
bool CreateEx(DWORD exStyle, LPCTSTR className,
bool CreateEx(DWORD exStyle, LPCTSTR className,
LPCTSTR windowName, DWORD style,
int x, int y, int width, int height,
HWND parentWindow, HMENU idOrHMenu,
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,
HWND parentWindow, HMENU idOrHMenu,
HINSTANCE instance);
#endif
+1 -1
View File
@@ -58,7 +58,7 @@ 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()); }
+2 -2
View File
@@ -17,7 +17,7 @@ namespace NError {
bool MyFormatMessage(DWORD messageID, CSysString &message)
{
LPVOID msgBuf;
if(::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
if(::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,messageID, 0, (LPTSTR) &msgBuf,0, NULL) == 0)
return false;
@@ -32,7 +32,7 @@ bool MyFormatMessage(DWORD messageID, UString &message)
if (g_IsNT)
{
LPVOID msgBuf;
if(::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
if(::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, messageID, 0, (LPWSTR) &msgBuf, 0, NULL) == 0)
return false;
+5 -5
View File
@@ -10,7 +10,7 @@ namespace NWindows {
namespace NFile {
namespace NDevice {
typedef struct _GET_LENGTH_INFORMATION
typedef struct _GET_LENGTH_INFORMATION
{
LARGE_INTEGER Length;
} GET_LENGTH_INFORMATION, *PGET_LENGTH_INFORMATION;
@@ -32,10 +32,10 @@ typedef struct _DISK_GEOMETRY_EX {
class CFileBase: public NIO::CFileBase
{
public:
bool DeviceIoControl(DWORD controlCode, LPVOID inBuffer, DWORD inSize,
bool DeviceIoControl(DWORD controlCode, LPVOID inBuffer, DWORD inSize,
LPVOID outBuffer, DWORD outSize, LPDWORD bytesReturned, LPOVERLAPPED overlapped) const
{
return BOOLToBool(::DeviceIoControl(_handle, controlCode, inBuffer, inSize,
return BOOLToBool(::DeviceIoControl(_handle, controlCode, inBuffer, inSize,
outBuffer, outSize, bytesReturned, overlapped));
}
@@ -82,8 +82,8 @@ public:
/*
bool FormatTracks(const FORMAT_PARAMETERS *formatParams,
BAD_TRACK_NUMBER *badTrackNumbers, DWORD numBadTrackNumbers,
bool FormatTracks(const FORMAT_PARAMETERS *formatParams,
BAD_TRACK_NUMBER *badTrackNumbers, DWORD numBadTrackNumbers,
DWORD &numBadTrackNumbersReturned)
{
DWORD ret;
+29 -29
View File
@@ -31,7 +31,7 @@ bool GetLongPath(LPCWSTR fileName, UString &res);
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)
@@ -84,7 +84,7 @@ bool MyGetSystemDirectory(UString &path)
}
#endif
bool SetDirTime(LPCWSTR fileName, const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime)
bool SetDirTime(LPCWSTR fileName, const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime)
{
#ifndef _UNICODE
if (!g_IsNT)
@@ -92,7 +92,7 @@ bool SetDirTime(LPCWSTR fileName, const FILETIME *creationTime, const FILETIME *
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return false;
}
#endif
#endif
HANDLE hDir = ::CreateFileW(fileName, GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
@@ -110,7 +110,7 @@ bool SetDirTime(LPCWSTR fileName, const FILETIME *creationTime, const FILETIME *
bool res = false;
if (hDir != INVALID_HANDLE_VALUE)
{
res = BOOLToBool(::SetFileTime(hDir, creationTime, lastAccessTime, lastWriteTime));
res = BOOLToBool(::SetFileTime(hDir, cTime, aTime, mTime));
::CloseHandle(hDir);
}
return res;
@@ -129,7 +129,7 @@ bool MySetFileAttributes(LPCTSTR fileName, DWORD fileAttributes)
}
bool MyRemoveDirectory(LPCTSTR pathName)
{
{
if (::RemoveDirectory(pathName))
return true;
#ifdef WIN_LONG_PATH2
@@ -153,12 +153,12 @@ bool GetLongPaths(LPCWSTR s1, LPCWSTR s2, UString &d1, UString &d2)
#endif
bool MyMoveFile(LPCTSTR existFileName, LPCTSTR newFileName)
{
{
if (::MoveFile(existFileName, newFileName))
return true;
#ifdef WIN_LONG_PATH2
UString d1, d2;
if (GetLongPaths(existFileName, newFileName, d1, d2))
if (GetLongPaths(existFileName, newFileName, d1, d2))
return BOOLToBool(::MoveFileW(d1, d2));
#endif
return false;
@@ -166,7 +166,7 @@ bool MyMoveFile(LPCTSTR existFileName, LPCTSTR newFileName)
#ifndef _UNICODE
bool MySetFileAttributes(LPCWSTR fileName, DWORD fileAttributes)
{
{
if (!g_IsNT)
return MySetFileAttributes(GetSysPath(fileName), fileAttributes);
if (::SetFileAttributesW(fileName, fileAttributes))
@@ -181,7 +181,7 @@ bool MySetFileAttributes(LPCWSTR fileName, DWORD fileAttributes)
bool MyRemoveDirectory(LPCWSTR pathName)
{
{
if (!g_IsNT)
return MyRemoveDirectory(GetSysPath(pathName));
if (::RemoveDirectoryW(pathName))
@@ -195,22 +195,22 @@ bool MyRemoveDirectory(LPCWSTR pathName)
}
bool MyMoveFile(LPCWSTR existFileName, LPCWSTR newFileName)
{
{
if (!g_IsNT)
return MyMoveFile(GetSysPath(existFileName), GetSysPath(newFileName));
if (::MoveFileW(existFileName, newFileName))
return true;
#ifdef WIN_LONG_PATH
UString d1, d2;
if (GetLongPaths(existFileName, newFileName, d1, d2))
if (GetLongPaths(existFileName, newFileName, d1, d2))
return BOOLToBool(::MoveFileW(d1, d2));
#endif
return false;
}
#endif
bool MyCreateDirectory(LPCTSTR pathName)
{
bool MyCreateDirectory(LPCTSTR pathName)
{
if (::CreateDirectory(pathName, NULL))
return true;
#ifdef WIN_LONG_PATH2
@@ -226,7 +226,7 @@ bool MyCreateDirectory(LPCTSTR pathName)
#ifndef _UNICODE
bool MyCreateDirectory(LPCWSTR pathName)
{
{
if (!g_IsNT)
return MyCreateDirectory(GetSysPath(pathName));
if (::CreateDirectoryW(pathName, NULL))
@@ -293,7 +293,7 @@ bool CreateComplexDirectory(LPCTSTR _aPathName)
NFind::CFileInfo fileInfo;
if (!NFind::FindFile(pathName, fileInfo)) // For network folders
return true;
if (!fileInfo.IsDirectory())
if (!fileInfo.IsDir())
return false;
break;
}
@@ -339,7 +339,7 @@ bool CreateComplexDirectory(LPCWSTR _aPathName)
NFind::CFileInfoW fileInfo;
if (!NFind::FindFile(pathName, fileInfo)) // For network folders
return true;
if (!fileInfo.IsDirectory())
if (!fileInfo.IsDir())
return false;
break;
}
@@ -380,7 +380,7 @@ bool DeleteFileAlways(LPCTSTR name)
#ifndef _UNICODE
bool DeleteFileAlways(LPCWSTR name)
{
{
if (!g_IsNT)
return DeleteFileAlways(GetSysPath(name));
if (!MySetFileAttributes(name, 0))
@@ -398,7 +398,7 @@ bool DeleteFileAlways(LPCWSTR name)
static bool RemoveDirectorySubItems2(const CSysString pathPrefix, const NFind::CFileInfo &fileInfo)
{
if(fileInfo.IsDirectory())
if(fileInfo.IsDir())
return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name);
return DeleteFileAlways(pathPrefix + fileInfo.Name);
}
@@ -421,7 +421,7 @@ bool RemoveDirectoryWithSubItems(const CSysString &path)
#ifndef _UNICODE
static bool RemoveDirectorySubItems2(const UString pathPrefix, const NFind::CFileInfoW &fileInfo)
{
if(fileInfo.IsDirectory())
if(fileInfo.IsDir())
return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name);
return DeleteFileAlways(pathPrefix + fileInfo.Name);
}
@@ -605,11 +605,11 @@ bool MyGetCurrentDirectory(UString &path)
#endif
#endif
bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
CSysString &resultPath, UINT32 &filePart)
{
LPTSTR filePartPointer;
DWORD value = ::SearchPath(path, fileName, extension,
DWORD value = ::SearchPath(path, fileName, extension,
MAX_PATH, resultPath.GetBuffer(MAX_PATH + 1), &filePartPointer);
filePart = (UINT32)(filePartPointer - (LPCTSTR)resultPath);
resultPath.ReleaseBuffer();
@@ -617,13 +617,13 @@ bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
}
#ifndef _UNICODE
bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
UString &resultPath, UINT32 &filePart)
{
if (g_IsNT)
{
LPWSTR filePartPointer = 0;
DWORD value = ::SearchPathW(path, fileName, extension,
DWORD value = ::SearchPathW(path, fileName, extension,
MAX_PATH, resultPath.GetBuffer(MAX_PATH + 1), &filePartPointer);
filePart = (UINT32)(filePartPointer - (LPCWSTR)resultPath);
resultPath.ReleaseBuffer();
@@ -688,8 +688,8 @@ UINT MyGetTempFileName(LPCWSTR dirPath, LPCWSTR prefix, UString &path)
}
CSysString sysPath;
UINT number = MyGetTempFileName(
dirPath ? (LPCTSTR)GetSysPath(dirPath): 0,
prefix ? (LPCTSTR)GetSysPath(prefix): 0,
dirPath ? (LPCTSTR)GetSysPath(dirPath): 0,
prefix ? (LPCTSTR)GetSysPath(prefix): 0,
sysPath);
path = GetUnicodePath(sysPath);
return number;
@@ -794,9 +794,9 @@ bool CreateTempDirectory(LPCTSTR prefix, CSysString &dirName)
}
bool CTempDirectory::Create(LPCTSTR prefix)
{
{
Remove();
return (_mustBeDeleted = CreateTempDirectory(prefix, _tempDir));
return (_mustBeDeleted = CreateTempDirectory(prefix, _tempDir));
}
#ifndef _UNICODE
@@ -831,9 +831,9 @@ bool CreateTempDirectory(LPCWSTR prefix, UString &dirName)
}
bool CTempDirectoryW::Create(LPCWSTR prefix)
{
{
Remove();
return (_mustBeDeleted = CreateTempDirectory(prefix, _tempDir));
return (_mustBeDeleted = CreateTempDirectory(prefix, _tempDir));
}
#endif
+7 -7
View File
@@ -21,7 +21,7 @@ bool MyGetWindowsDirectory(UString &path);
bool MyGetSystemDirectory(UString &path);
#endif
bool SetDirTime(LPCWSTR fileName, const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime);
bool SetDirTime(LPCWSTR fileName, const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime);
bool MySetFileAttributes(LPCTSTR fileName, DWORD fileAttributes);
bool MyMoveFile(LPCTSTR existFileName, LPCTSTR newFileName);
@@ -44,13 +44,13 @@ bool RemoveDirectoryWithSubItems(const UString &path);
#ifndef _WIN32_WCE
bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath);
bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath,
bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath,
int &fileNamePartStartIndex);
bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath);
bool GetOnlyName(LPCTSTR fileName, CSysString &resultName);
bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName);
#ifndef _UNICODE
bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath,
bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath,
int &fileNamePartStartIndex);
bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath);
bool GetOnlyName(LPCWSTR fileName, UString &resultName);
@@ -66,14 +66,14 @@ bool MyGetCurrentDirectory(UString &resultPath);
#endif
#endif
bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
CSysString &resultPath, UINT32 &filePart);
#ifndef _UNICODE
bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
UString &resultPath, UINT32 &filePart);
#endif
inline bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
inline bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
CSysString &resultPath)
{
UINT32 value;
@@ -81,7 +81,7 @@ inline bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
}
#ifndef _UNICODE
inline bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
inline bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
UString &resultPath)
{
UINT32 value;
+57 -63
View File
@@ -25,8 +25,8 @@ namespace NFind {
static const TCHAR kDot = TEXT('.');
bool CFileInfo::IsDots() const
{
if (!IsDirectory() || Name.IsEmpty())
{
if (!IsDir() || Name.IsEmpty())
return false;
if (Name[0] != kDot)
return false;
@@ -35,8 +35,8 @@ bool CFileInfo::IsDots() const
#ifndef _UNICODE
bool CFileInfoW::IsDots() const
{
if (!IsDirectory() || Name.IsEmpty())
{
if (!IsDir() || Name.IsEmpty())
return false;
if (Name[0] != kDot)
return false;
@@ -44,58 +44,52 @@ bool CFileInfoW::IsDots() const
}
#endif
static void ConvertWIN32_FIND_DATA_To_FileInfo(
const WIN32_FIND_DATA &findData,
CFileInfo &fileInfo)
static void ConvertWIN32_FIND_DATA_To_FileInfo(const WIN32_FIND_DATA &fd, CFileInfo &fi)
{
fileInfo.Attributes = findData.dwFileAttributes;
fileInfo.CreationTime = findData.ftCreationTime;
fileInfo.LastAccessTime = findData.ftLastAccessTime;
fileInfo.LastWriteTime = findData.ftLastWriteTime;
fileInfo.Size = (((UInt64)findData.nFileSizeHigh) << 32) + findData.nFileSizeLow;
fileInfo.Name = findData.cFileName;
fi.Attrib = fd.dwFileAttributes;
fi.CTime = fd.ftCreationTime;
fi.ATime = fd.ftLastAccessTime;
fi.MTime = fd.ftLastWriteTime;
fi.Size = (((UInt64)fd.nFileSizeHigh) << 32) + fd.nFileSizeLow;
fi.Name = fd.cFileName;
#ifndef _WIN32_WCE
fileInfo.ReparseTag = findData.dwReserved0;
fi.ReparseTag = fd.dwReserved0;
#else
fileInfo.ObjectID = findData.dwOID;
fi.ObjectID = fd.dwOID;
#endif
}
#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,
CFileInfoW &fileInfo)
static void ConvertWIN32_FIND_DATA_To_FileInfo(const WIN32_FIND_DATAW &fd, CFileInfoW &fi)
{
fileInfo.Attributes = findData.dwFileAttributes;
fileInfo.CreationTime = findData.ftCreationTime;
fileInfo.LastAccessTime = findData.ftLastAccessTime;
fileInfo.LastWriteTime = findData.ftLastWriteTime;
fileInfo.Size = (((UInt64)findData.nFileSizeHigh) << 32) + findData.nFileSizeLow;
fileInfo.Name = findData.cFileName;
fi.Attrib = fd.dwFileAttributes;
fi.CTime = fd.ftCreationTime;
fi.ATime = fd.ftLastAccessTime;
fi.MTime = fd.ftLastWriteTime;
fi.Size = (((UInt64)fd.nFileSizeHigh) << 32) + fd.nFileSizeLow;
fi.Name = fd.cFileName;
#ifndef _WIN32_WCE
fileInfo.ReparseTag = findData.dwReserved0;
fi.ReparseTag = fd.dwReserved0;
#else
fileInfo.ObjectID = findData.dwOID;
fi.ObjectID = fd.dwOID;
#endif
}
static void ConvertWIN32_FIND_DATA_To_FileInfo(
const WIN32_FIND_DATA &findData,
CFileInfoW &fileInfo)
static void ConvertWIN32_FIND_DATA_To_FileInfo(const WIN32_FIND_DATA &fd, CFileInfoW &fi)
{
fileInfo.Attributes = findData.dwFileAttributes;
fileInfo.CreationTime = findData.ftCreationTime;
fileInfo.LastAccessTime = findData.ftLastAccessTime;
fileInfo.LastWriteTime = findData.ftLastWriteTime;
fileInfo.Size = (((UInt64)findData.nFileSizeHigh) << 32) + findData.nFileSizeLow;
fileInfo.Name = GetUnicodeString(findData.cFileName, GetCurrentCodePage());
fi.Attrib = fd.dwFileAttributes;
fi.CTime = fd.ftCreationTime;
fi.ATime = fd.ftLastAccessTime;
fi.MTime = fd.ftLastWriteTime;
fi.Size = (((UInt64)fd.nFileSizeHigh) << 32) + fd.nFileSizeLow;
fi.Name = GetUnicodeString(fd.cFileName, GetCurrentCodePage());
#ifndef _WIN32_WCE
fileInfo.ReparseTag = findData.dwReserved0;
fi.ReparseTag = fd.dwReserved0;
#else
fileInfo.ObjectID = findData.dwOID;
fi.ObjectID = fd.dwOID;
#endif
}
#endif
@@ -118,19 +112,19 @@ bool CFindFile::FindFirst(LPCTSTR wildcard, CFileInfo &fileInfo)
{
if (!Close())
return false;
WIN32_FIND_DATA findData;
_handle = ::FindFirstFile(wildcard, &findData);
WIN32_FIND_DATA fd;
_handle = ::FindFirstFile(wildcard, &fd);
#ifdef WIN_LONG_PATH2
if (_handle == INVALID_HANDLE_VALUE)
{
UString longPath;
if (GetLongPath(wildcard, longPath))
_handle = ::FindFirstFileW(longPath, &findData);
_handle = ::FindFirstFileW(longPath, &fd);
}
#endif
if (_handle == INVALID_HANDLE_VALUE)
return false;
ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo);
return true;
}
@@ -141,26 +135,26 @@ bool CFindFile::FindFirst(LPCWSTR wildcard, CFileInfoW &fileInfo)
return false;
if (g_IsNT)
{
WIN32_FIND_DATAW findData;
_handle = ::FindFirstFileW(wildcard, &findData);
WIN32_FIND_DATAW fd;
_handle = ::FindFirstFileW(wildcard, &fd);
#ifdef WIN_LONG_PATH
if (_handle == INVALID_HANDLE_VALUE)
{
UString longPath;
if (GetLongPath(wildcard, longPath))
_handle = ::FindFirstFileW(longPath, &findData);
_handle = ::FindFirstFileW(longPath, &fd);
}
#endif
if (_handle != INVALID_HANDLE_VALUE)
ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo);
}
else
{
WIN32_FIND_DATAA findData;
_handle = ::FindFirstFileA(UnicodeStringToMultiByte(wildcard,
GetCurrentCodePage()), &findData);
WIN32_FIND_DATAA fd;
_handle = ::FindFirstFileA(UnicodeStringToMultiByte(wildcard,
GetCurrentCodePage()), &fd);
if (_handle != INVALID_HANDLE_VALUE)
ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo);
}
return (_handle != INVALID_HANDLE_VALUE);
}
@@ -168,10 +162,10 @@ bool CFindFile::FindFirst(LPCWSTR wildcard, CFileInfoW &fileInfo)
bool CFindFile::FindNext(CFileInfo &fileInfo)
{
WIN32_FIND_DATA findData;
bool result = BOOLToBool(::FindNextFile(_handle, &findData));
WIN32_FIND_DATA fd;
bool result = BOOLToBool(::FindNextFile(_handle, &fd));
if (result)
ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo);
return result;
}
@@ -180,17 +174,17 @@ bool CFindFile::FindNext(CFileInfoW &fileInfo)
{
if (g_IsNT)
{
WIN32_FIND_DATAW findData;
if (!::FindNextFileW(_handle, &findData))
WIN32_FIND_DATAW fd;
if (!::FindNextFileW(_handle, &fd))
return false;
ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo);
}
else
{
WIN32_FIND_DATAA findData;
if (!::FindNextFileA(_handle, &findData))
WIN32_FIND_DATAA fd;
if (!::FindNextFileA(_handle, &fd))
return false;
ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
ConvertWIN32_FIND_DATA_To_FileInfo(fd, fileInfo);
}
return true;
}
@@ -340,11 +334,11 @@ HANDLE CFindChangeNotification::FindFirst(LPCWSTR pathName, bool watchSubtree, D
bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings)
{
driveStrings.Clear();
UINT32 size = GetLogicalDriveStrings(0, NULL);
UINT32 size = GetLogicalDriveStrings(0, NULL);
if (size == 0)
return false;
CSysString buffer;
UINT32 newSize = GetLogicalDriveStrings(size, buffer.GetBuffer(size));
UINT32 newSize = GetLogicalDriveStrings(size, buffer.GetBuffer(size));
if (newSize == 0)
return false;
if (newSize > size)
@@ -372,11 +366,11 @@ bool MyGetLogicalDriveStrings(UStringVector &driveStrings)
driveStrings.Clear();
if (g_IsNT)
{
UINT32 size = GetLogicalDriveStringsW(0, NULL);
UINT32 size = GetLogicalDriveStringsW(0, NULL);
if (size == 0)
return false;
UString buffer;
UINT32 newSize = GetLogicalDriveStringsW(size, buffer.GetBuffer(size));
UINT32 newSize = GetLogicalDriveStringsW(size, buffer.GetBuffer(size));
if (newSize == 0)
return false;
if (newSize > size)
+17 -17
View File
@@ -14,34 +14,34 @@ namespace NFind {
namespace NAttributes
{
inline bool IsReadOnly(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_READONLY) != 0; }
inline bool IsHidden(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_HIDDEN) != 0; }
inline bool IsSystem(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_SYSTEM) != 0; }
inline bool IsDirectory(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; }
inline bool IsArchived(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_ARCHIVE) != 0; }
inline bool IsCompressed(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_COMPRESSED) != 0; }
inline bool IsEncrypted(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_ENCRYPTED) != 0; }
inline bool IsReadOnly(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_READONLY) != 0; }
inline bool IsHidden(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_HIDDEN) != 0; }
inline bool IsSystem(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_SYSTEM) != 0; }
inline bool IsDir(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0; }
inline bool IsArchived(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_ARCHIVE) != 0; }
inline bool IsCompressed(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_COMPRESSED) != 0; }
inline bool IsEncrypted(DWORD attrib) { return (attrib & FILE_ATTRIBUTE_ENCRYPTED) != 0; }
}
class CFileInfoBase
{
bool MatchesMask(UINT32 mask) const { return ((Attributes & mask) != 0); }
{
bool MatchesMask(UINT32 mask) const { return ((Attrib & mask) != 0); }
public:
DWORD Attributes;
FILETIME CreationTime;
FILETIME LastAccessTime;
FILETIME LastWriteTime;
UInt64 Size;
FILETIME CTime;
FILETIME ATime;
FILETIME MTime;
DWORD Attrib;
#ifndef _WIN32_WCE
UINT32 ReparseTag;
#else
DWORD ObjectID;
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); }
bool IsDir() const { return MatchesMask(FILE_ATTRIBUTE_DIRECTORY); }
bool IsEncrypted() const { return MatchesMask(FILE_ATTRIBUTE_ENCRYPTED); }
bool IsHidden() const { return MatchesMask(FILE_ATTRIBUTE_HIDDEN); }
bool IsNormal() const { return MatchesMask(FILE_ATTRIBUTE_NORMAL); }
@@ -54,7 +54,7 @@ public:
};
class CFileInfo: public CFileInfoBase
{
{
public:
CSysString Name;
bool IsDots() const;
@@ -64,7 +64,7 @@ public:
typedef CFileInfo CFileInfoW;
#else
class CFileInfoW: public CFileInfoBase
{
{
public:
UString Name;
bool IsDots() const;
+23 -24
View File
@@ -50,7 +50,7 @@ bool GetLongPathBase(LPCWSTR s, UString &res)
bool GetLongPath(LPCWSTR path, UString &longPath)
{
if (GetLongPathBase(path, longPath))
if (GetLongPathBase(path, longPath))
return !longPath.IsEmpty();
return false;
}
@@ -65,16 +65,16 @@ bool CFileBase::Create(LPCTSTR fileName, DWORD desiredAccess,
{
if (!Close())
return false;
_handle = ::CreateFile(fileName, desiredAccess, shareMode,
(LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
_handle = ::CreateFile(fileName, desiredAccess, shareMode,
(LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
flagsAndAttributes, (HANDLE)NULL);
#ifdef WIN_LONG_PATH2
if (_handle == INVALID_HANDLE_VALUE)
{
UString longPath;
if (GetLongPath(fileName, longPath))
_handle = ::CreateFileW(longPath, desiredAccess, shareMode,
(LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
_handle = ::CreateFileW(longPath, desiredAccess, shareMode,
(LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
flagsAndAttributes, (HANDLE)NULL);
}
#endif
@@ -86,20 +86,20 @@ bool CFileBase::Create(LPCWSTR fileName, DWORD desiredAccess,
DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
{
if (!g_IsNT)
return Create(UnicodeStringToMultiByte(fileName, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP),
return Create(UnicodeStringToMultiByte(fileName, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP),
desiredAccess, shareMode, creationDisposition, flagsAndAttributes);
if (!Close())
return false;
_handle = ::CreateFileW(fileName, desiredAccess, shareMode,
(LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
_handle = ::CreateFileW(fileName, desiredAccess, shareMode,
(LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
flagsAndAttributes, (HANDLE)NULL);
#ifdef WIN_LONG_PATH
if (_handle == INVALID_HANDLE_VALUE)
{
UString longPath;
if (GetLongPath(fileName, longPath))
_handle = ::CreateFileW(longPath, desiredAccess, shareMode,
(LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
_handle = ::CreateFileW(longPath, desiredAccess, shareMode,
(LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
flagsAndAttributes, (HANDLE)NULL);
}
#endif
@@ -139,7 +139,7 @@ bool CFileBase::Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition
value.QuadPart = distanceToMove;
value.LowPart = ::SetFilePointer(_handle, value.LowPart, &value.HighPart, moveMethod);
if (value.LowPart == 0xFFFFFFFF)
if(::GetLastError() != NO_ERROR)
if(::GetLastError() != NO_ERROR)
return false;
newPosition = value.QuadPart;
return true;
@@ -164,13 +164,13 @@ bool CFileBase::SeekToEnd(UInt64 &newPosition)
bool CFileBase::GetFileInformation(CByHandleFileInfo &fileInfo) const
{
BY_HANDLE_FILE_INFORMATION winFileInfo;
if(!::GetFileInformationByHandle(_handle, &winFileInfo))
if (!::GetFileInformationByHandle(_handle, &winFileInfo))
return false;
fileInfo.Attributes = winFileInfo.dwFileAttributes;
fileInfo.CreationTime = winFileInfo.ftCreationTime;
fileInfo.LastAccessTime = winFileInfo.ftLastAccessTime;
fileInfo.LastWriteTime = winFileInfo.ftLastWriteTime;
fileInfo.VolumeSerialNumber = winFileInfo.dwFileAttributes;
fileInfo.CTime = winFileInfo.ftCreationTime;
fileInfo.ATime = winFileInfo.ftLastAccessTime;
fileInfo.MTime = winFileInfo.ftLastWriteTime;
fileInfo.VolumeSerialNumber = winFileInfo.dwFileAttributes;
fileInfo.Size = (((UInt64)winFileInfo.nFileSizeHigh) << 32) + winFileInfo.nFileSizeLow;
fileInfo.NumberOfLinks = winFileInfo.nNumberOfLinks;
fileInfo.FileIndex = (((UInt64)winFileInfo.nFileIndexHigh) << 32) + winFileInfo.nFileIndexLow;
@@ -201,12 +201,12 @@ bool CInFile::Open(LPCWSTR fileName)
#endif
// ReadFile and WriteFile functions in Windows have BUG:
// If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1)
// from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES
// If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1)
// from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES
// (Insufficient system resources exist to complete the requested service).
// Probably in some version of Windows there are problems with other sizes:
// for 32 MB (maybe also for 16 MB).
// Probably in some version of Windows there are problems with other sizes:
// for 32 MB (maybe also for 16 MB).
// And message can be "Network connection was lost"
static UInt32 kChunkSizeMax = (1 << 22);
@@ -268,11 +268,10 @@ bool COutFile::Create(LPCWSTR fileName, bool 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 *cTime, const FILETIME *aTime, const FILETIME *mTime)
{ return BOOLToBool(::SetFileTime(_handle, cTime, aTime, mTime)); }
bool COutFile::SetLastWriteTime(const FILETIME *lastWriteTime)
{ return SetTime(NULL, NULL, lastWriteTime); }
bool COutFile::SetMTime(const FILETIME *mTime) { return SetTime(NULL, NULL, mTime); }
bool COutFile::WritePart(const void *data, UInt32 size, UInt32 &processedSize)
{
+13 -13
View File
@@ -10,15 +10,15 @@ namespace NFile {
namespace NIO {
struct CByHandleFileInfo
{
DWORD Attributes;
FILETIME CreationTime;
FILETIME LastAccessTime;
FILETIME LastWriteTime;
DWORD VolumeSerialNumber;
{
DWORD Attributes;
FILETIME CTime;
FILETIME ATime;
FILETIME MTime;
DWORD VolumeSerialNumber;
UInt64 Size;
DWORD NumberOfLinks;
UInt64 FileIndex;
DWORD NumberOfLinks;
UInt64 FileIndex;
};
class CFileBase
@@ -42,9 +42,9 @@ public:
bool GetLength(UInt64 &length) const;
bool Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const;
bool Seek(UInt64 position, UInt64 &newPosition);
bool SeekToBegin();
bool SeekToEnd(UInt64 &newPosition);
bool Seek(UInt64 position, UInt64 &newPosition);
bool SeekToBegin();
bool SeekToEnd(UInt64 &newPosition);
bool GetFileInformation(CByHandleFileInfo &fileInfo) const;
};
@@ -86,8 +86,8 @@ public:
{ m_CreationDisposition = CREATE_ALWAYS; }
*/
bool SetTime(const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime);
bool SetLastWriteTime(const FILETIME *lastWriteTime);
bool SetTime(const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime);
bool SetMTime(const FILETIME *mTime);
bool WritePart(const void *data, UInt32 size, UInt32 &processedSize);
bool Write(const void *data, UInt32 size, UInt32 &processedSize);
bool SetEndOfFile();
+5 -5
View File
@@ -27,18 +27,18 @@ public:
return (_handle != NULL);
}
LPVOID MapViewOfFile(DWORD desiredAccess, UINT64 fileOffset,
LPVOID MapViewOfFile(DWORD desiredAccess, UINT64 fileOffset,
SIZE_T numberOfBytesToMap)
{
return ::MapViewOfFile(_handle, desiredAccess,
return ::MapViewOfFile(_handle, desiredAccess,
DWORD(fileOffset >> 32), DWORD(fileOffset), numberOfBytesToMap);
}
LPVOID MapViewOfFileEx(DWORD desiredAccess, UINT64 fileOffset,
LPVOID MapViewOfFileEx(DWORD desiredAccess, UINT64 fileOffset,
SIZE_T numberOfBytesToMap, LPVOID baseAddress)
{
return ::MapViewOfFileEx(_handle, desiredAccess,
DWORD(fileOffset >> 32), DWORD(fileOffset),
return ::MapViewOfFileEx(_handle, desiredAccess,
DWORD(fileOffset >> 32), DWORD(fileOffset),
numberOfBytesToMap, baseAddress);
}
+1 -1
View File
@@ -31,7 +31,7 @@ void NormalizeDirPathPrefix(UString &dirPath)
const wchar_t kExtensionDelimiter = L'.';
void SplitNameToPureNameAndExtension(const UString &fullName,
void SplitNameToPureNameAndExtension(const UString &fullName,
UString &pureName, UString &extensionDelimiter, UString &extension)
{
int index = fullName.ReverseFind(kExtensionDelimiter);
+2 -2
View File
@@ -18,8 +18,8 @@ void NormalizeDirPathPrefix(UString &dirPath); // ensures that it ended with '\\
#endif
#ifdef _WIN32
void SplitNameToPureNameAndExtension(const UString &fullName,
UString &pureName, UString &extensionDelimiter, UString &extension);
void SplitNameToPureNameAndExtension(const UString &fullName,
UString &pureName, UString &extensionDelimiter, UString &extension);
#endif
}}}
+2 -2
View File
@@ -57,7 +57,7 @@ bool MyGetVolumeInformation(
return result;
}
AString volumeNameA, fileSystemNameA;
bool result = MyGetVolumeInformation(GetSystemString(rootPathName), volumeNameA,
bool result = MyGetVolumeInformation(GetSystemString(rootPathName), volumeNameA,
volumeSerialNumber, maximumComponentLength, fileSystemFlags,fileSystemNameA);
if (result)
{
@@ -78,7 +78,7 @@ typedef BOOL (WINAPI * GetDiskFreeSpaceExPointer)(
bool MyGetDiskFreeSpace(LPCTSTR rootPathName,
UInt64 &clusterSize, UInt64 &totalSize, UInt64 &freeSize)
{
GetDiskFreeSpaceExPointer pGetDiskFreeSpaceEx =
GetDiskFreeSpaceExPointer pGetDiskFreeSpaceEx =
(GetDiskFreeSpaceExPointer)GetProcAddress(
GetModuleHandle(TEXT("kernel32.dll")), "GetDiskFreeSpaceExA");
+4 -4
View File
@@ -22,12 +22,12 @@ public:
_handle = NULL;
return true;
}
void Attach(HANDLE handle)
void Attach(HANDLE handle)
{ _handle = handle; }
HANDLE Detach()
{
HANDLE Detach()
{
HANDLE handle = _handle;
_handle = NULL;
_handle = NULL;
return handle;
}
};
+1 -1
View File
@@ -31,7 +31,7 @@ public:
LPVOID GetPointer() const { return m_Pointer; }
CGlobalLock(HGLOBAL hGlobal): m_Global(hGlobal)
{
m_Pointer = ::GlobalLock(hGlobal);
m_Pointer = ::GlobalLock(hGlobal);
};
~CGlobalLock()
{
+1 -1
View File
@@ -10,4 +10,4 @@ bool EnableLockMemoryPrivilege(bool enable = true);
}}
#endif
#endif
+18 -18
View File
@@ -11,20 +11,20 @@ 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;
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),
CMenuItem(): fMask(0), fType(0), fState(0), wID(0), hSubMenu(0), hbmpChecked(0),
hbmpUnchecked(0), dwItemData(0) {}
};
@@ -44,19 +44,19 @@ public:
}
bool Create()
{
{
_menu = ::CreateMenu();
return (_menu != NULL);
return (_menu != NULL);
}
bool CreatePopup()
{
{
_menu = ::CreatePopupMenu();
return (_menu != NULL);
return (_menu != NULL);
}
bool Destroy()
{
{
if (_menu == NULL)
return false;
return BOOLToBool(::DestroyMenu(Detach()));
@@ -71,7 +71,7 @@ public:
{
result.Empty();
int len = ::GetMenuString(_menu, idItem, 0, 0, flag);
len = ::GetMenuString(_menu, idItem, result.GetBuffer(len + 2),
len = ::GetMenuString(_menu, idItem, result.GetBuffer(len + 2),
len + 1, flag);
result.ReleaseBuffer();
return (len != 0);
@@ -120,7 +120,7 @@ public:
DWORD CheckItem(UINT id, UINT uCheck)
{ return ::CheckMenuItem(_menu, id, uCheck); }
BOOL EnableItem(UINT uIDEnableItem, UINT uEnable)
BOOL EnableItem(UINT uIDEnableItem, UINT uEnable)
{ return EnableMenuItem(_menu, uIDEnableItem, uEnable); }
};
+2 -2
View File
@@ -8,7 +8,7 @@ namespace NWindows {
namespace NNational {
namespace NTime {
bool MyGetTimeFormat(LCID locale, DWORD flags, CONST SYSTEMTIME *time,
bool MyGetTimeFormat(LCID locale, DWORD flags, CONST SYSTEMTIME *time,
LPCTSTR format, CSysString &resultString)
{
resultString.Empty();
@@ -21,7 +21,7 @@ bool MyGetTimeFormat(LCID locale, DWORD flags, CONST SYSTEMTIME *time,
return (numChars != 0);
}
bool MyGetDateFormat(LCID locale, DWORD flags, CONST SYSTEMTIME *time,
bool MyGetDateFormat(LCID locale, DWORD flags, CONST SYSTEMTIME *time,
LPCTSTR format, CSysString &resultString)
{
resultString.Empty();
+2 -2
View File
@@ -9,10 +9,10 @@ namespace NWindows {
namespace NNational {
namespace NTime {
bool MyGetTimeFormat(LCID locale, DWORD flags, CONST SYSTEMTIME *time,
bool MyGetTimeFormat(LCID locale, DWORD flags, CONST SYSTEMTIME *time,
LPCTSTR format, CSysString &resultString);
bool MyGetDateFormat(LCID locale, DWORD flags, CONST SYSTEMTIME *time,
bool MyGetDateFormat(LCID locale, DWORD flags, CONST SYSTEMTIME *time,
LPCTSTR format, CSysString &resultString);
}}}
+10 -10
View File
@@ -134,7 +134,7 @@ static void ConvertResourceToResourceW(const CResource &resource, CResourceW &re
resourceW.Comment = GetUnicodeString(resource.Comment);
resourceW.Provider = GetUnicodeString(resource.Provider);
}
#endif
#endif
DWORD CEnum::Open(DWORD scope, DWORD type, DWORD usage, const CResource *resource)
{
@@ -290,7 +290,7 @@ DWORD GetResourceParent(const CResourceW &resource, CResourceW &parentResource)
}
#endif
DWORD GetResourceInformation(const CResource &resource,
DWORD GetResourceInformation(const CResource &resource,
CResource &destResource, CSysString &systemPathPart)
{
CByteBuffer byteBuffer;
@@ -301,8 +301,8 @@ DWORD GetResourceInformation(const CResource &resource,
DWORD bufferSize = kBufferSize;
NETRESOURCE netResource;
ConvertCResourceToNETRESOURCE(resource, netResource);
LPTSTR lplpSystem;
DWORD result = ::WNetGetResourceInformation(&netResource,
LPTSTR lplpSystem;
DWORD result = ::WNetGetResourceInformation(&netResource,
lpnrLocal, &bufferSize, &lplpSystem);
if (result != NO_ERROR)
return result;
@@ -313,7 +313,7 @@ DWORD GetResourceInformation(const CResource &resource,
}
#ifndef _UNICODE
DWORD GetResourceInformation(const CResourceW &resource,
DWORD GetResourceInformation(const CResourceW &resource,
CResourceW &destResource, UString &systemPathPart)
{
if (g_IsNT)
@@ -326,8 +326,8 @@ DWORD GetResourceInformation(const CResourceW &resource,
DWORD bufferSize = kBufferSize;
NETRESOURCEW netResource;
ConvertCResourceToNETRESOURCE(resource, netResource);
LPWSTR lplpSystem;
DWORD result = ::WNetGetResourceInformationW(&netResource,
LPWSTR lplpSystem;
DWORD result = ::WNetGetResourceInformationW(&netResource,
lpnrLocal, &bufferSize, &lplpSystem);
if (result != NO_ERROR)
return result;
@@ -346,7 +346,7 @@ DWORD GetResourceInformation(const CResourceW &resource,
}
#endif
DWORD AddConnection2(const CResource &resource,
DWORD AddConnection2(const CResource &resource,
LPCTSTR password, LPCTSTR userName, DWORD flags)
{
NETRESOURCE netResource;
@@ -370,8 +370,8 @@ DWORD AddConnection2(const CResourceW &resource, LPCWSTR password, LPCWSTR userN
ConvertResourceWToResource(resource, resourceA);
CSysString passwordA = GetSystemString(password);
CSysString userNameA = GetSystemString(userName);
return AddConnection2(resourceA,
password ? (LPCTSTR)passwordA: 0,
return AddConnection2(resourceA,
password ? (LPCTSTR)passwordA: 0,
userName ? (LPCTSTR)userNameA: 0,
flags);
}
+6 -6
View File
@@ -11,10 +11,10 @@ namespace NNet {
struct CResourceBase
{
DWORD Scope;
DWORD Type;
DWORD DisplayType;
DWORD Usage;
DWORD Scope;
DWORD Type;
DWORD DisplayType;
DWORD Usage;
bool LocalNameIsDefined;
bool RemoteNameIsDefined;
bool CommentIsDefined;
@@ -70,10 +70,10 @@ DWORD GetResourceParent(const CResource &resource, CResource &parentResource);
DWORD GetResourceParent(const CResourceW &resource, CResourceW &parentResource);
#endif
DWORD GetResourceInformation(const CResource &resource,
DWORD GetResourceInformation(const CResource &resource,
CResource &destResource, CSysString &systemPathPart);
#ifndef _UNICODE
DWORD GetResourceInformation(const CResourceW &resource,
DWORD GetResourceInformation(const CResourceW &resource,
CResourceW &destResource, UString &systemPathPart);
#endif
+9 -9
View File
@@ -6,17 +6,17 @@
namespace NWindows {
void ProcessMessages(HWND window)
void ProcessMessages(HWND window)
{
MSG msg;
while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
{
if (window == (HWND) NULL || !IsDialogMessage(window, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
{
if (window == (HWND) NULL || !IsDialogMessage(window, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
}
+12 -12
View File
@@ -156,8 +156,8 @@ CPropVariant& CPropVariant::operator=(LONG value)
}
*/
static HRESULT MyPropVariantClear(PROPVARIANT *propVariant)
{
static HRESULT MyPropVariantClear(PROPVARIANT *propVariant)
{
switch(propVariant->vt)
{
case VT_UI1:
@@ -177,20 +177,20 @@ static HRESULT MyPropVariantClear(PROPVARIANT *propVariant)
case VT_CY:
case VT_DATE:
propVariant->vt = VT_EMPTY;
propVariant->wReserved1 = 0;
propVariant->wReserved1 = 0;
return S_OK;
}
return ::VariantClear((VARIANTARG *)propVariant);
return ::VariantClear((VARIANTARG *)propVariant);
}
HRESULT CPropVariant::Clear()
{
HRESULT CPropVariant::Clear()
{
return MyPropVariantClear(this);
}
HRESULT CPropVariant::Copy(const PROPVARIANT* pSrc)
{
::VariantClear((tagVARIANT *)this);
HRESULT CPropVariant::Copy(const PROPVARIANT* pSrc)
{
::VariantClear((tagVARIANT *)this);
switch(pSrc->vt)
{
case VT_UI1:
@@ -212,7 +212,7 @@ HRESULT CPropVariant::Copy(const PROPVARIANT* pSrc)
memmove((PROPVARIANT*)this, pSrc, sizeof(PROPVARIANT));
return S_OK;
}
return ::VariantCopy((tagVARIANT *)this, (tagVARIANT *)(pSrc));
return ::VariantCopy((tagVARIANT *)this, (tagVARIANT *)(pSrc));
}
@@ -295,13 +295,13 @@ int CPropVariant::Compare(const CPropVariant &a)
case VT_UI8:
return MyCompare(uhVal.QuadPart, a.uhVal.QuadPart);
case VT_BOOL:
case VT_BOOL:
return -MyCompare(boolVal, a.boolVal);
case VT_FILETIME:
return ::CompareFileTime(&filetime, &a.filetime);
case VT_BSTR:
return 0; // Not implemented
return 0; // Not implemented
// return MyCompare(aPropVarint.cVal);
default:
+30 -59
View File
@@ -25,11 +25,13 @@ static UString ConvertInt64ToString(Int64 value)
return buffer;
}
static char *UIntToStringSpec(UInt32 value, char *s, int numPos)
static char *UIntToStringSpec(char c, UInt32 value, char *s, int numPos)
{
if (c != 0)
*s++ = c;
char temp[16];
int pos = 0;
do
do
{
temp[pos++] = (char)('0' + value % 10);
value /= 10;
@@ -51,27 +53,15 @@ bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime, bool
SYSTEMTIME st;
if(!BOOLToBool(FileTimeToSystemTime(&ft, &st)))
return false;
s = UIntToStringSpec(st.wYear, s, 4);
*s++ = '-';
s = UIntToStringSpec(st.wMonth, s, 2);
*s++ = '-';
s = UIntToStringSpec(st.wDay, s, 2);
s = UIntToStringSpec(0, st.wYear, s, 4);
s = UIntToStringSpec('-', st.wMonth, s, 2);
s = UIntToStringSpec('-', st.wDay, s, 2);
if (includeTime)
{
*s++ = ' ';
s = UIntToStringSpec(st.wHour, s, 2);
*s++ = ':';
s = UIntToStringSpec(st.wMinute, s, 2);
s = UIntToStringSpec(' ', st.wHour, s, 2);
s = UIntToStringSpec(':', st.wMinute, s, 2);
if (includeSeconds)
{
*s++ = ':';
UIntToStringSpec(st.wSecond, s, 2);
/*
s += 2;
*s++ = '.';
UIntToStringSpec(st.wMilliseconds, s, 3);
*/
}
UIntToStringSpec(':', st.wSecond, s, 2);
}
/*
sprintf(s, "%04d-%02d-%02d", st.wYear, st.wMonth, st.wDay);
@@ -93,37 +83,22 @@ UString ConvertFileTimeToString(const FILETIME &fileTime, bool includeTime, bool
}
UString ConvertPropVariantToString(const PROPVARIANT &propVariant)
UString ConvertPropVariantToString(const PROPVARIANT &prop)
{
switch (propVariant.vt)
switch (prop.vt)
{
case VT_EMPTY:
return UString();
case VT_BSTR:
return propVariant.bstrVal;
case VT_UI1:
return ConvertUInt64ToString(propVariant.bVal);
case VT_UI2:
return ConvertUInt64ToString(propVariant.uiVal);
case VT_UI4:
return ConvertUInt64ToString(propVariant.ulVal);
case VT_UI8:
return ConvertUInt64ToString(propVariant.uhVal.QuadPart);
case VT_FILETIME:
return ConvertFileTimeToString(propVariant.filetime, true, true);
/*
case VT_I1:
return ConvertInt64ToString(propVariant.cVal);
*/
case VT_I2:
return ConvertInt64ToString(propVariant.iVal);
case VT_I4:
return ConvertInt64ToString(propVariant.lVal);
case VT_I8:
return ConvertInt64ToString(propVariant.hVal.QuadPart);
case VT_BOOL:
return VARIANT_BOOLToBool(propVariant.boolVal) ? L"+" : L"-";
case VT_EMPTY: return UString();
case VT_BSTR: return prop.bstrVal;
case VT_UI1: return ConvertUInt64ToString(prop.bVal);
case VT_UI2: return ConvertUInt64ToString(prop.uiVal);
case VT_UI4: return ConvertUInt64ToString(prop.ulVal);
case VT_UI8: return ConvertUInt64ToString(prop.uhVal.QuadPart);
case VT_FILETIME: return ConvertFileTimeToString(prop.filetime, true, true);
// case VT_I1: return ConvertInt64ToString(prop.cVal);
case VT_I2: return ConvertInt64ToString(prop.iVal);
case VT_I4: return ConvertInt64ToString(prop.lVal);
case VT_I8: return ConvertInt64ToString(prop.hVal.QuadPart);
case VT_BOOL: return VARIANT_BOOLToBool(prop.boolVal) ? L"+" : L"-";
default:
#ifndef _WIN32_WCE
throw 150245;
@@ -133,18 +108,14 @@ UString ConvertPropVariantToString(const PROPVARIANT &propVariant)
}
}
UInt64 ConvertPropVariantToUInt64(const PROPVARIANT &propVariant)
UInt64 ConvertPropVariantToUInt64(const PROPVARIANT &prop)
{
switch (propVariant.vt)
switch (prop.vt)
{
case VT_UI1:
return propVariant.bVal;
case VT_UI2:
return propVariant.uiVal;
case VT_UI4:
return propVariant.ulVal;
case VT_UI8:
return (UInt64)propVariant.uhVal.QuadPart;
case VT_UI1: return prop.bVal;
case VT_UI2: return prop.uiVal;
case VT_UI4: return prop.ulVal;
case VT_UI8: return (UInt64)prop.uhVal.QuadPart;
default:
#ifndef _WIN32_WCE
throw 151199;
+77
View File
@@ -0,0 +1,77 @@
// PropVariantUtils.cpp
#include "StdAfx.h"
#include "PropVariantUtils.h"
#include "Common/StringConvert.h"
#include "Common/IntToString.h"
using namespace NWindows;
static AString GetHex(UInt32 v)
{
char sz[32] = { '0', 'x' };
ConvertUInt64ToString(v, sz + 2, 16);
return sz;
}
void StringToProp(const AString &s, NCOM::CPropVariant &prop)
{
prop = MultiByteToUnicodeString(s);
}
void PairToProp(const CUInt32PCharPair *pairs, unsigned num, UInt32 value, NCOM::CPropVariant &prop)
{
AString s;
for (unsigned i = 0; i < num; i++)
{
const CUInt32PCharPair &p = pairs[i];
if (p.Value == value)
s = p.Name;
}
if (s.IsEmpty())
s = GetHex(value);
StringToProp(s, prop);
}
AString TypeToString(const char *table[], unsigned num, UInt32 value)
{
if (value < num)
return table[value];
return GetHex(value);
}
void TypeToProp(const char *table[], unsigned num, UInt32 value, NCOM::CPropVariant &prop)
{
StringToProp(TypeToString(table, num, value), prop);
}
AString FlagsToString(const CUInt32PCharPair *pairs, unsigned num, UInt32 flags)
{
AString s;
for (unsigned i = 0; i < num; i++)
{
const CUInt32PCharPair &p = pairs[i];
if ((flags & p.Value) != 0)
{
if (!s.IsEmpty())
s += ' ';
s += p.Name;
}
flags &= ~p.Value;
}
if (flags != 0)
{
if (!s.IsEmpty())
s += ' ';
s += GetHex(flags);
}
return s;
}
void FlagsToProp(const CUInt32PCharPair *pairs, unsigned num, UInt32 flags, NCOM::CPropVariant &prop)
{
StringToProp(FlagsToString(pairs, num, flags), prop);
}
+28
View File
@@ -0,0 +1,28 @@
// Windows/PropVariantUtils.h
#ifndef __PROP_VARIANT_UTILS_H
#define __PROP_VARIANT_UTILS_H
#include "Common/MyString.h"
#include "PropVariant.h"
struct CUInt32PCharPair
{
UInt32 Value;
const char *Name;
};
void StringToProp(const AString &s, NWindows::NCOM::CPropVariant &prop);
void PairToProp(const CUInt32PCharPair *pairs, unsigned num, UInt32 value, NWindows::NCOM::CPropVariant &prop);
AString FlagsToString(const CUInt32PCharPair *pairs, unsigned num, UInt32 flags);
void FlagsToProp(const CUInt32PCharPair *pairs, unsigned num, UInt32 flags, NWindows::NCOM::CPropVariant &prop);
AString TypeToString(const char *table[], unsigned num, UInt32 value);
void TypeToProp(const char *table[], unsigned num, UInt32 value, NWindows::NCOM::CPropVariant &prop);
#define PAIR_TO_PROP(pairs, value, prop) PairToProp(pairs, sizeof(pairs) / sizeof(pairs[0]), value, prop)
#define FLAGS_TO_PROP(pairs, value, prop) FlagsToProp(pairs, sizeof(pairs) / sizeof(pairs[0]), value, prop)
#define TYPE_TO_PROP(table, value, prop) TypeToProp(table, sizeof(table) / sizeof(table[0]), value, prop)
#endif
+5 -5
View File
@@ -17,8 +17,8 @@ namespace NRegistry {
#define MYASSERT(expr) // _ASSERTE(expr)
CKey::~CKey()
{
Close();
{
Close();
}
HKEY CKey::Detach()
@@ -41,7 +41,7 @@ LONG CKey::Create(HKEY parentKey, LPCTSTR keyName,
MYASSERT(parentKey != NULL);
DWORD dispositionReal;
HKEY key = NULL;
LONG res = RegCreateKeyEx(parentKey, keyName, 0, keyClass,
LONG res = RegCreateKeyEx(parentKey, keyName, 0, keyClass,
options, accessMask, securityAttributes, &key, &dispositionReal);
if (disposition != NULL)
*disposition = dispositionReal;
@@ -170,7 +170,7 @@ LONG CKey::SetValue(LPCWSTR name, LPCWSTR value)
if (g_IsNT)
return RegSetValueExW(_object, name, NULL, REG_SZ,
(const BYTE * )value, (DWORD)((wcslen(value) + 1) * sizeof(wchar_t)));
return SetValue(name == 0 ? 0 : (LPCSTR)GetSystemString(name),
return SetValue(name == 0 ? 0 : (LPCSTR)GetSystemString(name),
value == 0 ? 0 : (LPCSTR)GetSystemString(value));
}
@@ -309,7 +309,7 @@ LONG CKey::EnumKeys(CSysStringVector &keyNames)
const UInt32 kBufferSize = MAX_PATH + 1; // 256 in ATL
FILETIME lastWriteTime;
UInt32 nameSize = kBufferSize;
LONG result = ::RegEnumKeyEx(_object, index, keyName.GetBuffer(kBufferSize),
LONG result = ::RegEnumKeyEx(_object, index, keyName.GetBuffer(kBufferSize),
(DWORD *)&nameSize, NULL, NULL, NULL, &lastWriteTime);
keyName.ReleaseBuffer();
if(result == ERROR_NO_MORE_ITEMS)
+2 -2
View File
@@ -23,7 +23,7 @@ CSysString MyLoadString(HINSTANCE hInstance, UINT resourceID)
{
size += 256;
len = ::LoadString(hInstance, resourceID, s.GetBuffer(size - 1), size);
}
}
while (size - len <= 1);
s.ReleaseBuffer();
return s;
@@ -46,7 +46,7 @@ UString MyLoadStringW(HINSTANCE hInstance, UINT resourceID)
{
size += 256;
len = ::LoadStringW(hInstance, resourceID, s.GetBuffer(size - 1), size);
}
}
while (size - len <= 1);
s.ReleaseBuffer();
return s;
+4 -4
View File
@@ -90,7 +90,7 @@ static PSID GetSid(LPWSTR accountName)
{
PSID pSid = ::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sidLen);
LPWSTR domainName = (LPWSTR)::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (domainLen + 1) * sizeof(WCHAR));
BOOL res =
BOOL res =
#ifdef _UNICODE
::LookupAccountNameW
#else
@@ -115,11 +115,11 @@ bool AddLockMemoryPrivilege()
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
if (policy.Open(NULL, &attr,
if (policy.Open(NULL, &attr,
// GENERIC_WRITE)
POLICY_ALL_ACCESS)
// STANDARD_RIGHTS_REQUIRED,
// GENERIC_READ | GENERIC_EXECUTE | POLICY_VIEW_LOCAL_INFORMATION | POLICY_LOOKUP_NAMES)
// STANDARD_RIGHTS_REQUIRED,
// GENERIC_READ | GENERIC_EXECUTE | POLICY_VIEW_LOCAL_INFORMATION | POLICY_LOOKUP_NAMES)
!= 0)
return false;
LSA_UNICODE_STRING userRights;
+7 -7
View File
@@ -71,7 +71,7 @@ protected:
#endif
public:
operator LSA_HANDLE() const { return _handle; }
CPolicy(): _handle(NULL)
CPolicy(): _handle(NULL)
{
#ifndef _UNICODE
hModule = GetModuleHandle(TEXT("Advapi32.dll"));
@@ -91,7 +91,7 @@ public:
#endif
Close();
return
return
#ifdef _UNICODE
::LsaOpenPolicy
#else
@@ -113,7 +113,7 @@ public:
return MY_STATUS_NOT_IMPLEMENTED;
#endif
NTSTATUS res =
NTSTATUS res =
#ifdef _UNICODE
::LsaClose
#else
@@ -131,12 +131,12 @@ public:
NTSTATUS EnumerateAccountRights(PSID sid, PLSA_UNICODE_STRING* userRights, PULONG countOfRights)
{ return ::LsaEnumerateAccountRights(_handle, sid, userRights, countOfRights); }
NTSTATUS LookupSids(ULONG count, PSID* sids,
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;
@@ -145,13 +145,13 @@ public:
return MY_STATUS_NOT_IMPLEMENTED;
#endif
return
return
#ifdef _UNICODE
::LsaAddAccountRights
#else
lsaAddAccountRights
#endif
(_handle, accountSid, userRights, countOfRights);
(_handle, accountSid, userRights, countOfRights);
}
NTSTATUS AddAccountRights(PSID accountSid, PLSA_UNICODE_STRING userRights)
{ return AddAccountRights(accountSid, userRights, 1); }
+20 -20
View File
@@ -20,7 +20,7 @@ namespace NShell {
// CItemIDList
void CItemIDList::Free()
{
{
if(m_Object == NULL)
return;
CMyComPtr<IMalloc> shellMalloc;
@@ -143,9 +143,9 @@ bool BrowseForFolder(LPBROWSEINFO browseInfo, CSysString &resultPath)
}
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM /* lp */, LPARAM data)
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM /* lp */, LPARAM data)
{
switch(uMsg)
switch(uMsg)
{
case BFFM_INITIALIZED:
{
@@ -153,10 +153,10 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM /* lp */, LPARAM da
break;
}
/*
case BFFM_SELCHANGED:
case BFFM_SELCHANGED:
{
TCHAR dir[MAX_PATH];
if (::SHGetPathFromIDList((LPITEMIDLIST) lp , dir))
if (::SHGetPathFromIDList((LPITEMIDLIST) lp , dir))
SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)dir);
else
SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)TEXT(""));
@@ -170,13 +170,13 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM /* lp */, LPARAM da
}
bool BrowseForFolder(HWND owner, LPCTSTR title, UINT ulFlags,
bool BrowseForFolder(HWND owner, LPCTSTR title, UINT ulFlags,
LPCTSTR initialFolder, CSysString &resultPath)
{
CSysString displayName;
BROWSEINFO browseInfo;
browseInfo.hwndOwner = owner;
browseInfo.pidlRoot = NULL;
browseInfo.pidlRoot = NULL;
browseInfo.pszDisplayName = displayName.GetBuffer(MAX_PATH);
browseInfo.lpszTitle = title;
browseInfo.ulFlags = ulFlags;
@@ -185,10 +185,10 @@ bool BrowseForFolder(HWND owner, LPCTSTR title, UINT ulFlags,
return BrowseForFolder(&browseInfo, resultPath);
}
bool BrowseForFolder(HWND owner, LPCTSTR title,
bool BrowseForFolder(HWND owner, LPCTSTR title,
LPCTSTR initialFolder, CSysString &resultPath)
{
return BrowseForFolder(owner, title,
return BrowseForFolder(owner, title,
BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT, initialFolder, resultPath);
// BIF_STATUSTEXT; BIF_USENEWUI (Version 5.0)
}
@@ -227,9 +227,9 @@ bool BrowseForFolder(LPBROWSEINFOW browseInfo, UString &resultPath)
}
int CALLBACK BrowseCallbackProc2(HWND hwnd, UINT uMsg, LPARAM /* lp */, LPARAM data)
int CALLBACK BrowseCallbackProc2(HWND hwnd, UINT uMsg, LPARAM /* lp */, LPARAM data)
{
switch(uMsg)
switch(uMsg)
{
case BFFM_INITIALIZED:
{
@@ -237,11 +237,11 @@ int CALLBACK BrowseCallbackProc2(HWND hwnd, UINT uMsg, LPARAM /* lp */, LPARAM d
break;
}
/*
case BFFM_SELCHANGED:
case BFFM_SELCHANGED:
{
wchar_t dir[MAX_PATH * 2];
if (shGetPathFromIDListW((LPITEMIDLIST)lp , dir))
if (shGetPathFromIDListW((LPITEMIDLIST)lp , dir))
SendMessageW(hwnd, BFFM_SETSTATUSTEXTW, 0, (LPARAM)dir);
else
SendMessageW(hwnd, BFFM_SETSTATUSTEXTW, 0, (LPARAM)L"");
@@ -255,13 +255,13 @@ int CALLBACK BrowseCallbackProc2(HWND hwnd, UINT uMsg, LPARAM /* lp */, LPARAM d
}
static bool BrowseForFolder(HWND owner, LPCWSTR title, UINT ulFlags,
static bool BrowseForFolder(HWND owner, LPCWSTR title, UINT ulFlags,
LPCWSTR initialFolder, UString &resultPath)
{
UString displayName;
BROWSEINFOW browseInfo;
browseInfo.hwndOwner = owner;
browseInfo.pidlRoot = NULL;
browseInfo.pidlRoot = NULL;
browseInfo.pszDisplayName = displayName.GetBuffer(MAX_PATH);
browseInfo.lpszTitle = title;
browseInfo.ulFlags = ulFlags;
@@ -273,16 +273,16 @@ static bool BrowseForFolder(HWND owner, LPCWSTR title, UINT ulFlags,
bool BrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath)
{
if (g_IsNT)
return BrowseForFolder(owner, title,
BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS
return BrowseForFolder(owner, title,
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)
CSysString s;
bool res = BrowseForFolder(owner, GetSystemString(title),
BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS
bool res = BrowseForFolder(owner, GetSystemString(title),
BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS
// | BIF_STATUSTEXT // This flag is not supported when BIF_NEWDIALOGSTYLE is specified.
, GetSystemString(initialFolder), s);
, GetSystemString(initialFolder), s);
resultPath = GetUnicodeString(s);
return res;
}
+1 -1
View File
@@ -60,7 +60,7 @@ public:
~CDrop();
void Attach(HDROP object);
operator HDROP() { return m_Object;}
bool QueryPoint(LPPOINT point)
bool QueryPoint(LPPOINT point)
{ return BOOLToBool(::DragQueryPoint(m_Object, point)); }
void Finish() { ::DragFinish(m_Object); }
UINT QueryFile(UINT fileIndex, LPTSTR fileName, UINT fileNameSize)
+1 -1
View File
@@ -6,4 +6,4 @@
#include "../Common/MyWindows.h"
#include "../Common/NewHandler.h"
#endif
#endif
+6 -6
View File
@@ -5,8 +5,8 @@
#include "Defs.h"
extern "C"
{
extern "C"
{
#include "../../C/Threads.h"
}
@@ -113,8 +113,8 @@ public:
return 0;
return ::GetLastError();
}
WRes Release()
{
WRes Release()
{
return ::ReleaseMutex(_handle) ? 0 : ::GetLastError();
}
};
@@ -122,7 +122,7 @@ class CMutexLock
{
CMutex *_object;
public:
CMutexLock(CMutex &object): _object(&object) { _object->Lock(); }
CMutexLock(CMutex &object): _object(&object) { _object->Lock(); }
~CMutexLock() { _object->Release(); }
};
#endif
@@ -159,7 +159,7 @@ class CCriticalSectionLock
CCriticalSection *_object;
void Unlock() { _object->Leave(); }
public:
CCriticalSectionLock(CCriticalSection &object): _object(&object) {_object->Enter(); }
CCriticalSectionLock(CCriticalSection &object): _object(&object) {_object->Enter(); }
~CCriticalSectionLock() { Unlock(); }
};
+2 -2
View File
@@ -5,8 +5,8 @@
#include "Defs.h"
extern "C"
{
extern "C"
{
#include "../../C/Threads.h"
}
+86
View File
@@ -0,0 +1,86 @@
// Windows/Time.cpp
#include "StdAfx.h"
#include "Time.h"
#include "Windows/Defs.h"
namespace NWindows {
namespace NTime {
bool DosTimeToFileTime(UInt32 dosTime, FILETIME &fileTime)
{
return BOOLToBool(::DosDateTimeToFileTime((UInt16)(dosTime >> 16), (UInt16)(dosTime & 0xFFFF), &fileTime));
}
static const UInt32 kHighDosTime = 0xFF9FBF7D;
static const UInt32 kLowDosTime = 0x210000;
bool FileTimeToDosTime(const FILETIME &fileTime, UInt32 &dosTime)
{
WORD datePart, timePart;
if (!::FileTimeToDosDateTime(&fileTime, &datePart, &timePart))
{
dosTime = (fileTime.dwHighDateTime >= 0x01C00000) ? kHighDosTime : kLowDosTime;
return false;
}
dosTime = (((UInt32)datePart) << 16) + timePart;
return true;
}
static const UInt32 kNumTimeQuantumsInSecond = 10000000;
static const UInt64 kUnixTimeStartValue = ((UInt64)kNumTimeQuantumsInSecond) * 60 * 60 * 24 * 134774;
void UnixTimeToFileTime(UInt32 unixTime, FILETIME &fileTime)
{
UInt64 v = kUnixTimeStartValue + ((UInt64)unixTime) * kNumTimeQuantumsInSecond;
fileTime.dwLowDateTime = (DWORD)v;
fileTime.dwHighDateTime = (DWORD)(v >> 32);
}
bool FileTimeToUnixTime(const FILETIME &fileTime, UInt32 &unixTime)
{
UInt64 winTime = (((UInt64)fileTime.dwHighDateTime) << 32) + fileTime.dwLowDateTime;
if (winTime < kUnixTimeStartValue)
{
unixTime = 0;
return false;
}
winTime = (winTime - kUnixTimeStartValue) / kNumTimeQuantumsInSecond;
if (winTime > 0xFFFFFFFF)
{
unixTime = 0xFFFFFFFF;
return false;
}
unixTime = (UInt32)winTime;
return true;
}
bool GetSecondsSince1601(unsigned year, unsigned month, unsigned day,
unsigned hour, unsigned min, unsigned sec, UInt64 &resSeconds)
{
resSeconds = 0;
if (year < 1601 || year >= 10000 || month < 1 || month > 12 ||
day < 1 || day > 31 || hour > 23 || min > 59 || sec > 59)
return false;
UInt32 numYears = year - 1601;
UInt32 numDays = numYears * 365 + numYears / 4 - numYears / 100 + numYears / 400;
Byte ms[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
ms[1] = 29;
month--;
for (unsigned i = 0; i < month; i++)
numDays += ms[i];
numDays += day - 1;
resSeconds = ((UInt64)(numDays * 24 + hour) * 60 + min) * 60 + sec;
return true;
}
void GetCurUtcFileTime(FILETIME &ft)
{
SYSTEMTIME st;
GetSystemTime(&st);
SystemTimeToFileTime(&st, &ft);
}
}}
+7 -52
View File
@@ -4,62 +4,17 @@
#define __WINDOWS_TIME_H
#include "Common/Types.h"
#include "Windows/Defs.h"
namespace NWindows {
namespace NTime {
inline bool DosTimeToFileTime(UInt32 dosTime, FILETIME &fileTime)
{
return BOOLToBool(::DosDateTimeToFileTime(UInt16(dosTime >> 16),
UInt16(dosTime & 0xFFFF), &fileTime));
}
const UInt32 kHighDosTime = 0xFF9FBF7D;
const UInt32 kLowDosTime = 0x210000;
inline bool FileTimeToDosTime(const FILETIME &fileTime, UInt32 &dosTime)
{
WORD datePart, timePart;
if (!::FileTimeToDosDateTime(&fileTime, &datePart, &timePart))
{
if (fileTime.dwHighDateTime >= 0x01C00000) // 2000
dosTime = kHighDosTime;
else
dosTime = kLowDosTime;
return false;
}
dosTime = (((UInt32)datePart) << 16) + timePart;
return true;
}
const UInt32 kNumTimeQuantumsInSecond = 10000000;
const UInt64 kUnixTimeStartValue = ((UInt64)kNumTimeQuantumsInSecond) * 60 * 60 * 24 * 134774;
inline void UnixTimeToFileTime(UInt32 unixTime, FILETIME &fileTime)
{
UInt64 v = kUnixTimeStartValue + ((UInt64)unixTime) * kNumTimeQuantumsInSecond;
fileTime.dwLowDateTime = (DWORD)v;
fileTime.dwHighDateTime = (DWORD)(v >> 32);
}
inline bool FileTimeToUnixTime(const FILETIME &fileTime, UInt32 &unixTime)
{
UInt64 winTime = (((UInt64)fileTime.dwHighDateTime) << 32) + fileTime.dwLowDateTime;
if (winTime < kUnixTimeStartValue)
{
unixTime = 0;
return false;
}
winTime = (winTime - kUnixTimeStartValue) / kNumTimeQuantumsInSecond;
if (winTime > 0xFFFFFFFF)
{
unixTime = 0xFFFFFFFF;
return false;
}
unixTime = (UInt32)winTime;
return true;
}
bool DosTimeToFileTime(UInt32 dosTime, FILETIME &fileTime);
bool FileTimeToDosTime(const FILETIME &fileTime, UInt32 &dosTime);
void UnixTimeToFileTime(UInt32 unixTime, FILETIME &fileTime);
bool FileTimeToUnixTime(const FILETIME &fileTime, UInt32 &unixTime);
bool GetSecondsSince1601(unsigned year, unsigned month, unsigned day,
unsigned hour, unsigned min, unsigned sec, UInt64 &resSeconds);
void GetCurUtcFileTime(FILETIME &ft);
}}
+17 -17
View File
@@ -19,14 +19,14 @@ 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;
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))
@@ -49,31 +49,31 @@ ATOM MyRegisterClass(CONST WNDCLASSW *wndClass)
bool CWindow::Create(LPCWSTR className,
LPCWSTR windowName, DWORD style,
int x, int y, int width, int height,
HWND parentWindow, HMENU idOrHMenu,
HWND parentWindow, HMENU idOrHMenu,
HINSTANCE instance, LPVOID createParam)
{
if (g_IsNT)
{
_window = ::CreateWindowW(className, windowName,
style, x, y, width, height, parentWindow,
style, x, y, width, height, parentWindow,
idOrHMenu, instance, createParam);
return (_window != NULL);
}
return Create(GetSystemString(className), GetSystemString(windowName),
style, x, y, width, height, parentWindow,
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,
HWND parentWindow, HMENU idOrHMenu,
HINSTANCE instance, LPVOID createParam)
{
if (g_IsNT)
{
_window = ::CreateWindowExW(exStyle, className, windowName,
style, x, y, width, height, parentWindow,
style, x, y, width, height, parentWindow,
idOrHMenu, instance, createParam);
return (_window != NULL);
}
@@ -96,7 +96,7 @@ bool CWindow::CreateEx(DWORD exStyle, LPCWSTR className,
windowNameP = windowNameA;
}
return CreateEx(exStyle, classNameP, windowNameP,
style, x, y, width, height, parentWindow,
style, x, y, width, height, parentWindow,
idOrHMenu, instance, createParam);
}
@@ -104,12 +104,12 @@ bool CWindow::CreateEx(DWORD exStyle, LPCWSTR className,
#ifndef _UNICODE
bool MySetWindowText(HWND wnd, LPCWSTR s)
{
{
if (g_IsNT)
return BOOLToBool(::SetWindowTextW(wnd, s));
return BOOLToBool(::SetWindowTextA(wnd, UnicodeStringToMultiByte(s)));
}
#endif
#endif
bool CWindow::GetText(CSysString &s)
{
@@ -154,7 +154,7 @@ bool CWindow::ModifyStyleBase(int styleOffset,
DWORD style = GetWindowLong(styleOffset);
DWORD newStyle = (style & ~remove) | add;
if (style == newStyle)
return false; // it is not good
return false; // it is not good
SetWindowLong(styleOffset, newStyle);
if (flags != 0)
+10 -10
View File
@@ -54,11 +54,11 @@ public:
bool CreateEx(DWORD exStyle, LPCTSTR className,
LPCTSTR windowName, DWORD style,
int x, int y, int width, int height,
HWND parentWindow, HMENU idOrHMenu,
HWND parentWindow, HMENU idOrHMenu,
HINSTANCE instance, LPVOID createParam)
{
_window = ::CreateWindowEx(exStyle, className, windowName,
style, x, y, width, height, parentWindow,
style, x, y, width, height, parentWindow,
idOrHMenu, instance, createParam);
return (_window != NULL);
}
@@ -66,11 +66,11 @@ public:
bool Create(LPCTSTR className,
LPCTSTR windowName, DWORD style,
int x, int y, int width, int height,
HWND parentWindow, HMENU idOrHMenu,
HWND parentWindow, HMENU idOrHMenu,
HINSTANCE instance, LPVOID createParam)
{
_window = ::CreateWindow(className, windowName,
style, x, y, width, height, parentWindow,
style, x, y, width, height, parentWindow,
idOrHMenu, instance, createParam);
return (_window != NULL);
}
@@ -79,12 +79,12 @@ public:
bool Create(LPCWSTR className,
LPCWSTR windowName, DWORD style,
int x, int y, int width, int height,
HWND parentWindow, HMENU idOrHMenu,
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,
HWND parentWindow, HMENU idOrHMenu,
HINSTANCE instance, LPVOID createParam);
#endif
@@ -127,20 +127,20 @@ public:
LONG_PTR GetLong(int index) const
{ return ::GetWindowLong(_window, index ); }
LONG_PTR SetUserDataLong(LONG newLongPtr )
{ return SetLong(GWLP_USERDATA, newLongPtr); }
{ return SetLong(GWLP_USERDATA, newLongPtr); }
LONG_PTR GetUserDataLong() const
{ return GetLong(GWLP_USERDATA); }
#ifndef _WIN32_WCE
LONG_PTR SetLongPtr(int index, LONG_PTR newLongPtr )
{ return ::SetWindowLongPtr(_window, index,
{ return ::SetWindowLongPtr(_window, index,
#ifndef _WIN64
(LONG)
#endif
newLongPtr); }
#ifndef _UNICODE
LONG_PTR SetLongPtrW(int index, LONG_PTR newLongPtr )
{ return ::SetWindowLongPtrW(_window, index,
{ return ::SetWindowLongPtrW(_window, index,
#ifndef _WIN64
(LONG)
#endif
@@ -183,7 +183,7 @@ public:
bool CWindow::SetText(LPCWSTR s) { return MySetWindowText(_window, s); }
#endif
int GetTextLength() const
int GetTextLength() const
{ return GetWindowTextLength(_window); }
UINT GetText(LPTSTR string, int maxCount) const
{ return GetWindowText(_window, string, maxCount); }