ReactOS 0.4.15-dev-8135-g1bc6c90
CFileDefExt Class Reference

#include <filedefext.h>

Inheritance diagram for CFileDefExt:
Collaboration diagram for CFileDefExt:

Public Member Functions

 CFileDefExt ()
 
 ~CFileDefExt ()
 
BOOL OnFolderCustApply (HWND hwndDlg)
 
void OnFolderCustChangeIcon (HWND hwndDlg)
 
void OnFolderCustDestroy (HWND hwndDlg)
 
void UpdateFolderIcon (HWND hwndDlg)
 
STDMETHOD() Initialize (PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID) override
 
STDMETHOD() QueryContextMenu (HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) override
 
STDMETHOD() InvokeCommand (LPCMINVOKECOMMANDINFO lpici) override
 
STDMETHOD() GetCommandString (UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax) override
 
STDMETHOD() AddPages (LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam) override
 
STDMETHOD() ReplacePage (UINT uPageID, LPFNADDPROPSHEETPAGE pfnReplacePage, LPARAM lParam) override
 
STDMETHOD() SetSite (IUnknown *punk) override
 
STDMETHOD() GetSite (REFIID iid, void **ppvSite) override
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
HRESULT Initialize ([in] PCIDLIST_ABSOLUTE pidlFolder, [in] IDataObject *pdtobj, [in] HKEY hkeyProgID)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 
HRESULT QueryContextMenu ([in] HMENU hmenu, [in] UINT indexMenu, [in] UINT idCmdFirst, [in] UINT idCmdLast, [in] UINT uFlags)
 
HRESULT InvokeCommand ([in] LPCMINVOKECOMMANDINFO lpici)
 
HRESULT GetCommandString ([in] UINT_PTR idCmd, [in] UINT uType, [out] UINT *pwReserved, [out, size_is(cchMax)] LPSTR pszName, [in] UINT cchMax)
 
- Public Member Functions inherited from IShellPropSheetExt
HRESULT AddPages ([in] LPFNSVADDPROPSHEETPAGE pfnAddPage, [in] LPARAM lParam)
 
HRESULT ReplacePage ([in] EXPPS uPageID, [in] LPFNSVADDPROPSHEETPAGE pfnReplaceWith, [in] LPARAM lParam)
 
- Public Member Functions inherited from IObjectWithSite
HRESULT SetSite ([in] IUnknown *pUnkSite)
 
HRESULT GetSite ([in] REFIID riid, [out, iid_is(riid)] PVOID *ppvSite)
 

Private Member Functions

VOID InitOpensWithField (HWND hwndDlg)
 
BOOL InitFileType (HWND hwndDlg)
 
BOOL InitFilePath (HWND hwndDlg)
 
BOOL InitFileAttr (HWND hwndDlg)
 
BOOL InitGeneralPage (HWND hwndDlg)
 
BOOL SetVersionLabel (HWND hwndDlg, DWORD idCtrl, LPCWSTR pwszName)
 
BOOL AddVersionString (HWND hwndDlg, LPCWSTR pwszName)
 
BOOL InitVersionPage (HWND hwndDlg)
 
BOOL InitFolderCustomizePage (HWND hwndDlg)
 
BOOL CountFolderAndFiles (HWND hwndDlg, LPCWSTR pwszBuf, LPDWORD ticks)
 

Static Private Member Functions

static BOOL GetFileTimeString (LPFILETIME lpFileTime, LPWSTR pwszResult, UINT cchResult)
 
static INT_PTR CALLBACK GeneralPageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static INT_PTR CALLBACK VersionPageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static INT_PTR CALLBACK FolderCustomizePageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static DWORD WINAPI _CountFolderAndFilesThreadProc (LPVOID lpParameter)
 

Private Attributes

WCHAR m_wszPath [MAX_PATH]
 
CFileVersionInfo m_VerInfo
 
BOOL m_bDir
 
DWORD m_cFiles
 
DWORD m_cFolders
 
ULARGE_INTEGER m_DirSize
 
ULARGE_INTEGER m_DirSizeOnDisc
 
WCHAR m_szFolderIconPath [MAX_PATH]
 
INT m_nFolderIconIndex
 
HICON m_hFolderIcon
 
BOOL m_bFolderIconIsSet
 

Additional Inherited Members

- Public Types inherited from IShellExtInit
typedef IShellExtInitLPSHELLEXTINIT
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Types inherited from IContextMenu
typedef IContextMenuLPCONTEXTMENU
 
typedef struct IContextMenu::tagCMINVOKECOMMANDINFO CMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMINVOKECOMMANDINFOLPCMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMInvokeCommandInfoEx CMINVOKECOMMANDINFOEX
 
typedef struct IContextMenu::tagCMInvokeCommandInfoExLPCMINVOKECOMMANDINFOEX
 
- Public Types inherited from IShellPropSheetExt
enum  tagSHELLPROPSHEETEXTPAGEID { EXPPS_FILETYPES = 0x1 }
 
typedef UINT EXPPS
 
- Public Types inherited from IObjectWithSite
typedef IObjectWithSiteLPOBJECTWITHSITE
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 
- Static Public Attributes inherited from IContextMenu
static const WCHAR CMDSTR_NEWFOLDERW [] = {'N','e','w','F','o','l','d','e','r',0}
 
static const WCHAR CMDSTR_VIEWLISTW [] = {'V','i','e','w','L','i','s','t',0}
 
static const WCHAR CMDSTR_VIEWDETAILSW [] = {'V','i','e','w','D','e','t','a','i','l','s',0}
 

Detailed Description

Definition at line 56 of file filedefext.h.

Constructor & Destructor Documentation

◆ CFileDefExt()

CFileDefExt::CFileDefExt ( )

Definition at line 1235 of file filedefext.cpp.

1235 :
1237{
1238 m_wszPath[0] = L'\0';
1239 m_DirSize.QuadPart = 0ull;
1241
1242 m_szFolderIconPath[0] = 0;
1246}
WCHAR m_szFolderIconPath[MAX_PATH]
Definition: filedefext.h:92
ULARGE_INTEGER m_DirSize
Definition: filedefext.h:86
DWORD m_cFiles
Definition: filedefext.h:84
ULARGE_INTEGER m_DirSizeOnDisc
Definition: filedefext.h:87
BOOL m_bFolderIconIsSet
Definition: filedefext.h:95
WCHAR m_wszPath[MAX_PATH]
Definition: filedefext.h:80
INT m_nFolderIconIndex
Definition: filedefext.h:93
DWORD m_cFolders
Definition: filedefext.h:85
BOOL m_bDir
Definition: filedefext.h:82
HICON m_hFolderIcon
Definition: filedefext.h:94
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define L(x)
Definition: ntvdm.h:50
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185

◆ ~CFileDefExt()

CFileDefExt::~CFileDefExt ( )

Definition at line 1248 of file filedefext.cpp.

1249{
1250
1251}

Member Function Documentation

◆ _CountFolderAndFilesThreadProc()

DWORD WINAPI CFileDefExt::_CountFolderAndFilesThreadProc ( LPVOID  lpParameter)
staticprivate

Definition at line 1371 of file filedefext.cpp.

1372{
1373 _CountFolderAndFilesData *data = static_cast<_CountFolderAndFilesData*>(lpParameter);
1374 DWORD ticks = 0;
1375 data->This->CountFolderAndFiles(data->hwndDlg, data->pwszBuf, &ticks);
1376
1377 //Release the CFileDefExt and data object holds in the copying thread.
1378 data->This->Release();
1379 HeapFree(GetProcessHeap(), 0, data->pwszBuf);
1381
1382 return 0;
1383}
BOOL CountFolderAndFiles(HWND hwndDlg, LPCWSTR pwszBuf, LPDWORD ticks)
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

