Changelog - include/shlobj.h Add declaration for PathGetShortPath - dlls/shell32/undocshell.h Change prototype of PathGetShortPathAW to match MSDN - dlls/shell32/shellpath.c Implement PathGetShortPathA/W and change it's prototype to match the documentation on MSDN. Tests show that at least under W2K SP4 the return value actually seems to be the buffer pointer on success or NULL otherwise, but that might be rather a side effect of the function than intended behaviour.
One thing I'm not entirely sure is how to declare the prototype in shlobj.h correctly. This is one of those functions shell32 exports as Unicode/ANSI depending on the Windows version, without the normal A and W exports as well. So shlobj.h needs to declare a function name without the A or W ending. The normal WINELIB_AW macros won't work here as the decision about A/W is not made on compile time of the application but instead on compile time of the library. What I don't like about this approach is the fact that there are basically two declarations for the same exported function in two different places GetShortPathAW in dlls/shell32/undocshell.h and GetShortPath in include/shlobj.h.
License: X11/LGPL
Rolf Kalbermatter
Index: include/shlobj.h =================================================================== RCS file: /home/wine/wine/include/shlobj.h,v retrieving revision 1.80 diff -u -r1.80 shlobj.h --- include/shlobj.h 8 Jan 2004 00:39:21 -0000 1.80 +++ include/shlobj.h 19 Jan 2004 11:21:45 -0000 @@ -841,6 +841,11 @@ DECL_WINELIB_TYPE_AW(FILEGROUPDESCRIPTOR) DECL_WINELIB_TYPE_AW(LPFILEGROUPDESCRIPTOR)
+/**************************************************************************** + * Path Manipulation Routines + */ +VOID WINAPI PathGetShortPath(LPVOID pszPath); + #include <poppack.h>
/*****************************************************************************
Index: dlls/shell32/undocshell.h =================================================================== RCS file: /home/wine/wine/dlls/shell32/undocshell.h,v retrieving revision 1.19 diff -u -r1.19 undocshell.h --- dlls/shell32/undocshell.h 16 Jan 2004 23:04:41 -0000 1.19 +++ dlls/shell32/undocshell.h 19 Jan 2004 11:51:43 -0000 @@ -544,7 +544,7 @@
BOOL WINAPI PathRemoveFileSpecAW(LPVOID lpszPath);
-LPVOID WINAPI PathGetShortPathAW(LPVOID lpszPath); +VOID WINAPI PathGetShortPathAW(LPVOID lpszPath);
void WINAPI PathRemoveBlanksAW(LPVOID lpszPath);
Index: dlls/shell32/shellpath.c =================================================================== RCS file: /home/wine/wine/dlls/shell32/shellpath.c,v retrieving revision 1.77 diff -u -r1.77 shellpath.c --- dlls/shell32/shellpath.c 16 Jan 2004 23:04:41 -0000 1.77 +++ dlls/shell32/shellpath.c 19 Jan 2004 11:25:29 -0000 @@ -22,7 +22,6 @@ * Many of these functions are in SHLWAPI.DLL also * */ - #include "config.h" #include "wine/port.h"
@@ -236,29 +235,41 @@ /************************************************************************* * PathGetShortPathA [internal] */ -LPSTR WINAPI PathGetShortPathA(LPSTR lpszPath) +VOID WINAPI PathGetShortPathA(LPSTR pszPath) { - FIXME("%s stub\n", lpszPath); - return NULL; + CHAR path[MAX_PATH]; + + TRACE("%s\n", pszPath); + + if (GetShortPathNameA(pszPath, path, MAX_PATH)) + { + lstrcpyA(pszPath, path); + } }
/************************************************************************* * PathGetShortPathW [internal] */ -LPWSTR WINAPI PathGetShortPathW(LPWSTR lpszPath) +VOID WINAPI PathGetShortPathW(LPWSTR pszPath) { - FIXME("%s stub\n", debugstr_w(lpszPath)); - return NULL; + WCHAR path[MAX_PATH]; + + TRACE("%s\n", debugstr_w(pszPath)); + + if (GetShortPathNameW(pszPath, path, MAX_PATH)) + { + lstrcpyW(pszPath, path); + } }
/************************************************************************* * PathGetShortPath [SHELL32.92] */ -LPVOID WINAPI PathGetShortPathAW(LPVOID lpszPath) +VOID WINAPI PathGetShortPathAW(LPVOID pszPath) { if(SHELL_OsIsUnicode()) - return PathGetShortPathW(lpszPath); - return PathGetShortPathA(lpszPath); + PathGetShortPathW(pszPath); + PathGetShortPathA(pszPath); } /*************************************************************************