]> git.sesse.net Git - vlc/blobdiff - src/misc/win32_specific.c
Backported r11448.
[vlc] / src / misc / win32_specific.c
index 98a3de4118e4566160d3b82fedeab3bb9fe9717f..4ce7914d00fcba48e968ccc9f4ba59c485a4ee98 100644 (file)
@@ -37,7 +37,7 @@
 #   include <fcntl.h>
 #endif
 
-#include <winsock2.h>
+#include <winsock.h>
 
 /*****************************************************************************
  * system_Init: initialize winsock and misc other things.
@@ -60,7 +60,11 @@ void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
     else psz_path[0] = '\0';
 
 #else
-    if( !GetModuleFileName( NULL, psz_path, MAX_PATH ) )
+    if( ppsz_argv[0] )
+    {
+        GetFullPathName( ppsz_argv[0], MAX_PATH, psz_path, &psz_vlc );
+    }
+    else if( !GetModuleFileName( NULL, psz_path, MAX_PATH ) )
     {
         psz_path[0] = '\0';
     }
@@ -73,8 +77,8 @@ void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
     /* Set the default file-translation mode */
 #if !defined( UNDER_CE )
     _fmode = _O_BINARY;
-#endif
     _setmode( _fileno( stdin ), _O_BINARY ); /* Needed for pipes */
+#endif
 
     /* Call mdate() once to make sure it is initialized properly */
     mdate();
@@ -152,7 +156,7 @@ void system_Configure( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
         msg_Info( p_this, "one instance mode ENABLED");
 
         /* Use a named mutex to check if another instance is already running */
-        if( ( hmutex = CreateMutex( NULL, TRUE, "VLC ipc "VERSION ) ) == NULL )
+        if( !( hmutex = CreateMutex( 0, TRUE, _T("VLC ipc ") _T(VERSION) ) ) )
         {
             /* Failed for some reason. Just ignore the option and go on as
              * normal. */
@@ -191,8 +195,7 @@ void system_Configure( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
 
             /* Locate the window created by the IPC helper thread of the
              * 1st instance */
-            if( ( ipcwindow = FindWindow( NULL, "VLC ipc "VERSION ) )
-                == NULL )
+            if( !( ipcwindow = FindWindow( 0, _T("VLC ipc ") _T(VERSION) ) ) )
             {
                 msg_Err( p_this, "one instance mode DISABLED "
                          "(couldn't find 1st instance of program)" );
@@ -253,8 +256,8 @@ static void IPCHelperThread( vlc_object_t *p_this )
     MSG message;
 
     ipcwindow =
-        CreateWindow( "STATIC",                      /* name of window class */
-                  "VLC ipc "VERSION,                /* window title bar text */
+        CreateWindow( _T("STATIC"),                  /* name of window class */
+                  _T("VLC ipc ") _T(VERSION),       /* window title bar text */
                   0,                                         /* window style */
                   0,                                 /* default X coordinate */
                   0,                                 /* default Y coordinate */