Referenced by InitFileAttr().

◆ AddPages()

HRESULT WINAPI CFileDefExt::AddPages ( LPFNADDPROPSHEETPAGE  pfnAddPage,
LPARAM  lParam 
)
override

Definition at line 1314 of file filedefext.cpp.

1315{
1316 HPROPSHEETPAGE hPage;
1318
1319 hPage = SH_CreatePropertySheetPage(wResId,
1321 (LPARAM)this,
1322 NULL);
1323 if (hPage)
1324 pfnAddPage(hPage, lParam);
1325
1327 {
1330 (LPARAM)this,
1331 NULL);
1332 if (hPage)
1333 pfnAddPage(hPage, lParam);
1334 }
1335
1336 if (m_bDir)
1337 {
1340 (LPARAM)this,
1341 NULL);
1342 if (hPage)
1343 pfnAddPage(hPage, lParam);
1344 }
1345
1346 return S_OK;
1347}
static INT_PTR CALLBACK VersionPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filedefext.cpp:939
static INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filedefext.cpp:720
static INT_PTR CALLBACK FolderCustomizePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filedefext.cpp:998
LPARAM lParam
Definition: combotst.c:139
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:611
HPROPSHEETPAGE SH_CreatePropertySheetPage(LPCSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
unsigned short WORD
Definition: ntddk_ex.h:93
#define S_OK
Definition: intsafe.h:52
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
#define IDD_FILE_VERSION
Definition: shresdef.h:402
#define IDD_FILE_PROPERTIES
Definition: shresdef.h:393
#define IDD_FOLDER_CUSTOMIZE
Definition: shresdef.h:523
#define IDD_FOLDER_PROPERTIES
Definition: shresdef.h:394
LONG_PTR LPARAM
Definition: windef.h:208

◆ AddVersionString()

BOOL CFileDefExt::AddVersionString ( HWND  hwndDlg,
LPCWSTR  pwszName 
)
private

Definition at line 910 of file filedefext.cpp.

911{
912 TRACE("pwszName %s, hwndDlg %p\n", debugstr_w(pwszName), hwndDlg);
913
914 if (hwndDlg == NULL || pwszName == NULL)
915 return FALSE;
916
917 LPCWSTR pwszValue = m_VerInfo.GetString(pwszName);
918 if (pwszValue)
919 {
920 /* listbox name property */
921 HWND hDlgCtrl = GetDlgItem(hwndDlg, 14009);
922 TRACE("%s :: %s\n", debugstr_w(pwszName), debugstr_w(pwszValue));
923 UINT Index = SendMessageW(hDlgCtrl, LB_ADDSTRING, (WPARAM) -1, (LPARAM)pwszName);
924 SendMessageW(hDlgCtrl, LB_SETITEMDATA, (WPARAM)Index, (LPARAM)(WCHAR *)pwszValue);
925 return TRUE;
926 }
927
928 return FALSE;
929}
CFileVersionInfo m_VerInfo
Definition: filedefext.h:81
LPCWSTR GetString(LPCWSTR pwszName)
Definition: filedefext.cpp:123
#define TRUE
Definition: types.h:120
#define debugstr_w
Definition: kernel32.h:32
unsigned int UINT
Definition: ndis.h:50
#define TRACE(s)
Definition: solgame.cpp:4
_In_ WDFCOLLECTION _In_ ULONG Index
UINT_PTR WPARAM
Definition: windef.h:207
#define LB_ADDSTRING
Definition: winuser.h:2031
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define LB_SETITEMDATA
Definition: winuser.h:2065
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by InitVersionPage().

◆ CountFolderAndFiles()

BOOL CFileDefExt::CountFolderAndFiles ( HWND  hwndDlg,
LPCWSTR  pwszBuf,
LPDWORD  ticks 
)
private

Definition at line 1386 of file filedefext.cpp.

1387{
1388 CString sBuf = pwszBuf;
1389 sBuf += L"\\" ;
1390 CString sSearch = sBuf;
1391 sSearch += L"*" ;
1392 CString sFileName;
1393
1394 WIN32_FIND_DATAW wfd;
1395 HANDLE hFind = FindFirstFileW(sSearch, &wfd);
1396 if (hFind == INVALID_HANDLE_VALUE)
1397 {
1398 ERR("FindFirstFileW %ls failed\n", sSearch.GetString());
1399 return FALSE;
1400 }
1401
1402 BOOL root = FALSE;
1403 if (*ticks == 0) {
1404 *ticks = GetTickCount();
1405 root = TRUE;
1406 }
1407
1408 do
1409 {
1410 sFileName = sBuf;
1411 sFileName += wfd.cFileName;
1412 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1413 {
1414 /* Don't process "." and ".." items */
1415 if (!wcscmp(wfd.cFileName, L".") || !wcscmp(wfd.cFileName, L".."))
1416 continue;
1417
1418 ++m_cFolders;
1419
1420 CountFolderAndFiles(hwndDlg, sFileName, ticks);
1421 }
1422 else
1423 {
1424 m_cFiles++;
1425
1427 FileSize.u.LowPart = wfd.nFileSizeLow;
1428 FileSize.u.HighPart = wfd.nFileSizeHigh;
1430 // Calculate size on disc
1431 if (!GetPhysicalFileSize(sFileName.GetString(), &FileSize))
1432 ERR("GetPhysicalFileSize failed for %ls\n", sFileName.GetString());
1434 }
1435 if (GetTickCount() - *ticks > (DWORD) 300)
1436 {
1437 /* FIXME Using IsWindow is generally ill advised */
1438 if (IsWindow(hwndDlg))
1439 {
1440 WCHAR wszBuf[100];
1441
1442 if (SH_FormatFileSizeWithBytes(&m_DirSize, wszBuf, _countof(wszBuf)))
1443 SetDlgItemTextW(hwndDlg, 14011, wszBuf);
1444
1446 SetDlgItemTextW(hwndDlg, 14012, wszBuf);
1447
1448 /* Display files and folders count */
1449 WCHAR wszFormat[100];
1450 LoadStringW(shell32_hInstance, IDS_FILE_FOLDER, wszFormat, _countof(wszFormat));
1451 StringCchPrintfW(wszBuf, _countof(wszBuf), wszFormat, m_cFiles, m_cFolders);
1452 SetDlgItemTextW(hwndDlg, 14027, wszBuf);
1453 *ticks = GetTickCount();
1454 }
1455 else
1456 break;
1457 }
1458 } while(FindNextFileW(hFind, &wfd));
1459
1460 if (root && IsWindow(hwndDlg))
1461 {
1462 WCHAR wszBuf[100];
1463
1464 if (SH_FormatFileSizeWithBytes(&m_DirSize, wszBuf, _countof(wszBuf)))
1465 SetDlgItemTextW(hwndDlg, 14011, wszBuf);
1466
1468 SetDlgItemTextW(hwndDlg, 14012, wszBuf);
1469
1470 /* Display files and folders count */
1471 WCHAR wszFormat[100];
1472 LoadStringW(shell32_hInstance, IDS_FILE_FOLDER, wszFormat, _countof(wszFormat));
1473 StringCchPrintfW(wszBuf, _countof(wszBuf), wszFormat, m_cFiles, m_cFolders);
1474 SetDlgItemTextW(hwndDlg, 14027, wszBuf);
1475 }
1476
1477 FindClose(hFind);
1478 return TRUE;
1479}
#define shell32_hInstance
#define ERR(fmt,...)
Definition: debug.h:113
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
LPWSTR SH_FormatFileSizeWithBytes(const PULARGE_INTEGER lpQwSize, LPWSTR pwszResult, UINT cchResultMax)
Definition: filedefext.cpp:266
BOOL GetPhysicalFileSize(LPCWSTR PathBuffer, PULARGE_INTEGER Size)
Definition: filedefext.cpp:32
unsigned int BOOL
Definition: ntddk_ex.h:94
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
CStringA CString
Definition: atlstr.h:139
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define IDS_FILE_FOLDER
Definition: shresdef.h:220
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2300 u
BOOL WINAPI IsWindow(_In_opt_ HWND)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)

