]> git.sesse.net Git - vlc/blobdiff - src/misc/win32_specific.c
* src/misc/win32_specific.c, modules.c: WinCE improvements (support for finding out...
[vlc] / src / misc / win32_specific.c
index 4da2a43122151a0edc1b5a2ccaa9a4e2936f8ce1..98a3de4118e4566160d3b82fedeab3bb9fe9717f 100644 (file)
@@ -47,33 +47,28 @@ void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
     WSADATA Data;
 
     /* Get our full path */
-    if( ppsz_argv[0] )
-    {
-        char psz_path[MAX_PATH];
-        char *psz_vlc;
+    char psz_path[MAX_PATH];
+    char *psz_vlc;
 
 #if defined( UNDER_CE )
-        strcpy( psz_path, ppsz_argv[0] );
-        psz_vlc = strrchr( psz_path, '\\' );
-        if( psz_vlc ) psz_vlc++;
-#else
-        GetFullPathName( ppsz_argv[0], MAX_PATH, psz_path, &psz_vlc );
-#endif
-
-        if( psz_vlc > psz_path && psz_vlc[-1] == '\\' )
-        {
-            psz_vlc[-1] = '\0';
-            p_this->p_libvlc->psz_vlcpath = strdup( psz_path );
-        }
-        else
-        {
-            p_this->p_libvlc->psz_vlcpath = strdup( "" );
-        }
+    wchar_t psz_wpath[MAX_PATH];
+    if( GetModuleFileName( NULL, psz_wpath, MAX_PATH ) )
+    {
+        WideCharToMultiByte( CP_ACP, 0, psz_wpath, -1,
+                             psz_path, MAX_PATH, NULL, NULL );
     }
-    else
+    else psz_path[0] = '\0';
+
+#else
+    if( !GetModuleFileName( NULL, psz_path, MAX_PATH ) )
     {
-        p_this->p_libvlc->psz_vlcpath = strdup( "" );
+        psz_path[0] = '\0';
     }
+#endif
+
+    if( (psz_vlc = strrchr( psz_path, '\\' )) ) *psz_vlc = '\0';
+
+    p_this->p_libvlc->psz_vlcpath = strdup( psz_path );
 
     /* Set the default file-translation mode */
 #if !defined( UNDER_CE )