diff --git a/mozilla/modules/plugin/base/src/ns4xPlugin.cpp b/mozilla/modules/plugin/base/src/ns4xPlugin.cpp index cb9ef64369e..aa5b3fd09bd 100644 --- a/mozilla/modules/plugin/base/src/ns4xPlugin.cpp +++ b/mozilla/modules/plugin/base/src/ns4xPlugin.cpp @@ -26,10 +26,16 @@ //////////////////////////////////////////////////////////////////////// +#ifdef XP_WIN // XXX These are defined in platform specific FE directories right now :-/ +typedef NPError (__stdcall *NP_GETENTRYPOINTS)(NPPluginFuncs* pCallbacks); +typedef NPError (__stdcall *NP_PLUGININIT)(const NPNetscapeFuncs* pCallbacks); +typedef NPError (__stdcall *NP_PLUGINSHUTDOWN)(); +#else typedef NPError (*NP_GETENTRYPOINTS)(NPPluginFuncs* pCallbacks); typedef NPError (*NP_PLUGININIT)(const NPNetscapeFuncs* pCallbacks); typedef NPError (*NP_PLUGINSHUTDOWN)(); +#endif /* XP_WIN */ //////////////////////////////////////////////////////////////////////// diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 093229df66b..79ad458e027 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -529,39 +529,62 @@ nsresult nsPluginHostImpl :: Init(void) nsresult nsPluginHostImpl :: LoadPlugins(void) { -#ifdef XP_PC - long result; - HKEY keyloc; - DWORD type, pathlen; - char path[2000]; +#ifdef XP_PC + long result; + HKEY keyloc; + DWORD type, pathlen; + char path[2000]; + PRDir *dir = nsnull; - path[0] = 0; + if (::GetModuleFileName(NULL, path, sizeof(path)) > 0) + { + pathlen = PL_strlen(path) - 1; - result = ::RegOpenKeyEx(HKEY_CURRENT_USER, - "Software\\Netscape\\Netscape Navigator\\Main", - 0, KEY_READ, &keyloc); + while (pathlen > 0) + { + if (path[pathlen] == '\\') + break; - if (result == ERROR_SUCCESS) - { - pathlen = sizeof(path); + pathlen--; + } - result = ::RegQueryValueEx(keyloc, "Install Directory", - NULL, &type, (LPBYTE)&path, &pathlen); + if (pathlen > 0) + { + PL_strcpy(&path[pathlen + 1], "plugins"); + dir = PR_OpenDir(path); + } + } - if (result == ERROR_SUCCESS) - { - strcat(path, "\\Program\\Plugins"); -#ifdef NS_DEBUG -printf("plugins at: %s\n", path); -#endif - } + if (nsnull == dir) + { + path[0] = 0; - ::RegCloseKey(keyloc); - } + result = ::RegOpenKeyEx(HKEY_CURRENT_USER, + "Software\\Netscape\\Netscape Navigator\\Main", + 0, KEY_READ, &keyloc); - PRDir *dir; + if (result == ERROR_SUCCESS) + { + pathlen = sizeof(path); - dir = PR_OpenDir(path); + result = ::RegQueryValueEx(keyloc, "Install Directory", + NULL, &type, (LPBYTE)&path, &pathlen); + + if (result == ERROR_SUCCESS) + { + PL_strcat(path, "\\Program\\Plugins"); + } + + ::RegCloseKey(keyloc); + } + + dir = PR_OpenDir(path); + } + +#ifdef NS_DEBUG + if (path[0] != 0) + printf("plugins at: %s\n", path); +#endif if (nsnull != dir) { diff --git a/mozilla/modules/plugin/nglsrc/ns4xPlugin.cpp b/mozilla/modules/plugin/nglsrc/ns4xPlugin.cpp index cb9ef64369e..aa5b3fd09bd 100644 --- a/mozilla/modules/plugin/nglsrc/ns4xPlugin.cpp +++ b/mozilla/modules/plugin/nglsrc/ns4xPlugin.cpp @@ -26,10 +26,16 @@ //////////////////////////////////////////////////////////////////////// +#ifdef XP_WIN // XXX These are defined in platform specific FE directories right now :-/ +typedef NPError (__stdcall *NP_GETENTRYPOINTS)(NPPluginFuncs* pCallbacks); +typedef NPError (__stdcall *NP_PLUGININIT)(const NPNetscapeFuncs* pCallbacks); +typedef NPError (__stdcall *NP_PLUGINSHUTDOWN)(); +#else typedef NPError (*NP_GETENTRYPOINTS)(NPPluginFuncs* pCallbacks); typedef NPError (*NP_PLUGININIT)(const NPNetscapeFuncs* pCallbacks); typedef NPError (*NP_PLUGINSHUTDOWN)(); +#endif /* XP_WIN */ //////////////////////////////////////////////////////////////////////// diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp index 093229df66b..79ad458e027 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -529,39 +529,62 @@ nsresult nsPluginHostImpl :: Init(void) nsresult nsPluginHostImpl :: LoadPlugins(void) { -#ifdef XP_PC - long result; - HKEY keyloc; - DWORD type, pathlen; - char path[2000]; +#ifdef XP_PC + long result; + HKEY keyloc; + DWORD type, pathlen; + char path[2000]; + PRDir *dir = nsnull; - path[0] = 0; + if (::GetModuleFileName(NULL, path, sizeof(path)) > 0) + { + pathlen = PL_strlen(path) - 1; - result = ::RegOpenKeyEx(HKEY_CURRENT_USER, - "Software\\Netscape\\Netscape Navigator\\Main", - 0, KEY_READ, &keyloc); + while (pathlen > 0) + { + if (path[pathlen] == '\\') + break; - if (result == ERROR_SUCCESS) - { - pathlen = sizeof(path); + pathlen--; + } - result = ::RegQueryValueEx(keyloc, "Install Directory", - NULL, &type, (LPBYTE)&path, &pathlen); + if (pathlen > 0) + { + PL_strcpy(&path[pathlen + 1], "plugins"); + dir = PR_OpenDir(path); + } + } - if (result == ERROR_SUCCESS) - { - strcat(path, "\\Program\\Plugins"); -#ifdef NS_DEBUG -printf("plugins at: %s\n", path); -#endif - } + if (nsnull == dir) + { + path[0] = 0; - ::RegCloseKey(keyloc); - } + result = ::RegOpenKeyEx(HKEY_CURRENT_USER, + "Software\\Netscape\\Netscape Navigator\\Main", + 0, KEY_READ, &keyloc); - PRDir *dir; + if (result == ERROR_SUCCESS) + { + pathlen = sizeof(path); - dir = PR_OpenDir(path); + result = ::RegQueryValueEx(keyloc, "Install Directory", + NULL, &type, (LPBYTE)&path, &pathlen); + + if (result == ERROR_SUCCESS) + { + PL_strcat(path, "\\Program\\Plugins"); + } + + ::RegCloseKey(keyloc); + } + + dir = PR_OpenDir(path); + } + +#ifdef NS_DEBUG + if (path[0] != 0) + printf("plugins at: %s\n", path); +#endif if (nsnull != dir) {