Referenced by _CountFolderAndFilesThreadProc(), and CountFolderAndFiles().

◆ FolderCustomizePageProc()

INT_PTR CALLBACK CFileDefExt::FolderCustomizePageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
staticprivate

Definition at line 998 of file filedefext.cpp.

999{
1000 CFileDefExt *pFileDefExt = reinterpret_cast<CFileDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
1001 switch (uMsg)
1002 {
1003 case WM_INITDIALOG:
1004 {
1006
1007 if (ppsp == NULL || !ppsp->lParam)
1008 break;
1009
1010 TRACE("WM_INITDIALOG hwnd %p lParam %p ppsplParam %x\n", hwndDlg, lParam, ppsp->lParam);
1011
1012 pFileDefExt = reinterpret_cast<CFileDefExt *>(ppsp->lParam);
1013 return pFileDefExt->InitFolderCustomizePage(hwndDlg);
1014 }
1015
1016 case WM_COMMAND:
1017 switch (LOWORD(wParam))
1018 {
1020 pFileDefExt->OnFolderCustChangeIcon(hwndDlg);
1021 break;
1022
1024 // TODO:
1025 break;
1026
1028 // TODO:
1029 break;
1030 }
1031 break;
1032
1033 case WM_NOTIFY:
1034 {
1036 if (lppsn->hdr.code == PSN_APPLY)
1037 {
1038 // apply or not
1039 if (pFileDefExt->OnFolderCustApply(hwndDlg))
1040 {
1042 }
1043 else
1044 {
1046 }
1047 return TRUE;
1048 }
1049 break;
1050 }
1051
1052 case PSM_QUERYSIBLINGS:
1053 return FALSE; // continue
1054
1055 case WM_DESTROY:
1056 pFileDefExt->OnFolderCustDestroy(hwndDlg);
1057 break;
1058
1059 default:
1060 break;
1061 }
1062
1063 return FALSE;
1064}
void OnFolderCustDestroy(HWND hwndDlg)
BOOL OnFolderCustApply(HWND hwndDlg)
BOOL InitFolderCustomizePage(HWND hwndDlg)
void OnFolderCustChangeIcon(HWND hwndDlg)
WPARAM wParam
Definition: combotst.c:138
#define LOWORD(l)
Definition: pedump.c:82
#define PSNRET_INVALID_NOCHANGEPAGE
Definition: prsht.h:131
#define PSN_APPLY
Definition: prsht.h:117
#define PSNRET_NOERROR
Definition: prsht.h:129
#define LPPROPSHEETPAGE
Definition: prsht.h:390
struct _PSHNOTIFY * LPPSHNOTIFY
#define PSM_QUERYSIBLINGS
Definition: prsht.h:160
#define WM_NOTIFY
Definition: richedit.h:61
#define IDC_FOLDERCUST_CHANGE_ICON
Definition: shresdef.h:533
#define IDC_FOLDERCUST_RESTORE_DEFAULTS
Definition: shresdef.h:530
#define IDC_FOLDERCUST_CHOOSE_PIC
Definition: shresdef.h:529
NMHDR hdr
Definition: prsht.h:330
UINT code
Definition: winuser.h:3159
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define DWLP_USER
Definition: winuser.h:872
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define DWLP_MSGRESULT
Definition: winuser.h:870
#define WM_DESTROY
Definition: winuser.h:1609

Referenced by AddPages().

◆ GeneralPageProc()

INT_PTR CALLBACK CFileDefExt::GeneralPageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
staticprivate

Definition at line 720 of file filedefext.cpp.

721{
722 CFileDefExt *pFileDefExt = reinterpret_cast<CFileDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
723 switch (uMsg)
724 {
725 case WM_INITDIALOG:
726 {
728
729 if (ppsp == NULL || !ppsp->lParam)
730 break;
731
732 TRACE("WM_INITDIALOG hwnd %p lParam %p ppsplParam %S\n", hwndDlg, lParam, ppsp->lParam);
733
734 pFileDefExt = reinterpret_cast<CFileDefExt *>(ppsp->lParam);
735 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pFileDefExt);
736 pFileDefExt->InitGeneralPage(hwndDlg);
737 break;
738 }
739 case WM_COMMAND:
740 if (LOWORD(wParam) == 14024) /* Opens With - Change */
741 {
742 OPENASINFO oainfo;
743 oainfo.pcszFile = pFileDefExt->m_wszPath;
744 oainfo.pcszClass = NULL;
746 return SUCCEEDED(SHOpenWithDialog(hwndDlg, &oainfo));
747 }
748 else if (LOWORD(wParam) == 14021 || LOWORD(wParam) == 14022 || LOWORD(wParam) == 14023) /* checkboxes */
749 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
750 else if (LOWORD(wParam) == 14001) /* Name */
751 {
752 if (HIWORD(wParam) == EN_CHANGE)
753 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
754 }
755 break;
756 case WM_NOTIFY:
757 {
759 if (lppsn->hdr.code == PSN_APPLY)
760 {
761 /* Update attributes first */
762 DWORD dwAttr = GetFileAttributesW(pFileDefExt->m_wszPath);
763 if (dwAttr)
764 {
766
767 if (BST_CHECKED == SendDlgItemMessageW(hwndDlg, 14021, BM_GETCHECK, 0, 0))
768 dwAttr |= FILE_ATTRIBUTE_READONLY;
769 if (BST_CHECKED == SendDlgItemMessageW(hwndDlg, 14022, BM_GETCHECK, 0, 0))
770 dwAttr |= FILE_ATTRIBUTE_HIDDEN;
771 if (BST_CHECKED == SendDlgItemMessageW(hwndDlg, 14023, BM_GETCHECK, 0, 0))
772 dwAttr |= FILE_ATTRIBUTE_ARCHIVE;
773
774 if (!SetFileAttributesW(pFileDefExt->m_wszPath, dwAttr))
775 ERR("SetFileAttributesW failed\n");
776 }
777
778 /* Update filename now */
779 WCHAR wszBuf[MAX_PATH];
780 StringCchCopyW(wszBuf, _countof(wszBuf), pFileDefExt->m_wszPath);
781 LPWSTR pwszFilename = PathFindFileNameW(wszBuf);
782 UINT cchFilenameMax = _countof(wszBuf) - (pwszFilename - wszBuf);
783 if (GetDlgItemTextW(hwndDlg, 14001, pwszFilename, cchFilenameMax))
784 {
785 if (!MoveFileW(pFileDefExt->m_wszPath, wszBuf))
786 ERR("MoveFileW failed\n");
787 }
788
790 return TRUE;
791 }
792 break;
793 }
795 {
796 // reset icon
797 HWND hIconCtrl = GetDlgItem(hwndDlg, 14025);
798 HICON hIcon = (HICON)SendMessageW(hIconCtrl, STM_GETICON, 0, 0);
800 hIcon = NULL;
801 SendMessageW(hIconCtrl, STM_SETICON, (WPARAM)hIcon, 0);
802
803 // refresh the page
804 pFileDefExt->InitGeneralPage(hwndDlg);
805 return FALSE; // continue
806 }
807 default:
808 break;
809 }
810
811 return FALSE;
812}
HRESULT WINAPI SHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo)
BOOL InitGeneralPage(HWND hwndDlg)
Definition: filedefext.cpp:664
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:794
BOOL WINAPI MoveFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName)
Definition: move.c:1104
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
struct _PROPSHEETPAGEW * LPPROPSHEETPAGEW
@ OAIF_REGISTER_EXT
Definition: shlobj.h:2667
@ OAIF_FORCE_REGISTRATION
Definition: shlobj.h:2669
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
LPARAM lParam
Definition: prsht.h:227
LPCWSTR pcszFile
Definition: shlobj.h:2679
LPCWSTR pcszClass
Definition: shlobj.h:2680
OPEN_AS_INFO_FLAGS oaifInFlags
Definition: shlobj.h:2681
#define HIWORD(l)
Definition: typedefs.h:247
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
#define STM_SETICON
Definition: winuser.h:2092
#define STM_GETICON
Definition: winuser.h:2090
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HWND WINAPI GetParent(_In_ HWND)
#define BST_CHECKED
Definition: winuser.h:197
#define BM_GETCHECK
Definition: winuser.h:1918
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2084
#define EN_CHANGE
Definition: winuser.h:2022
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by AddPages().

