From af135d8b9b1def3c9cc0fb631450a84f95f639a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Tue, 21 Sep 2004 18:55:53 +0000 Subject: [PATCH] Juan Lang - Add stub for ShellDDEInit to let Windows explorer.exe get past the beginning. Francois Gouget - Make Unicode strings static const. Eric Pouech - GetModuleFileName[AW] doesn't terminate the string if the buffer is too small. Jon Griffiths - Delete the about dialog font when the dialog is closed. Juan Lang - Added support for DLLVERSIONINFO2 in DllGetVersion. svn path=/trunk/; revision=10955 --- reactos/lib/shell32/shell32.spec | 2 +- reactos/lib/shell32/shell32_main.c | 86 +++++++++++++++++++----------- 2 files changed, 57 insertions(+), 31 deletions(-) diff --git a/reactos/lib/shell32/shell32.spec b/reactos/lib/shell32/shell32.spec index f5e5fb6e667..11966ab3e7e 100644 --- a/reactos/lib/shell32/shell32.spec +++ b/reactos/lib/shell32/shell32.spec @@ -179,7 +179,7 @@ 185 stub SHHandleDiskFull 186 stdcall ILGetDisplayNameEx(ptr ptr ptr long) 187 stub ILGetPseudoNameW - 188 stub ShellDDEInit + 188 stdcall ShellDDEInit(long) 189 stdcall ILCreateFromPathA(str) 190 stdcall ILCreateFromPathW(wstr) 191 stub SHUpdateImageA diff --git a/reactos/lib/shell32/shell32_main.c b/reactos/lib/shell32/shell32_main.c index 5de39d65eb2..2bfdcac902d 100644 --- a/reactos/lib/shell32/shell32_main.c +++ b/reactos/lib/shell32/shell32_main.c @@ -91,11 +91,17 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs) if (*lpCmdline==0) { /* Return the path to the executable */ - DWORD size=16; + DWORD len, size=16; hargv=GlobalAlloc(size, 0); argv=GlobalLock(hargv); - while (GetModuleFileNameW(0, (LPWSTR)(argv+1), size-sizeof(LPWSTR)) == 0) { + for (;;) { + len = GetModuleFileNameW(0, (LPWSTR)(argv+1), size-sizeof(LPWSTR)); + if (!len) { + GlobalFree(hargv); + return NULL; + } + if (len < size) break; size*=2; hargv=GlobalReAlloc(hargv, size, 0); argv=GlobalLock(hargv); @@ -356,8 +362,8 @@ DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, /* get the type name */ if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME)) { - WCHAR szFile[] = { 'F','i','l','e',0 }; - WCHAR szDashFile[] = { '-','f','i','l','e',0 }; + static const WCHAR szFile[] = { 'F','i','l','e',0 }; + static const WCHAR szDashFile[] = { '-','f','i','l','e',0 }; if (!(flags & SHGFI_USEFILEATTRIBUTES)) { char ftype[80]; @@ -428,7 +434,7 @@ DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, psfi->iIcon = 2; else { - WCHAR p1W[] = {'%','1',0}; + static const WCHAR p1W[] = {'%','1',0}; psfi->iIcon = 0; szExt = (LPWSTR) PathFindExtensionW(sTemp); if ( szExt && HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) @@ -619,6 +625,7 @@ typedef struct LPCWSTR szApp; LPCWSTR szOtherStuff; HICON hIcon; + HFONT hFont; } ABOUT_INFO; #define IDC_STATIC_TEXT 100 @@ -628,8 +635,6 @@ typedef struct #define DROP_FIELD_TOP (-15) #define DROP_FIELD_HEIGHT 15 -static HFONT hIconTitleFont; - static BOOL __get_dropline( HWND hWnd, LPRECT lprect ) { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT); if( hWndCtl ) @@ -749,13 +754,7 @@ INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, SetWindowTextW( GetDlgItem(hWnd, IDC_STATIC_TEXT), info->szOtherStuff ); hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX); SendMessageW( hWndCtl, WM_SETREDRAW, 0, 0 ); - if (!hIconTitleFont) - { - LOGFONTW logFont; - SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 ); - hIconTitleFont = CreateFontIndirectW( &logFont ); - } - SendMessageW( hWndCtl, WM_SETFONT, (WPARAM)hIconTitleFont, 0 ); + SendMessageW( hWndCtl, WM_SETFONT, (WPARAM)info->hFont, 0 ); while (*pstr) { WCHAR name[64]; @@ -836,8 +835,10 @@ BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON hIcon ) { ABOUT_INFO info; + LOGFONTW logFont; HRSRC hRes; LPVOID template; + BOOL bRet; TRACE("\n"); @@ -848,8 +849,14 @@ BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, info.szApp = szApp; info.szOtherStuff = szOtherStuff; info.hIcon = hIcon ? hIcon : LoadIconW( 0, (LPWSTR)IDI_WINLOGO ); - return DialogBoxIndirectParamW((HINSTANCE)GetWindowLongW( hWnd, GWL_HINSTANCE ), + + SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 ); + info.hFont = CreateFontIndirectW( &logFont ); + + bRet = DialogBoxIndirectParamW((HINSTANCE)GetWindowLongW( hWnd, GWL_HINSTANCE ), template, hWnd, AboutDlgProc, (LPARAM)&info ); + DeleteObject(info.hFont); + return bRet; } /************************************************************************* @@ -859,6 +866,15 @@ void WINAPI FreeIconList( DWORD dw ) { FIXME("(%lx): stub\n",dw); } + +/************************************************************************* + * ShellDDEInit (SHELL32.@) + */ +void WINAPI ShellDDEInit(BOOL start) +{ + FIXME("stub: %d\n", start); +} + /*********************************************************************** * DllGetVersion [SHELL32.@] * @@ -877,22 +893,31 @@ void WINAPI FreeIconList( DWORD dw ) HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi) { - if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) + /* FIXME: shouldn't these values come from the version resource? */ + if (pdvi->cbSize == sizeof(DLLVERSIONINFO) || + pdvi->cbSize == sizeof(DLLVERSIONINFO2)) + { + pdvi->dwMajorVersion = 4; + pdvi->dwMinorVersion = 72; + pdvi->dwBuildNumber = 3110; + pdvi->dwPlatformID = DLLVER_PLATFORM_WINDOWS; + if (pdvi->cbSize == sizeof(DLLVERSIONINFO2)) + { + DLLVERSIONINFO2 *pdvi2 = (DLLVERSIONINFO2 *)pdvi; + + pdvi2->dwFlags = 0; + pdvi2->ullVersion = MAKEDLLVERULL(4, 72, 3110, 0); + } + TRACE("%lu.%lu.%lu.%lu\n", + pdvi->dwMajorVersion, pdvi->dwMinorVersion, + pdvi->dwBuildNumber, pdvi->dwPlatformID); + return S_OK; + } + else { - WARN("wrong DLLVERSIONINFO size from app\n"); - return E_INVALIDARG; - } - - pdvi->dwMajorVersion = 4; - pdvi->dwMinorVersion = 72; - pdvi->dwBuildNumber = 3110; - pdvi->dwPlatformID = 1; - - TRACE("%lu.%lu.%lu.%lu\n", - pdvi->dwMajorVersion, pdvi->dwMinorVersion, - pdvi->dwBuildNumber, pdvi->dwPlatformID); - - return S_OK; + WARN("wrong DLLVERSIONINFO size from app\n"); + return E_INVALIDARG; + } } /************************************************************************* * global variables of the shell32.dll @@ -923,6 +948,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */ GetModuleFileNameW(hinstDLL, swShell32Name, MAX_PATH); + swShell32Name[MAX_PATH - 1] = '\0'; InitCommonControlsEx(NULL);