diff --git a/projects/mozilla/vlcplugin.cpp b/projects/mozilla/vlcplugin.cpp
index 5f4444b..022019a 100644
--- a/projects/mozilla/vlcplugin.cpp
+++ b/projects/mozilla/vlcplugin.cpp
@@ -98,27 +98,60 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
 
     /* locate VLC module path */
 #ifdef XP_MACOSX
-    ppsz_argv[ppsz_argc++] = "--plugin-path=/Library/Internet\\ Plug-Ins/VLC\\ Plugin.plugin/Contents/MacOS/modules";
+    Dl_info info;
+    char plugin_path[MAX_PATH + 1] = {0};
+    ppsz_argv[ppsz_argc++] = "--plugin-path";
+    if( dladdr(init, &info) ) {
+        char *path = dirname( info.dli_fname );
+        strncpy( plugin_path, path, MAX_PATH );
+        strncpy( plugin_path + strlen(path), "/modules",
+                 MAX_PATH - strlen(path) );
+        ppsz_argv[ppsz_argc++] = plugin_path;
+    } else
+        ppsz_argv[ppsz_argc++] = "/Library/Internet\\ Plug-Ins/VLC\\ Plugin.plugin/Contents/MacOS/modules";
     ppsz_argv[ppsz_argc++] = "--vout=minimal_macosx";
 #elif defined(XP_WIN)
     HKEY h_key;
     DWORD i_type, i_data = MAX_PATH + 1;
-    char p_data[MAX_PATH + 1];
+    MEMORY_BASIC_INFORMATION mbi;
+    char path_buffer[_MAX_PATH];
+    char drive[_MAX_DRIVE];
+    char dir[_MAX_DIR];
+    char fname[_MAX_FNAME];
+    char ext[_MAX_EXT];
+    char p_data[MAX_PATH + 1] = {0};
+
+    if( VirtualQuery( init, &mbi, sizeof(mbi) ) )
+    {
+        HMODULE hMod = (HMODULE) mbi.AllocationBase;
+        char moduleName[MAX_PATH];
+        if( GetModuleFileName( hMod, moduleName, sizeof(moduleName) ) )
+        {
+            _splitpath( moduleName, drive, dir, fname, ext );
+            _makepath( path_buffer, drive, dir, NULL, NULL );
+            strncpy( p_data, path_buffer, MAX_PATH );
+            strncpy( p_data + strlen(path_buffer), "\\plugins",
+                     MAX_PATH - strlen(path_buffer));
+        }
+    } else
+
     if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
                       0, KEY_READ, &h_key ) == ERROR_SUCCESS )
     {
          if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
                               (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
-         {
              if( i_type == REG_SZ )
-             {
-                 strcat( p_data, "\\plugins" );
-                 ppsz_argv[ppsz_argc++] = "--plugin-path";
-                 ppsz_argv[ppsz_argc++] = p_data;
-             }
-         }
+                 strncpy( p_data + strlen(p_data), "\\plugins",
+                          MAX_PATH - strlen(p_data) );
          RegCloseKey( h_key );
     }
+
+    if( p_data[0] )
+    {
+        ppsz_argv[ppsz_argc++] = "--plugin-path"
+        ppsz_argv[ppsz_argc++] = p_data;
+    }
+
     ppsz_argv[ppsz_argc++] = "--no-one-instance";
 
 #endif /* XP_MACOSX */