◆ GetCommandString()

HRESULT WINAPI CFileDefExt::GetCommandString ( UINT_PTR  idCmd,
UINT  uType,
UINT pwReserved,
LPSTR  pszName,
UINT  cchMax 
)
override

Implements IContextMenu.

Definition at line 1307 of file filedefext.cpp.

1308{
1310 return E_NOTIMPL;
1311}
#define UNIMPLEMENTED
Definition: debug.h:118
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ GetFileTimeString()

BOOL CFileDefExt::GetFileTimeString ( LPFILETIME  lpFileTime,
LPWSTR  pwszResult,
UINT  cchResult 
)
staticprivate

Definition at line 498 of file filedefext.cpp.

499{
500 FILETIME ft;
501 SYSTEMTIME st;
502
503 if (!FileTimeToLocalFileTime(lpFileTime, &ft) || !FileTimeToSystemTime(&ft, &st))
504 return FALSE;
505
506 size_t cchRemaining = cchResult;
507 LPWSTR pwszEnd = pwszResult;
508 int cchWritten = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, pwszEnd, cchRemaining);
509 if (cchWritten)
510 --cchWritten; // GetDateFormatW returns count with terminating zero
511 else
512 ERR("GetDateFormatW failed\n");
513 cchRemaining -= cchWritten;
514 pwszEnd += cchWritten;
515
516 StringCchCopyExW(pwszEnd, cchRemaining, L", ", &pwszEnd, &cchRemaining, 0);
517
518 cchWritten = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, pwszEnd, cchRemaining);
519 if (cchWritten)
520 --cchWritten; // GetTimeFormatW returns count with terminating zero
521 else
522 ERR("GetTimeFormatW failed\n");
523 TRACE("result %s\n", debugstr_w(pwszResult));
524 return TRUE;
525}
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
Definition: time.c:221
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1093
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:993
#define LOCALE_USER_DEFAULT
STRSAFEAPI StringCchCopyExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags)
Definition: strsafe.h:184
#define DATE_LONGDATE
Definition: winnls.h:197

Referenced by InitFileAttr().

◆ GetSite()

HRESULT WINAPI CFileDefExt::GetSite ( REFIID  iid,
void **  ppvSite 
)
override

Definition at line 1364 of file filedefext.cpp.

1365{
1367 return E_NOTIMPL;
1368}

◆ InitFileAttr()

BOOL CFileDefExt::InitFileAttr ( HWND  hwndDlg)
private

Definition at line 536 of file filedefext.cpp.

537{
539 WIN32_FIND_DATAW FileInfo; // WIN32_FILE_ATTRIBUTE_DATA
540 WCHAR wszBuf[MAX_PATH];
541
542 TRACE("InitFileAttr %ls\n", m_wszPath);
543
544 /*
545 * There are situations where GetFileAttributes(Ex) can fail even if the
546 * specified path represents a file. This happens when e.g. the file is a
547 * locked system file, such as C:\pagefile.sys . In this case, the function
548 * returns INVALID_FILE_ATTRIBUTES and GetLastError returns ERROR_SHARING_VIOLATION.
549 * (this would allow us to distinguish between this failure and a failure
550 * due to the fact that the path actually refers to a directory).
551 *
552 * Because we really want to retrieve the file attributes/size/date&time,
553 * we do the following trick:
554 * - First we call GetFileAttributesEx. If it succeeds we know we have
555 * a file or a directory, and we have retrieved its attributes.
556 * - If GetFileAttributesEx fails, we call FindFirstFile on the full path.
557 * While we could have called FindFirstFile at first and skip GetFileAttributesEx
558 * altogether, we do it after GetFileAttributesEx because it performs more
559 * work to retrieve the file attributes. However it actually works even
560 * for locked system files.
561 * - If FindFirstFile succeeds we have retrieved its attributes.
562 * - Otherwise (FindFirstFile has failed), we do not retrieve anything.
563 *
564 * The following code also relies on the fact that the first 6 members
565 * of WIN32_FIND_DATA are *exactly* the same as the WIN32_FILE_ATTRIBUTE_DATA
566 * structure. Therefore it is safe to use a single WIN32_FIND_DATA
567 * structure for both the GetFileAttributesEx and FindFirstFile calls.
568 */
569
573 if (!Success)
574 {
576 Success = (hFind != INVALID_HANDLE_VALUE);
577 if (Success)
578 FindClose(hFind);
579 }
580
581 if (Success)
582 {
583 /* Update attribute checkboxes */
584 if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
585 SendDlgItemMessage(hwndDlg, 14021, BM_SETCHECK, BST_CHECKED, 0);
586 if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
587 SendDlgItemMessage(hwndDlg, 14022, BM_SETCHECK, BST_CHECKED, 0);
588 if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE)
589 SendDlgItemMessage(hwndDlg, 14023, BM_SETCHECK, BST_CHECKED, 0);
590
591 /* Update creation time */
592 if (GetFileTimeString(&FileInfo.ftCreationTime, wszBuf, _countof(wszBuf)))
593 SetDlgItemTextW(hwndDlg, 14015, wszBuf);
594
595 /* For files display last access and last write time */
596 if (!m_bDir)
597 {
598 if (GetFileTimeString(&FileInfo.ftLastAccessTime, wszBuf, _countof(wszBuf)))
599 SetDlgItemTextW(hwndDlg, 14019, wszBuf);
600
601 if (GetFileTimeString(&FileInfo.ftLastWriteTime, wszBuf, _countof(wszBuf)))
602 SetDlgItemTextW(hwndDlg, 14017, wszBuf);
603
604 /* Update size of file */
606 FileSize.u.LowPart = FileInfo.nFileSizeLow;
607 FileSize.u.HighPart = FileInfo.nFileSizeHigh;
608 if (SH_FormatFileSizeWithBytes(&FileSize, wszBuf, _countof(wszBuf)))
609 {
610 SetDlgItemTextW(hwndDlg, 14011, wszBuf);
611
612 // Compute file on disk. If fails, use logical size
615 else
616 ERR("Unreliable size on disk\n");
617
618 SetDlgItemTextW(hwndDlg, 14012, wszBuf);
619 }
620 }
621 }
622
623 if (m_bDir)
624 {
625 /* For directories files have to be counted */
626
628 data->This = this;
629 data->pwszBuf = static_cast<LPWSTR>(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WCHAR) * MAX_PATH));
630 data->hwndDlg = hwndDlg;
631 this->AddRef();
633
635
636 /* Update size field */
637 if (SH_FormatFileSizeWithBytes(&m_DirSize, wszBuf, _countof(wszBuf)))
638 SetDlgItemTextW(hwndDlg, 14011, wszBuf);
639
641 SetDlgItemTextW(hwndDlg, 14012, wszBuf);
642
643 /* Display files and folders count */
644 WCHAR wszFormat[256];
645 LoadStringW(shell32_hInstance, IDS_FILE_FOLDER, wszFormat, _countof(wszFormat));
646 StringCchPrintfW(wszBuf, _countof(wszBuf), wszFormat, m_cFiles, m_cFolders);
647 SetDlgItemTextW(hwndDlg, 14027, wszBuf);
648 }
649
650 /* Hide Advanced button. TODO: Implement advanced dialog and enable this button if filesystem supports compression or encryption */
651 ShowWindow(GetDlgItem(hwndDlg, 14028), SW_HIDE);
652
653 return TRUE;
654}
static BOOL GetFileTimeString(LPFILETIME lpFileTime, LPWSTR pwszResult, UINT cchResult)
Definition: filedefext.cpp:498
static DWORD WINAPI _CountFolderAndFilesThreadProc(LPVOID lpParameter)
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
BOOL WINAPI GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation)
Definition: fileinfo.c:552
BOOL WINAPI SHCreateThread(LPTHREAD_START_ROUTINE pfnThreadProc, VOID *pData, DWORD dwFlags, LPTHREAD_START_ROUTINE pfnCallback)
Definition: thread.c:356
@ Success
Definition: eventcreate.c:712
ULONG AddRef()
@ GetFileExInfoStandard
Definition: winbase.h:1161
#define SW_HIDE
Definition: winuser.h:768
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define BM_SETCHECK
Definition: winuser.h:1921
#define SendDlgItemMessage
Definition: winuser.h:5842

