X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmisc%2Fwin32_specific.c;h=98a3de4118e4566160d3b82fedeab3bb9fe9717f;hb=2fab80da23cb41b9a9b9173c69c755dbbcc3515d;hp=4da2a43122151a0edc1b5a2ccaa9a4e2936f8ce1;hpb=997ef25182ffbd986682edc85e81adbe921ac1dd;p=vlc diff --git a/src/misc/win32_specific.c b/src/misc/win32_specific.c index 4da2a43122..98a3de4118 100644 --- a/src/misc/win32_specific.c +++ b/src/misc/win32_specific.c @@ -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 )