ReactOS  0.4.14-dev-384-g5b37caa
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)
 
virtual HRESULT STDMETHODCALLTYPE Initialize (PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID)
 
virtual HRESULT WINAPI QueryContextMenu (HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
 
virtual HRESULT WINAPI InvokeCommand (LPCMINVOKECOMMANDINFO lpici)
 
virtual HRESULT WINAPI GetCommandString (UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax)
 
virtual HRESULT WINAPI AddPages (LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
 
virtual HRESULT WINAPI ReplacePage (UINT uPageID, LPFNADDPROPSHEETPAGE pfnReplacePage, LPARAM lParam)
 
virtual HRESULT WINAPI SetSite (IUnknown *punk)
 
virtual HRESULT WINAPI GetSite (REFIID iid, void **ppvSite)
 
- 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 ()
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 
- 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 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, LPWSTR pwszBuf, UINT cchBufMax, 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
 
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 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
 
- Public Attributes inherited from IContextMenu
CMIC_MASK_NOZONECHECKS typedef IContextMenuLPCONTEXTMENU
 
- Static Public Attributes inherited from IContextMenu
static CMDSTR_VIEWDETAILSW(const WCHAR []) 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 1157 of file filedefext.cpp.

1157  :
1158  m_bDir(FALSE), m_cFiles(0), m_cFolders(0)
1159 {
1160  m_wszPath[0] = L'\0';
1161  m_DirSize.QuadPart = 0ull;
1162 
1163  m_szFolderIconPath[0] = 0;
1164  m_nFolderIconIndex = 0;
1165  m_hFolderIcon = NULL;
1167 }
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
smooth NULL
Definition: ftsmooth.c:416
INT m_nFolderIconIndex
Definition: filedefext.h:92
DWORD m_cFolders
Definition: filedefext.h:85
DWORD m_cFiles
Definition: filedefext.h:84
ULARGE_INTEGER m_DirSize
Definition: filedefext.h:86
BOOL m_bFolderIconIsSet
Definition: filedefext.h:94
static const WCHAR L[]
Definition: oid.c:1250
WCHAR m_szFolderIconPath[MAX_PATH]
Definition: filedefext.h:91
WCHAR m_wszPath[MAX_PATH]
Definition: filedefext.h:80
HICON m_hFolderIcon
Definition: filedefext.h:93
BOOL m_bDir
Definition: filedefext.h:82

◆ ~CFileDefExt()

CFileDefExt::~CFileDefExt ( )

Definition at line 1169 of file filedefext.cpp.

1170 {
1171 
1172 }

Member Function Documentation

◆ _CountFolderAndFilesThreadProc()

DWORD WINAPI CFileDefExt::_CountFolderAndFilesThreadProc ( LPVOID  lpParameter)
staticprivate

Definition at line 1292 of file filedefext.cpp.

1293 {
1294  _CountFolderAndFilesData *data = static_cast<_CountFolderAndFilesData*>(lpParameter);
1295  DWORD ticks = 0;
1296  data->This->CountFolderAndFiles(data->hwndDlg, data->pwszBuf, data->cchBufMax, &ticks);
1297 
1298  //Release the CFileDefExt and data object holds in the copying thread.
1299  data->This->Release();
1300  HeapFree(GetProcessHeap(), 0, data->pwszBuf);
1301  HeapFree(GetProcessHeap(), 0, data);
1302 
1303  return 0;
1304 }
#define GetProcessHeap()
Definition: compat.h:403
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
LPVOID lpParameter
Definition: kernel32.h:241
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by InitFileAttr().

◆ AddPages()

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

Definition at line 1235 of file filedefext.cpp.

1236 {
1237  HPROPSHEETPAGE hPage;
1239 
1240  hPage = SH_CreatePropertySheetPage(wResId,
1242  (LPARAM)this,
1243  NULL);
1244  if (hPage)
1245  pfnAddPage(hPage, lParam);
1246 
1248  {
1251  (LPARAM)this,
1252  NULL);
1253  if (hPage)
1254  pfnAddPage(hPage, lParam);
1255  }
1256 
1257  if (m_bDir)
1258  {
1261  (LPARAM)this,
1262  NULL);
1263  if (hPage)
1264  pfnAddPage(hPage, lParam);
1265  }
1266 
1267  return S_OK;
1268 }
static INT_PTR CALLBACK VersionPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filedefext.cpp:865
#define IDD_FOLDER_CUSTOMIZE
Definition: shresdef.h:447
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
static INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filedefext.cpp:654
static INT_PTR CALLBACK FolderCustomizePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filedefext.cpp:921
unsigned short WORD
Definition: ntddk_ex.h:93
#define IDD_FOLDER_PROPERTIES
Definition: shresdef.h:325
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:616
#define S_OK
Definition: intsafe.h:59
#define IDD_FILE_PROPERTIES
Definition: shresdef.h:324
WCHAR m_wszPath[MAX_PATH]
Definition: filedefext.h:80
HPROPSHEETPAGE SH_CreatePropertySheetPage(WORD wDialogId, DLGPROC pfnDlgProc, LPARAM lParam, LPCWSTR pwszTitle)
Definition: filedefext.cpp:248
BOOL m_bDir
Definition: filedefext.h:82
LPARAM lParam
Definition: combotst.c:139
#define IDD_FILE_VERSION
Definition: shresdef.h:333

◆ AddVersionString()

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

Definition at line 836 of file filedefext.cpp.

837 {
838  TRACE("pwszName %s, hwndDlg %p\n", debugstr_w(pwszName), hwndDlg);
839 
840  if (hwndDlg == NULL || pwszName == NULL)
841  return FALSE;
842 
843  LPCWSTR pwszValue = m_VerInfo.GetString(pwszName);
844  if (pwszValue)
845  {
846  /* listbox name property */
847  HWND hDlgCtrl = GetDlgItem(hwndDlg, 14009);
848  TRACE("%s :: %s\n", debugstr_w(pwszName), debugstr_w(pwszValue));
849  UINT Index = SendMessageW(hDlgCtrl, LB_ADDSTRING, (WPARAM) -1, (LPARAM)pwszName);
850  SendMessageW(hDlgCtrl, LB_SETITEMDATA, (WPARAM)Index, (LPARAM)(WCHAR *)pwszValue);
851  return TRUE;
852  }
853 
854  return FALSE;
855 }
CFileVersionInfo m_VerInfo
Definition: filedefext.h:81
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define LB_ADDSTRING
Definition: winuser.h:2013
UINT_PTR WPARAM
Definition: windef.h:207
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define TRACE(s)
Definition: solgame.cpp:4
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const UCHAR Index[8]
Definition: usbohci.c:18
#define LB_SETITEMDATA
Definition: winuser.h:2047
LPCWSTR GetString(LPCWSTR pwszName)
Definition: filedefext.cpp:69
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned int UINT
Definition: ndis.h:50

Referenced by InitVersionPage().

◆ CountFolderAndFiles()

BOOL CFileDefExt::CountFolderAndFiles ( HWND  hwndDlg,
LPWSTR  pwszBuf,
UINT  cchBufMax,
LPDWORD  ticks 
)
private

Definition at line 1307 of file filedefext.cpp.

1308 {
1309  /* Find filename position */
1310  UINT cchBuf = wcslen(pwszBuf);
1311  WCHAR *pwszFilename = pwszBuf + cchBuf;
1312  size_t cchFilenameMax = cchBufMax - cchBuf;
1313  if (!cchFilenameMax)
1314  return FALSE;
1315  *(pwszFilename++) = '\\';
1316  --cchFilenameMax;
1317 
1318  /* Find all files, FIXME: shouldn't be "*"? */
1319  StringCchCopyW(pwszFilename, cchFilenameMax, L"*");
1320 
1321  WIN32_FIND_DATAW wfd;
1322  HANDLE hFind = FindFirstFileW(pwszBuf, &wfd);
1323  if (hFind == INVALID_HANDLE_VALUE)
1324  {
1325  ERR("FindFirstFileW %ls failed\n", pwszBuf);
1326  return FALSE;
1327  }
1328 
1329  BOOL root = FALSE;
1330  if (*ticks == 0) {
1331  *ticks = GetTickCount();
1332  root = TRUE;
1333  }
1334 
1335  do
1336  {
1337  if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1338  {
1339  /* Don't process "." and ".." items */
1340  if (!wcscmp(wfd.cFileName, L".") || !wcscmp(wfd.cFileName, L".."))
1341  continue;
1342 
1343  ++m_cFolders;
1344 
1345  StringCchCopyW(pwszFilename, cchFilenameMax, wfd.cFileName);
1346  CountFolderAndFiles(hwndDlg, pwszBuf, cchBufMax, ticks);
1347  }
1348  else
1349  {
1350  m_cFiles++;
1351 
1353  FileSize.u.LowPart = wfd.nFileSizeLow;
1354  FileSize.u.HighPart = wfd.nFileSizeHigh;
1356  }
1357  if (GetTickCount() - *ticks > (DWORD) 300)
1358  {
1359  /* FIXME Using IsWindow is generally ill advised */
1360  if (IsWindow(hwndDlg))
1361  {
1362  WCHAR wszBuf[MAX_PATH];
1363 
1364  if (SH_FormatFileSizeWithBytes(&m_DirSize, wszBuf, _countof(wszBuf)))
1365  SetDlgItemTextW(hwndDlg, 14011, wszBuf);
1366 
1367  /* Display files and folders count */
1368  WCHAR wszFormat[256];
1369  LoadStringW(shell32_hInstance, IDS_FILE_FOLDER, wszFormat, _countof(wszFormat));
1370  StringCchPrintfW(wszBuf, _countof(wszBuf), wszFormat, m_cFiles, m_cFolders);
1371  SetDlgItemTextW(hwndDlg, 14027, wszBuf);
1372  *ticks = GetTickCount();
1373  }
1374  else
1375  break;
1376  }
1377  } while(FindNextFileW(hFind, &wfd));
1378 
1379  if (root && IsWindow(hwndDlg))
1380  {
1381  WCHAR wszBuf[MAX_PATH];
1382 
1383  if (SH_FormatFileSizeWithBytes(&m_DirSize, wszBuf, _countof(wszBuf)))
1384  SetDlgItemTextW(hwndDlg, 14011, wszBuf);
1385 
1386  /* Display files and folders count */
1387  WCHAR wszFormat[256];
1388  LoadStringW(shell32_hInstance, IDS_FILE_FOLDER, wszFormat, _countof(wszFormat));
1389  StringCchPrintfW(wszBuf, _countof(wszBuf), wszFormat, m_cFiles, m_cFolders);
1390  SetDlgItemTextW(hwndDlg, 14027, wszBuf);
1391  }
1392 
1393  FindClose(hFind);
1394  return TRUE;
1395 }
struct _LARGE_INTEGER::@2220 u
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
#define TRUE
Definition: types.h:120
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define _countof(array)
Definition: fontsub.cpp:30
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
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)
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
unsigned int BOOL
Definition: ntddk_ex.h:94
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define IDS_FILE_FOLDER
Definition: shresdef.h:205
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
DWORD m_cFolders
Definition: filedefext.h:85
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD m_cFiles
Definition: filedefext.h:84
#define MAX_PATH
Definition: compat.h:26
ULARGE_INTEGER m_DirSize
Definition: filedefext.h:86
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL CountFolderAndFiles(HWND hwndDlg, LPWSTR pwszBuf, UINT cchBufMax, LPDWORD ticks)
static const WCHAR L[]
Definition: oid.c:1250
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
#define ERR(fmt,...)
Definition: debug.h:109
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
unsigned int UINT
Definition: ndis.h:50
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LPWSTR SH_FormatFileSizeWithBytes(const PULARGE_INTEGER lpQwSize, LPWSTR pwszResult, UINT cchResultMax)
Definition: filedefext.cpp:212
LONGLONG QuadPart
Definition: typedefs.h:112
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

◆ FolderCustomizePageProc()

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

Definition at line 921 of file filedefext.cpp.

922 {
923  CFileDefExt *pFileDefExt = reinterpret_cast<CFileDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
924  switch (uMsg)
925  {
926  case WM_INITDIALOG:
927  {
929 
930  if (ppsp == NULL || !ppsp->lParam)
931  break;
932 
933  TRACE("WM_INITDIALOG hwnd %p lParam %p ppsplParam %x\n", hwndDlg, lParam, ppsp->lParam);
934 
935  pFileDefExt = reinterpret_cast<CFileDefExt *>(ppsp->lParam);
936  return pFileDefExt->InitFolderCustomizePage(hwndDlg);
937  }
938 
939  case WM_COMMAND:
940  switch (LOWORD(wParam))
941  {
943  pFileDefExt->OnFolderCustChangeIcon(hwndDlg);
944  break;
945 
947  // TODO:
948  break;
949 
951  // TODO:
952  break;
953  }
954  break;
955 
956  case WM_NOTIFY:
957  {
958  LPPSHNOTIFY lppsn = (LPPSHNOTIFY)lParam;
959  if (lppsn->hdr.code == PSN_APPLY)
960  {
961  // apply or not
962  if (pFileDefExt->OnFolderCustApply(hwndDlg))
963  {
965  }
966  else
967  {
969  }
970  return TRUE;
971  }
972  break;
973  }
974 
975  case PSM_QUERYSIBLINGS:
976  return FALSE; // continue
977 
978  case WM_DESTROY:
979  pFileDefExt->OnFolderCustDestroy(hwndDlg);
980  break;
981 
982  default:
983  break;
984  }
985 
986  return FALSE;
987 }
#define IDC_FOLDERCUST_CHOOSE_PIC
Definition: shresdef.h:452
#define TRUE
Definition: types.h:120
struct _PSHNOTIFY * LPPSHNOTIFY
#define IDC_FOLDERCUST_RESTORE_DEFAULTS
Definition: shresdef.h:453
#define PSN_APPLY
Definition: prsht.h:117
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
void OnFolderCustChangeIcon(HWND hwndDlg)
#define DWLP_MSGRESULT
Definition: winuser.h:864
UINT code
Definition: winuser.h:3133
NMHDR hdr
Definition: prsht.h:312
BOOL InitFolderCustomizePage(HWND hwndDlg)
void OnFolderCustDestroy(HWND hwndDlg)
Definition: filedefext.cpp:990
BOOL OnFolderCustApply(HWND hwndDlg)
#define LPPROPSHEETPAGE
Definition: prsht.h:372
#define PSNRET_INVALID_NOCHANGEPAGE
Definition: prsht.h:131
smooth NULL
Definition: ftsmooth.c:416
#define WM_DESTROY
Definition: winuser.h:1591
#define TRACE(s)
Definition: solgame.cpp:4
#define PSNRET_NOERROR
Definition: prsht.h:129
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1722
#define IDC_FOLDERCUST_CHANGE_ICON
Definition: shresdef.h:456
#define PSM_QUERYSIBLINGS
Definition: prsht.h:160
#define GetWindowLongPtr
Definition: treelist.c:73
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by AddPages().

◆ GeneralPageProc()

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

Definition at line 654 of file filedefext.cpp.

655 {
656  CFileDefExt *pFileDefExt = reinterpret_cast<CFileDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
657  switch (uMsg)
658  {
659  case WM_INITDIALOG:
660  {
662 
663  if (ppsp == NULL || !ppsp->lParam)
664  break;
665 
666  TRACE("WM_INITDIALOG hwnd %p lParam %p ppsplParam %S\n", hwndDlg, lParam, ppsp->lParam);
667 
668  pFileDefExt = reinterpret_cast<CFileDefExt *>(ppsp->lParam);
669  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pFileDefExt);
670  pFileDefExt->InitGeneralPage(hwndDlg);
671  break;
672  }
673  case WM_COMMAND:
674  if (LOWORD(wParam) == 14024) /* Opens With - Change */
675  {
676  OPENASINFO oainfo;
677  oainfo.pcszFile = pFileDefExt->m_wszPath;
678  oainfo.pcszClass = NULL;
680  return SUCCEEDED(SHOpenWithDialog(hwndDlg, &oainfo));
681  }
682  else if (LOWORD(wParam) == 14021 || LOWORD(wParam) == 14022 || LOWORD(wParam) == 14023) /* checkboxes */
683  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
684  else if (LOWORD(wParam) == 14001) /* Name */
685  {
686  if (HIWORD(wParam) == EN_CHANGE)
687  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
688  }
689  break;
690  case WM_NOTIFY:
691  {
692  LPPSHNOTIFY lppsn = (LPPSHNOTIFY)lParam;
693  if (lppsn->hdr.code == PSN_APPLY)
694  {
695  /* Update attributes first */
696  DWORD dwAttr = GetFileAttributesW(pFileDefExt->m_wszPath);
697  if (dwAttr)
698  {
700 
701  if (BST_CHECKED == SendDlgItemMessageW(hwndDlg, 14021, BM_GETCHECK, 0, 0))
702  dwAttr |= FILE_ATTRIBUTE_READONLY;
703  if (BST_CHECKED == SendDlgItemMessageW(hwndDlg, 14022, BM_GETCHECK, 0, 0))
704  dwAttr |= FILE_ATTRIBUTE_HIDDEN;
705  if (BST_CHECKED == SendDlgItemMessageW(hwndDlg, 14023, BM_GETCHECK, 0, 0))
706  dwAttr |= FILE_ATTRIBUTE_ARCHIVE;
707 
708  if (!SetFileAttributesW(pFileDefExt->m_wszPath, dwAttr))
709  ERR("SetFileAttributesW failed\n");
710  }
711 
712  /* Update filename now */
713  WCHAR wszBuf[MAX_PATH];
714  StringCchCopyW(wszBuf, _countof(wszBuf), pFileDefExt->m_wszPath);
715  LPWSTR pwszFilename = PathFindFileNameW(wszBuf);
716  UINT cchFilenameMax = _countof(wszBuf) - (pwszFilename - wszBuf);
717  if (GetDlgItemTextW(hwndDlg, 14001, pwszFilename, cchFilenameMax))
718  {
719  if (!MoveFileW(pFileDefExt->m_wszPath, wszBuf))
720  ERR("MoveFileW failed\n");
721  }
722 
724  return TRUE;
725  }
726  break;
727  }
728  case PSM_QUERYSIBLINGS:
729  {
730  // reset icon
731  HWND hIconCtrl = GetDlgItem(hwndDlg, 14025);
732  HICON hIcon = (HICON)SendMessageW(hIconCtrl, STM_GETICON, 0, 0);
734  hIcon = NULL;
735  SendMessageW(hIconCtrl, STM_SETICON, (WPARAM)hIcon, 0);
736 
737  // refresh the page
738  pFileDefExt->InitGeneralPage(hwndDlg);
739  return FALSE; // continue
740  }
741  default:
742  break;
743  }
744 
745  return FALSE;
746 }
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:944
#define STM_SETICON
Definition: winuser.h:2074
static HICON
Definition: imagelist.c:84
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2265
#define TRUE
Definition: types.h:120
LPCWSTR pcszFile
Definition: shlobj.h:2462
struct _PSHNOTIFY * LPPSHNOTIFY
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define _countof(array)
Definition: fontsub.cpp:30
OPEN_AS_INFO_FLAGS oaifInFlags
Definition: shlobj.h:2464
BOOL InitGeneralPage(HWND hwndDlg)
Definition: filedefext.cpp:598
UINT_PTR WPARAM
Definition: windef.h:207
#define PSN_APPLY
Definition: prsht.h:117
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
#define DWLP_MSGRESULT
Definition: winuser.h:864
LPCWSTR pcszClass
Definition: shlobj.h:2463
UINT code
Definition: winuser.h:3133
NMHDR hdr
Definition: prsht.h:312
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
BOOL WINAPI MoveFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName)
Definition: move.c:1044
smooth NULL
Definition: ftsmooth.c:416
struct _PROPSHEETPAGEW * LPPROPSHEETPAGEW
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:389
#define BM_GETCHECK
Definition: winuser.h:1900
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI SHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
#define MAX_PATH
Definition: compat.h:26
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define STM_GETICON
Definition: winuser.h:2072
#define PSNRET_NOERROR
Definition: prsht.h:129
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
LPARAM lParam
Definition: prsht.h:218
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1722
#define ERR(fmt,...)
Definition: debug.h:109
HWND WINAPI GetParent(_In_ HWND)
HICON hIcon
Definition: msconfig.c:44
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
unsigned int UINT
Definition: ndis.h:50
WCHAR m_wszPath[MAX_PATH]
Definition: filedefext.h:80
#define BST_CHECKED
Definition: winuser.h:197
#define PSM_QUERYSIBLINGS
Definition: prsht.h:160
#define HIWORD(l)
Definition: typedefs.h:246
#define GetWindowLongPtr
Definition: treelist.c:73
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_NOTIFY
Definition: richedit.h:61
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define EN_CHANGE
Definition: winuser.h:2004

Referenced by AddPages().

◆ GetCommandString()

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

Implements IContextMenu.

Definition at line 1228 of file filedefext.cpp.

1229 {
1230  UNIMPLEMENTED;
1231  return E_NOTIMPL;
1232 }
#define E_NOTIMPL
Definition: ddrawi.h:99
#define UNIMPLEMENTED
Definition: debug.h:114

◆ GetFileTimeString()

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

Definition at line 444 of file filedefext.cpp.

445 {
446  FILETIME ft;
447  SYSTEMTIME st;
448 
449  if (!FileTimeToLocalFileTime(lpFileTime, &ft) || !FileTimeToSystemTime(&ft, &st))
450  return FALSE;
451 
452  size_t cchRemaining = cchResult;
453  LPWSTR pwszEnd = pwszResult;
454  int cchWritten = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, pwszEnd, cchRemaining);
455  if (cchWritten)
456  --cchWritten; // GetDateFormatW returns count with terminating zero
457  else
458  ERR("GetDateFormatW failed\n");
459  cchRemaining -= cchWritten;
460  pwszEnd += cchWritten;
461 
462  StringCchCopyExW(pwszEnd, cchRemaining, L", ", &pwszEnd, &cchRemaining, 0);
463 
464  cchWritten = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, pwszEnd, cchRemaining);
465  if (cchWritten)
466  --cchWritten; // GetTimeFormatW returns count with terminating zero
467  else
468  ERR("GetTimeFormatW failed\n");
469  TRACE("result %s\n", debugstr_w(pwszResult));
470  return TRUE;
471 }
#define TRUE
Definition: types.h:120
#define LOCALE_USER_DEFAULT
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
Definition: time.c:211
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:178
static const WCHAR L[]
Definition: oid.c:1250
STRSAFEAPI StringCchCopyExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags)
Definition: strsafe.h:184
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:979
#define ERR(fmt,...)
Definition: debug.h:109
#define DATE_LONGDATE
Definition: winnls.h:194
WCHAR * LPWSTR
Definition: xmlstorage.h:184
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1079

Referenced by InitFileAttr().

◆ GetSite()

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

Definition at line 1285 of file filedefext.cpp.

1286 {
1287  UNIMPLEMENTED;
1288  return E_NOTIMPL;
1289 }
#define E_NOTIMPL
Definition: ddrawi.h:99
#define UNIMPLEMENTED
Definition: debug.h:114

◆ InitFileAttr()

BOOL CFileDefExt::InitFileAttr ( HWND  hwndDlg)
private

Definition at line 482 of file filedefext.cpp.

483 {
484  BOOL Success;
485  WIN32_FIND_DATAW FileInfo; // WIN32_FILE_ATTRIBUTE_DATA
486  WCHAR wszBuf[MAX_PATH];
487 
488  TRACE("InitFileAttr %ls\n", m_wszPath);
489 
490  /*
491  * There are situations where GetFileAttributes(Ex) can fail even if the
492  * specified path represents a file. This happens when e.g. the file is a
493  * locked system file, such as C:\pagefile.sys . In this case, the function
494  * returns INVALID_FILE_ATTRIBUTES and GetLastError returns ERROR_SHARING_VIOLATION.
495  * (this would allow us to distinguish between this failure and a failure
496  * due to the fact that the path actually refers to a directory).
497  *
498  * Because we really want to retrieve the file attributes/size/date&time,
499  * we do the following trick:
500  * - First we call GetFileAttributesEx. If it succeeds we know we have
501  * a file or a directory, and we have retrieved its attributes.
502  * - If GetFileAttributesEx fails, we call FindFirstFile on the full path.
503  * While we could have called FindFirstFile at first and skip GetFileAttributesEx
504  * altogether, we do it after GetFileAttributesEx because it performs more
505  * work to retrieve the file attributes. However it actually works even
506  * for locked system files.
507  * - If FindFirstFile succeeds we have retrieved its attributes.
508  * - Otherwise (FindFirstFile has failed), we do not retrieve anything.
509  *
510  * The following code also relies on the fact that the first 6 members
511  * of WIN32_FIND_DATA are *exactly* the same as the WIN32_FILE_ATTRIBUTE_DATA
512  * structure. Therefore it is safe to use a single WIN32_FIND_DATA
513  * structure for both the GetFileAttributesEx and FindFirstFile calls.
514  */
515 
519  if (!Success)
520  {
522  Success = (hFind != INVALID_HANDLE_VALUE);
523  if (Success)
524  FindClose(hFind);
525  }
526 
527  if (Success)
528  {
529  /* Update attribute checkboxes */
530  if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
531  SendDlgItemMessage(hwndDlg, 14021, BM_SETCHECK, BST_CHECKED, 0);
532  if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
533  SendDlgItemMessage(hwndDlg, 14022, BM_SETCHECK, BST_CHECKED, 0);
534  if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE)
535  SendDlgItemMessage(hwndDlg, 14023, BM_SETCHECK, BST_CHECKED, 0);
536 
537  /* Update creation time */
538  if (GetFileTimeString(&FileInfo.ftCreationTime, wszBuf, _countof(wszBuf)))
539  SetDlgItemTextW(hwndDlg, 14015, wszBuf);
540 
541  /* For files display last access and last write time */
542  if (!m_bDir)
543  {
544  if (GetFileTimeString(&FileInfo.ftLastAccessTime, wszBuf, _countof(wszBuf)))
545  SetDlgItemTextW(hwndDlg, 14019, wszBuf);
546 
547  if (GetFileTimeString(&FileInfo.ftLastWriteTime, wszBuf, _countof(wszBuf)))
548  SetDlgItemTextW(hwndDlg, 14017, wszBuf);
549 
550  /* Update size of file */
552  FileSize.u.LowPart = FileInfo.nFileSizeLow;
553  FileSize.u.HighPart = FileInfo.nFileSizeHigh;
554  if (SH_FormatFileSizeWithBytes(&FileSize, wszBuf, _countof(wszBuf)))
555  SetDlgItemTextW(hwndDlg, 14011, wszBuf);
556  }
557  }
558 
559  if (m_bDir)
560  {
561  /* For directories files have to be counted */
562 
563  _CountFolderAndFilesData *data = static_cast<_CountFolderAndFilesData*>(HeapAlloc(GetProcessHeap(), 0, sizeof(_CountFolderAndFilesData)));
564  data->This = this;
565  data->pwszBuf = static_cast<LPWSTR>(HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * MAX_PATH));
566  data->cchBufMax = MAX_PATH;
567  data->hwndDlg = hwndDlg;
568  this->AddRef();
570 
572 
573  /* Update size field */
574  if (SH_FormatFileSizeWithBytes(&m_DirSize, wszBuf, _countof(wszBuf)))
575  SetDlgItemTextW(hwndDlg, 14011, wszBuf);
576 
577  /* Display files and folders count */
578  WCHAR wszFormat[256];
579  LoadStringW(shell32_hInstance, IDS_FILE_FOLDER, wszFormat, _countof(wszFormat));
580  StringCchPrintfW(wszBuf, _countof(wszBuf), wszFormat, m_cFiles, m_cFolders);
581  SetDlgItemTextW(hwndDlg, 14027, wszBuf);
582  }
583 
584  /* Hide Advanced button. TODO: Implement advanced dialog and enable this button if filesystem supports compression or encryption */
585  ShowWindow(GetDlgItem(hwndDlg, 14028), SW_HIDE);
586 
587  return TRUE;
588 }
struct _LARGE_INTEGER::@2220 u
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
#define _countof(array)
Definition: fontsub.cpp:30
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#define SendDlgItemMessage
Definition: winuser.h:5743
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
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)
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
unsigned int BOOL
Definition: ntddk_ex.h:94
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
smooth NULL
Definition: ftsmooth.c:416
#define IDS_FILE_FOLDER
Definition: shresdef.h:205
DWORD m_cFolders
Definition: filedefext.h:85
#define BM_SETCHECK
Definition: winuser.h:1903
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD m_cFiles
Definition: filedefext.h:84
#define MAX_PATH
Definition: compat.h:26
ULARGE_INTEGER m_DirSize
Definition: filedefext.h:86
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
ULONG AddRef()
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
WCHAR m_wszPath[MAX_PATH]
Definition: filedefext.h:80
#define BST_CHECKED
Definition: winuser.h:197
struct FileInfo FileInfo
static DWORD WINAPI _CountFolderAndFilesThreadProc(LPVOID lpParameter)
static BOOL GetFileTimeString(LPFILETIME lpFileTime, LPWSTR pwszResult, UINT cchResult)
Definition: filedefext.cpp:444
BOOL WINAPI GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation)
Definition: fileinfo.c:702
BOOL m_bDir
Definition: filedefext.h:82
BOOL WINAPI SHCreateThread(LPTHREAD_START_ROUTINE pfnThreadProc, VOID *pData, DWORD dwFlags, LPTHREAD_START_ROUTINE pfnCallback)
Definition: thread.c:356
LPWSTR SH_FormatFileSizeWithBytes(const PULARGE_INTEGER lpQwSize, LPWSTR pwszResult, UINT cchResultMax)
Definition: filedefext.cpp:212
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by InitGeneralPage().

◆ InitFilePath()

BOOL CFileDefExt::InitFilePath ( HWND  hwndDlg)
private

Definition at line 415 of file filedefext.cpp.

416 {
417  /* Find the filename */
418  WCHAR *pwszFilename = PathFindFileNameW(m_wszPath);
419 
420  if (pwszFilename > m_wszPath)
421  {
422  /* Location field */
423  WCHAR wszLocation[MAX_PATH];
424  StringCchCopyNW(wszLocation, _countof(wszLocation), m_wszPath, pwszFilename - m_wszPath);
425  PathRemoveBackslashW(wszLocation);
426 
427  SetDlgItemTextW(hwndDlg, 14009, wszLocation);
428  }
429 
430  /* Filename field */
431  SetDlgItemTextW(hwndDlg, 14001, pwszFilename);
432 
433  return TRUE;
434 }
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236
#define TRUE
Definition: types.h:120
#define _countof(array)
Definition: fontsub.cpp:30
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:389
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
LPWSTR WINAPI PathRemoveBackslashW(LPWSTR lpszPath)
Definition: path.c:862
WCHAR m_wszPath[MAX_PATH]
Definition: filedefext.h:80

Referenced by InitGeneralPage().

◆ InitFileType()

BOOL CFileDefExt::InitFileType ( HWND  hwndDlg)
private

Definition at line 356 of file filedefext.cpp.

357 {
358  TRACE("path %s\n", debugstr_w(m_wszPath));
359 
360  HWND hDlgCtrl = GetDlgItem(hwndDlg, 14005);
361  if (hDlgCtrl == NULL)
362  return FALSE;
363 
364  /* Get file information */
365  SHFILEINFOW fi;
366  if (!SHGetFileInfoW(m_wszPath, 0, &fi, sizeof(fi), SHGFI_TYPENAME|SHGFI_ICON))
367  {
368  ERR("SHGetFileInfoW failed for %ls (%lu)\n", m_wszPath, GetLastError());
369  fi.szTypeName[0] = L'\0';
370  fi.hIcon = NULL;
371  }
372 
374  if (pwszExt[0])
375  {
376  WCHAR wszBuf[256];
377 
378  if (!fi.szTypeName[0])
379  {
380  /* The file type is unknown, so default to string "FileExtension File" */
381  size_t cchRemaining = 0;
382  LPWSTR pwszEnd = NULL;
383 
384  StringCchPrintfExW(wszBuf, _countof(wszBuf), &pwszEnd, &cchRemaining, 0, L"%s ", pwszExt + 1);
385  SendMessageW(hDlgCtrl, WM_GETTEXT, (WPARAM)cchRemaining, (LPARAM)pwszEnd);
386 
387  SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)wszBuf);
388  }
389  else
390  {
391  /* Update file type */
392  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"%s (%s)", fi.szTypeName, pwszExt);
393  SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)wszBuf);
394  }
395  }
396 
397  /* Update file icon */
398  if (fi.hIcon)
399  SendDlgItemMessageW(hwndDlg, 14000, STM_SETICON, (WPARAM)fi.hIcon, 0);
400  else
401  ERR("No icon %ls\n", m_wszPath);
402 
403  return TRUE;
404 }
#define STM_SETICON
Definition: winuser.h:2074
#define TRUE
Definition: types.h:120
#define SHGFI_TYPENAME
Definition: shellapi.h:165
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define _countof(array)
Definition: fontsub.cpp:30
#define WM_GETTEXT
Definition: winuser.h:1600
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
UINT_PTR WPARAM
Definition: windef.h:207
WCHAR szTypeName[80]
Definition: shellapi.h:374
STRSAFEAPI StringCchPrintfExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:585
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
LONG_PTR LPARAM
Definition: windef.h:208
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:442
#define WM_SETTEXT
Definition: winuser.h:1599
#define TRACE(s)
Definition: solgame.cpp:4
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:410
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const WCHAR L[]
Definition: oid.c:1250
HICON hIcon
Definition: shellapi.h:370
#define ERR(fmt,...)
Definition: debug.h:109
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
WCHAR m_wszPath[MAX_PATH]
Definition: filedefext.h:80
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define SHGFI_ICON
Definition: shellapi.h:162

Referenced by InitGeneralPage().

◆ InitFolderCustomizePage()

BOOL CFileDefExt::InitFolderCustomizePage ( HWND  hwndDlg)
private

Definition at line 1023 of file filedefext.cpp.

1024 {
1025  /* Attach the object to dialog window */
1026  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)this);
1027 
1032 
1033  // build the desktop.ini file path
1036  PathAppendW(szIniFile, L"desktop.ini");
1037 
1038  // desktop.ini --> m_szFolderIconPath, m_nFolderIconIndex
1039  m_szFolderIconPath[0] = 0;
1040  m_nFolderIconIndex = 0;
1043  {
1045  }
1048  {
1050  }
1051 
1052  // update icon
1053  UpdateFolderIcon(hwndDlg);
1054 
1055  return TRUE;
1056 }
#define IDC_FOLDERCUST_CHOOSE_PIC
Definition: shresdef.h:452
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
#define TRUE
Definition: types.h:120
void UpdateFolderIcon(HWND hwndDlg)
Definition: filedefext.cpp:999
static const WCHAR s_szIconResource[]
Definition: filedefext.cpp:917
#define _countof(array)
Definition: fontsub.cpp:30
#define IDC_FOLDERCUST_RESTORE_DEFAULTS
Definition: shresdef.h:453
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:121
UINT WINAPI GetPrivateProfileIntW(LPCWSTR section, LPCWSTR entry, INT def_val, LPCWSTR filename)
Definition: profile.c:1297
TCHAR szIniFile[]
Definition: scrnsave.c:28
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
smooth NULL
Definition: ftsmooth.c:416
INT m_nFolderIconIndex
Definition: filedefext.h:92
#define IDC_FOLDERCUST_CHECKBOX
Definition: shresdef.h:451
static const WCHAR s_szIconIndex[]
Definition: filedefext.cpp:915
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define IDC_FOLDERCUST_COMBOBOX
Definition: shresdef.h:450
static const WCHAR L[]
Definition: oid.c:1250
#define DWLP_USER
Definition: winuser.h:866
WCHAR m_szFolderIconPath[MAX_PATH]
Definition: filedefext.h:91
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
int WINAPI PathParseIconLocationW(LPWSTR lpszPath)
Definition: path.c:1087
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
WCHAR m_wszPath[MAX_PATH]
Definition: filedefext.h:80
static const WCHAR s_szIconFile[]
Definition: filedefext.cpp:916
static const WCHAR s_szShellClassInfo[]
Definition: filedefext.cpp:914

Referenced by FolderCustomizePageProc().

◆ InitGeneralPage()

BOOL CFileDefExt::InitGeneralPage ( HWND  hwndDlg)
private

Definition at line 598 of file filedefext.cpp.

599 {
600  /* Set general text properties filename filelocation and icon */
601  InitFilePath(hwndDlg);
602 
603  /* Set file type and icon */
604  InitFileType(hwndDlg);
605 
606  /* Set open with application */
607  if (!m_bDir)
608  {
609  if (!PathIsExeW(m_wszPath))
610  InitOpensWithField(hwndDlg);
611  else
612  {
613  WCHAR wszBuf[MAX_PATH];
615  SetDlgItemTextW(hwndDlg, 14006, wszBuf);
616  ShowWindow(GetDlgItem(hwndDlg, 14024), SW_HIDE);
617 
618  /* hidden button 14024 allows to draw edit 14007 larger than defined in resources , we use edit 14009 as idol */
619  RECT rectIdol, rectToAdjust;
620  GetClientRect(GetDlgItem(hwndDlg, 14009), &rectIdol);
621  GetClientRect(GetDlgItem(hwndDlg, 14007), &rectToAdjust);
622  SetWindowPos(GetDlgItem(hwndDlg, 14007), HWND_TOP, 0, 0,
623  rectIdol.right-rectIdol.left /* make it as wide as its idol */,
624  rectToAdjust.bottom-rectToAdjust.top /* but keep its current height */,
626 
627  LPCWSTR pwszDescr = m_VerInfo.GetString(L"FileDescription");
628  if (pwszDescr)
629  SetDlgItemTextW(hwndDlg, 14007, pwszDescr);
630  else
631  {
632  StringCbCopyW(wszBuf, sizeof(wszBuf), PathFindFileNameW(m_wszPath));
633  PathRemoveExtension(wszBuf);
634  SetDlgItemTextW(hwndDlg, 14007, wszBuf);
635  }
636  }
637  }
638 
639  /* Set file created/modfied/accessed time, size and attributes */
640  InitFileAttr(hwndDlg);
641 
642  return TRUE;
643 }
CFileVersionInfo m_VerInfo
Definition: filedefext.h:81
#define TRUE
Definition: types.h:120
VOID InitOpensWithField(HWND hwndDlg)
Definition: filedefext.cpp:268
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define IDS_EXE_DESCRIPTION
Definition: shresdef.h:195
#define SW_HIDE
Definition: winuser.h:762
#define _countof(array)
Definition: fontsub.cpp:30
LONG top
Definition: windef.h:292
#define HWND_TOP
Definition: winuser.h:1193
#define PathRemoveExtension
Definition: shlwapi.h:1031
LONG left
Definition: windef.h:291
#define SWP_NOZORDER
Definition: winuser.h:1232
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LONG right
Definition: windef.h:293
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)
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
BOOL InitFileAttr(HWND hwndDlg)
Definition: filedefext.cpp:482
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:389
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL InitFileType(HWND hwndDlg)
Definition: filedefext.cpp:356
#define MAX_PATH
Definition: compat.h:26
static const WCHAR L[]
Definition: oid.c:1250
BOOL InitFilePath(HWND hwndDlg)
Definition: filedefext.cpp:415
LPCWSTR GetString(LPCWSTR pwszName)
Definition: filedefext.cpp:69
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
WCHAR m_wszPath[MAX_PATH]
Definition: filedefext.h:80
LONG bottom
Definition: windef.h:294
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
BOOL m_bDir
Definition: filedefext.h:82
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
EXTERN_C BOOL PathIsExeW(LPCWSTR lpszPath)
Definition: shellpath.c:196

Referenced by GeneralPageProc().

◆ Initialize()

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

Implements IShellExtInit.

Definition at line 1175 of file filedefext.cpp.

1176 {
1177  FORMATETC format;
1178  STGMEDIUM stgm;
1179  HRESULT hr;
1180 
1181  TRACE("%p %p %p %p\n", this, pidlFolder, pDataObj, hkeyProgID);
1182 
1183  if (!pDataObj)
1184  return E_FAIL;
1185 
1186  format.cfFormat = CF_HDROP;
1187  format.ptd = NULL;
1188  format.dwAspect = DVASPECT_CONTENT;
1189  format.lindex = -1;
1190  format.tymed = TYMED_HGLOBAL;
1191 
1192  hr = pDataObj->GetData(&format, &stgm);
1193  if (FAILED_UNEXPECTEDLY(hr))
1194  return hr;
1195 
1196  if (!DragQueryFileW((HDROP)stgm.hGlobal, 0, m_wszPath, _countof(m_wszPath)))
1197  {
1198  ERR("DragQueryFileW failed\n");
1199  ReleaseStgMedium(&stgm);
1200  return E_FAIL;
1201  }
1202 
1203  ReleaseStgMedium(&stgm);
1204 
1205  TRACE("File properties %ls\n", m_wszPath);
1207  if (!m_bDir)
1209 
1210  return S_OK;
1211 }
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1702
BOOL Load(LPCWSTR pwszPath)
Definition: filedefext.cpp:28
CFileVersionInfo m_VerInfo
Definition: filedefext.h:81
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
#define _countof(array)
Definition: fontsub.cpp:30
#define E_FAIL
Definition: ddrawi.h:102
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
smooth NULL
Definition: ftsmooth.c:416
#define CF_HDROP
Definition: constants.h:410
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
WCHAR m_wszPath[MAX_PATH]
Definition: filedefext.h:80
BOOL m_bDir
Definition: filedefext.h:82
UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, UINT lLength)
Definition: shellole.c:627

◆ InitOpensWithField()

VOID CFileDefExt::InitOpensWithField ( HWND  hwndDlg)
private

Definition at line 268 of file filedefext.cpp.

269 {
270  WCHAR wszBuf[MAX_PATH] = L"";
271  WCHAR wszPath[MAX_PATH] = L"";
272  DWORD dwSize = sizeof(wszBuf);
273  BOOL bUnknownApp = TRUE;
275 
276  if (RegGetValueW(HKEY_CLASSES_ROOT, pwszExt, L"", RRF_RT_REG_SZ, NULL, wszBuf, &dwSize) == ERROR_SUCCESS)
277  {
278  bUnknownApp = FALSE;
279  StringCbCatW(wszBuf, sizeof(wszBuf), L"\\shell\\open\\command");
280  dwSize = sizeof(wszPath);
281  if (RegGetValueW(HKEY_CLASSES_ROOT, wszBuf, L"", RRF_RT_REG_SZ, NULL, wszPath, &dwSize) == ERROR_SUCCESS)
282  {
283  /* Get path from command line */
284  ExpandEnvironmentStringsW(wszPath, wszBuf, _countof(wszBuf));
285  PathRemoveArgs(wszBuf);
286  PathUnquoteSpacesW(wszBuf);
287  PathSearchAndQualify(wszBuf, wszPath, _countof(wszPath));
288 
289  HICON hIcon;
290  if (ExtractIconExW(wszPath, 0, NULL, &hIcon, 1))
291  {
292  HWND hIconCtrl = GetDlgItem(hwndDlg, 14025);
293  HWND hDescrCtrl = GetDlgItem(hwndDlg, 14007);
294  ShowWindow(hIconCtrl, SW_SHOW);
295  RECT rcIcon, rcDescr;
296  GetWindowRect(hIconCtrl, &rcIcon);
297 
298  rcIcon.right = rcIcon.left + GetSystemMetrics(SM_CXSMICON);
299  rcIcon.bottom = rcIcon.top + GetSystemMetrics(SM_CYSMICON);
300 
301  MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rcIcon, 2);
302  GetWindowRect(hDescrCtrl, &rcDescr);
303  MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rcDescr, 2);
304  INT cxOffset = rcIcon.right + 2 - rcDescr.left;
305  SetWindowPos(hDescrCtrl, NULL,
306  rcDescr.left + cxOffset, rcDescr.top,
307  rcDescr.right - rcDescr.left - cxOffset, rcDescr.bottom - rcDescr.top,
308  SWP_NOZORDER);
309  SendMessageW(hIconCtrl, STM_SETICON, (WPARAM)hIcon, 0);
310  } else
311  ERR("Failed to extract icon\n");
312 
313  if (PathFileExistsW(wszPath))
314  {
315  /* Get file description */
316  CFileVersionInfo VerInfo;
317  VerInfo.Load(wszPath);
318  LPCWSTR pwszDescr = VerInfo.GetString(L"FileDescription");
319  if (pwszDescr)
320  SetDlgItemTextW(hwndDlg, 14007, pwszDescr);
321  else
322  {
323  /* File has no description - display filename */
324  LPWSTR pwszFilename = PathFindFileNameW(wszPath);
325  PathRemoveExtension(pwszFilename);
326  pwszFilename[0] = towupper(pwszFilename[0]);
327  SetDlgItemTextW(hwndDlg, 14007, pwszFilename);
328  }
329  }
330  else
331  bUnknownApp = TRUE;
332  } else
333  WARN("RegGetValueW %ls failed\n", wszBuf);
334  } else
335  WARN("RegGetValueW %ls failed\n", pwszExt);
336 
337  if (bUnknownApp)
338  {
339  /* Unknown application */
341  SetDlgItemTextW(hwndDlg, 14007, wszBuf);
342  }
343 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
#define STM_SETICON
Definition: winuser.h:2074
static HICON
Definition: imagelist.c:84
BOOL Load(LPCWSTR pwszPath)
Definition: filedefext.cpp:28
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define _countof(array)
Definition: fontsub.cpp:30
#define WARN(fmt,...)
Definition: debug.h:111
LONG top
Definition: windef.h:292
#define RRF_RT_REG_SZ
Definition: driver.c:575
#define SM_CYSMICON
Definition: winuser.h:1003
UINT_PTR WPARAM
Definition: windef.h:207
#define PathRemoveExtension
Definition: shlwapi.h:1031
LONG left
Definition: windef.h:291
#define SWP_NOZORDER
Definition: winuser.h:1232
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LONG right
Definition: windef.h:293
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
#define PathRemoveArgs
Definition: shlwapi.h:1019
unsigned int BOOL
Definition: ntddk_ex.h:94
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:873
smooth NULL
Definition: ftsmooth.c:416
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:389
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1756
#define SW_SHOW
Definition: winuser.h:769
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:442
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SM_CXSMICON
Definition: winuser.h:1002
static const WCHAR L[]
Definition: oid.c:1250
LPCWSTR GetString(LPCWSTR pwszName)
Definition: filedefext.cpp:69
#define IDS_UNKNOWN_APP
Definition: shresdef.h:194
#define ERR(fmt,...)
Definition: debug.h:109
HICON hIcon
Definition: msconfig.c:44
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1029
WCHAR m_wszPath[MAX_PATH]
Definition: filedefext.h:80
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
LONG bottom
Definition: windef.h:294
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define towupper(c)
Definition: wctype.h:99
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define PathSearchAndQualify
Definition: shlwapi.h:1065
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by InitGeneralPage().

◆ InitVersionPage()

BOOL CFileDefExt::InitVersionPage ( HWND  hwndDlg)
private

Definition at line 756 of file filedefext.cpp.

757 {
758  /* Get fixed info */
760  if (pInfo)
761  {
762  WCHAR wszVersion[256];
763  swprintf(wszVersion, L"%u.%u.%u.%u", HIWORD(pInfo->dwFileVersionMS),
764  LOWORD(pInfo->dwFileVersionMS),
765  HIWORD(pInfo->dwFileVersionLS),
766  LOWORD(pInfo->dwFileVersionLS));
767  TRACE("MS %x LS %x ver %s \n", pInfo->dwFileVersionMS, pInfo->dwFileVersionLS, debugstr_w(wszVersion));
768  SetDlgItemTextW(hwndDlg, 14001, wszVersion);
769  }
770 
771  /* Update labels */
772  SetVersionLabel(hwndDlg, 14003, L"FileDescription");
773  SetVersionLabel(hwndDlg, 14005, L"LegalCopyright");
774 
775  /* Add items to listbox */
776  AddVersionString(hwndDlg, L"CompanyName");
777  LPCWSTR pwszLang = m_VerInfo.GetLangName();
778  if (pwszLang)
779  {
780  HWND hDlgCtrl = GetDlgItem(hwndDlg, 14009);
781  UINT Index = SendMessageW(hDlgCtrl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)L"Language");
782  SendMessageW(hDlgCtrl, LB_SETITEMDATA, (WPARAM)Index, (LPARAM)(WCHAR *)pwszLang);
783  }
784  AddVersionString(hwndDlg, L"ProductName");
785  AddVersionString(hwndDlg, L"InternalName");
786  AddVersionString(hwndDlg, L"OriginalFilename");
787  AddVersionString(hwndDlg, L"FileVersion");
788  AddVersionString(hwndDlg, L"ProductVersion");
789 
790  /* Attach file version to dialog window */
791  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)this);
792 
793  /* Select first item */
794  HWND hDlgCtrl = GetDlgItem(hwndDlg, 14009);
795  SendMessageW(hDlgCtrl, LB_SETCURSEL, 0, 0);
796  LPCWSTR pwszText = (LPCWSTR)SendMessageW(hDlgCtrl, LB_GETITEMDATA, (WPARAM)0, (LPARAM)NULL);
797  if (pwszText && pwszText != (LPCWSTR)LB_ERR)
798  SetDlgItemTextW(hwndDlg, 14010, pwszText);
799 
800  return TRUE;
801 }
#define LB_SETCURSEL
Definition: winuser.h:2045
CFileVersionInfo m_VerInfo
Definition: filedefext.h:81
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define LB_ADDSTRING
Definition: winuser.h:2013
BOOL AddVersionString(HWND hwndDlg, LPCWSTR pwszName)
Definition: filedefext.cpp:836
#define LB_GETITEMDATA
Definition: winuser.h:2023
DWORD dwFileVersionLS
Definition: compat.h:560
UINT_PTR WPARAM
Definition: windef.h:207
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define LB_ERR
Definition: winuser.h:2407
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define TRACE(s)
Definition: solgame.cpp:4
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL SetVersionLabel(HWND hwndDlg, DWORD idCtrl, LPCWSTR pwszName)
Definition: filedefext.cpp:811
#define swprintf(buf, format,...)
Definition: sprintf.c:56
static const UCHAR Index[8]
Definition: usbohci.c:18
DWORD dwFileVersionMS
Definition: compat.h:559
#define LB_SETITEMDATA
Definition: winuser.h:2047
static const WCHAR L[]
Definition: oid.c:1250
#define DWLP_USER
Definition: winuser.h:866
VS_FIXEDFILEINFO * GetFixedInfo()
Definition: filedefext.cpp:99
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define HIWORD(l)
Definition: typedefs.h:246
LPCWSTR GetLangName()
Definition: filedefext.cpp:111
#define LOWORD(l)
Definition: pedump.c:82

Referenced by VersionPageProc().

◆ InvokeCommand()

HRESULT WINAPI CFileDefExt::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpici)
virtual

Implements IContextMenu.

Definition at line 1221 of file filedefext.cpp.

1222 {
1223  UNIMPLEMENTED;
1224  return E_NOTIMPL;
1225 }
#define E_NOTIMPL
Definition: ddrawi.h:99
#define UNIMPLEMENTED
Definition: debug.h:114

◆ OnFolderCustApply()

BOOL CFileDefExt::OnFolderCustApply ( HWND  hwndDlg)

Definition at line 1091 of file filedefext.cpp.

1092 {
1093  // build the desktop.ini file path
1096  PathAppendW(szIniFile, L"desktop.ini");
1097 
1098  if (m_bFolderIconIsSet) // it is set!
1099  {
1100  DWORD attrs;
1101 
1102  // change folder attributes (-S -R)
1103  attrs = GetFileAttributesW(m_wszPath);
1105  SetFileAttributesW(m_wszPath, attrs);
1106 
1107  // change desktop.ini attributes (-S -H -R)
1108  attrs = GetFileAttributesW(szIniFile);
1110  SetFileAttributesW(szIniFile, attrs);
1111 
1112  if (m_szFolderIconPath[0])
1113  {
1114  // write IconFile and IconIndex
1116 
1117  WCHAR szInt[32];
1118  StringCchPrintfW(szInt, _countof(szInt), L"%d", m_nFolderIconIndex);
1120 
1121  // flush!
1123  }
1124  else
1125  {
1126  // erase three values
1130 
1131  // flush!
1133  }
1134 
1135  // change desktop.ini attributes (+S +H)
1136  attrs = GetFileAttributesW(szIniFile);
1138  SetFileAttributesW(szIniFile, attrs);
1139 
1140  // change folder attributes (+R)
1141  attrs = GetFileAttributesW(m_wszPath);
1142  attrs |= FILE_ATTRIBUTE_READONLY;
1143  SetFileAttributesW(m_wszPath, attrs);
1144 
1145  // notify to the siblings
1146  PropSheet_QuerySiblings(GetParent(hwndDlg), 0, 0);
1147 
1148  // done!
1150  }
1151 
1152  return TRUE;
1153 }
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:944
#define TRUE
Definition: types.h:120
static const WCHAR s_szIconResource[]
Definition: filedefext.cpp:917
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define _countof(array)
Definition: fontsub.cpp:30
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:121
TCHAR szIniFile[]
Definition: scrnsave.c:28
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
smooth NULL
Definition: ftsmooth.c:416
INT m_nFolderIconIndex
Definition: filedefext.h:92
static const WCHAR s_szIconIndex[]
Definition: filedefext.cpp:915
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
BOOL m_bFolderIconIsSet
Definition: filedefext.h:94
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PropSheet_QuerySiblings(d, w, l)
Definition: prsht.h:331
static const WCHAR L[]
Definition: oid.c:1250
WCHAR m_szFolderIconPath[MAX_PATH]
Definition: filedefext.h:91
BOOL WINAPI WritePrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR string, LPCWSTR filename)
Definition: profile.c:1453
HWND WINAPI GetParent(_In_ HWND)
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
WCHAR m_wszPath[MAX_PATH]
Definition: filedefext.h:80
static const WCHAR s_szIconFile[]
Definition: filedefext.cpp:916
static const WCHAR s_szShellClassInfo[]
Definition: filedefext.cpp:914

Referenced by FolderCustomizePageProc().

◆ OnFolderCustChangeIcon()

void CFileDefExt::OnFolderCustChangeIcon ( HWND  hwndDlg)

Definition at line 1059 of file filedefext.cpp.

1060 {
1062  INT nIconIndex;
1063 
1064  // m_szFolderIconPath, m_nFolderIconIndex --> szPath, nIconIndex
1065  if (m_szFolderIconPath[0])
1066  {
1068  nIconIndex = m_nFolderIconIndex;
1069  }
1070  else
1071  {
1072  szPath[0] = 0;
1073  nIconIndex = 0;
1074  }
1075 
1076  // let the user choose the icon
1077  if (PickIconDlg(hwndDlg, szPath, _countof(szPath), &nIconIndex))
1078  {
1079  // changed
1081  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1082 
1083  // update
1085  m_nFolderIconIndex = nIconIndex;
1086  UpdateFolderIcon(hwndDlg);
1087  }
1088 }
#define TRUE
Definition: types.h:120
void UpdateFolderIcon(HWND hwndDlg)
Definition: filedefext.cpp:999
#define _countof(array)
Definition: fontsub.cpp:30
int32_t INT
Definition: typedefs.h:56
BOOL WINAPI PickIconDlg(HWND hWndOwner, LPWSTR lpstrFile, UINT nMaxFile, INT *lpdwIconIndex)
Definition: dialogs.cpp:350
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
INT m_nFolderIconIndex
Definition: filedefext.h:92
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
#define MAX_PATH
Definition: compat.h:26
BOOL m_bFolderIconIsSet
Definition: filedefext.h:94
WCHAR m_szFolderIconPath[MAX_PATH]
Definition: filedefext.h:91
HWND WINAPI GetParent(_In_ HWND)
LPCWSTR szPath
Definition: env.c:35

Referenced by FolderCustomizePageProc().

◆ OnFolderCustDestroy()

void CFileDefExt::OnFolderCustDestroy ( HWND  hwndDlg)

Definition at line 990 of file filedefext.cpp.

991 {
994 
995  /* Detach the object from dialog window */
996  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)0);
997 }
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define SetWindowLongPtr
Definition: treelist.c:70
smooth NULL
Definition: ftsmooth.c:416
#define DWLP_USER
Definition: winuser.h:866
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
HICON m_hFolderIcon
Definition: filedefext.h:93

Referenced by FolderCustomizePageProc().

◆ QueryContextMenu()

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

Implements IContextMenu.

Definition at line 1214 of file filedefext.cpp.

1215 {
1216  UNIMPLEMENTED;
1217  return E_NOTIMPL;
1218 }
#define E_NOTIMPL
Definition: ddrawi.h:99
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ReplacePage()

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

Definition at line 1271 of file filedefext.cpp.

1272 {
1273  UNIMPLEMENTED;
1274  return E_NOTIMPL;
1275 }
#define E_NOTIMPL
Definition: ddrawi.h:99
#define UNIMPLEMENTED
Definition: debug.h:114

◆ SetSite()

HRESULT WINAPI CFileDefExt::SetSite ( IUnknown punk)
virtual

Implements IObjectWithSite.

Definition at line 1278 of file filedefext.cpp.

1279 {
1280  UNIMPLEMENTED;
1281  return E_NOTIMPL;
1282 }
#define E_NOTIMPL
Definition: ddrawi.h:99
#define UNIMPLEMENTED
Definition: debug.h:114

◆ SetVersionLabel()

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

Definition at line 811 of file filedefext.cpp.

812 {
813  if (hwndDlg == NULL || pwszName == NULL)
814  return FALSE;
815 
816  LPCWSTR pwszValue = m_VerInfo.GetString(pwszName);
817  if (pwszValue)
818  {
819  /* file description property */
820  TRACE("%s :: %s\n", debugstr_w(pwszName), debugstr_w(pwszValue));
821  SetDlgItemTextW(hwndDlg, idCtrl, pwszValue);
822  return TRUE;
823  }
824 
825  return FALSE;
826 }
CFileVersionInfo m_VerInfo
Definition: filedefext.h:81
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LPCWSTR GetString(LPCWSTR pwszName)
Definition: filedefext.cpp:69

Referenced by InitVersionPage().

◆ UpdateFolderIcon()

void CFileDefExt::UpdateFolderIcon ( HWND  hwndDlg)

Definition at line 999 of file filedefext.cpp.

1000 {
1001  // destroy icon if any
1002  if (m_hFolderIcon)
1003  {
1005  m_hFolderIcon = NULL;
1006  }
1007 
1008  // create the icon
1009  if (m_szFolderIconPath[0] == 0 && m_nFolderIconIndex == 0)
1010  {
1012  }
1013  else
1014  {
1016  }
1017 
1018  // set icon
1020 }
#define STM_SETICON
Definition: winuser.h:2074
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define IDC_FOLDERCUST_ICON
Definition: shresdef.h:455
UINT_PTR WPARAM
Definition: windef.h:207
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:873
smooth NULL
Definition: ftsmooth.c:416
INT m_nFolderIconIndex
Definition: filedefext.h:92
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDI_SHELL_FOLDER
Definition: shresdef.h:471
WCHAR m_szFolderIconPath[MAX_PATH]
Definition: filedefext.h:91
HICON m_hFolderIcon
Definition: filedefext.h:93
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by InitFolderCustomizePage(), and OnFolderCustChangeIcon().

◆ VersionPageProc()

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

Definition at line 865 of file filedefext.cpp.

866 {
867  switch (uMsg)
868  {
869  case WM_INITDIALOG:
870  {
872 
873  if (ppsp == NULL || !ppsp->lParam)
874  break;
875 
876  TRACE("WM_INITDIALOG hwnd %p lParam %p ppsplParam %x\n", hwndDlg, lParam, ppsp->lParam);
877 
878  CFileDefExt *pFileDefExt = reinterpret_cast<CFileDefExt *>(ppsp->lParam);
879  return pFileDefExt->InitVersionPage(hwndDlg);
880  }
881  case WM_COMMAND:
882  if (LOWORD(wParam) == 14009 && HIWORD(wParam) == LBN_SELCHANGE)
883  {
884  HWND hDlgCtrl = (HWND)lParam;
885 
887  if (Index == LB_ERR)
888  break;
889 
890  LPCWSTR pwszData = (LPCWSTR)SendMessageW(hDlgCtrl, LB_GETITEMDATA, (WPARAM)Index, (LPARAM)NULL);
891  if (pwszData == NULL)
892  break;
893 
894  TRACE("hDlgCtrl %x string %s\n", hDlgCtrl, debugstr_w(pwszData));
895  SetDlgItemTextW(hwndDlg, 14010, pwszData);
896 
897  return TRUE;
898  }
899  break;
900  case WM_DESTROY:
901  break;
902  case PSM_QUERYSIBLINGS:
903  return FALSE; // continue
904  default:
905  break;
906  }
907 
908  return FALSE;
909 }
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define LB_GETITEMDATA
Definition: winuser.h:2023
HANDLE HWND
Definition: compat.h:13
UINT_PTR WPARAM
Definition: windef.h:207
BOOL InitVersionPage(HWND hwndDlg)
Definition: filedefext.cpp:756
#define LBN_SELCHANGE
Definition: winuser.h:2057
WPARAM wParam
Definition: combotst.c:138
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define LB_ERR
Definition: winuser.h:2407
#define debugstr_w
Definition: kernel32.h:32
#define LPPROPSHEETPAGE
Definition: prsht.h:372
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_DESTROY
Definition: winuser.h:1591
#define TRACE(s)
Definition: solgame.cpp:4
static const UCHAR Index[8]
Definition: usbohci.c:18
#define WM_COMMAND
Definition: winuser.h:1722
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LB_GETCURSEL
Definition: winuser.h:2021
#define PSM_QUERYSIBLINGS
Definition: prsht.h:160
#define HIWORD(l)
Definition: typedefs.h:246
LONG_PTR LRESULT
Definition: windef.h:209
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

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 94 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_hFolderIcon

HICON CFileDefExt::m_hFolderIcon
private

Definition at line 93 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: