[libdvdcss-devel] [PATCH] Win32: use directly SHGetFolderPath

Diego Biurrun diego at biurrun.de
Sat Mar 23 05:27:06 CET 2013


From: Jean-Baptiste Kempf <jb at videolan.org>

This drops support for IE < 5.0
---
 configure.ac    |    4 ++--
 msvc/config.h   |    9 +++++----
 src/libdvdcss.c |   43 ++++++++-----------------------------------
 3 files changed, 15 insertions(+), 41 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3d3a5fe..ae21fcb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,10 +112,10 @@ case x"${host_os}" in
     ;;
   x*msvc*)
     SYS_MSVC=1
-    AC_DEFINE([_WIN32_IE], 0x0401, [Define to '0x0401' for IE 4.01 (and shell) APIs.])
+    AC_DEFINE([_WIN32_IE], 0x0500, [Define to '0x0500' for IE 5.0 (and shell) APIs.])
     ;;
   x*mingw* | *wince* | *mingwce*)
-    AC_DEFINE([_WIN32_IE], 0x0401, [Define to '0x0401' for IE 4.01 (and shell) APIs.])
+    AC_DEFINE([_WIN32_IE], 0x0500, [Define to '0x0500' for IE 5.0 (and shell) APIs.])
     ;;
   x*)
     ;;
diff --git a/msvc/config.h b/msvc/config.h
index 0d5e3c3..8fb9e5f 100644
--- a/msvc/config.h
+++ b/msvc/config.h
@@ -30,13 +30,14 @@
 /* #undef HPUX_SCTL_IO */
 #define PACKAGE "libdvdcss"
 #define PACKAGE_BUGREPORT ""
-#define PACKAGE_NAME ""
-#define PACKAGE_STRING ""
-#define PACKAGE_TARNAME ""
+#define PACKAGE_NAME "libdvdcss"
+#define PACKAGE_STRING "libdvdcss 1.2.13"
+#define PACKAGE_TARNAME "libdvdcss"
 #define PACKAGE_VERSION ""
 /* #undef SOLARIS_USCSI */
 #define STDC_HEADERS 1
-#define VERSION "1.2.11"
+#define VERSION "1.2.13"
+#define _WIN32_IE 0x0500
 /* #undef const */
 /* #undef inline */
 /* #undef size_t */
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index cbda930..a5014b4 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -119,6 +119,10 @@
 #   include <limits.h>
 #endif
 
+#if defined(_WIN32_IE) && _WIN32_IE >= 0x500
+#   include <shlobj.h>
+#endif
+
 #include "dvdcss/dvdcss.h"
 
 #include "common.h"
@@ -238,46 +242,15 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( char *psz_target )
      */
     if( psz_cache == NULL || psz_cache[0] == '\0' )
     {
-#if defined(_WIN32_IE) && _WIN32_IE >= 0x401
-        typedef HRESULT( WINAPI *SHGETFOLDERPATH )
-                       ( HWND, int, HANDLE, DWORD, LPTSTR );
-
-#   define CSIDL_FLAG_CREATE 0x8000
-#   define CSIDL_APPDATA 0x1A
-#   define SHGFP_TYPE_CURRENT 0
-
+#if defined(_WIN32_IE) && _WIN32_IE >= 0x500
         char psz_home[MAX_PATH];
-        HINSTANCE p_dll;
-        SHGETFOLDERPATH p_getpath;
-
-        *psz_home = '\0';
-
-        /* Load the shfolder DLL to retrieve SHGetFolderPath */
-        p_dll = LoadLibrary( "shfolder.dll" );
-        if( p_dll )
-        {
-            p_getpath = (void*)GetProcAddress( p_dll, "SHGetFolderPathA" );
-            if( p_getpath )
-            {
-                /* Get the "Application Data" folder for the current user */
-                if( p_getpath( NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE,
-                               NULL, SHGFP_TYPE_CURRENT, psz_home ) == S_OK )
-                {
-                    FreeLibrary( p_dll );
-                }
-                else
-                {
-                    *psz_home = '\0';
-                }
-            }
-            FreeLibrary( p_dll );
-        }
 
         /* Cache our keys in
          * C:\Documents and Settings\$USER\Application Data\dvdcss\ */
-        if( *psz_home )
+        if (SHGetFolderPathA (NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE,
+                              NULL, SHGFP_TYPE_CURRENT, psz_home ) == S_OK)
         {
-            snprintf( psz_buffer, PATH_MAX, "%s/dvdcss", psz_home );
+            snprintf( psz_buffer, PATH_MAX, "%s\\dvdcss", psz_home );
             psz_buffer[PATH_MAX-1] = '\0';
             psz_cache = psz_buffer;
         }
-- 
1.7.9.5



More information about the libdvdcss-devel mailing list