mixing SHELL32.DLL and SHFOLDER.DLL

Saulius Krasuckas saulius2 at ar.fi.lt
Sun Aug 29 16:05:28 CDT 2004


On Sun, 29 Aug 2004, Steven Edwards wrote:
> --- Saulius Krasuckas <saulius2 at ar.fi.lt> wrote:
> > should I wait even more, or should I try writing a patch on my own? 
> 
> Write your own. Everyone else seems to have other stuff they are
> working on.

Lets try.  I am not sure about many things:

1, whether is better to duplicate code SHGetFolderPathW() or to try
finding it by an ordinal its value (the case for the older versions of
SHELL32.DLL) as it was stated by Juergen?

2, shouldn't we output the whole string of pszPath instead of printing
just a pointer value?

Waiting for the corrections.


Changelog:
	Initial code for the Dll.
	Stop forwarding SHGetFolderPath[AW] exports to SHELL32.DLL.
	Instead try locating SHGetFolderPathW() dynamically.


Index: dlls/shfolder/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/shfolder/Makefile.in,v
retrieving revision 1.7
diff -u -r1.7 Makefile.in
--- dlls/shfolder/Makefile.in	11 Oct 2003 01:09:17 -0000	1.7
+++ dlls/shfolder/Makefile.in	29 Aug 2004 19:19:31 -0000
@@ -3,7 +3,7 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = shfolder.dll
-IMPORTS   = shell32
+IMPORTS   = shell32 kernel32
 
 C_SRCS = shfolder_main.c
 
Index: dlls/shfolder/shfolder.spec
===================================================================
RCS file: /home/wine/wine/dlls/shfolder/shfolder.spec,v
retrieving revision 1.7
diff -u -r1.7 shfolder.spec
--- dlls/shfolder/shfolder.spec	17 Mar 2003 00:17:01 -0000	1.7
+++ dlls/shfolder/shfolder.spec	29 Aug 2004 19:19:31 -0000
@@ -1,2 +1,2 @@
-@ stdcall SHGetFolderPathA(long long long long ptr) shell32.SHGetFolderPathA
-@ stdcall SHGetFolderPathW(long long long long ptr) shell32.SHGetFolderPathW
+@ stdcall SHGetFolderPathA(long long long long ptr)
+@ stdcall SHGetFolderPathW(long long long long ptr)
Index: dlls/shfolder/shfolder_main.c
===================================================================
RCS file: /home/wine/wine/dlls/shfolder/shfolder_main.c,v
retrieving revision 1.1
diff -u -r1.1 shfolder_main.c
--- dlls/shfolder/shfolder_main.c	26 Jul 2000 18:30:38 -0000	1.1
+++ dlls/shfolder/shfolder_main.c	29 Aug 2004 19:19:31 -0000
@@ -1 +1,90 @@
-/* nothing here yet */
+/*
+ * Shell Folder Service
+ *
+ * Copyright 2000 Juergen Schmied
+ * Copyright 2004 Saulius Krasuckas
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "wine/debug.h"
+#include "winbase.h"
+#include "winnls.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(shfolder);
+
+
+HINSTANCE SHELL32_hInstance = 0;
+
+BOOL (WINAPI *SHFOLDER_SHGetFolderPathW)(HWND,int,HANDLE,DWORD,LPWSTR);
+
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+    TRACE("(hinstDLL=%p, fdwReason=%lx, lpvReserved=%p)\n", hinstDLL, fdwReason, lpvReserved);
+    switch (fdwReason) 
+    {
+    case DLL_PROCESS_ATTACH:
+        SHELL32_hInstance = GetModuleHandleA("SHELL32.DLL");
+        if (!SHELL32_hInstance)
+        {
+            ERR("failed to retrieve handle for SHELL32.DLL\n");
+            return FALSE;
+        }
+          
+        SHFOLDER_SHGetFolderPathW = GetProcAddress(SHELL32_hInstance, "SHGetFolderPathW");
+        if (!SHFOLDER_SHGetFolderPathW)
+            ERR("failed to get entry point for SHGetFolderPathW() in SHELL32.DLL\n");
+        break;
+    }
+    return TRUE;
+}
+
+HRESULT WINAPI SHGetFolderPathW(
+                 HWND hwndOwner,
+                 int csidl,
+                 HANDLE hToken,
+                 DWORD dwFlags,
+                 LPWSTR pszPath)
+{
+    if (!SHFOLDER_SHGetFolderPathW)
+    {
+        FIXME("is a semi-stub: SHELL32.DLL code is still not duplicated neither imported by an ordinal value");
+        return E_FAIL;
+    }
+    return SHFOLDER_SHGetFolderPathW(hwndOwner, csidl, hToken, dwFlags, pszPath);
+}
+
+HRESULT WINAPI SHGetFolderPathA(
+                   HWND hwndOwner,
+                   int csidl,
+                   HANDLE hToken,
+                   DWORD dwFlags,
+                   LPSTR pszPath)
+{
+    WCHAR szTempPath[MAX_PATH];
+    HRESULT hr;
+
+    if (!pszPath) return E_INVALIDARG;
+    
+    *pszPath = '\0';
+    hr = SHGetFolderPathW(hwndOwner, csidl, hToken, dwFlags, szTempPath);
+    if (SUCCEEDED(hr))
+        WideCharToMultiByte(CP_ACP, 0, szTempPath, -1, pszPath, MAX_PATH, NULL, NULL);
+    
+    TRACE("%p, %p, csidl=0x%04x\n", hwndOwner, pszPath, csidl);
+    return hr;
+}
+




More information about the wine-devel mailing list