Referenced by InitGeneralPage().

◆ InitFilePath()

BOOL CFileDefExt::InitFilePath ( HWND  hwndDlg)
private

Definition at line 469 of file filedefext.cpp.

470{
471 /* Find the filename */
472 WCHAR *pwszFilename = PathFindFileNameW(m_wszPath);
473
474 if (pwszFilename > m_wszPath)
475 {
476 /* Location field */
477 WCHAR wszLocation[MAX_PATH];
478 StringCchCopyNW(wszLocation, _countof(wszLocation), m_wszPath, pwszFilename - m_wszPath);
479 PathRemoveBackslashW(wszLocation);
480
481 SetDlgItemTextW(hwndDlg, 14009, wszLocation);
482 }
483
484 /* Filename field */
485 SetDlgItemTextW(hwndDlg, 14001, pwszFilename);
486
487 return TRUE;
488}
LPWSTR WINAPI PathRemoveBackslashW(LPWSTR lpszPath)
Definition: path.c:867
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236

Referenced by InitGeneralPage().

◆ InitFileType()

BOOL CFileDefExt::InitFileType ( HWND  hwndDlg)
private

Definition at line 410 of file filedefext.cpp.

411{
412 TRACE("path %s\n", debugstr_w(m_wszPath));
413
414 HWND hDlgCtrl = GetDlgItem(hwndDlg, 14005);
415 if (hDlgCtrl == NULL)
416 return FALSE;
417
418 /* Get file information */
419 SHFILEINFOW fi;
420 if (!SHGetFileInfoW(m_wszPath, 0, &fi, sizeof(fi), SHGFI_TYPENAME|SHGFI_ICON))
421 {
422 ERR("SHGetFileInfoW failed for %ls (%lu)\n", m_wszPath, GetLastError());
423 fi.szTypeName[0] = L'\0';
424 fi.hIcon = NULL;
425 }
426
428 if (pwszExt[0])
429 {
430 WCHAR wszBuf[256];
431
432 if (!fi.szTypeName[0])
433 {
434 /* The file type is unknown, so default to string "FileExtension File" */
435 size_t cchRemaining = 0;
436 LPWSTR pwszEnd = NULL;
437
438 StringCchPrintfExW(wszBuf, _countof(wszBuf), &pwszEnd, &cchRemaining, 0, L"%s ", pwszExt + 1);
439 SendMessageW(hDlgCtrl, WM_GETTEXT, (WPARAM)cchRemaining, (LPARAM)pwszEnd);
440
441 SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)wszBuf);
442 }
443 else
444 {
445 /* Update file type */
446 StringCbPrintfW(wszBuf, sizeof(wszBuf), L"%s (%s)", fi.szTypeName, pwszExt);
447 SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)wszBuf);
448 }
449 }
450
451 /* Update file icon */
452 if (fi.hIcon)
453 SendDlgItemMessageW(hwndDlg, 14000, STM_SETICON, (WPARAM)fi.hIcon, 0);
454 else
455 ERR("No icon %ls\n", m_wszPath);
456
457 return TRUE;
458}
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:415
#define SHGFI_ICON
Definition: shellapi.h:164
#define SHGFI_TYPENAME
Definition: shellapi.h:167
STRSAFEAPI StringCchPrintfExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:585
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
WCHAR szTypeName[80]
Definition: shellapi.h:376
HICON hIcon
Definition: shellapi.h:372
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WM_GETTEXT
Definition: winuser.h:1618
#define WM_SETTEXT
Definition: winuser.h:1617

Referenced by InitGeneralPage().

◆ InitFolderCustomizePage()

BOOL CFileDefExt::InitFolderCustomizePage ( HWND  hwndDlg)
private

Definition at line 1101 of file filedefext.cpp.

1102{
1103 /* Attach the object to dialog window */
1104 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)this);
1105
1110
1111 // build the desktop.ini file path
1114 PathAppendW(szIniFile, L"desktop.ini");
1115
1116 // desktop.ini --> m_szFolderIconPath, m_nFolderIconIndex
1117 m_szFolderIconPath[0] = 0;
1121 {
1123 }
1126 {
1128 }
1129
1130 // update icon
1131 UpdateFolderIcon(hwndDlg);
1132
1133 return TRUE;
1134}
void UpdateFolderIcon(HWND hwndDlg)
UINT WINAPI GetPrivateProfileIntW(LPCWSTR section, LPCWSTR entry, INT def_val, LPCWSTR filename)
Definition: profile.c:1297
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
int WINAPI PathParseIconLocationW(LPWSTR lpszPath)
Definition: path.c:1092
static const WCHAR s_szShellClassInfo[]
Definition: filedefext.cpp:991
static const WCHAR s_szIconFile[]
Definition: filedefext.cpp:993
static const WCHAR s_szIconResource[]
Definition: filedefext.cpp:994
static const WCHAR s_szIconIndex[]
Definition: filedefext.cpp:992
#define PathAppendW
Definition: pathcch.h:309
TCHAR szIniFile[]
Definition: scrnsave.c:29
#define IDC_FOLDERCUST_CHECKBOX
Definition: shresdef.h:528
#define IDC_FOLDERCUST_COMBOBOX
Definition: shresdef.h:527
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)

Referenced by FolderCustomizePageProc().

◆ InitGeneralPage()

