[vlc-commits] Use WNetAddConnection2 directly

Rémi Denis-Courmont git at videolan.org
Tue Aug 23 17:57:31 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Aug 23 18:54:55 2011 +0300| [5ba0e02b363bbaffdd570b7bb16aa7277433cb56] | committer: Rémi Denis-Courmont

Use WNetAddConnection2 directly

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5ba0e02b363bbaffdd570b7bb16aa7277433cb56
---

 modules/access/Modules.am |   15 ++++++++++++---
 modules/access/smb.c      |   20 +-------------------
 2 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/modules/access/Modules.am b/modules/access/Modules.am
index b2b041e..2db7a4c 100644
--- a/modules/access/Modules.am
+++ b/modules/access/Modules.am
@@ -34,13 +34,21 @@ libsdp_plugin_la_CFLAGS = $(AM_CFLAGS)
 libsdp_plugin_la_LIBADD = $(AM_LIBADD)
 libsdp_plugin_la_DEPENDENCIES =
 
+libaccess_smb_plugin_la_SOURCES = smb.c
+libaccess_smb_plugin_la_CFLAGS = $(AM_CFLAGS)
+libaccess_smb_plugin_la_LIBADD = $(AM_LIBADD)
+if HAVE_WIN32
+libaccess_smb_plugin_la_LIBADD += -lmpr
+endif
+libaccess_smb_plugin_la_DEPENDENCIES =
+libvlc_LTLIBRARIES += $(LTLIBaccess_smb)
+
 SOURCES_access_directory = directory.c
 SOURCES_access_dv = dv.c
 SOURCES_access_udp = udp.c
 SOURCES_access_tcp = tcp.c
 SOURCES_access_http = http.c
 SOURCES_access_ftp = ftp.c
-SOURCES_access_smb = smb.c
 SOURCES_access_gnomevfs = gnomevfs.c
 SOURCES_access_eyetv = eyetv.m
 SOURCES_dvdnav = dvdnav.c
@@ -175,7 +183,8 @@ libvlc_LTLIBRARIES += libdtv_plugin.la
 endif
 
 
-
 EXTRA_LTLIBRARIES += \
 	libaccess_rtmp_plugin.la \
-	libaccess_shm_plugin.la
+	libaccess_shm_plugin.la \
+	libaccess_smb_plugin.la \
+	$(NULL)
diff --git a/modules/access/smb.c b/modules/access/smb.c
index d2e44b1..693f920 100644
--- a/modules/access/smb.c
+++ b/modules/access/smb.c
@@ -363,28 +363,12 @@ static void Win32AddConnection( access_t *p_access, char *psz_path,
                                 char *psz_user, char *psz_pwd,
                                 char *psz_domain )
 {
-    DWORD WINAPI (*OurWNetAddConnection2)( LPNETRESOURCE, LPCTSTR, LPCTSTR, DWORD );
     char psz_remote[MAX_PATH], psz_server[MAX_PATH], psz_share[MAX_PATH];
     NETRESOURCE net_resource;
     DWORD i_result;
     char *psz_parser;
     VLC_UNUSED( psz_domain );
 
-    HINSTANCE hdll = LoadLibrary(_T("MPR.DLL"));
-    if( !hdll )
-    {
-        msg_Warn( p_access, "couldn't load mpr.dll" );
-        return;
-    }
-
-    OurWNetAddConnection2 =
-      (void *)GetProcAddress( hdll, _T("WNetAddConnection2A") );
-    if( !OurWNetAddConnection2 )
-    {
-        msg_Warn( p_access, "couldn't find WNetAddConnection2 in mpr.dll" );
-        return;
-    }
-
     memset( &net_resource, 0, sizeof(net_resource) );
     net_resource.dwType = RESOURCETYPE_DISK;
 
@@ -402,7 +386,7 @@ static void Win32AddConnection( access_t *p_access, char *psz_path,
     snprintf( psz_remote, sizeof( psz_remote ), "\\\\%s\\%s", psz_server, psz_share );
     net_resource.lpRemoteName = psz_remote;
 
-    i_result = OurWNetAddConnection2( &net_resource, psz_pwd, psz_user, 0 );
+    i_result = WNetAddConnection2( &net_resource, psz_pwd, psz_user, 0 );
 
     if( i_result != NO_ERROR )
     {
@@ -417,7 +401,5 @@ static void Win32AddConnection( access_t *p_access, char *psz_path,
     {
         msg_Dbg( p_access, "failed to connect to %s", psz_remote );
     }
-
-    FreeLibrary( hdll );
 }
 #endif // WIN32



More information about the vlc-commits mailing list