Ivan Sinitsin wrote:
this is corrected patch for winefile.
You want to use the explicit RegQueryValueExW and RegSetValueExW functions.
bye michael
This patch adds an opportunity to keep adjustments of a font between sessions, if menu "Save settings on exit" is checked.
Changelog: this patch add opportunity to save font option to the regestry, and load font option from regestry in the winefile program
Index: programs/winefile/winefile.c
RCS file: /home/wine/wine/programs/winefile/winefile.c,v retrieving revision 1.75 diff -u -p -u -r1.75 winefile.c --- programs/winefile/winefile.c 25 Oct 2006 18:31:13 -0000 1.75 +++ programs/winefile/winefile.c 14 Jun 2007 07:22:19 -0000 @@ -66,6 +66,20 @@ static const WCHAR reg_start_x[] = { 's' static const WCHAR reg_start_y[] = { 's','t','a','r','t','Y','\0'}; static const WCHAR reg_width[] = { 'w','i','d','t','h','\0'}; static const WCHAR reg_height[] = { 'h','e','i','g','h','t','\0'}; +static const WCHAR reg_font_height[] = { 'f','o','n','t','_','h','e','i','g','h','t','\0'}; +static const WCHAR reg_font_width[] = { 'f','o','n','t','_','w','i','d','t','h','\0'}; +static const WCHAR reg_font_escapement[] = { 'f','o','n','t','_','E','s','c','a','p','e','m','e','n','t','\0'}; +static const WCHAR reg_font_orientation[] = { 'f','o','n','t','_','O','r','i','e','n','t','a','t','i','o','n','\0'}; +static const WCHAR reg_font_weight[] = { 'f','o','n','t','_','W','e','i','g','h','t','\0'}; +static const WCHAR reg_font_italic[] = { 'f','o','n','t','_','I','t','a','l','i','c','\0'}; +static const WCHAR reg_font_underline[] = { 'f','o','n','t','_','U','n','d','e','r','l','i','n','e','\0'}; +static const WCHAR reg_font_strikeout[] = { 'f','o','n','t','_','S','t','r','i','k','e','O','u','t','\0'}; +static const WCHAR reg_font_charset[] = { 'f','o','n','t','_','C','h','a','r','S','e','t','\0'}; +static const WCHAR reg_font_outprecision[] = { 'f','o','n','t','_','O','u','t','P','r','e','c','i','s','i','o','n','\0'}; +static const WCHAR reg_font_clipprecision[] = { 'f','o','n','t','_','C','l','i','p','P','r','e','c','i','s','i','o','n','\0'}; +static const WCHAR reg_font_quality[] = { 'f','o','n','t','_','Q','u','a','l','i','t','y','\0'}; +static const WCHAR reg_font_pitchandfamily[] = { 'f','o','n','t','_','P','i','t','c','h','A','n','d','F','a','m','i','l','y','\0'}; +static const WCHAR reg_font_facename[] = { 'f','o','n','t','_','F','a','c','e','N','a','m','e','\0'};
enum ENTRY_TYPE { ET_WINDOWS, @@ -1588,15 +1602,20 @@ static void get_path(Entry* dir, PTSTR p
static windowOptions load_registry_settings(void) {
- DWORD size;
DWORD size, sizeW; DWORD type; HKEY hKey; windowOptions opts;
LOGFONT logfont;
HFONT hFont;
RegOpenKeyEx( HKEY_CURRENT_USER, registry_key, 0, KEY_QUERY_VALUE, &hKey );
hFont=GetStockObject(DEFAULT_GUI_FONT);
GetObject(hFont,sizeof(logfont),&logfont); size = sizeof(DWORD);
sizeW = sizeof(logfont.lfFaceName);
if( RegQueryValueEx( hKey, reg_start_x, NULL, &type, (LPBYTE) &opts.start_x, &size ) != ERROR_SUCCESS )
@@ -1614,8 +1633,51 @@ static windowOptions load_registry_setti (LPBYTE) &opts.height, &size ) != ERROR_SUCCESS ) opts.height = CW_USEDEFAULT;
RegQueryValueEx( hKey, reg_font_height, NULL, &type,
(LPBYTE) &logfont.lfHeight, &size );
RegQueryValueEx( hKey, reg_font_width, NULL, &type,
(LPBYTE) &logfont.lfWidth, &size );
RegQueryValueEx( hKey, reg_font_escapement, NULL, &type,
(LPBYTE) &logfont.lfEscapement, &size );
RegQueryValueEx( hKey, reg_font_orientation, NULL, &type,
(LPBYTE) &logfont.lfOrientation, &size );
RegQueryValueEx( hKey, reg_font_weight, NULL, &type,
(LPBYTE) &logfont.lfWeight, &size );
RegQueryValueEx( hKey, reg_font_italic, NULL, &type,
(LPBYTE) &logfont.lfItalic, &size );
RegQueryValueEx( hKey, reg_font_underline, NULL, &type,
(LPBYTE) &logfont.lfUnderline, &size );
RegQueryValueEx( hKey, reg_font_strikeout, NULL, &type,
(LPBYTE) &logfont.lfStrikeOut, &size );
RegQueryValueEx( hKey, reg_font_charset, NULL, &type,
(LPBYTE) &logfont.lfCharSet, &size );
RegQueryValueEx( hKey, reg_font_outprecision, NULL, &type,
(LPBYTE) &logfont.lfOutPrecision, &size );
RegQueryValueEx( hKey, reg_font_clipprecision, NULL, &type,
(LPBYTE) &logfont.lfClipPrecision, &size );
RegQueryValueEx( hKey, reg_font_quality, NULL, &type,
(LPBYTE) &logfont.lfQuality, &size );
RegQueryValueEx( hKey, reg_font_pitchandfamily, NULL, &type,
(LPBYTE) &logfont.lfPitchAndFamily, &size );
RegQueryValueEx( hKey, reg_font_facename, NULL, &type,
(LPBYTE) &logfont.lfFaceName, &sizeW);
RegCloseKey( hKey );
Globals.hfont = CreateFontIndirect(&logfont); return opts;
}
@@ -1624,11 +1686,13 @@ static void save_registry_settings(void) WINDOWINFO wi; HKEY hKey; INT width, height;
LOGFONT logfont;
wi.cbSize = sizeof( WINDOWINFO ); GetWindowInfo(Globals.hMainWnd, &wi); width = wi.rcWindow.right - wi.rcWindow.left; height = wi.rcWindow.bottom - wi.rcWindow.top;
GetObject(Globals.hfont, sizeof(logfont), &logfont);
if ( RegOpenKeyEx( HKEY_CURRENT_USER, registry_key, 0, KEY_SET_VALUE, &hKey ) != ERROR_SUCCESS )
@@ -1651,6 +1715,34 @@ static void save_registry_settings(void) (LPBYTE) &width, sizeof(DWORD) ); RegSetValueEx( hKey, reg_height, 0, REG_DWORD, (LPBYTE) &height, sizeof(DWORD) );
RegSetValueEx( hKey, reg_font_height, 0, REG_DWORD,
(LPBYTE) &logfont.lfHeight, sizeof(DWORD) );
RegSetValueEx( hKey, reg_font_width, 0, REG_DWORD,
(LPBYTE) &logfont.lfWidth, sizeof(DWORD) );
RegSetValueEx( hKey, reg_font_escapement, 0, REG_DWORD,
(LPBYTE) &logfont.lfEscapement, sizeof(DWORD) );
RegSetValueEx( hKey, reg_font_orientation, 0, REG_DWORD,
(LPBYTE) &logfont.lfOrientation, sizeof(DWORD) );
RegSetValueEx( hKey, reg_font_weight, 0, REG_DWORD,
(LPBYTE) &logfont.lfWeight, sizeof(DWORD) );
RegSetValueEx( hKey, reg_font_italic, 0, REG_DWORD,
(LPBYTE) &logfont.lfItalic, sizeof(DWORD) );
RegSetValueEx( hKey, reg_font_underline, 0, REG_DWORD,
(LPBYTE) &logfont.lfUnderline, sizeof(DWORD) );
RegSetValueEx( hKey, reg_font_strikeout, 0, REG_DWORD,
(LPBYTE) &logfont.lfStrikeOut, sizeof(DWORD) );
RegSetValueEx( hKey, reg_font_charset, 0, REG_DWORD,
(LPBYTE) &logfont.lfCharSet, sizeof(DWORD) );
RegSetValueEx( hKey, reg_font_outprecision, 0, REG_DWORD,
(LPBYTE) &logfont.lfOutPrecision, sizeof(DWORD) );
RegSetValueEx( hKey, reg_font_clipprecision, 0, REG_DWORD,
(LPBYTE) &logfont.lfClipPrecision, sizeof(DWORD) );
RegSetValueEx( hKey, reg_font_quality, 0, REG_DWORD,
(LPBYTE) &logfont.lfQuality, sizeof(DWORD) );
RegSetValueEx( hKey, reg_font_pitchandfamily, 0, REG_DWORD,
(LPBYTE) &logfont.lfPitchAndFamily, sizeof(DWORD) );
RegSetValueEx( hKey, reg_font_facename, 0, REG_SZ,
(LPBYTE) &logfont.lfFaceName,(strlenW(&logfont.lfFaceName) + 1)*sizeof(WCHAR));
/* TODO: Save more settings here (List vs. Detailed View, etc.) */ RegCloseKey( hKey );