BOOL CFileDefExt::InitGeneralPage ( HWND  hwndDlg)
private

Definition at line 664 of file filedefext.cpp.

665{
666 /* Set general text properties filename filelocation and icon */
667 InitFilePath(hwndDlg);
668
669 /* Set file type and icon */
670 InitFileType(hwndDlg);
671
672 /* Set open with application */
673 if (!m_bDir)
674 {
675 if (!PathIsExeW(m_wszPath))
676 InitOpensWithField(hwndDlg);
677 else
678 {
679 WCHAR wszBuf[MAX_PATH];
681 SetDlgItemTextW(hwndDlg, 14006, wszBuf);
682 ShowWindow(GetDlgItem(hwndDlg, 14024), SW_HIDE);
683
684 /* hidden button 14024 allows to draw edit 14007 larger than defined in resources , we use edit 14009 as idol */
685 RECT rectIdol, rectToAdjust;
686 GetClientRect(GetDlgItem(hwndDlg, 14009), &rectIdol);
687 GetClientRect(GetDlgItem(hwndDlg, 14007), &rectToAdjust);
688 SetWindowPos(GetDlgItem(hwndDlg, 14007), HWND_TOP, 0, 0,
689 rectIdol.right-rectIdol.left /* make it as wide as its idol */,
690 rectToAdjust.bottom-rectToAdjust.top /* but keep its current height */,
692
693 LPCWSTR pwszDescr = m_VerInfo.GetString(L"FileDescription");
694 if (pwszDescr)
695 SetDlgItemTextW(hwndDlg, 14007, pwszDescr);
696 else
697 {
698 StringCbCopyW(wszBuf, sizeof(wszBuf), PathFindFileNameW(m_wszPath));
699 PathRemoveExtension(wszBuf);
700 SetDlgItemTextW(hwndDlg, 14007, wszBuf);
701 }
702 }
703 }
704
705 /* Set file created/modfied/accessed time, size and attributes */
706 InitFileAttr(hwndDlg);
707
708 return TRUE;
709}
EXTERN_C BOOL PathIsExeW(LPCWSTR lpszPath)
Definition: shellpath.c:539
BOOL InitFileAttr(HWND hwndDlg)
Definition: filedefext.cpp:536
BOOL InitFileType(HWND hwndDlg)
Definition: filedefext.cpp:410
VOID InitOpensWithField(HWND hwndDlg)
Definition: filedefext.cpp:322
BOOL InitFilePath(HWND hwndDlg)
Definition: filedefext.cpp:469
#define PathRemoveExtension
Definition: shlwapi.h:1031
#define IDS_EXE_DESCRIPTION
Definition: shresdef.h:210
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOMOVE
Definition: winuser.h:1244
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define HWND_TOP
Definition: winuser.h:1207
#define SWP_NOZORDER
Definition: winuser.h:1247

Referenced by GeneralPageProc().

◆ Initialize()

HRESULT WINAPI CFileDefExt::Initialize ( PCIDLIST_ABSOLUTE  pidlFolder,
IDataObject pdtobj,
HKEY  hkeyProgID 
)
override

Implements IShellExtInit.

Definition at line 1254 of file filedefext.cpp.

1255{
1256 FORMATETC format;
1257 STGMEDIUM stgm;
1258 HRESULT hr;
1259
1260 TRACE("%p %p %p %p\n", this, pidlFolder, pDataObj, hkeyProgID);
1261
1262 if (!pDataObj)
1263 return E_FAIL;
1264
1265 format.cfFormat = CF_HDROP;
1266 format.ptd = NULL;
1267 format.dwAspect = DVASPECT_CONTENT;
1268 format.lindex = -1;
1269 format.tymed = TYMED_HGLOBAL;
1270
1271 hr = pDataObj->GetData(&format, &stgm);
1273 return hr;
1274
1275 if (!DragQueryFileW((HDROP)stgm.hGlobal, 0, m_wszPath, _countof(m_wszPath)))
1276 {
1277 ERR("DragQueryFileW failed\n");
1278 ReleaseStgMedium(&stgm);
1279 return E_FAIL;
1280 }
1281
1282 ReleaseStgMedium(&stgm);
1283
1284 TRACE("File properties %ls\n", m_wszPath);
1286 if (!m_bDir)
1288
1289 return S_OK;
1290}
#define CF_HDROP
Definition: constants.h:410
BOOL Load(LPCWSTR pwszPath)
Definition: filedefext.cpp:82
#define E_FAIL
Definition: ddrawi.h:102
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, UINT lLength)
Definition: shellole.c:622
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1723
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
HRESULT hr
Definition: shlfolder.c:183

◆ InitOpensWithField()

VOID CFileDefExt::InitOpensWithField ( HWND  hwndDlg)
private

Definition at line 322 of file filedefext.cpp.

323{
324 WCHAR wszBuf[MAX_PATH] = L"";
325 WCHAR wszPath[MAX_PATH] = L"";
326 DWORD dwSize = sizeof(wszBuf);
327 BOOL bUnknownApp = TRUE;
329
330 if (RegGetValueW(HKEY_CLASSES_ROOT, pwszExt, L"", RRF_RT_REG_SZ, NULL, wszBuf, &dwSize) == ERROR_SUCCESS)
331 {
332 bUnknownApp = FALSE;
333 StringCbCatW(wszBuf, sizeof(wszBuf), L"\\shell\\open\\command");
334 dwSize = sizeof(wszPath);
335 if (RegGetValueW(HKEY_CLASSES_ROOT, wszBuf, L"", RRF_RT_REG_SZ, NULL, wszPath, &dwSize) == ERROR_SUCCESS)
336 {
337 /* Get path from command line */
338 ExpandEnvironmentStringsW(wszPath, wszBuf, _countof(wszBuf));
339 PathRemoveArgs(wszBuf);
340 PathUnquoteSpacesW(wszBuf);
341 PathSearchAndQualify(wszBuf, wszPath, _countof(wszPath));
342
343 HICON hIcon;
344 if (ExtractIconExW(wszPath, 0, NULL, &hIcon, 1))
345 {
346 HWND hIconCtrl = GetDlgItem(hwndDlg, 14025);
347 HWND hDescrCtrl = GetDlgItem(hwndDlg, 14007);
348 ShowWindow(hIconCtrl, SW_SHOW);
349 RECT rcIcon, rcDescr;
350 GetWindowRect(hIconCtrl, &rcIcon);
351
352 rcIcon.right = rcIcon.left + GetSystemMetrics(SM_CXSMICON);
353 rcIcon.bottom = rcIcon.top + GetSystemMetrics(SM_CYSMICON);
354
355 MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rcIcon, 2);
356 GetWindowRect(hDescrCtrl, &rcDescr);
357 MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rcDescr, 2);
358 INT cxOffset = rcIcon.right + 2 - rcDescr.left;
359 SetWindowPos(hDescrCtrl, NULL,
360 rcDescr.left + cxOffset, rcDescr.top,
361 rcDescr.right - rcDescr.left - cxOffset, rcDescr.bottom - rcDescr.top,
363 SendMessageW(hIconCtrl, STM_SETICON, (WPARAM)hIcon, 0);
364 } else
365 ERR("Failed to extract icon\n");
366
367 if (PathFileExistsW(wszPath))
368 {
369 /* Get file description */
370 CFileVersionInfo VerInfo;
371 VerInfo.Load(wszPath);
372 LPCWSTR pwszDescr = VerInfo.GetString(L"FileDescription");
373 if (pwszDescr)
374 SetDlgItemTextW(hwndDlg, 14007, pwszDescr);
375 else
376 {
377 /* File has no description - display filename */
378 LPWSTR pwszFilename = PathFindFileNameW(wszPath);
379 PathRemoveExtension(pwszFilename);
380 pwszFilename[0] = towupper(pwszFilename[0]);
381 SetDlgItemTextW(hwndDlg, 14007, pwszFilename);
382 }
383 }
384 else
385 bUnknownApp = TRUE;
386 } else
387 WARN("RegGetValueW %ls failed\n", wszBuf);
388 } else
389 WARN("RegGetValueW %ls failed\n", pwszExt);
390
391 if (bUnknownApp)
392 {
393 /* Unknown application */
395 SetDlgItemTextW(hwndDlg, 14007, wszBuf);
396 }
397}
#define WARN(fmt,...)
Definition: debug.h:115
#define ERROR_SUCCESS
Definition: deptool.c:10
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
#define RRF_RT_REG_SZ
Definition: driver.c:575
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1777
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1034
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:849
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define PathSearchAndQualify
Definition: shlwapi.h:1065
#define PathRemoveArgs
Definition: shlwapi.h:1019
#define IDS_UNKNOWN_APP
Definition: shresdef.h:209
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
#define towupper(c)
Definition: wctype.h:99
int32_t INT
Definition: typedefs.h:58
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define SM_CYSMICON
Definition: winuser.h:1013
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define SM_CXSMICON
Definition: winuser.h:1012
#define SW_SHOW
Definition: winuser.h:775
int WINAPI GetSystemMetrics(_In_ int)

