* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#define COBJMACROS
-#define NONAMELESSUNION
-
-#include "config.h"
-#include "wine/port.h"
-#include <string.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include "winerror.h"
-#include "windef.h"
-#include "winbase.h"
-#include "winreg.h"
-#include "wingdi.h"
-#include "winuser.h"
-#include "commdlg.h"
-#include "wine/debug.h"
-
-#include "shellapi.h"
-#include <shlwapi.h>
-#include "shlobj.h"
-#include "shell32_main.h"
-#include "shresdef.h"
-#include "undocshell.h"
-#include "prsht.h"
+#include <precomp.h>
WINE_DEFAULT_DEBUG_CHANNEL(shell);
#define MAX_PROPERTY_SHEET_PAGE 32
typedef struct _LANGANDCODEPAGE_
- {
+{
WORD lang;
WORD code;
} LANGANDCODEPAGE, *LPLANGANDCODEPAGE;
HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj);
+
/*************************************************************************
*
* SH_CreatePropertySheetPage [Internal]
* creates a property sheet page from an resource name
*
*/
+
HPROPSHEETPAGE
SH_CreatePropertySheetPage(LPSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
{
ERR("failed to find resource name\n");
return (HPROPSHEETPAGE)0;
}
+
lpsztemplate = LoadResource(shell32_hInstance, hRes);
+
if (lpsztemplate == NULL)
return (HPROPSHEETPAGE)0;
ppage.pfnDlgProc = dlgproc;
ppage.lParam = lParam;
ppage.pszTitle = szTitle;
+
if (szTitle)
{
ppage.dwFlags |= PSP_USETITLE;
}
+
return CreatePropertySheetPageW(&ppage);
}
-
-
-
-
-
-
/*************************************************************************
*
* SH_FileGeneralFileType [Internal]
*/
BOOL
-SH_FileGeneralSetFileType(HWND hwndDlg, WCHAR * filext)
+SH_FileGeneralSetFileType(HWND hwndDlg, WCHAR *filext)
{
- WCHAR name[MAX_PATH];
- WCHAR value[MAX_PATH];
- DWORD lname = MAX_PATH;
- DWORD lvalue = MAX_PATH;
+ WCHAR name[MAX_PATH];
+ WCHAR value[MAX_PATH];
+ DWORD lname = MAX_PATH;
+ DWORD lvalue = MAX_PATH;
+ HKEY hKey;
+ LONG result;
+ HWND hDlgCtrl;
- HKEY hKey;
- LONG result;
- HWND hDlgCtrl;
+ TRACE("fileext %s\n", debugstr_w(filext));
- TRACE("fileext %s\n", debugstr_w(filext));
+ if (filext == NULL)
+ return FALSE;
- if (filext == NULL)
- return FALSE;
+ hDlgCtrl = GetDlgItem(hwndDlg, 14005);
- hDlgCtrl = GetDlgItem(hwndDlg, 14005);
+ if (hDlgCtrl == NULL)
+ return FALSE;
- if (hDlgCtrl == NULL)
- return FALSE;
+ if (RegOpenKeyW(HKEY_CLASSES_ROOT, filext, &hKey) != ERROR_SUCCESS)
+ {
+ /* the file extension is unknown, so default to string "FileExtension File" */
+ SendMessageW(hDlgCtrl, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)value);
+ swprintf(name, value, &filext[1]);
+ SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)name);
+ return TRUE;
+ }
- if (RegOpenKeyW(HKEY_CLASSES_ROOT, filext, &hKey) != ERROR_SUCCESS)
- {
- /* the fileextension is unknown, so default to string "FileExtension File" */
- SendMessageW(hDlgCtrl, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)value);
- sprintfW(name, value, &filext[1]);
- SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)name);
- return TRUE;
- }
- result = RegEnumValueW(hKey, 0, name, &lname, NULL, NULL, (LPBYTE)value, &lvalue);
- RegCloseKey(hKey);
+ result = RegEnumValueW(hKey, 0, name, &lname, NULL, NULL, (LPBYTE)value, &lvalue);
+ RegCloseKey(hKey);
if (result != ERROR_SUCCESS)
return FALSE;
+
if (RegOpenKeyW(HKEY_CLASSES_ROOT, value, &hKey) == ERROR_SUCCESS)
{
if (RegLoadMUIStringW(hKey, L"FriendlyTypeName", value, MAX_PATH, NULL, 0, NULL) != ERROR_SUCCESS)
{
lvalue = lname = MAX_PATH;
- result = RegEnumValueW(hKey,0, name, &lname, NULL, NULL, (LPBYTE)value, &lvalue);
+ result = RegEnumValueW(hKey, 0, name, &lname, NULL, NULL, (LPBYTE)value, &lvalue);
}
+
lname = MAX_PATH;
+
if (RegGetValueW(hKey, L"DefaultIcon", NULL, RRF_RT_REG_SZ, NULL, name, &lname) == ERROR_SUCCESS)
{
UINT IconIndex;
WCHAR szBuffer[MAX_PATH];
- WCHAR * Offset;
+ WCHAR *Offset;
HICON hIcon = 0;
HRSRC hResource;
LPVOID pResource = NULL;
HGLOBAL hGlobal;
HANDLE hLibrary;
Offset = wcsrchr(name, L',');
+
if (Offset)
{
IconIndex = _wtoi(Offset + 2);
*Offset = L'\0';
- name[MAX_PATH-1] = L'\0';
+ name[MAX_PATH - 1] = L'\0';
+
if (ExpandEnvironmentStringsW(name, szBuffer, MAX_PATH))
{
- szBuffer[MAX_PATH-1] = L'\0';
+ szBuffer[MAX_PATH - 1] = L'\0';
hLibrary = LoadLibraryExW(szBuffer, NULL, LOAD_LIBRARY_AS_DATAFILE);
if (hLibrary)
{
if (pResource != NULL)
{
hIcon = CreateIconFromResource(pResource, SizeofResource(shell32_hInstance, hResource), TRUE, 0x00030000);
- TRACE("hIcon %p,- szBuffer %s IconIndex %u error %u icon %p hResource %p pResource %p\n", hIcon, debugstr_w(szBuffer), IconIndex, MAKEINTRESOURCEW(IconIndex), hResource, pResource);
+ TRACE("hIcon %p,- szBuffer %s IconIndex %u error %u icon %p hResource %p pResource %p\n",
+ hIcon,
+ debugstr_w(szBuffer),
+ IconIndex,
+ MAKEINTRESOURCEW(IconIndex),
+ hResource,
+ pResource);
SendDlgItemMessageW(hwndDlg, 14000, STM_SETICON, (WPARAM)hIcon, 0);
}
}
}
/* file extension type */
- value[MAX_PATH-1] = L'\0';
+ value[MAX_PATH - 1] = L'\0';
SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)value);
+
return TRUE;
}
+
/*************************************************************************
*
* SHFileGeneralGetFileTimeString [Internal]
*/
BOOL
-SHFileGeneralGetFileTimeString(LPFILETIME lpFileTime, WCHAR * lpResult)
+SHFileGeneralGetFileTimeString(LPFILETIME lpFileTime, WCHAR *lpResult)
{
FILETIME ft;
SYSTEMTIME dt;
WORD wYear;
- static const WCHAR wFormat[] = {'%','0','2','d','/','%','0','2','d','/','%','0','4','d',' ',' ','%','0','2','d',':','%','0','2','u',0};
+ static const WCHAR wFormat[] = {
+ '%', '0', '2', 'd', '/', '%', '0', '2', 'd', '/', '%', '0', '4', 'd',
+ ' ', ' ', '%', '0', '2', 'd', ':', '%', '0', '2', 'u', 0 };
if (lpFileTime == NULL || lpResult == NULL)
return FALSE;
FileTimeToSystemTime(&ft, &dt);
wYear = dt.wYear;
+
/* ddmmyy */
- sprintfW (lpResult, wFormat, dt.wDay, dt.wMonth, wYear, dt.wHour, dt.wMinute);
+ swprintf(lpResult, wFormat, dt.wDay, dt.wMonth, wYear, dt.wHour, dt.wMinute);
- TRACE("result %s\n",debugstr_w(lpResult));
+ TRACE("result %s\n", debugstr_w(lpResult));
return TRUE;
}
*/
BOOL
-SH_FileGeneralSetText(HWND hwndDlg, WCHAR * lpstr)
+SH_FileGeneralSetText(HWND hwndDlg, WCHAR *lpstr)
{
int flength;
int plength;
- WCHAR * lpdir;
+ WCHAR *lpdir;
WCHAR buff[MAX_PATH];
HWND hDlgCtrl;
if (lpstr == NULL)
return FALSE;
- lpdir = strrchrW(lpstr, '\\'); /* find the last occurence of '\\' */
+ lpdir = wcsrchr(lpstr, '\\'); /* find the last occurence of '\\' */
- plength = strlenW(lpstr);
- flength = strlenW(lpdir);
+ plength = wcslen(lpstr);
+ flength = wcslen(lpdir);
if (lpdir)
{
/* location text field */
- strncpyW(buff, lpstr, plength - flength);
+ wcsncpy(buff, lpstr, plength - flength);
buff[plength - flength] = UNICODE_NULL;
hDlgCtrl = GetDlgItem(hwndDlg, 14009);
SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)buff);
}
- if(flength > 1)
+ if (flength > 1)
{
- /* text filename field */
- strncpyW(buff, &lpdir[1], flength);
- hDlgCtrl = GetDlgItem(hwndDlg, 14001);
- SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)buff);
+ /* text filename field */
+ wcsncpy(buff, &lpdir[1], flength);
+ hDlgCtrl = GetDlgItem(hwndDlg, 14001);
+ SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)buff);
}
return TRUE;
*/
BOOL
-SH_FileGeneralSetFileSizeTime(HWND hwndDlg, WCHAR * lpfilename, PULARGE_INTEGER lpfilesize)
+SH_FileGeneralSetFileSizeTime(HWND hwndDlg, WCHAR *lpfilename, PULARGE_INTEGER lpfilesize)
{
BOOL result;
HANDLE hFile;
hFile = CreateFileW(lpfilename,
GENERIC_READ,
- FILE_SHARE_READ,NULL,
+ FILE_SHARE_READ,
+ NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
WARN("GetFileTime failed\n");
return FALSE;
}
- if (SHFileGeneralGetFileTimeString(&create_time,resultstr))
+
+ if (SHFileGeneralGetFileTimeString(&create_time, resultstr))
{
hDlgCtrl = GetDlgItem(hwndDlg, 14015);
SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)resultstr);
CloseHandle(hFile);
return FALSE;
}
+
CloseHandle(hFile);
- if (!StrFormatByteSizeW(file_size.QuadPart, resultstr, sizeof(resultstr)/sizeof(resultstr[0])));
- return FALSE;
+
+ if (!StrFormatByteSizeW(file_size.QuadPart,
+ resultstr,
+ sizeof(resultstr) / sizeof(WCHAR)))
+ return FALSE;
+
hDlgCtrl = GetDlgItem(hwndDlg, 14011);
- ERR("result size %u resultstr %s %s\n", file_size.QuadPart, debugstr_w(resultstr), resultstr);
+
+ TRACE("result size %u resultstr %s\n", file_size.QuadPart, debugstr_w(resultstr));
SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)resultstr);
if (lpfilesize)
- lpfilesize->QuadPart = (ULONGLONG)file_size.QuadPart;
+ lpfilesize->QuadPart = (ULONGLONG)file_size.QuadPart;
return TRUE;
}
*/
BOOL
-SH_FileVersionQuerySetText(HWND hwndDlg, DWORD dlgId, LPVOID pInfo, WCHAR * text, WCHAR ** resptr)
+SH_FileVersionQuerySetText(HWND hwndDlg, DWORD dlgId, LPVOID pInfo, WCHAR *text, WCHAR **resptr)
{
- UINT reslen;
- HWND hDlgCtrl;
-
- if(hwndDlg == NULL || resptr == NULL || text == NULL)
- return FALSE;
-
- if(VerQueryValueW(pInfo, text, (LPVOID *)resptr, &reslen))
- {
- /* file description property */
- hDlgCtrl = GetDlgItem(hwndDlg, dlgId);
- TRACE("%s :: %s\n",debugstr_w(text), debugstr_w(*resptr));
- SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)0, (LPARAM)*resptr);
- return TRUE;
- }
- return FALSE;
+ UINT reslen;
+ HWND hDlgCtrl;
+
+ if (hwndDlg == NULL || resptr == NULL || text == NULL)
+ return FALSE;
+
+ if (VerQueryValueW(pInfo, text, (LPVOID *)resptr, &reslen))
+ {
+ /* file description property */
+ hDlgCtrl = GetDlgItem(hwndDlg, dlgId);
+ TRACE("%s :: %s\n", debugstr_w(text), debugstr_w(*resptr));
+ SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)0, (LPARAM)*resptr);
+ return TRUE;
+ }
+
+ return FALSE;
}
/*************************************************************************
*
*/
-
BOOL
-SH_FileVersionQuerySetListText(HWND hwndDlg, LPVOID pInfo, const WCHAR * text, WCHAR **resptr, WORD lang, WORD code)
+SH_FileVersionQuerySetListText(HWND hwndDlg, LPVOID pInfo, const WCHAR *text, WCHAR **resptr, WORD lang, WORD code)
{
- UINT reslen;
- HWND hDlgCtrl;
- UINT index;
- static const WCHAR wFormat[] = { '\\','S','t','r','i','n','g','F','i','l','e','I','n',
- 'f','o','\\','%','0','4','x','%','0','4','x','\\','%','s',0 };
- WCHAR buff[256];
-
- TRACE("text %s, resptr %p hwndDlg %p\n",debugstr_w(text), resptr, hwndDlg);
-
- if(hwndDlg == NULL || resptr == NULL || text == NULL)
- return FALSE;
-
- sprintfW(buff, wFormat, lang, code, text);
- if(VerQueryValueW(pInfo, buff, (LPVOID *)resptr, &reslen))
- {
- /* listbox name property */
- hDlgCtrl = GetDlgItem(hwndDlg, 14009);
- TRACE("%s :: %s\n",debugstr_w(text), debugstr_w(*resptr));
- index = SendMessageW(hDlgCtrl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)text);
- SendMessageW(hDlgCtrl, LB_SETITEMDATA, (WPARAM)index, (LPARAM)(WCHAR*)*resptr);
- return TRUE;
- }
- return FALSE;
+ UINT reslen;
+ HWND hDlgCtrl;
+ UINT index;
+ static const WCHAR wFormat[] = {
+ '\\', 'S', 't', 'r', 'i', 'n', 'g', 'F', 'i', 'l', 'e', 'I', 'n', 'f', 'o',
+ '\\', '%', '0', '4', 'x', '%', '0', '4', 'x', '\\', '%', 's', 0 };
+ WCHAR buff[256];
+
+ TRACE("text %s, resptr %p hwndDlg %p\n", debugstr_w(text), resptr, hwndDlg);
+
+ if (hwndDlg == NULL || resptr == NULL || text == NULL)
+ return FALSE;
+
+ swprintf(buff, wFormat, lang, code, text);
+
+ if (VerQueryValueW(pInfo, buff, (LPVOID *)resptr, &reslen))
+ {
+ /* listbox name property */
+ hDlgCtrl = GetDlgItem(hwndDlg, 14009);
+ TRACE("%s :: %s\n", debugstr_w(text), debugstr_w(*resptr));
+ index = SendMessageW(hDlgCtrl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)text);
+ SendMessageW(hDlgCtrl, LB_SETITEMDATA, (WPARAM)index, (LPARAM)(WCHAR *)*resptr);
+ return TRUE;
+ }
+
+ return FALSE;
}
/*************************************************************************
*
* sets all file version properties in dialog
*/
+
BOOL
-SH_FileVersionInitialize(HWND hwndDlg, WCHAR * lpfilename)
+SH_FileVersionInitialize(HWND hwndDlg, WCHAR *lpfilename)
{
- LPVOID pBuf;
- DWORD versize;
- DWORD handle;
- LPVOID info = NULL;
- UINT infolen;
- WCHAR buff[256];
- HWND hDlgCtrl;
- WORD lang = 0;
- WORD code = 0;
- LPLANGANDCODEPAGE lplangcode;
- WCHAR * str;
- static const WCHAR wVersionFormat[] = { '%','d','.','%','d','.','%','d','.','%','d',0 };
- static const WCHAR wFileDescriptionFormat[] = { '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
- '\\','%','0','4','x','%','0','4','x','\\','F','i','l','e','D','e','s','c','r','i','p','t','i','o','n',0 };
- static const WCHAR wLegalCopyrightFormat[] = { '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
- '\\','%','0','4','x','%','0','4','x','\\','L','e','g','a','l','C','o','p','y','r','i','g','h','t',0 };
- static const WCHAR wTranslation[] = { 'V','a','r','F','i','l','e','I','n','f','o','\\','T','r','a','n','s','l','a','t','i','o','n',0 };
- static const WCHAR wCompanyName[] = { 'C','o','m','p','a','n','y','N','a','m','e',0 };
- static const WCHAR wFileVersion[] = { 'F','i','l','e','V','e','r','s','i','o','n',0 };
- static const WCHAR wInternalName[] = { 'I','n','t','e','r','n','a','l','N','a','m','e',0 };
- static const WCHAR wOriginalFilename[] = { 'O','r','i','g','i','n','a','l','F','i','l','e','n','a','m','e',0 };
- static const WCHAR wProductName[] = { 'P','r','o','d','u','c','t','N','a','m','e',0 };
- static const WCHAR wProductVersion[] = { 'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0 };
- static const WCHAR wSlash[] = { '\\',0 };
-
-
- if(lpfilename == 0)
- return FALSE;
+ LPVOID pBuf;
+ DWORD versize;
+ DWORD handle;
+ LPVOID info = NULL;
+ UINT infolen;
+ WCHAR buff[256];
+ HWND hDlgCtrl;
+ WORD lang = 0;
+ WORD code = 0;
+ LPLANGANDCODEPAGE lplangcode;
+ WCHAR *str;
+ static const WCHAR wVersionFormat[] = {
+ '%', 'd', '.', '%', 'd', '.', '%', 'd', '.', '%', 'd', 0 };
+ static const WCHAR wFileDescriptionFormat[] = {
+ '\\', 'S', 't', 'r', 'i', 'n', 'g', 'F', 'i', 'l', 'e', 'I', 'n', 'f', 'o',
+ '\\', '%', '0', '4', 'x', '%', '0', '4', 'x',
+ '\\', 'F', 'i', 'l', 'e', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'i', 'o', 'n', 0 };
+ static const WCHAR wLegalCopyrightFormat[] = {
+ '\\', 'S', 't', 'r', 'i', 'n', 'g', 'F', 'i', 'l', 'e', 'I', 'n', 'f', 'o',
+ '\\', '%', '0', '4', 'x', '%', '0', '4', 'x',
+ '\\', 'L', 'e', 'g', 'a', 'l', 'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', 0 };
+ static const WCHAR wTranslation[] = {
+ 'V', 'a', 'r', 'F', 'i', 'l', 'e', 'I', 'n', 'f', 'o',
+ '\\', 'T', 'r', 'a', 'n', 's', 'l', 'a', 't', 'i', 'o', 'n', 0 };
+ static const WCHAR wCompanyName[] = {
+ 'C', 'o', 'm', 'p', 'a', 'n', 'y', 'N', 'a', 'm', 'e', 0 };
+ static const WCHAR wFileVersion[] = {
+ 'F', 'i', 'l', 'e', 'V', 'e', 'r', 's', 'i', 'o', 'n', 0 };
+ static const WCHAR wInternalName[] = {
+ 'I', 'n', 't', 'e', 'r', 'n', 'a', 'l', 'N', 'a', 'm', 'e', 0 };
+ static const WCHAR wOriginalFilename[] = {
+ 'O', 'r', 'i', 'g', 'i', 'n', 'a', 'l', 'F', 'i', 'l', 'e', 'n', 'a', 'm', 'e', 0 };
+ static const WCHAR wProductName[] = {
+ 'P', 'r', 'o', 'd', 'u', 'c', 't', 'N', 'a', 'm', 'e', 0 };
+ static const WCHAR wProductVersion[] = {
+ 'P', 'r', 'o', 'd', 'u', 'c', 't', 'V', 'e', 'r', 's', 'i', 'o', 'n', 0 };
+ static const WCHAR wSlash[] = { '\\', 0 };
+
+ if (lpfilename == 0)
+ return FALSE;
- if(!(versize = GetFileVersionInfoSizeW(lpfilename, &handle)))
- {
- WARN("GetFileVersionInfoSize failed\n");
- return FALSE;
- }
+ if (!(versize = GetFileVersionInfoSizeW(lpfilename, &handle)))
+ {
+ WARN("GetFileVersionInfoSize failed\n");
+ return FALSE;
+ }
- if(!(pBuf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, versize)))
- {
- WARN("HeapAlloc failed bytes %x\n",versize);
- return FALSE;
- }
+ if (!(pBuf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, versize)))
+ {
+ WARN("HeapAlloc failed bytes %x\n", versize);
+ return FALSE;
+ }
- if(!GetFileVersionInfoW(lpfilename, handle, versize, pBuf))
- {
- HeapFree(GetProcessHeap(), 0, pBuf);
- return FALSE;
- }
- if(VerQueryValueW(pBuf, wSlash, &info, &infolen))
- {
- VS_FIXEDFILEINFO * inf = (VS_FIXEDFILEINFO *)info;
- sprintfW(buff, wVersionFormat, HIWORD(inf->dwFileVersionMS),
- LOWORD(inf->dwFileVersionMS),
- HIWORD(inf->dwFileVersionLS),
- LOWORD(inf->dwFileVersionLS));
-
- hDlgCtrl = GetDlgItem(hwndDlg, 14001);
- TRACE("MS %x LS %x res %s \n",inf->dwFileVersionMS, inf->dwFileVersionLS, debugstr_w(buff));
- SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)buff);
- }
- if(VerQueryValueW(pBuf, wTranslation, (LPVOID *)&lplangcode, &infolen))
- {
- /* FIXME find language from current locale / if not available,
- * default to english
- * for now default to first available language
- */
- lang = lplangcode->lang;
- code = lplangcode->code;
- }
-
- sprintfW(buff, wFileDescriptionFormat, lang, code);
- SH_FileVersionQuerySetText(hwndDlg, 14003, pBuf, buff, &str);
-
- sprintfW(buff, wLegalCopyrightFormat, lang, code);
- SH_FileVersionQuerySetText(hwndDlg, 14005, pBuf, buff, &str);
-
- /* listbox properties */
- SH_FileVersionQuerySetListText(hwndDlg, pBuf, wCompanyName, &str, lang, code);
- SH_FileVersionQuerySetListText(hwndDlg, pBuf, wFileVersion, &str, lang, code);
- SH_FileVersionQuerySetListText(hwndDlg, pBuf, wInternalName, &str, lang, code);
-
- /* FIXME insert language identifier */
-
- SH_FileVersionQuerySetListText(hwndDlg, pBuf, wOriginalFilename, &str, lang, code);
- SH_FileVersionQuerySetListText(hwndDlg, pBuf, wProductName, &str, lang, code);
- SH_FileVersionQuerySetListText(hwndDlg, pBuf, wProductVersion, &str, lang, code);
- SetWindowLong(hwndDlg, DWL_USER, (LONG)pBuf);
-
- /* select first item */
- hDlgCtrl = GetDlgItem(hwndDlg, 14009);
- SendMessageW(hDlgCtrl, LB_SETCURSEL, 0, 0);
- str = (WCHAR *)SendMessageW(hDlgCtrl, LB_GETITEMDATA, (WPARAM)0, (LPARAM)NULL);
- hDlgCtrl = GetDlgItem(hwndDlg, 14010);
- SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)str);
- return TRUE;
+ if (!GetFileVersionInfoW(lpfilename, handle, versize, pBuf))
+ {
+ HeapFree(GetProcessHeap(), 0, pBuf);
+ return FALSE;
+ }
+
+ if (VerQueryValueW(pBuf, wSlash, &info, &infolen))
+ {
+ VS_FIXEDFILEINFO *inf = (VS_FIXEDFILEINFO *)info;
+ swprintf(buff, wVersionFormat, HIWORD(inf->dwFileVersionMS),
+ LOWORD(inf->dwFileVersionMS),
+ HIWORD(inf->dwFileVersionLS),
+ LOWORD(inf->dwFileVersionLS));
+ hDlgCtrl = GetDlgItem(hwndDlg, 14001);
+ TRACE("MS %x LS %x res %s \n", inf->dwFileVersionMS, inf->dwFileVersionLS, debugstr_w(buff));
+ SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)buff);
+ }
+
+ if (VerQueryValueW(pBuf, wTranslation, (LPVOID *)&lplangcode, &infolen))
+ {
+ /* FIXME find language from current locale / if not available,
+ * default to english
+ * for now default to first available language
+ */
+ lang = lplangcode->lang;
+ code = lplangcode->code;
+ }
+
+ swprintf(buff, wFileDescriptionFormat, lang, code);
+ SH_FileVersionQuerySetText(hwndDlg, 14003, pBuf, buff, &str);
+
+ swprintf(buff, wLegalCopyrightFormat, lang, code);
+ SH_FileVersionQuerySetText(hwndDlg, 14005, pBuf, buff, &str);
+
+ /* listbox properties */
+ SH_FileVersionQuerySetListText(hwndDlg, pBuf, wCompanyName, &str, lang, code);
+ SH_FileVersionQuerySetListText(hwndDlg, pBuf, wFileVersion, &str, lang, code);
+ SH_FileVersionQuerySetListText(hwndDlg, pBuf, wInternalName, &str, lang, code);
+
+ /* FIXME insert language identifier */
+
+ SH_FileVersionQuerySetListText(hwndDlg, pBuf, wOriginalFilename, &str, lang, code);
+ SH_FileVersionQuerySetListText(hwndDlg, pBuf, wProductName, &str, lang, code);
+ SH_FileVersionQuerySetListText(hwndDlg, pBuf, wProductVersion, &str, lang, code);
+ SetWindowLong(hwndDlg, DWL_USER, (LONG)pBuf);
+
+ /* select first item */
+ hDlgCtrl = GetDlgItem(hwndDlg, 14009);
+ SendMessageW(hDlgCtrl, LB_SETCURSEL, 0, 0);
+ str = (WCHAR *) SendMessageW(hDlgCtrl, LB_GETITEMDATA, (WPARAM)0, (LPARAM)NULL);
+ hDlgCtrl = GetDlgItem(hwndDlg, 14010);
+ SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)str);
+
+ return TRUE;
}
/*************************************************************************
*
* wnd proc of 'Version' property sheet page
*/
+
INT_PTR
CALLBACK
-SH_FileVersionDlgProc(
- HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
-)
+SH_FileVersionDlgProc(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
{
- LPPROPSHEETPAGE ppsp;
- WCHAR * lpstr;
- LPVOID * buf;
- switch(uMsg)
- {
- case WM_INITDIALOG:
- ppsp = (LPPROPSHEETPAGE)lParam;
- if(ppsp == NULL)
- break;
-
- TRACE("WM_INITDIALOG hwnd %p lParam %p ppsplParam %x\n",hwndDlg, lParam, ppsp->lParam);
-
- lpstr = (WCHAR *)ppsp->lParam;
-
- if(lpstr == NULL)
- break;
-
- return SH_FileVersionInitialize(hwndDlg, lpstr);
-
-
- case WM_COMMAND:
- if(LOWORD(wParam) == 14009 && HIWORD(wParam) == LBN_DBLCLK)
- {
- HWND hDlgCtrl;
- LRESULT lresult;
- WCHAR * str;
-
- hDlgCtrl = GetDlgItem(hwndDlg, 14009);
- lresult = SendMessageW(hDlgCtrl, LB_GETCURSEL, (WPARAM)NULL, (LPARAM)NULL);
- if(lresult == LB_ERR)
- {
- break;
- }
- str = (WCHAR *)SendMessageW(hDlgCtrl, LB_GETITEMDATA, (WPARAM)lresult, (LPARAM)NULL);
-
- if(str == NULL)
- {
- break;
- }
- hDlgCtrl = GetDlgItem(hwndDlg, 14010);
- TRACE("hDlgCtrl %x string %s \n",hDlgCtrl, debugstr_w(str));
- SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)str);
- return TRUE;
- }
- break;
-
- case WM_DESTROY:
- buf = (LPVOID)GetWindowLong(hwndDlg, DWL_USER);
- HeapFree(GetProcessHeap(), 0, buf);
- break;
-
- default:
- break;
- }
- return FALSE;
+ LPPROPSHEETPAGE ppsp;
+ WCHAR *lpstr;
+ LPVOID *buf;
+
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ ppsp = (LPPROPSHEETPAGE)lParam;
+
+ if (ppsp == NULL)
+ break;
+
+ TRACE("WM_INITDIALOG hwnd %p lParam %p ppsplParam %x\n", hwndDlg, lParam, ppsp->lParam);
+
+ lpstr = (WCHAR *)ppsp->lParam;
+
+ if (lpstr == NULL)
+ break;
+
+ return SH_FileVersionInitialize(hwndDlg, lpstr);
+
+ case WM_COMMAND:
+ if (LOWORD(wParam) == 14009 && HIWORD(wParam) == LBN_DBLCLK)
+ {
+ HWND hDlgCtrl;
+ LRESULT lresult;
+ WCHAR *str;
+
+ hDlgCtrl = GetDlgItem(hwndDlg, 14009);
+ lresult = SendMessageW(hDlgCtrl, LB_GETCURSEL, (WPARAM)NULL, (LPARAM)NULL);
+
+ if (lresult == LB_ERR)
+ break;
+
+ str = (WCHAR *) SendMessageW(hDlgCtrl, LB_GETITEMDATA, (WPARAM)lresult, (LPARAM)NULL);
+
+ if (str == NULL)
+ break;
+
+ hDlgCtrl = GetDlgItem(hwndDlg, 14010);
+ TRACE("hDlgCtrl %x string %s \n", hDlgCtrl, debugstr_w(str));
+ SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)str);
+
+ return TRUE;
+ }
+ break;
+
+ case WM_DESTROY:
+ buf = (LPVOID) GetWindowLong(hwndDlg, DWL_USER);
+ HeapFree(GetProcessHeap(), 0, buf);
+ break;
+
+ default:
+ break;
+ }
+
+ return FALSE;
}
/*************************************************************************
INT_PTR
CALLBACK
-SH_FileGeneralDlgProc(
- HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
-)
+SH_FileGeneralDlgProc(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
{
LPPROPSHEETPAGEW ppsp;
- WCHAR * lpstr;
- switch(uMsg)
+ WCHAR *lpstr;
+
+ switch (uMsg)
{
- case WM_INITDIALOG:
- ppsp = (LPPROPSHEETPAGEW)lParam;
- if (ppsp == NULL)
- break;
- TRACE("WM_INITDIALOG hwnd %p lParam %p ppsplParam %S\n",hwndDlg, lParam, ppsp->lParam);
+ case WM_INITDIALOG:
+ ppsp = (LPPROPSHEETPAGEW)lParam;
- lpstr = (WCHAR *)ppsp->lParam;
+ if (ppsp == NULL)
+ break;
- if ( lpstr == NULL)
- {
- ERR("no filename\n");
+ TRACE("WM_INITDIALOG hwnd %p lParam %p ppsplParam %S\n", hwndDlg, lParam, ppsp->lParam);
+
+ lpstr = (WCHAR *)ppsp->lParam;
+
+ if (lpstr == NULL)
+ {
+ ERR("no filename\n");
+ break;
+ }
+
+ /* set general text properties filename filelocation and icon */
+ SH_FileGeneralSetText(hwndDlg, lpstr);
+
+ /* enumerate file extension from registry and application which opens it */
+ SH_FileGeneralSetFileType(hwndDlg, wcsrchr(lpstr, '.'));
+
+ /* set file time create/modfied/accessed */
+ SH_FileGeneralSetFileSizeTime(hwndDlg, lpstr, NULL);
+
+ return TRUE;
+
+ default:
break;
- }
- /* set general text properties filename filelocation and icon */
- SH_FileGeneralSetText(hwndDlg, lpstr);
- /* enumerate file extension from registry and application which opens it*/
- SH_FileGeneralSetFileType(hwndDlg, strrchrW(lpstr, '.'));
- /* set file time create/modfied/accessed */
- SH_FileGeneralSetFileSizeTime(hwndDlg, lpstr, NULL);
- return TRUE;
- default:
- break;
- }
- return FALSE;
+ }
+
+ return FALSE;
}
-BOOL CALLBACK AddShellPropSheetExCallback(HPROPSHEETPAGE hPage, LPARAM lParam)
+BOOL
+CALLBACK
+AddShellPropSheetExCallback(HPROPSHEETPAGE hPage,
+ LPARAM lParam)
{
- UINT iIndex;
- HPROPSHEETPAGE * hppages = (HPROPSHEETPAGE *)lParam;
+ PROPSHEETHEADERW *pinfo = (PROPSHEETHEADERW *)lParam;
- TRACE("AddShellPropSheetExCallback called\n");
- for(iIndex = 0; iIndex < MAX_PROPERTY_SHEET_PAGE; iIndex++)
+ if (pinfo->nPages < MAX_PROPERTY_SHEET_PAGE)
{
- if (hppages[iIndex] == NULL)
- {
- hppages[iIndex] = hPage;
- return TRUE;
- }
+ pinfo->u3.phpage[pinfo->nPages++] = hPage;
+ return TRUE;
}
+
return FALSE;
}
-
int
-EnumPropSheetExt(LPWSTR wFileName, HPROPSHEETPAGE * hppages, int NumPages, HPSXA * hpsxa, IDataObject *pDataObj)
+EnumPropSheetExt(LPWSTR wFileName, PROPSHEETHEADERW *pinfo, int NumPages, HPSXA *hpsxa, IDataObject *pDataObj)
{
- WCHAR szName[100];
- WCHAR * pOffset;
+ WCHAR szName[MAX_PATH] = { 0 };
+ WCHAR *pOffset;
UINT Length;
DWORD dwName;
int Pages;
CLSID clsid;
pOffset = wcsrchr(wFileName, L'.');
+
if (!pOffset)
{
Length = wcslen(szName);
- if (Length >=94)
- return 0;
+
+ if (Length + 6 > sizeof(szName) / sizeof(szName[0]))
+ return 0;
if (CLSIDFromString(wFileName, &clsid) == NOERROR)
{
- wcscpy(szName, L"CLSID\\");
- wcscpy(&szName[6], wFileName);
+ wcscpy(szName, L"CLSID\\");
+ wcscpy(&szName[6], wFileName);
}
else
{
- wcscpy(szName, wFileName);
+ wcscpy(szName, wFileName);
}
}
else
{
Length = wcslen(pOffset);
- if (Length >= 100)
+
+ if (Length >= sizeof(szName) / sizeof(szName[0]))
return 0;
+
wcscpy(szName, pOffset);
}
+
TRACE("EnumPropSheetExt szName %s\n", debugstr_w(szName));
+
hpsxa[0] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, szName, NumPages, pDataObj);
- Pages = SHAddFromPropSheetExtArray(hpsxa[0], AddShellPropSheetExCallback, (LPARAM)hppages);
+ hpsxa[1] = NULL;
+ Pages = SHAddFromPropSheetExtArray(hpsxa[0], AddShellPropSheetExCallback, (LPARAM)pinfo);
if (pOffset)
{
/* try to load property sheet handlers from prog id key */
dwName = sizeof(szName);
+
if (RegGetValueW(HKEY_CLASSES_ROOT, pOffset, NULL, RRF_RT_REG_SZ, NULL, szName, &dwName) == ERROR_SUCCESS)
{
TRACE("EnumPropSheetExt szName %s, pOffset %s\n", debugstr_w(szName), debugstr_w(pOffset));
- szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
+ szName[(sizeof(szName) / sizeof(WCHAR)) - 1] = L'\0';
hpsxa[1] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, szName, NumPages - Pages, pDataObj);
- Pages +=SHAddFromPropSheetExtArray(hpsxa[1], AddShellPropSheetExCallback, (LPARAM)hppages);
+ Pages += SHAddFromPropSheetExtArray(hpsxa[1], AddShellPropSheetExCallback, (LPARAM)pinfo);
}
}
+
return Pages;
}
-
-
/*************************************************************************
*
* SH_ShowPropertiesDialog
* lpf contains (quoted) path of folder/file
*
* TODO: provide button change application type if file has registered type
- * make filename field editable and apply changes to filename on close
+ * make filename field editable and apply changes to filename on close
*/
BOOL
-SH_ShowPropertiesDialog(PCWSTR lpf)
+SH_ShowPropertiesDialog(WCHAR *lpf, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST *apidl)
{
PROPSHEETHEADERW pinfo;
HPROPSHEETPAGE hppages[MAX_PROPERTY_SHEET_PAGE];
- HPROPSHEETPAGE hpage;
WCHAR wFileName[MAX_PATH];
- UINT num_pages = 0;
DWORD dwHandle = 0;
- WCHAR * pFileName;
+ WCHAR *pFileName;
HPSXA hpsxa[2];
INT_PTR res;
- LPITEMIDLIST pidlChild, pidlFolder;
- WCHAR szTemp[MAX_PATH];
- IDataObject* pDataObj = NULL;
+ IDataObject *pDataObj = NULL;
HRESULT hResult;
TRACE("SH_ShowPropertiesDialog entered filename %s\n", debugstr_w(lpf));
- if (lpf== NULL)
+ if (lpf == NULL)
return FALSE;
- if ( !strlenW(lpf) )
+ if (!wcslen(lpf))
return FALSE;
memset(hppages, 0x0, sizeof(HPROPSHEETPAGE) * MAX_PROPERTY_SHEET_PAGE);
+
if (lpf[0] == '"')
{
/* remove quotes from lpf */
LPCWSTR src = lpf + 1;
LPWSTR dst = wFileName;
- while(*src && *src!='"')
+ while (*src && *src != '"')
*dst++ = *src++;
*dst = '\0';
}
else
{
- strcpyW(wFileName, lpf);
+ wcscpy(wFileName, lpf);
}
if (PathIsDirectoryW(wFileName))
if (wcslen(wFileName) == 3)
{
- return SH_ShowDriveProperties(wFileName);
- }
-
- wcscpy(szTemp, wFileName);
- pFileName = wcsrchr(szTemp, '\\');
- if (pFileName)
- {
- pFileName[0] = L'\0';
- pFileName++;
- pidlChild = ILCreateFromPathW(pFileName);
- pidlFolder = ILCreateFromPathW(szTemp);
- if (pidlChild && pidlFolder)
- {
- hResult = SHCreateDataObject(pidlFolder, 1, (LPCITEMIDLIST*)&pidlChild, NULL, &IID_IDataObject, (LPVOID*)&pDataObj);
- ILFree(pidlChild);
- ILFree(pidlFolder);
- if (hResult != S_OK)
- pDataObj = NULL;
- }
- }
-
-
- hpage = SH_CreatePropertySheetPage("SHELL_FILE_GENERAL_DLG", SH_FileGeneralDlgProc, (LPARAM)wFileName, NULL);
-
- if (hpage == NULL)
- return FALSE;
-
- hppages[num_pages] = hpage;
- num_pages++;
- num_pages += EnumPropSheetExt(wFileName, hppages, MAX_PROPERTY_SHEET_PAGE-1, hpsxa, pDataObj);
-
- if ( GetFileVersionInfoSizeW(lpf, &dwHandle) && num_pages)
- {
- if ( (hpage = SH_CreatePropertySheetPage("SHELL_FILE_VERSION_DLG",SH_FileVersionDlgProc, (LPARAM)wFileName, NULL))!= NULL)
- {
- hppages[num_pages] = hpage;
- num_pages++;
- }
+ return SH_ShowDriveProperties(wFileName, pidlFolder, apidl);
}
pFileName = wcsrchr(wFileName, '\\');
+
if (!pFileName)
pFileName = wFileName;
else
pFileName++;
-
memset(&pinfo, 0x0, sizeof(PROPSHEETHEADERW));
pinfo.dwSize = sizeof(PROPSHEETHEADERW);
pinfo.dwFlags = PSH_NOCONTEXTHELP | PSH_PROPTITLE;
- pinfo.nPages = num_pages;
pinfo.u3.phpage = hppages;
pinfo.pszCaption = pFileName;
- TRACE("SH_ShowPropertiesDialog pages %u\n", num_pages);
+ hppages[pinfo.nPages] =
+ SH_CreatePropertySheetPage("SHELL_FILE_GENERAL_DLG",
+ SH_FileGeneralDlgProc,
+ (LPARAM)wFileName,
+ NULL);
+
+ if (hppages[pinfo.nPages])
+ pinfo.nPages++;
+
+ hResult = SHCreateDataObject(pidlFolder, 1, apidl, NULL, &IID_IDataObject, (LPVOID *)&pDataObj);
+
+ if (hResult == S_OK)
+ {
+ if (!EnumPropSheetExt(wFileName, &pinfo, MAX_PROPERTY_SHEET_PAGE - 1, hpsxa, pDataObj))
+ {
+ hpsxa[0] = NULL;
+ hpsxa[1] = NULL;
+ }
+ }
+
+ if (GetFileVersionInfoSizeW(lpf, &dwHandle))
+ {
+ hppages[pinfo.nPages] =
+ SH_CreatePropertySheetPage("SHELL_FILE_VERSION_DLG",
+ SH_FileVersionDlgProc,
+ (LPARAM)wFileName,
+ NULL);
+ if (hppages[pinfo.nPages])
+ pinfo.nPages++;
+ }
+
res = PropertySheetW(&pinfo);
- SHDestroyPropSheetExtArray(hpsxa[0]);
- SHDestroyPropSheetExtArray(hpsxa[1]);
- if (pDataObj)
+ if (hResult == S_OK)
+ {
+ SHDestroyPropSheetExtArray(hpsxa[0]);
+ SHDestroyPropSheetExtArray(hpsxa[1]);
IDataObject_Release(pDataObj);
+ }
return (res != -1);
}
+
/*EOF */