Referenced by InitGeneralPage().

◆ InitVersionPage()

BOOL CFileDefExt::InitVersionPage ( HWND  hwndDlg)
private

Definition at line 822 of file filedefext.cpp.

823{
824 /* Get fixed info */
826 if (pInfo)
827 {
828 WCHAR wszVersion[256];
829 swprintf(wszVersion, L"%u.%u.%u.%u", HIWORD(pInfo->dwFileVersionMS),
830 LOWORD(pInfo->dwFileVersionMS),
831 HIWORD(pInfo->dwFileVersionLS),
832 LOWORD(pInfo->dwFileVersionLS));
833 TRACE("MS %x LS %x ver %s \n", pInfo->dwFileVersionMS, pInfo->dwFileVersionLS, debugstr_w(wszVersion));
834 SetDlgItemTextW(hwndDlg, 14001, wszVersion);
835 }
836
837 /* Update labels */
838 SetVersionLabel(hwndDlg, 14003, L"FileDescription");
839 SetVersionLabel(hwndDlg, 14005, L"LegalCopyright");
840
841 /* Add items to listbox */
842 AddVersionString(hwndDlg, L"CompanyName");
843 LPCWSTR pwszLang = m_VerInfo.GetLangName();
844 if (pwszLang)
845 {
846 HWND hDlgCtrl = GetDlgItem(hwndDlg, 14009);
847 UINT Index = SendMessageW(hDlgCtrl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)L"Language");
848 SendMessageW(hDlgCtrl, LB_SETITEMDATA, (WPARAM)Index, (LPARAM)(WCHAR *)pwszLang);
849 }
850 AddVersionString(hwndDlg, L"ProductName");
851 AddVersionString(hwndDlg, L"InternalName");
852 AddVersionString(hwndDlg, L"OriginalFilename");
853 AddVersionString(hwndDlg, L"FileVersion");
854 AddVersionString(hwndDlg, L"ProductVersion");
855 AddVersionString(hwndDlg, L"Comments");
856 AddVersionString(hwndDlg, L"LegalTrademarks");
857
858 if (pInfo && (pInfo->dwFileFlags & VS_FF_PRIVATEBUILD))
859 AddVersionString(hwndDlg, L"PrivateBuild");
860
861 if (pInfo && (pInfo->dwFileFlags & VS_FF_SPECIALBUILD))
862 AddVersionString(hwndDlg, L"SpecialBuild");
863
864 /* Attach file version to dialog window */
865 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)this);
866
867 /* Select first item */
868 HWND hDlgCtrl = GetDlgItem(hwndDlg, 14009);
869 SendMessageW(hDlgCtrl, LB_SETCURSEL, 0, 0);
870 LPCWSTR pwszText = (LPCWSTR)SendMessageW(hDlgCtrl, LB_GETITEMDATA, (WPARAM)0, (LPARAM)NULL);
871 if (pwszText && pwszText != (LPCWSTR)LB_ERR)
872 SetDlgItemTextW(hwndDlg, 14010, pwszText);
873
874 return TRUE;
875}
BOOL AddVersionString(HWND hwndDlg, LPCWSTR pwszName)
Definition: filedefext.cpp:910
BOOL SetVersionLabel(HWND hwndDlg, DWORD idCtrl, LPCWSTR pwszName)
Definition: filedefext.cpp:885
VS_FIXEDFILEINFO * GetFixedInfo()
Definition: filedefext.cpp:153
LPCWSTR GetLangName()
Definition: filedefext.cpp:165
#define swprintf
Definition: precomp.h:40
DWORD dwFileVersionLS
Definition: compat.h:903
DWORD dwFileVersionMS
Definition: compat.h:902
#define VS_FF_SPECIALBUILD
Definition: verrsrc.h:47
#define VS_FF_PRIVATEBUILD
Definition: verrsrc.h:45
#define LB_ERR
Definition: winuser.h:2432
#define LB_GETITEMDATA
Definition: winuser.h:2041
#define LB_SETCURSEL
Definition: winuser.h:2063

Referenced by VersionPageProc().

◆ InvokeCommand()

HRESULT WINAPI CFileDefExt::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpici)
override

Implements IContextMenu.

Definition at line 1300 of file filedefext.cpp.

1301{
1303 return E_NOTIMPL;
1304}

◆ OnFolderCustApply()

BOOL CFileDefExt::OnFolderCustApply ( HWND  hwndDlg)

Definition at line 1169 of file filedefext.cpp.

1170{
1171 // build the desktop.ini file path
1174 PathAppendW(szIniFile, L"desktop.ini");
1175
1176 if (m_bFolderIconIsSet) // it is set!
1177 {
1178 DWORD attrs;
1179
1180 // change folder attributes (-S -R)
1184
1185 // change desktop.ini attributes (-S -H -R)
1189
1190 if (m_szFolderIconPath[0])
1191 {
1192 // write IconFile and IconIndex
1194
1195 WCHAR szInt[32];
1196 StringCchPrintfW(szInt, _countof(szInt), L"%d", m_nFolderIconIndex);
1198
1199 // flush!
1201 }
1202 else
1203 {
1204 // erase three values
1208
1209 // flush!
1211 }
1212
1213 // change desktop.ini attributes (+S +H)
1217
1218 // change folder attributes (+R)
1220 attrs |= FILE_ATTRIBUTE_READONLY;
1222
1223 // notify to the siblings
1224 PropSheet_QuerySiblings(GetParent(hwndDlg), 0, 0);
1225
1226 // done!
1228 }
1229
1230 return TRUE;
1231}
BOOL WINAPI WritePrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR string, LPCWSTR filename)
Definition: profile.c:1453
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define PropSheet_QuerySiblings(d, w, l)
Definition: prsht.h:349

Referenced by FolderCustomizePageProc().

◆ OnFolderCustChangeIcon()

void CFileDefExt::OnFolderCustChangeIcon ( HWND  hwndDlg)

Definition at line 1137 of file filedefext.cpp.

1138{
1140 INT nIconIndex;
1141
1142 // m_szFolderIconPath, m_nFolderIconIndex --> szPath, nIconIndex
1143 if (m_szFolderIconPath[0])
1144 {
1146 nIconIndex = m_nFolderIconIndex;
1147 }
1148 else
1149 {
1150 szPath[0] = 0;
1151 nIconIndex = 0;
1152 }
1153
1154 // let the user choose the icon
1155 if (PickIconDlg(hwndDlg, szPath, _countof(szPath), &nIconIndex))
1156 {
1157 // changed
1159 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1160
1161 // update
1163 m_nFolderIconIndex = nIconIndex;
1164 UpdateFolderIcon(hwndDlg);
1165 }
1166}
BOOL WINAPI PickIconDlg(HWND hWndOwner, LPWSTR lpstrFile, UINT nMaxFile, INT *lpdwIconIndex)
Definition: dialogs.cpp:362
LPCWSTR szPath
Definition: env.c:37

Referenced by FolderCustomizePageProc().

◆ OnFolderCustDestroy()

void CFileDefExt::OnFolderCustDestroy ( HWND  hwndDlg)

Definition at line 1067 of file filedefext.cpp.

1068{
1071
1072 /* Detach the object from dialog window */
1073 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)0);
1074}

Referenced by FolderCustomizePageProc().

◆ QueryContextMenu()

HRESULT WINAPI CFileDefExt::QueryContextMenu ( HMENU  hmenu,
UINT  indexMenu,
UINT  idCmdFirst,
UINT  idCmdLast,
UINT  uFlags 
)
override

Implements IContextMenu.

Definition at line 1293 of file filedefext.cpp.

1294{
1296 return E_NOTIMPL;
1297}

◆ ReplacePage()

HRESULT WINAPI CFileDefExt::ReplacePage ( UINT  uPageID,
LPFNADDPROPSHEETPAGE  pfnReplacePage,
LPARAM  lParam 
)
override

Definition at line 1350 of file filedefext.cpp.

1351{
1353 return E_NOTIMPL;
1354}

◆ SetSite()

HRESULT WINAPI CFileDefExt::SetSite ( IUnknown punk)
override

Implements IObjectWithSite.

Definition at line 1357 of file filedefext.cpp.

1358{
1360 return E_NOTIMPL;
1361}

◆ SetVersionLabel()

BOOL CFileDefExt::SetVersionLabel ( HWND  hwndDlg,
DWORD  idCtrl,
LPCWSTR  pwszName 
)
private

Definition at line 885 of file filedefext.cpp.

886{
887 if (hwndDlg == NULL || pwszName == NULL)
888 return FALSE;
889
890 LPCWSTR pwszValue = m_VerInfo.GetString(pwszName);
891 if (pwszValue)
892 {
893 /* file description property */
894 TRACE("%s :: %s\n", debugstr_w(pwszName), debugstr_w(pwszValue));
895 SetDlgItemTextW(hwndDlg, idCtrl, pwszValue);
896 return TRUE;
897 }
898
899 return FALSE;
900}

Referenced by InitVersionPage().

◆ UpdateFolderIcon()

void CFileDefExt::UpdateFolderIcon ( HWND  hwndDlg)

Definition at line 1076 of file filedefext.cpp.

1077{
1078 // destroy icon if any
1079 if (m_hFolderIcon)
1080 {
1083 }
1084
1085 // create the icon
1086 if (m_szFolderIconPath[0] == 0 && m_nFolderIconIndex == 0)
1087 {
1088 // Windows ignores shell customization here and uses the default icon
1090 }
1091 else
1092 {
1094 }
1095
1096 // set icon
1098}
#define IDI_SHELL_FOLDER
Definition: treeview.c:36
#define IDC_FOLDERCUST_ICON
Definition: shresdef.h:532
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2106

Referenced by InitFolderCustomizePage(), and OnFolderCustChangeIcon().

◆ VersionPageProc()

INT_PTR CALLBACK CFileDefExt::VersionPageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
staticprivate

Definition at line 939 of file filedefext.cpp.

940{
941 switch (uMsg)
942 {
943 case WM_INITDIALOG:
944 {
946
947 if (ppsp == NULL || !ppsp->lParam)
948 break;
949
950 TRACE("WM_INITDIALOG hwnd %p lParam %p ppsplParam %x\n", hwndDlg, lParam, ppsp->lParam);
951
952 CFileDefExt *pFileDefExt = reinterpret_cast<CFileDefExt *>(ppsp->lParam);
953 return pFileDefExt->InitVersionPage(hwndDlg);
954 }
955 case WM_COMMAND:
956 if (LOWORD(wParam) == 14009 && HIWORD(wParam) == LBN_SELCHANGE)
957 {
958 HWND hDlgCtrl = (HWND)lParam;
959
961 if (Index == LB_ERR)
962 break;
963
965 if (pwszData == NULL)
966 break;
967
968 CString str(pwszData);
969 str.Trim();
970
971 TRACE("hDlgCtrl %x string %s\n", hDlgCtrl, debugstr_w(str));
972 SetDlgItemTextW(hwndDlg, 14010, str);
973
974 return TRUE;
975 }
976 break;
977 case WM_DESTROY:
978 break;
980 return FALSE; // continue
981 default:
982 break;
983 }
984
985 return FALSE;
986}
BOOL InitVersionPage(HWND hwndDlg)
Definition: filedefext.cpp:822
HANDLE HWND
Definition: compat.h:19
const WCHAR * str
LONG_PTR LRESULT
Definition: windef.h:209
#define LBN_SELCHANGE
Definition: winuser.h:2075
#define LB_GETCURSEL
Definition: winuser.h:2039

Referenced by AddPages().

Member Data Documentation

◆ m_bDir

BOOL CFileDefExt::m_bDir
private

Definition at line 82 of file filedefext.h.

Referenced by AddPages(), InitFileAttr(), InitGeneralPage(), and Initialize().

◆ m_bFolderIconIsSet

BOOL CFileDefExt::m_bFolderIconIsSet
private

Definition at line 95 of file filedefext.h.

Referenced by CFileDefExt(), OnFolderCustApply(), and OnFolderCustChangeIcon().

◆ m_cFiles

DWORD CFileDefExt::m_cFiles
private

Definition at line 84 of file filedefext.h.

Referenced by CountFolderAndFiles(), and InitFileAttr().

◆ m_cFolders

DWORD CFileDefExt::m_cFolders
private

Definition at line 85 of file filedefext.h.

Referenced by CountFolderAndFiles(), and InitFileAttr().

◆ m_DirSize

ULARGE_INTEGER CFileDefExt::m_DirSize
private

Definition at line 86 of file filedefext.h.

Referenced by CFileDefExt(), CountFolderAndFiles(), and InitFileAttr().

◆ m_DirSizeOnDisc

ULARGE_INTEGER CFileDefExt::m_DirSizeOnDisc
private

Definition at line 87 of file filedefext.h.

Referenced by CFileDefExt(), CountFolderAndFiles(), and InitFileAttr().

◆ m_hFolderIcon

HICON CFileDefExt::m_hFolderIcon
private

Definition at line 94 of file filedefext.h.

Referenced by CFileDefExt(), OnFolderCustDestroy(), and UpdateFolderIcon().

◆ m_nFolderIconIndex

INT CFileDefExt::m_nFolderIconIndex
private

◆ m_szFolderIconPath

WCHAR CFileDefExt::m_szFolderIconPath[MAX_PATH]
private

◆ m_VerInfo

CFileVersionInfo CFileDefExt::m_VerInfo
private

◆ m_wszPath


The documentation for this class was generated from the following files: